Commit Graph

1420 Commits (92d3056db35df729efdbdf757ec389485ce7d8fd)
 

Author SHA1 Message Date
Tamir Duberstein e813a054ad
Merge pull request #744 from aya-rs/programfd-borrowed
programs: `ProgramFd` is owned
1 year ago
Tamir Duberstein 504fd1df0a
programs: `ProgramFd` is owned
`ProgramData::fd` is now a `ProgramFd`. This means that `ProgramData`
now closes the file descriptor on drop. In the future we might consider
making `ProgramFd` hold a `BorrowedFd` but this requires API design work
due to overlapping borrows.

Since `ProgramFd` is no longer `Copy`, update methods to take it by
reference to allow callers to use it multiple times as they are
accustomed to doing.

`ProgramFd` is now returned by reference and implements `try_clone` to
allow callers to avoid file descriptor cloning when desired.

This is an API breaking change.

Updates #612.
1 year ago
Tamir Duberstein 7874ad99f7
Merge pull request #756 from aya-rs/wget
github: fix CI
1 year ago
Tamir Duberstein 6740c43a02
github: update 6.4.0 URLs
Seems the previous spin was pulled.
1 year ago
Tamir Duberstein 89eafd139d
github: use gxargs on macOS
`xargs -P0` always exits 0 on macOS, even on error.
1 year ago
Tamir Duberstein 47a8a4b878
github: reduce wget verbosity, remove -q
This allows errors to be shown; -q hides *all* output, which is not what
we want.
1 year ago
Andrew Stoycos bcc9743254
Merge pull request #637 from astoycos/helpers
Add more helpful methods to `ProgramInfo`
1 year ago
Andrew Stoycos e1a556894c
aya: add helper methods for ProgramInfo
- Add helper methods to get useful information from the ProgramInfo
object which is returned by the `loaded_programs()` API.  Specifically
this code mirrors the `bpftool prog` command in terms of useful fields.
- Add a new API macro to each aya `Program` type to allow us to fetch
its accompanying `ProgramInfo` metadata after its been loaded.
- Add a new ProgramInfo constructor that builds a new instance using
a raw fd.
- Add a smoke test for the loaded_programs() API as well as
all the relevant methods on the ProgramInfo type.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
1 year ago
Dave Tucker 03c5012db2
Merge pull request #702 from dave-tucker/mapdata-btffd
aya: Don't store btf_fd in MapData
1 year ago
Dave Tucker 8ce1c00ad8
Merge pull request #749 from dave-tucker/clang-format
.github: Add clang-format
1 year ago
Tamir Duberstein 7f98e419e6
Merge pull request #748 from aya-rs/btf_obj_fd-owned
programs: Plug attach_btf_obj_fd leak
1 year ago
Tamir Duberstein d88ca62aaa
programs: Plug attach_btf_obj_fd leak
`ProgramData::attach_btf_obj_fd` is now owned.  This means that
`ProgramData` now closes the file descriptor on drop.

Updates #612.
1 year ago
Dave Tucker db975e9778 aya: Don't store bpf_fd in MapData
This is only used in create and therefore can be passed
as a parameter.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Dave Tucker 02124002c8 .github: Add clang-format
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Dave Tucker c0a08276a6
Merge pull request #750 from dave-tucker/public-api-bless 1 year ago
Dave Tucker d85afe78f9 xtask: Fix aya public-api
Changes to the bitflags crate changed some of our public api signature.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Tamir Duberstein 5bc922af23
Merge pull request #747 from aya-rs/helpers
sys: add map_ids to bpf_prog_get_info_by_fd
1 year ago
Tamir Duberstein 5ac186299b
sys: refactor btf_obj_get_info_by_fd to share code 1 year ago
Tamir Duberstein c7a19bcefb
sys: add map_ids to bpf_prog_get_info_by_fd
Allows the caller to pass a slice which the kernel will populate with
map ids used by the program.
1 year ago
Tamir Duberstein 68bf8818ec
Merge pull request #745 from aya-rs/even-more-aggro-kp-handling
xtask: watch for kernel panic in stdout too
1 year ago
Tamir Duberstein 7e14214f47
xtask: add noapic to kernel parameters
This might prevent some kernel panics.
1 year ago
Tamir Duberstein de65ba0067
xtask: watch for kernel panic in stdout too
Seems unclear whether kernel panics go to stdout or stderr, so do them
both.
1 year ago
Tamir Duberstein 90cf13163b
Merge pull request #743 from aya-rs/avoid-vec-ksyms
util: avoid vector allocation when parsing ksyms
1 year ago
Tamir Duberstein 5138c731a9
util: avoid vector allocation when parsing ksyms 1 year ago
Alessandro Decina 0c0cf70deb
Merge pull request #740 from addisoncrump/main
Revisit the stack trace API to remove resolution support
1 year ago
Addison Crump ed777273b1
nuclear option: no symbol resolution in the crate 1 year ago
Tamir Duberstein fbbf191bd3
Merge pull request #738 from aya-rs/kill-qemu-better
xtask: watch for kernel panics on stderr
1 year ago
Tamir Duberstein 58ba66c003
xtask: watch for kernel panics on stderr
It seems these go to stderr, not stdout. Use `Ctrl-A x` to shut QEMU
down if a panic is seen.
1 year ago
Tamir Duberstein b54a106584
log: update comments
These were missed when the code was updated.
1 year ago
Tamir Duberstein 45df2519b6
Merge pull request #736 from aya-rs/logging-better
Remove pointless DefaultLogger
1 year ago
Tamir Duberstein ecf0dd9739
Merge pull request #735 from aya-rs/log-option-not-result
aya-log: s/Result<usize, ()>/Option<NonZeroUsize>/
1 year ago
Tamir Duberstein ca3f70b16a
aya-log: s/Result<usize, ()>/Option<NonZeroUsize>/
`Option<NonZeroUsize>` is guaranteed to have the same size as `usize`,
which is not guarnateed for `Result`. This is a minor optimization, but
also results in simpler code.
1 year ago
Tamir Duberstein 00d265c51b
Remove pointless DefaultLogger
This avoids an atomic load on every log.
1 year ago
Tamir Duberstein 412a0875b4
Merge pull request #733 from tamird/kernel-test
integration-test: Implement running on VMs
1 year ago
Tamir Duberstein 82a77bc83d
integration-test: Implement running on VMs
Implements running integration tests on multiple VMs with arbitrary
kernel images using `cargo xtask integration-test vm ...`.

