Where possible, replace the hardcoded byte arrays in the tests with the
structs they represent, then convert the structs to byte arrays.
Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
bpfman, a project using aya, has a requirement to support powerpc64 and
s390x architectures. Adding these two architectures to aya.
Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
Adding support for s390x (big endian architecture) and found that some
of the unit tests have structures and files implemented as byte arrays.
They are all coded as little endian and need a bug endian version to
work properly.
Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
Update libbpf to 686f600bca59e107af4040d0838ca2b02c14ff50
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_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
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Update libbpf to c1a6c770c46c6e78ad6755bf596c23a4e6f6b216
Files changed:
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_powerpc64.rs
M aya-obj/src/generated/linux_bindings_riscv64.rs
A 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/powerpc64/bindings.rs
A ebpf/aya-ebpf-bindings/src/powerpc64/helpers.rs
M ebpf/aya-ebpf-bindings/src/riscv64/bindings.rs
A ebpf/aya-ebpf-bindings/src/s390x/bindings.rs
A ebpf/aya-ebpf-bindings/src/s390x/helpers.rs
M ebpf/aya-ebpf-bindings/src/x86_64/bindings.rs
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
And BpfLoader to EbpfLoader.
This also adds type aliases to preserve the use of the old names, making
updating to a new Aya release less of a burden. These aliases are marked
as deprecated since we'll likely remove them in a later release.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
```
error: unnecessary use of `get("foo").is_some()`
--> aya-obj/src/obj.rs:1690:26
|
1690 | assert!(obj.maps.get("foo").is_some());
| ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("foo")`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
note: the lint level is defined here
--> aya-obj/src/lib.rs:68:9
|
68 | #![deny(clippy::all, missing_docs)]
| ^^^^^^^^^^^
= note: `#[deny(clippy::unnecessary_get_then_check)]` implied by `#[deny(clippy::all)]`
error: unnecessary use of `get("foo").is_some()`
--> aya-obj/src/obj.rs:1777:26
|
1777 | assert!(obj.maps.get("foo").is_some());
| ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("foo")`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
error: unnecessary use of `get("bar").is_some()`
--> aya-obj/src/obj.rs:1778:26
|
1778 | assert!(obj.maps.get("bar").is_some());
| ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("bar")`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
error: unnecessary use of `get("baz").is_some()`
--> aya-obj/src/obj.rs:1779:26
|
1779 | assert!(obj.maps.get("baz").is_some());
| ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("baz")`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
error: unnecessary use of `get(".bss").is_some()`
--> aya-obj/src/obj.rs:1799:26
|
1799 | assert!(obj.maps.get(".bss").is_some());
| ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(".bss")`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
error: unnecessary use of `get(".rodata").is_some()`
--> aya-obj/src/obj.rs:1810:26
|
1810 | assert!(obj.maps.get(".rodata").is_some());
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(".rodata")`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
error: unnecessary use of `get(".rodata.boo").is_some()`
--> aya-obj/src/obj.rs:1821:26
|
1821 | assert!(obj.maps.get(".rodata.boo").is_some());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(".rodata.boo")`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
error: unnecessary use of `get(".data").is_some()`
--> aya-obj/src/obj.rs:1832:26
|
1832 | assert!(obj.maps.get(".data").is_some());
| ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(".data")`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
error: unnecessary use of `get(".data.boo").is_some()`
--> aya-obj/src/obj.rs:1843:26
|
1843 | assert!(obj.maps.get(".data.boo").is_some());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(".data.boo")`
```
When comparing `local_spec` with `target_spec` for enum relocations,
we can encounter a situation when a matchinng variant in a candidate
spec doesn't exist.
Before this change, such case wasn't handled explicitly, therefore
resulted in returning currently constructed `target_spec` at the
end. The problem is that such `target_spec` was, due to lack of
match, incomplete. It didn't contain any `accessors` nor `parts`.
Later usage of such incomplete `target_spec` was leading to panics,
since the code operating on enums' `target_spec` expects at least
one `accessor` to be available.
Fixes#868
On startup, the kernel is probed for support of chained program ids for
CpuMap, DevMap and DevMapHash, and will patch maps at load time to have
the proper size. Then, at runtime, the support is checked and will error
out if a program id is passed when the kernel does not support it.
`MapData::fd` is now a `MapFd`. This means that `MapData` now closes the
file descriptor on drop. In the future we might consider making `MapFd`
hold a `BorrowedFd` but this requires API design work due to overlapping
borrows.
Since `SockMapFd` is no longer `Copy`, attach methods to take it by
reference to allow callers to use it multiple times as they are
accustomed to doing.
`SockMapFd` implements `try_clone`. `MapFd` and `SockMapFd` are now
returned by reference to allow callers to avoid file descriptor cloning
when desired.
This is an API breaking change.
Updates #612.
Remove repetition of permitted cgroup attach types. Make optionality of
name more explicit rather than pretending both kind and name are equal
to section.
The primary driver of change here is that `MapData::create` is now a
factory function that returns `Result<Self, _>` rather than mutating
`&mut self`. The remaining changes are consequences of that change, the
most notable of which is the removal of several errors which are no
longer possible.
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>
The BTF we're working on is Cow anyway so modifying in-place is fine.
All we need to do is store some information before we start our
mutable iteration to avoid concurrently borrowing types both mutably and
immutably.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Rather than creating an empty vector and iteratively appending - which
might induce intermediate allocations - create an ExactSizeIterator and
collect it into a vector, which should produce exactly one allocation.
This commit fixes the (func|line)_info when we have multiple programs in
the same section. The integration test reloc.bpf.c serves as our test
case here. This required filtering down the (func|line)_info to only
that in scope of the current symbol + then adjusting the offets to
appease the kernel.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
This makes a few changes to the way that Aya reads the ELF object
files.
1. To find programs in a section, we use the symbols table. This allows
for cases where multiple programs could appear in the same section.
2. When parsing our ELF file we build symbols_by_section_index as an
optimization as we use it for legacy maps, BTF maps and now programs.
As a result of theses changes the "NAME" used in `bpf.prog_mut("NAME")`
is now ALWAYS the same as the function name in the eBPF code, making the
user experience more consistent.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Wrap verifier logs in a newtype whose `Debug` impl emits unescaped
newlines. This improves ergonomics in tests where we `Result::unwrap()`
those load errors; when these fail today they emit the errors with
newlines escaped, making them incredibly difficult to read.
The matches crate has been archived now that `matches!` is in std.
However `assert_matches!` is still unstable in std, and the
assert_matches crate provides a more expressive form:
```
assert_matches!(foo, Ok(bar) => {
assert_eq!(bar, baz);
});
```
Replace all `assert!(matches!(..))` with `assert_matches!(..)`.
Remove the now-unused build-integration-test xtask command whose logic
doesn't match that of the build-and-run command.
This commit adds a new probe for bpf_attach_cookie, which would be used
to implement USDT probes. Since USDT probes aren't currently supported,
we this triggers a dead_code warning in clippy.
There are cases where exposing FEATURES - our lazy static - is actually
helpful to users of the library. For example, they may wish to choose to
load a different version of their bytecode based on current features.
Or, in the case of an orchestrator like bpfd, we might want to allow
users to describe which features their program needs and return nice
error message is one or more nodes in their cluster doesn't support the
necessary feature set.
To do this without breaking the API, we make all the internal members of
the `Features` and `BtfFeatures` structs private, and add accessors for
them. We then add a `features()` API to avoid leaking the
lazy_static.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>