Before this change, Aya supported only legacy BPF map definitions, which
are instances of the `bpf_map_def` struct and end up in the `maps` ELF
section. This change introduces BTF maps, with custom structs indicating
the metadata of the map, which end up in the `.maps` section.
Legacy maps are not supported by libbpf anymore and not even by the
kernel for newer types of maps like inode/task storage.
Add support of BTF maps in aya-ebpf under the `btf-maps` feature flag.
Usage of this feature requires emitting debug info for the eBPF crate
and passing the `--btf` flag to bpf-linker.
```
error: called `Iterator::last` on a `DoubleEndedIterator`; this will needlessly iterate the entire iterator
--> aya/src/programs/uprobe.rs:282:64
|
282 | let path = line.split(|b| b.is_ascii_whitespace()).last()?;
| ^^^^^^ help: try: `next_back()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_ended_iterator_last
```
Fixes#1132.
Note that this change does not add support in the public API for kprobes
or tracepoints, but it's a trivial matter of plumbing.
Along the way, the Uprobe::attach API is cleaned up to make the
attachment location more coherent. The logic being: if we're going to be
breaking the API anyway, may as well clean it up a bit.
Furthermore, the aya::sys::bpf_link_attach function is cleaned up by
properly modeling the the union in the final field with a rust enum.
Provide an `arg()` method in `RawTracepointArgs` wrapper of
`bpf_raw_tracepoint_args` and also in `RawTracepointContext`, so
it's directly available in raw tracepoint programs.
The methods and traits implemented here are unsafe. There is no
way to reliably check the number of available arguments, so
requesting a non-existing one leads to undefined behavior.
* docs: update docs for load to mention include_bytes_aligned
This macro is required if you are bundling programs statically into your binary, which is not an uncommon thing to do.
This change updates the documentation for the load function to mention this macro and the need for alignment.
We're seeing 429 from Github trying to download gen_init_cpio, so cache
it using actions cache. Since I'm here add this for kernel images as
well to save time waiting on slow Debian servers.
Unwinding gives us more information, so we shouldn't disable it
globally. It is already disabled for BPF targets via the target configs
in rustc itself.
This complicates the clippy invocation somewhat, so put it in a shell
script for developer as well as CI use.
The const-assert crate doesn't even compile with stable rust, so we
shouldn't depend on it. Instead we replicate its functionality behind
cfg(unstable) which is set at build time based on the toolchain in use.
BPF iterators[0] are a way to dump kernel data into user-space and an
alternative to `/proc` filesystem.
This change adds support for BPF iterators on the user-space side. It
provides a possibility to retrieve the outputs of BPF iterator programs
both from sync and async Rust code.
[0] https://docs.kernel.org/bpf/bpf_iterators.html