Make the xz2 dependency optional to allow building without a C cross
compiler. This allows clippy.sh to be used on e.g. macOS more easily:
```
./clippy.sh --target x86_64-unknown-linux-gnu --exclude-features xz2
```
This removes octorust which takes absolutely ages to compile and also
requires native TLS libraries which in turn require a C toolchain. The
latter is a pain when cross compiling from macOS.
This reverts commit cc2da4a2a4.
The binding for BPF_ADD was missing from codegen.
Use BPF_.* to capture all of these to avoid missing bindings in future.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
At present, `aya_build` will always use `+nightly` to build the
eBPF kernel. This is problematic in environments such as CI, where
tools always need to be installed first. Installing the current
nightly Rust toolchain gives you a new toolchain every day. This
poisones caches and makes CI jobs non-deterministic.
Resolves: #1226
Allow for a ProgramInfo to be converted into one of the program types
that we support. This allows for a user of Aya access to reattach,
pin or unload a program that was either, previously loaded, or was
loaded by another process.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
We have previously tried to import traits anonymously where possible but
enforcing this manually was hard.
Since Rust 1.83 clippy can now enforce this for us.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
The init module contains a small init system for running our integration
tests against a kernel. While we don't need a full-blown linux distro,
we do need some utilities.
Once such utility is `modprobe` which allows us to load kernel modules.
Rather than create a new module for this utility, I've instead
refactored `init` into `test-distro` which is a module that contains
multiple binaries.
The xtask code has been adjusted to ensure these binaries are inserted
into the correct places in our cpio archive, as well as bringing in the
kernel modules.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
In practice this will forbid unused dependencies because we run clippy
with `--deny warnings`.
Workspace lints is a nice place to ratchet up lints through the codebase
all at once and consistently.
- Document the need for external rustfmt invocation.
- Remove reexports.
- Remove `write_to_file`.
- Avoid allocating strings when using bindgen to write bindings.
This can be done externally. Do so in CI.
This is an attempt to resolve the inconsistency between CI and local
rustfmt in the generated bindings.
Restore running CI on generated branches; the presence of a PR is
apparently not enough.
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.
This change exposes the ifindex field from the underlying xdp_md
data structure to the XdpContext in Aya. The ifindex represents the
unique OS-provided index for a network interface.
Fixes#1140
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.
libbpf commit: d4a841a32b04d69194ab5bdac359a51938a206ce
Files changed:
M aya-obj/src/generated/linux_bindings_aarch64.rs
M aya-obj/src/generated/linux_bindings_armv7.rs
M aya-obj/src/generated/linux_bindings_mips.rs
M aya-obj/src/generated/linux_bindings_powerpc64.rs
M aya-obj/src/generated/linux_bindings_riscv64.rs
M aya-obj/src/generated/linux_bindings_s390x.rs
M aya-obj/src/generated/linux_bindings_x86_64.rs
M xtask/public-api/aya-obj.txt
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>
libbpf commit: d4a841a32b04d69194ab5bdac359a51938a206ce
Files changed:
M aya-obj/src/generated/linux_bindings_aarch64.rs
M aya-obj/src/generated/linux_bindings_armv7.rs
M aya-obj/src/generated/linux_bindings_mips.rs
M aya-obj/src/generated/linux_bindings_powerpc64.rs
M aya-obj/src/generated/linux_bindings_riscv64.rs
M aya-obj/src/generated/linux_bindings_s390x.rs
M aya-obj/src/generated/linux_bindings_x86_64.rs
M xtask/public-api/aya-obj.txt
Update libbpf to 324f3c3846d99c8a1e1384a55591f893f0ae5de4
Files changed:
M aya-obj/src/generated/btf_internal_bindings.rs
M aya-obj/src/generated/linux_bindings_aarch64.rs
M aya-obj/src/generated/linux_bindings_armv7.rs
A aya-obj/src/generated/linux_bindings_mips.rs
M aya-obj/src/generated/linux_bindings_powerpc64.rs
M aya-obj/src/generated/linux_bindings_riscv64.rs
M aya-obj/src/generated/linux_bindings_s390x.rs
M aya-obj/src/generated/linux_bindings_x86_64.rs
M ebpf/aya-ebpf-bindings/src/aarch64/bindings.rs
M ebpf/aya-ebpf-bindings/src/armv7/bindings.rs
A ebpf/aya-ebpf-bindings/src/mips/bindings.rs
A ebpf/aya-ebpf-bindings/src/mips/helpers.rs
M ebpf/aya-ebpf-bindings/src/powerpc64/bindings.rs
M ebpf/aya-ebpf-bindings/src/riscv64/bindings.rs
M ebpf/aya-ebpf-bindings/src/s390x/bindings.rs
M ebpf/aya-ebpf-bindings/src/x86_64/bindings.rs
Per the comment added in the code, there are 2 definitions of
BPF_F_LINK in the kernel headers. Once is in an anonymous enum which
bindgen will constify, and once is via a #define macro. The values are
identical. The fix is to exclude BPF_F_LINK from the list of variables
in bindgen removing one of the duplicate definitions.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
This will generate bindings for mips the next time that the codegen job
is run.
Signed-off-by: Ishan Jain <contact@ishanjain.me>
Co-authored-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
```