Turns out this was actually being used through magic.
Remove mips since it is a tier 3 target that is only supported on
nightly and dtolnay/rust-toolchain doesn't seem to handle installing
targets without std.
Exclude xtask since it depends on `ring` which doesn't build on all
targets.
Fix compilation on armv7 which had rotted.
This reverts commit d92fc95c39.
Change FromRawTracepointArgs::arg to return T rather than *const T which
seems to have been returning a dangling pointer.
Arguably this is not strictly necessary; edition 2024 seems to be
focused on increased strictness around unsafe code which doesn't unlock
new functionality for our users. That said, this work revealed an
apparent bug (see above) that we wouldn't otherwise catch due to
allow-by-default lints.
Per man 2 perf_event_open:
> RETURN VALUE
> On success, perf_event_open() returns the new file descriptor. On
> error, -1 is returned and errno is set to indicate the error.
Bake this into our syscalls so we stop using `_` so much which can hide
information loss. Remove the type parameter to SysResult.
Per man 2 bpf:
> RETURN VALUE
> For a successful call, the return value depends on the operation:
>
> BPF_MAP_CREATE
> The new file descriptor associated with the eBPF map.
>
> BPF_PROG_LOAD
> The new file descriptor associated with the eBPF program.
>
> All other commands
> Zero.
>
> On error, -1 is returned, and errno is set to indicate the error.
Bake this into our syscalls so we stop using `_` so much which can hide
information loss.
PerCpuHashMap was never returning MapError::KeyNotFound because
bpf_map_lookup_elem_per_cpu was replacing Ok(None) with
Ok(Some(zeroed_value)).
Update bpf_map_lookup_elem_per_cpu to map the Option value.
When `aya::obj` was migrated to be its own crate `aya-obj`, the `obj`
alias was created to preserve existing imports that relied on
`crate::obj`.
This resulted in 3 ways to import `aya-obj` objects:
- `use aya_obj::*`
- `use obj::*`
- `use crate::obj::*`
The `obj` alias is now removed to avoid confusion, and all `obj` imports
are funneled through `aya_obj`.
This returns error strings from netlink since they are more informative
than the raw os error. For example:
"Device or Resource Busy" vs. "XDP program already attached".
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
```
error: manual implementation of `ok`
--> aya/src/util.rs:261:28
|
261 | let addr = match u64::from_str_radix(addr, 16) {
| ____________________________^
262 | | Ok(addr) => Some(addr),
263 | | Err(ParseIntError { .. }) => None,
264 | | }?;
| |_________________^ help: replace with: `u64::from_str_radix(addr, 16).ok()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_err
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:1705:44
|
1705 | section: ProgramSection::KProbe { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
note: the lint level is defined here
--> aya-obj/src/lib.rs:68:9
|
68 | #![deny(clippy::all, missing_docs)]
| ^^^^^^^^^^^
= note: `#[deny(clippy::unneeded_struct_pattern)]` implied by `#[deny(clippy::all)]`
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:1769:44
|
1769 | section: ProgramSection::KProbe { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:1787:44
|
1787 | section: ProgramSection::KProbe { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:1919:48
|
1919 | section: ProgramSection::KProbe { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:2041:52
|
2041 | section: ProgramSection::TracePoint { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:2058:52
|
2058 | section: ProgramSection::TracePoint { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:2081:54
|
2081 | section: ProgramSection::SocketFilter { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:2151:55
|
2151 | section: ProgramSection::RawTracePoint { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:2168:55
|
2168 | section: ProgramSection::RawTracePoint { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:2243:55
|
2243 | section: ProgramSection::BtfTracePoint { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:2266:59
|
2266 | section: ProgramSection::SkSkbStreamParser { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:2289:59
|
2289 | section: ProgramSection::SkSkbStreamParser { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:2410:58
|
2410 | section: ProgramSection::CgroupSkbIngress { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:2433:58
|
2433 | section: ProgramSection::CgroupSkbIngress { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:2456:51
|
2456 | section: ProgramSection::CgroupSkb { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: struct pattern is not needed for a unit variant
--> aya-obj/src/obj.rs:2479:51
|
2479 | section: ProgramSection::CgroupSkb { .. },
| ^^^^^^^ help: remove the struct pattern
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
error: manual implementation of `ok`
--> aya-log-common/src/lib.rs:168:36
|
168 | let wire_len: LogValueLength = match value.len().try_into() {
| ____________________________________^
169 | | Ok(wire_len) => Some(wire_len),
170 | | Err(TryFromIntError { .. }) => None,
171 | | }?;
| |_____^ help: replace with: `value.len().try_into().ok()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_err
error: manual implementation of `err`
--> init/src/main.rs:141:30
|
141 | .filter_map(|result| match result {
| ______________________________^
142 | | Ok(()) => None,
143 | | Err(err) => Some(err),
144 | | })
| |_________^ help: replace with: `result.err()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_err
error: manual implementation of `err`
--> xtask/src/public_api.rs:80:30
|
80 | .filter_map(|result| match result {
| ______________________________^
81 | | Ok(()) => None,
82 | | Err(err) => Some(err),
83 | | })
| |_________^ help: replace with: `result.err()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_err
```
```
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.
* 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.
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
The loader should fill bss maps with zeros according to the size of the
ELF section.
Failure to do so yields weird verifier messages as follows:
```
cannot access ptr member ops with moff 0 in struct bpf_map with off 0 size 4
```
Reference to this in the cilium/ebpf code is here [1].
I could not find a reference in libbpf.
1: d0c8fc1937/elf_reader.go (L1159-L1165)
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
This commit adds the initial support for TCX
bpf links. This is a new, multi-program, attachment
type allows for the caller to specify where
they would like to be attached relative to other
programs at the attachment point using the LinkOrder
type.
Signed-off-by: astoycos <astoycos@redhat.com>
Co-authored-by: Andre Fredette <afredette@redhat.com>
Co-authored-by: Dave Tucker <dave@dtucker.co.uk>
Co-authored-by: Tamir Duberstein <tamird@gmail.com>