-
use FdLink in SockOps programs
-
remove unwrap and NonZero* in info
Addresses the feedback from #1007:
- remove panic from
unwrap and expect
- Option<NonZero*> => Option with
0 mapping to None
-
revamp MapInfo be more friendly with older kernels
Adds detection for whether a field is available in MapInfo:
- For
map_type(), we treturn new enum MapType instead of the integer
representation.
- For fields that can't be zero, we return
Option<NonZero*> type.
- For
name_as_str(), it now uses the feature probe bpf_name() to
detect if field is available.
Although the feature probe checks for program name, it can also be
used for map name since they were both introduced in the same commit.
-
revamp ProgramInfo be more friendly with older kernels
Purpose of this commit is to add detections for whether a field is
available in ProgramInfo.
- For
program_type(), we return the new enum ProgramType instead of
the integer representation.
- For fields that we know cannot be zero, we return
Option<NonZero*>
type.
- For
name_as_str(), it now also uses the feature probe bpf_name()
to detect if field is available or not.
- Two additional feature probes are added for the fields:
prog_info_map_ids() probe -> map_ids() field
prog_info_gpl_compatible() probe -> gpl_compatible() field
With the prog_info_map_ids() probe, the previous implementation that
I had for bpf_prog_get_info_by_fd() is shortened to use the probe
instead of having to make 2 potential syscalls.
The test_loaded_at() test is also moved into info tests since it is
better related to the info tests.
-
add conversion u32 to enum type for prog, link, & attach type
Add conversion from u32 to program type, link type, and attach type.
Additionally, remove duplicate match statement for u32 conversion to
BPF_MAP_TYPE_BLOOM_FILTER & BPF_MAP_TYPE_CGRP_STORAGE.
New error InvalidTypeBinding<T> is created to represent when a
parsed/received value binding to a type is invalid.
This is used in the new conversions added here, and also replaces
InvalidMapTypeError in TryFrom for bpf_map_type.
-
improve integration tests for info API
Improves the existing integraiton tests for loaded_programs() and
loaded_maps() in consideration for older kernels:
- Opt for
SocketFilter program in tests since XDP requires v4.8 and
fragments requires v5.18.
- For assertion tests, first perform the assertion, if the assertion
fails, then it checks the host kernel version to see if it is above
the minimum version requirement. If not, then continue with test,
otherwise fail.
For assertions that are skipped, they're logged in stderr which can
be observed with
-- --nocapture.
This also fixes the bpf_prog_get_info_by_fd() call for kernels below
v4.15. If calling syscall on kernels below v4.15, it can produce an
E2BIG error because check_uarg_tail_zero() expects the entire
struct to all-zero bytes (which is caused from the map info).
Instead, we first attempt the syscall with the map info filled, if it
returns E2BIG, then perform syscall again with empty closure.
Also adds doc for which version a kernel feature was introduced for
better awareness.
The tests have been verified kernel versions:
-
adjust bpf programs for big endian
In aya/src/sys/bpf.rs, there are several simple bpf programs written as
byte arrays. These need to be adjusted to account for big endian.
-
expose run_time_ns and run_cnt fields in ProgramInfo
Added functions to expose run_time_ns & run_cnt statistics from
ProgramInfo/bpf_prog_info.
-
add BPF_ENABLE_STATS syscall function
Add bpf syscall function for BPF_ENABLE_STATS to enable stats tracking
for benchmarking purposes.
Additionally, move #[cfg(test)] annotation around the Drop trait
instead. Having separate functions causes some complications when
needing ownership/moving of the inner value OwnedFd when Drop is
manually implemented.
-
:programs::uprobe: fix bad variable name
The variable fn_name was very much not the fn_name, but rather the
object file path.
-
adjust symbol lookup tests for object crate alignment requirements
The object::File::parse API requires parameter to be aligned with 8 bytes.
Adjusted the Vec in the tests with miri to meet this requirement.
-
add symbol lookup in associated debug files
This change enhances the logic for symbol lookup in uprobe or uretprobe.
If the symbol is not found in the original binary, the search continues
in the debug file associated through the debuglink section. Before
searching the symbol table, it compares the build IDs of the two files.
The symbol lookup will only be terminated if both build IDs exist and do
not match. This modification does not affect the existing symbol lookup
logic.
-
Generate new bindings
-
include license in crate workspace
This PR includes the licenses files in the crate workspace subdirectory.
Without this, they won't be showing on crates.io and would be giving out
errors on tooling such as rust2rpm.
-
appease new nightly clippy lints
error: unnecessary qualification
--> aya/src/maps/ring_buf.rs:434:22
|
434 | ptr: ptr::NonNull::new(ptr).ok_or(
| ^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> aya/src/lib.rs:72:5
|
72 | unused_qualifications,
| ^^^^^^^^^^^^^^^^^^^^^
help: remove the unnecessary path segments
|
434 - ptr: ptr::NonNull::new(ptr).ok_or(
434 + ptr: NonNull::new(ptr).ok_or(
|
error: unnecessary qualification
--> aya/src/maps/mod.rs:225:21
|
225 | let mut limit = std::mem::MaybeUninit::<rlimit>::uninit();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: remove the unnecessary path segments
|
225 - let mut limit = std::mem::MaybeUninit::<rlimit>::uninit();
225 + let mut limit = mem::MaybeUninit::<rlimit>::uninit();
|
error: unnecessary qualification
--> aya/src/programs/mod.rs:614:9
|
614 | crate::obj::Program {
| ^^^^^^^^^^^^^^^^^^^
|
help: remove the unnecessary path segments
|
614 - crate::obj::Program {
614 + obj::Program {
|
error: unnecessary qualification
--> aya/src/util.rs:373:14
|
373 | unsafe { std::slice::from_raw_parts(bpf_name.as_ptr() as
*const _, length) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: remove the unnecessary path segments
|
373 - unsafe { std::slice::from_raw_parts(bpf_name.as_ptr() as
*const _, length) }
373 + unsafe { slice::from_raw_parts(bpf_name.as_ptr() as *const _,
length) }
|
error: unnecessary qualification
--> aya/src/maps/mod.rs:1130:47
|
1130 | .copy_from_slice(unsafe {
std::mem::transmute(TEST_NAME) });
| ^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> aya/src/lib.rs:72:5
|
72 | unused_qualifications,
| ^^^^^^^^^^^^^^^^^^^^^
help: remove the unnecessary path segments
|
1130 - .copy_from_slice(unsafe {
std::mem::transmute(TEST_NAME) });
1130 + .copy_from_slice(unsafe {
mem::transmute(TEST_NAME) });
|