This changes our coverage from 6.2 to 6.1 and 6.4.
1 year ago
Tamir Duberstein b6a6a81f95
integration-test: deflake log test
Wait for at least one log and increase the wait time 10x.
1 year ago
Tamir Duberstein d3513e7010
Merge pull request #734 from aya-rs/reduce-slicing
aya-obj: s/types.types[i]/*t/ where possible
1 year ago
Tamir Duberstein dfb6020a1d
aya-obj: s/types.types[i]/*t/ where possible
We already have a mutable reference in scope, use it where possible.
1 year ago
Tamir Duberstein 84d5791d4e
Merge pull request #729 from aya-rs/logs-inline-always
log: annotate logging functions inlining
1 year ago
Dave Tucker 2a55fc7bd3
Merge pull request #725 from dave-tucker/enum64
aya, aya-obj: Implement ENUM64 fixups
1 year ago
Dave Tucker e38e2566e3 aya, aya-obj: Implement ENUM64 fixups
This commit adds:

- A probe to see if the ENUM64 feature is supported
- Fixups for the use of signed enums, or enum64 types
  on systems where enum64 is not supported

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Tamir Duberstein 3cfd886dc5
log: annotate logging functions inlining
Some of these functions fail to compile when not inlined, so we should
be explicit.

Before deciding on this approach I tried various ways of making all
these functions #[inline(never)] to save instructions but I ran into
blockers:
- These functions currently return Result, which is a structure. This is
  not permitted in BPF.
- I tried inventing a newtype that is a #[repr(transparent)] wrapper of
  u16, and having these functions return that; however it seems that
  even if the object code is legal, the verifier will reject such
  functions because the BTF (if present, and it was in my local
  experiments) would indicate that the return is a structure.
- I tried having these functions return a plain u16 where 0 means error,
  but the verifier still rejected the BTF because the receiver (even if
  made into &self) is considered a structure, and forbidden.

We can eventually overcome these problems by "lying" in our BTF once
support for it matures in the bpf-linker repo (e.g. Option<NonZeroU16>
should be perfectly legal as it is guaranteed to be word-sized), but we
aren't there yet, and this is the safest thing we can do for now.
1 year ago
Tamir Duberstein fe047d79a3
aya-log-common: Simplify
- Remove `TagLenValue`; this type has a single method, which is now a
  function.
- Remove generics from `TagLenValue::write` (now `write`). The tag is
  always `u8`, and the value is always a sequence of bytes.
- Replace slicing operations which can panic with calls to `get` which
  explicit check bounds.
1 year ago
Dave Tucker e21001226f
Merge pull request #731 from dave-tucker/noclone-btf
aya-obj: Mutate BTF in-place without clone
1 year ago
Tamir Duberstein cb42d028d0
Merge pull request #727 from tamird/build-everywhere
integration-test: avoid reliance on kernel headers
1 year ago
Tamir Duberstein 54c90ec72c
integration-test: De-duplicate BTF relocation test 1 year ago
Tamir Duberstein 71bc3ea0b5
integration-test: avoid reliance on kernel headers
This should allow us to build on any system.
1 year ago
Tamir Duberstein b46fb616be
integration-test: fix BTF relocation test
The struct_flavors test previously expected the same thing with and
without relocations. It now expects different values.

Also rename an enum variant "u64" to "S64". This was a typo. Turns out
that U32 is a type that exists in kernel headers, so all enum values are
suffixed with "_VAL".

Remove stdlib.h and the call to exit(). This alone makes the test fail
with a poisoned relocation. Bringing over the map definition makes the
test work again.
1 year ago
Tamir Duberstein 0904cd089e
integration-test: DRY clang setup 1 year ago
Tamir Duberstein dc9f72adf0
test,xtask: Simplify ExitStatus handling 1 year ago