# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 0.13.1 (2024-11-01)
### Chore
- Add comments in `*_wrong_map` tests
- Rename bpf -> ebpf
- Fix unused_qualifications lints
This was failing the docs build.
### Documentation
- fix typo
- Use `Ebpf` instead of `Bpf`
### New Features
- Implement TCX
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.
- Provide a deprecated `BpfError` alias
- Rename Bpf to Ebpf
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.
### Bug Fixes
- Fill bss maps with zeros
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.
- Fix PerfEventArray resize logic
There was a logic bug in the previously merged patch where we
set the correctly calculated max_entries size with the original.
To fix this and prevent regressions a unit test was added.
This highlighted that the original map definition needs to be
mutated in order for the max_entries change to be properly applied.
As such, this resize logic moved out of aya::sys into aya::maps
- Set PerfEventArray max_entries to nCPUs
Both libbpf and cilium/ebpf have will set the max_entries of a
BPF_MAP_TYPE_PERF_EVENT_ARRAY to the number of online CPUs if
it was omitted at map definition time. This adds that same
logic to Aya.
- fix panic when creating map on custom ubuntu kernel
- fix rustdocs-args ordering in taplo to -D warnings
This fixes the current rustdoc build error by correcting the ordering of
`rustdoc-args` to `-D warnings`. Additionally, this also removes the
`recorder_arrays` field (defaults to false) so that the order is not
modified, which is what caused the error in the first place.
### Other
- use FdLink in SockOps programs
- remove unwrap and NonZero* in info
Addresses the feedback from #1007:
- remove panic from `unwrap` and `expect`
- Option => 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` 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`
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` 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:
- 4.13.0
- 4.15.0
- 6.1.0
- 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::::uninit();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: remove the unnecessary path segments
|
225 - let mut limit = std::mem::MaybeUninit::::uninit();
225 + let mut limit = mem::MaybeUninit::::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) });
|
```
### Performance
- cache `nr_cpus` in a thread_local
### Test
- adjust test byte arrays for big endian
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.
### New Features (BREAKING)
- Rename BpfRelocationError -> EbpfRelocationError
- Rename BpfSectionKind to EbpfSectionKind
### Commit Statistics
- 69 commits contributed to the release over the course of 241 calendar days.
- 247 days passed between releases.
- 32 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Release aya-obj v0.2.1 ([`c6a34ca`](https://github.com/aya-rs/aya/commit/c6a34cade195d682e1eece5b71e3ab48e48f3cda))
- Merge pull request #1073 from dave-tucker/reloc-bug ([`b2ac9fe`](https://github.com/aya-rs/aya/commit/b2ac9fe85db6c25d0b8155a75a2df96a80a19811))
- Fill bss maps with zeros ([`ca0c32d`](https://github.com/aya-rs/aya/commit/ca0c32d1076af81349a52235a4b6fb3937a697b3))
- Release aya-obj v0.2.0, aya v0.13.0, safety bump aya v0.13.0 ([`c169b72`](https://github.com/aya-rs/aya/commit/c169b727e6b8f8c2dda57f54b8c77f8b551025c6))
- Implement TCX ([`5478cac`](https://github.com/aya-rs/aya/commit/5478cac008471bdb80aa30733e4456b70ec1a5bd))
- Cache `nr_cpus` in a thread_local ([`d05110f`](https://github.com/aya-rs/aya/commit/d05110fd86f9b317d47ffb7cf5c00e588635d4cd))
- Clarify `Arc` usage ([`afd777b`](https://github.com/aya-rs/aya/commit/afd777b705312b7bafec2a116041a2318d3aa70f))
- Replace `Arc` with `&'static` ([`e992c28`](https://github.com/aya-rs/aya/commit/e992c280cbae7af7e484767a0b79314b14a4de84))
- Avoid intermediate allocations in parse_cpu_ranges ([`0e86757`](https://github.com/aya-rs/aya/commit/0e867572ff8e009bbcd1a63037b4ab5b80e35549))
- Reduce duplication in `{nr,possible}_cpus` ([`f3b2744`](https://github.com/aya-rs/aya/commit/f3b27440725a0eb2f1615c92cb0047e3b1548d66))
- Replace `lazy_static` with `std::sync::LazyLock` ([`2b299d4`](https://github.com/aya-rs/aya/commit/2b299d4fba1ddda70c2e8af324f999cb23683559))
- Appease clippy ([`0f16363`](https://github.com/aya-rs/aya/commit/0f163633e3d73c59f857880c967c27e9f52e8610))
- Merge pull request #1023 from l2dy/fdlink/sockops ([`2cd3576`](https://github.com/aya-rs/aya/commit/2cd35769dce05b46a4dd07381c990c6acd4cfe0d))
- Use FdLink in SockOps programs ([`c44f8b0`](https://github.com/aya-rs/aya/commit/c44f8b0f5bddd820a4a98cff293126c0146b827a))
- Remove unwrap and NonZero* in info ([`02d1db5`](https://github.com/aya-rs/aya/commit/02d1db5fc043fb7af90c14d13de6419ec5b9bcb5))
- Merge pull request #985 from reyzell/main ([`40f3032`](https://github.com/aya-rs/aya/commit/40f303205f7a800877fe3f9a4fb1893141741e13))
- Add the option to support multiple and overrideable programs per cgroup ([`f790685`](https://github.com/aya-rs/aya/commit/f790685d759cbd97cb09ad48d87cdece28fbe579))
- Merge pull request #1007 from tyrone-wu/aya/info-api ([`15eb935`](https://github.com/aya-rs/aya/commit/15eb935bce6d41fb67189c48ce582b074544e0ed))
- Revamp MapInfo be more friendly with older kernels ([`fbb0930`](https://github.com/aya-rs/aya/commit/fbb09304a2de0d8baf7ea20c9727fcd2e4fb7f41))
- Revamp ProgramInfo be more friendly with older kernels ([`88f5ac3`](https://github.com/aya-rs/aya/commit/88f5ac31142f1657b41b1ee0f217dcd9125b210a))
- Add conversion u32 to enum type for prog, link, & attach type ([`1634fa7`](https://github.com/aya-rs/aya/commit/1634fa7188e40ed75da53517f1fdb7396c348c34))
- Improve integration tests for info API ([`cb8e478`](https://github.com/aya-rs/aya/commit/cb8e47880082ccfcd75b02209b686e15426e9b6a))
- Merge pull request #959 from tyrone-wu/aya/program_info_stats ([`ab000ad`](https://github.com/aya-rs/aya/commit/ab000ad7c3b0715c3cdd9798bd08fc834b114f1a))
- Merge pull request #974 from Billy99/billy99-arch-ppc64-s390x ([`ab5e688`](https://github.com/aya-rs/aya/commit/ab5e688fd49fcfb402ad47d51cb445437fbd8cb7))
- Adjust bpf programs for big endian ([`cd1db86`](https://github.com/aya-rs/aya/commit/cd1db86fd490b3c0f03229bd8999a2e67ccecfc4))
- Adjust test byte arrays for big endian ([`eef7346`](https://github.com/aya-rs/aya/commit/eef7346fb2231f8741410381198015cceeebfac9))
- Simplify doctest ([`4362020`](https://github.com/aya-rs/aya/commit/43620206918facbf003d8b878ae28c5b07955167))
- Appease nightly clippy ([`bce3c4f`](https://github.com/aya-rs/aya/commit/bce3c4fb1d0cd6e8f9f64420c59e02a42c96b2c8))
- Expose run_time_ns and run_cnt fields in ProgramInfo ([`a25f501`](https://github.com/aya-rs/aya/commit/a25f501ecebaceaacdd1212fac34f528b51ad0fd))
- Add BPF_ENABLE_STATS syscall function ([`fa6af6a`](https://github.com/aya-rs/aya/commit/fa6af6a20439cccd8ab961f83dce545fb5884dd4))
- Fix PerfEventArray resize logic ([`3d57d35`](https://github.com/aya-rs/aya/commit/3d57d358e40591acf23dfde740697fbfff026410))
- Add comments in `*_wrong_map` tests ([`e575712`](https://github.com/aya-rs/aya/commit/e575712c596d03b93f75d160e3d95241eb895d39))
- Set PerfEventArray max_entries to nCPUs ([`25d986a`](https://github.com/aya-rs/aya/commit/25d986a26d9c88cd499a8b795054d583f01476b2))
- Use MockableFd everywhere ([`e12fcf4`](https://github.com/aya-rs/aya/commit/e12fcf46cb1e0856a8105ed43fda184fa4648713))
- Merge pull request #991 from l2dy/typo-1 ([`2cd9858`](https://github.com/aya-rs/aya/commit/2cd9858ea9381232acaffcb5a08bc74e90a8863e))
- Fix typo ([`f1773d5`](https://github.com/aya-rs/aya/commit/f1773d5af43f5f29b100572e65a60d58f2ce7fac))
- Merge pull request #983 from ajwerner/fix-variable-name ([`d5414bf`](https://github.com/aya-rs/aya/commit/d5414bf10c80ae8cef757f0cdf06bfdd38746daa))
- :programs::uprobe: fix bad variable name ([`d413e2f`](https://github.com/aya-rs/aya/commit/d413e2f285643cbeb665fd3c517e2c9d93d45825))
- Fix panic when creating map on custom ubuntu kernel ([`38d8e32`](https://github.com/aya-rs/aya/commit/38d8e32baa5a4538de9daa6fae634aea6372573c))
- Appease clippy ([`78acd74`](https://github.com/aya-rs/aya/commit/78acd74badb6aa2463f89fbdf713325dad75dc9e))
- Don't deny unused_qualifications ([`781914f`](https://github.com/aya-rs/aya/commit/781914f058ef805bd0780ff72a2a66c63255bc07))
- Fix rustdocs-args ordering in taplo to -D warnings ([`5e13283`](https://github.com/aya-rs/aya/commit/5e13283f59b0c3b4cb47de1e31d8d0960e80b4cc))
- Remove deny(pointer_structural_match) ([`4e843a3`](https://github.com/aya-rs/aya/commit/4e843a35237c2de49d17621dccb4a2a35bb4030c))
- Merge pull request #938 from swananan/enhance_urpobe_symbol_lookup ([`bde4b5f`](https://github.com/aya-rs/aya/commit/bde4b5f86b12a3e4ac2f99898edb1b564fe9dd7e))
- Fix clippy ([`c7898c5`](https://github.com/aya-rs/aya/commit/c7898c596f2f74f29570101d0f71f35b0ab4104b))
- Adjust symbol lookup tests for object crate alignment requirements ([`462514e`](https://github.com/aya-rs/aya/commit/462514ed4c4c06e9618d029a57708c7fa14ab748))
- Add symbol lookup in associated debug files ([`e6e1bfe`](https://github.com/aya-rs/aya/commit/e6e1bfeb58ac392637061640365b057182ee1b39))
- Merge pull request #928 from seanyoung/io-error ([`d0e9b95`](https://github.com/aya-rs/aya/commit/d0e9b95aa5edc6c056687caeb950e1ce44b18d66))
- S/MiriSafeFd/MockableFd/ ([`a11b61e`](https://github.com/aya-rs/aya/commit/a11b61ebfde8713c35b6f2a760e470d3586803a7))
- Remove miri ignores ([`cb6d3bd`](https://github.com/aya-rs/aya/commit/cb6d3bd75d162e4928fdf4daa7f515e1ad85ae85))
- Document miri skip reasons ([`35962a4`](https://github.com/aya-rs/aya/commit/35962a4794484aa3b37dadc98a70a659fd107b75))
- Avoid crashing under Miri ([`7a7d168`](https://github.com/aya-rs/aya/commit/7a7d16885a89af8c10a52e5aba0927784d42f551))
- Deduplicate test helpers ([`7e1666f`](https://github.com/aya-rs/aya/commit/7e1666fb83e5c2b270cb24becb84adebbe29be1a))
- Reduce duplication ([`58e154e`](https://github.com/aya-rs/aya/commit/58e154e1bc4846a6a2afcb8397aa599cfb7ea6fd))
- Expose io_error in SyscallError ([`a6c45f6`](https://github.com/aya-rs/aya/commit/a6c45f61c77c4bbec4409debb8447cd606f0db5d))
- Appease clippy ([`09442c2`](https://github.com/aya-rs/aya/commit/09442c2cbe9513365dfc1df8d4f7cf6f808a67ed))
- Generate new bindings ([`b06ff40`](https://github.com/aya-rs/aya/commit/b06ff402780b80862933791831c578e4c339fc96))
- Appease clippy ([`0a32dac`](https://github.com/aya-rs/aya/commit/0a32dacd2fd2f225f4a3709ac4ea2838a9937378))
- Merge pull request #528 from dave-tucker/rename-all-the-things ([`63d8d4d`](https://github.com/aya-rs/aya/commit/63d8d4d34bdbbee149047dc0a5e9c2b191f3b32d))
- Include license in crate workspace ([`a4e68eb`](https://github.com/aya-rs/aya/commit/a4e68ebdbf0e0b591509f36316d12d9689d23f89))
- Use `Ebpf` instead of `Bpf` ([`57a69fe`](https://github.com/aya-rs/aya/commit/57a69fe9d28e858562a429bacd9a0a7700b96726))
- Provide a deprecated `BpfError` alias ([`110a76c`](https://github.com/aya-rs/aya/commit/110a76cb9a1b2ab5c5ad3b6c0828a4ae670e67a0))
- Rename Bpf to Ebpf ([`8c79b71`](https://github.com/aya-rs/aya/commit/8c79b71bd5699a686f33360520aa95c1a2895fa5))
- Rename BpfRelocationError -> EbpfRelocationError ([`fd48c55`](https://github.com/aya-rs/aya/commit/fd48c55466a23953ce7a4912306e1acf059b498b))
- Rename BpfSectionKind to EbpfSectionKind ([`cf3e2ca`](https://github.com/aya-rs/aya/commit/cf3e2ca677c81224368fb2838ebc5b10ee98419a))
- Rename bpf -> ebpf ([`70ac91d`](https://github.com/aya-rs/aya/commit/70ac91dc1e6f209a701cd868db215763d65efa73))
- Fix unused_qualifications lints ([`481b73b`](https://github.com/aya-rs/aya/commit/481b73b6d8dd9a796d891bba137400c2a43a0afe))
- Add `CgroupDevice::query` ([`542306d`](https://github.com/aya-rs/aya/commit/542306d295e51ac1ec117ce453544f201875af3d))
- Appease new nightly clippy lints ([`e38eac6`](https://github.com/aya-rs/aya/commit/e38eac6352ccb5c2b44d621161a27898744ea397))
## 0.13.0 (2024-10-09)
### Chore
- Add comments in `*_wrong_map` tests
- Rename bpf -> ebpf
- Fix unused_qualifications lints
This was failing the docs build.
### Documentation
- fix typo
- Use `Ebpf` instead of `Bpf`
### New Features
- Implement TCX
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.
- Provide a deprecated `BpfError` alias
- Rename Bpf to Ebpf
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.
### Bug Fixes
- Fix PerfEventArray resize logic
There was a logic bug in the previously merged patch where we
set the correctly calculated max_entries size with the original.
To fix this and prevent regressions a unit test was added.
This highlighted that the original map definition needs to be
mutated in order for the max_entries change to be properly applied.
As such, this resize logic moved out of aya::sys into aya::maps
- Set PerfEventArray max_entries to nCPUs
Both libbpf and cilium/ebpf have will set the max_entries of a
BPF_MAP_TYPE_PERF_EVENT_ARRAY to the number of online CPUs if
it was omitted at map definition time. This adds that same
logic to Aya.
- fix panic when creating map on custom ubuntu kernel
- fix rustdocs-args ordering in taplo to -D warnings
This fixes the current rustdoc build error by correcting the ordering of
`rustdoc-args` to `-D warnings`. Additionally, this also removes the
`recorder_arrays` field (defaults to false) so that the order is not
modified, which is what caused the error in the first place.
### Other
- use FdLink in SockOps programs
- remove unwrap and NonZero* in info
Addresses the feedback from #1007:
- remove panic from `unwrap` and `expect`
- Option => 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` 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`
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` 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:
- 4.13.0
- 4.15.0
- 6.1.0
- 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::::uninit();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: remove the unnecessary path segments
|
225 - let mut limit = std::mem::MaybeUninit::::uninit();
225 + let mut limit = mem::MaybeUninit::::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) });
|
```
### Performance
- cache `nr_cpus` in a thread_local
### Test
- adjust test byte arrays for big endian
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.
### New Features (BREAKING)
- Rename BpfRelocationError -> EbpfRelocationError
- Rename BpfSectionKind to EbpfSectionKind
## 0.12.0 (2024-02-28)
### Chore
- Use the cargo workspace package table
This allows for inheritance of common fields from the workspace root.
The following fields have been made common:
- authors
- license
- repository
- homepage
- edition
- Appease clippy unused imports
- tracefs review fixes
### Chore
- Don't use path deps in workspace
This moves the path dependencies back into the per-crate Cargo.toml.
It is required such that the release tooling can correctly calculate
which version constraints require changing when we perform a release.
### Documentation
- Document breaking changes
This provides a `BREAKING-CHANGES.md` that we can populate per-crate.
Doing so will allow us to pull this content into our changelog and
websites to make things easier for users.
- Add labels for optional features
Following the lead of crates like tokio and nix, we now annotate APIs
that require optional features. This helps in cases where a user wants
to have an `AsyncPerfEventArray` which is documented on crates.io, but
it's not obvious that you have to enable the `async` feature.
- Add crabby logo
- Document more breaking changes
- Add CHANGELOG
### New Features
- get_tracefs function
### Bug Fixes
- invalid transmute when calling fd
Corrent an invalid transmutation for sock_map.
fd is already a ref of MapFd, so transmuting &fd to &SockMapFd is
equivalent to transmuting &&SockMapFd into &SockMapFd which is buggy.
- Relax unnecessarily strict atomic ordering on probe event_alias
- remove useless `any` `all` in cfg.
### Other
- reformat to please rustfmt
- export some missing modules
Previously we were only re-exporting the program types from these, so
links and other pub types were not exported.
- perf_event: add inherit argument to attach()
- add StackTraceMap::remove()
- appease new nightly clippy lints
```
error: this call to `as_ref.map(...)` does nothing
--> aya/src/bpf.rs:536:30
|
536 | let btf_fd = btf_fd.as_ref().map(Arc::clone);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `btf_fd.clone()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_asref
note: the lint level is defined here
--> aya/src/lib.rs:41:5
|
41 | clippy::all,
| ^^^^^^^^^^^
= note: `#[deny(clippy::useless_asref)]` implied by `#[deny(clippy::all)]`
error: could not compile `aya` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: initializer for `thread_local` value can be made `const`
--> aya/src/sys/fake.rs:14:61
|
14 | pub(crate) static TEST_MMAP_RET: RefCell<*mut c_void> = RefCell::new(ptr::null_mut());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(ptr::null_mut()) }`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#thread_local_initializer_can_be_made_const
= note: `#[deny(clippy::thread_local_initializer_can_be_made_const)]` implied by `#[deny(clippy::all)]`
```
- appease nightly lint
```
error: lint `unused_tuple_struct_fields` has been renamed to `dead_code`
--> aya/src/lib.rs:74:5
|
74 | unused_tuple_struct_fields,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `dead_code`
|
= note: `-D renamed-and-removed-lints` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(renamed_and_removed_lints)]`
```
See https://github.com/rust-lang/rust/commit/9fcf9c141068984ffcbb4cb00c.
- add SchedClassifier::attach_to_link
Similar to Xdp::attach_to_link, can be used to replace/upgrade the
program attached to a link.
- add SchedClassifierLink::attach_type() getter
The link already exposes priority() and handle(). Expose attach_type()
too.
- Fix ringbuf docs
doctests are not running in CI and therefore the didn't catch the
ringbuf docs failures. This commit fixes the issues in the examples.
- pin for (async)perf_event_array
Implement pinning for perf_event_array and async_perf_event_array.
Additionally make the core MapData.pin method operate on a reference
rather than a mutable reference.
- make RingBuf: Send + Sync
There was no reason for them not to be -- the APIs all require mutable
references and hold onto mutable references, so there cannot be internal
concurrency. The !Send + !Sync came from the MMap, but not for any good
reason.
- extracting program and map names with the same function
- add MapInfo struct following the same pattern as ProgramInfo
This makes the APIs for loading maps and programs more similar.
- support loading a map by fd
This adds support to loading maps by fd similarly to the way programs
can be loaded by fd.
- make KernelVersion::code public
- Add markdownlint
This adds a linter to catch common markdown formatting errors.
The linter used is markdownlint-cli2 which is available on all platforms
and has an associated Github Action to automate these checks in CI.
Configuration is checked in at .markdownlint-cli2.yaml.
You may run the check locally using `markdownlint-cli2`.
Or you may install the extension for VSCode:
DavidAnson.vscode-markdownlint
- update async-io requirement from 1.3 to 2.0
Updates the requirements on [async-io](https://github.com/smol-rs/async-io) to permit the latest version.
- [Release notes](https://github.com/smol-rs/async-io/releases)
- [Changelog](https://github.com/smol-rs/async-io/blob/master/CHANGELOG.md)
- [Commits](https://github.com/smol-rs/async-io/compare/v1.3.0...v1.13.0)
---
updated-dependencies:
- dependency-name: async-io
dependency-type: direct:production
...
- fix unused async-io dependency linter error
Not using the `dep:` syntax created a Cargo feature flag for async-io,
though this feature alone does nothing without the `async_std` or
`async_tokio` features.
- Implement RingBuf
This implements the userspace binding for RingBuf.
Instead of streaming the samples as heap buffers, the process_ring
function takes a callback to which we pass the event's byte region,
roughly following [libbpf]'s API design. This avoids a copy and allows
marking the consumer pointer in a timely manner.
- move mmap from perf_buffer.rs to sys/mod.rs
mmap() is needed for the ring buffer implementation, so move it to a common module
- impl From for MapTypeError
- sort variants
Missed in 5e637071c130fece2b26f6a7246bdef5f782fced due to merge skew
with 7b71c7e1cd8d6948764d02afb0279151c6eae437.
- import types from std::ffi rather than libc
- sort variants
- remove redundant keys
`default-features = false` is already in the root Cargo.toml.
- add pin() api
- Adds new `maps_mut()` API to the BpfManager to allow us to iterate though
and pin all of maps at the same time.
- Adds new pin(Path)/unpin(Path) api to Maps so they
can be generically pinned AFTER load.
- Adds macro for pinning explicit map types in aya.
Convert all explicit map types "inner" field to be
pub crate in order to facilitate this.
- fix libbpf_pin_by_name
Aligns with libbpf for the special LIBBPF_PIN_BY_NAME
map flag. Specifically if the flag is provided without a pin path
default to "/sys/fs/bpf".
- Deprecate `syscall_prefix`
Using the prefix only for the host architecture is often not enough,
kernels usually provide symbols for more architectures, which are
used by multilib applications. Handling them might or might not be
necessary depending on the use case. Due to that complexity, we
decided to let the callers to handle prefixes the way they prefer.
- group_imports = "StdExternalCrate"
High time we stop debating this; let the robots do the work.
- Fix program loading on kernels with a patch > 255
- fix load time and add test
Time since boot is defined as the UNIX_EPOCH plus the duration
since boot. which is realtime - boottime NOT boottime - realtime.
Add a integration test to ensure this doesn't happen again.
- make maps work on kernels not supporting ProgIds
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.
- use ProgramFd instead of impl AsRawFd
Not having a generic here allows to pass `None` without specifying the
actual type you don't care about.
- add documentation for XDP maps
- fix docstring missing trailing period
- add support for chained xdp programs in {cpu,dev}map
set/insert functions can now take an optional bpf program fd to run once
the packet has been redirected from the main probe
- add support for map-bound XDP programs
Such programs are to be bound to cpumap or devmap instead of the usual
network interfaces.
- Update XDP maps implementations
Map impls changed since this was first written.
- Implement XDP Map Types
This commit adds implementations for:
- xskmap
- devmap
- devmap_hash
- cpumap
Which can all be used to redirect XDP packets to various different
locations
- Make MapData::pin pub
This is to solve a use-case where a user (in this case bpfd) may want
to:
- MapData::from_pin to open a pinned map from bpffs
- MapData::pin to pin that object into another bpffs
Both operations should be easily accomplished without needing to cast
a MapData into a concrete Map type - e.g aya::maps::HashMap.
- Remove MapData::pinned
BPF objects can be pinned multiple times, to multiple different places.
Tracking whether or not a map is pinned in a bool is therefore not sufficient.
We could track this in a HashSet, but there is really no reason
to track it at all.
- fix typos, avoid fallible conversions
- MapData::{obj, fd} are private
- `MapFd` and `SockMapFd` are owned
- add program_info() api to program
Add a new api to the outer level `Program` structure which
allows users to get the program's kernel info before casting
it to an explicit program variant.
- support TryFrom for LRU hash maps
The macro to implement TryFrom for MapData didn't have the ability to
specify that more than one variant of MapData can be valid for a single
map implementation. Support for new syntax was added to the macro so that
the implementation can succeed for both valid variants in the HashMap
and PerCpuHashMap impl.
- rework TryFrom macros
The old macros were repetitive and inflexible. This unifies the various
macros used to generate TryFrom implementations for map implementations
from the relevant map enum variants.
Cleanup in anticipation of fixing #636.
The API changes are just about renaming the return to Self and
Self::Error; they are not real changes.
- access inner through async
Avoid holding onto raw file descriptors.
Remove some implied bounds (BorrowMut implies Borrow).
- ProgAttachLink and LircLink hold owned FDs
- use OwnedFd
- Use AsFd when attaching fds to programs
This is a breaking change but adds another level of safety to ensure
the file descriptor we receive is valid. Additionally, this allows
aya to internally easily duplicate this file descriptor using std
library methods instead of manually calling `dup` which doesn't
duplicate with the CLOSE_ON_EXEC flag that is standard pratice to
avoid leaking the file descriptor when exec'ing.
- Use BorrowedFd when using the program fd in sys/bpf.rs
This commit reveals but does not address a file descriptor leak in
LircLink2::query. This function returns a list of `LircLink`s where
each of them have a program file descriptor that is not going to be
closed. This commit does not add this leak; it merely makes it louder
in the code.
- support non-UTF8 probing
- avoid path UTF-8 assumptions
- deny various allow-by-default lints
- fix docs build
Appease the new lint rustdoc::redundant_explicit_links that was added in
https://github.com/rust-lang/rust/pull/113167.
- BloomFilter::insert takes &mut self
This is consistent with all the other maps.
- MapData::fd is non-optional
The primary driver of change here is that `MapData::create` is now a
factory function that returns `Result` 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.
- use RAII to close FDs
- `ProgramData::attach_prog_fd` is owned
This prevents a file descriptor leak when extensions are used.
This is an API breaking change.
- `ProgramFd` is owned
- add helper methods for ProgramInfo
- Add helper methods to get useful information from the ProgramInfo
object which is returned by the `loaded_programs()` API. Specifically
this code mirrors the `bpftool prog` command in terms of useful fields.
- Add a new API macro to each aya `Program` type to allow us to fetch
its accompanying `ProgramInfo` metadata after its been loaded.
- Add a new ProgramInfo constructor that builds a new instance using
a raw fd.
- Add a smoke test for the loaded_programs() API as well as
all the relevant methods on the ProgramInfo type.
- Plug attach_btf_obj_fd leak
- Don't store bpf_fd in MapData
This is only used in create and therefore can be passed
as a parameter.
- refactor btf_obj_get_info_by_fd to share code
- add map_ids to bpf_prog_get_info_by_fd
Allows the caller to pass a slice which the kernel will populate with
map ids used by the program.
- avoid vector allocation when parsing ksyms
- Use OwnedFd in FdLink.
- Remove name from ProgramSection
The name here is never used as we get the program name from the symbol
table instead.
- refactor target resolution
This attempts to do fewer lossy conversions and to avoid some
allocations.
- extract library path resolving
The function is extracted so that a test could be written. This test is
valid on linux-gnu targets, and it doesn't need any special privileges.
This is in anticipation of removing the code that uses this functionality
(seemingly incidentally) from integration tests.
- Set BPF_F_SLEEPABLE for sleepable programs
- preallocate the vector
This code badly needs tests :(
- plug file descriptor leak
This leaked a file descriptor if bpf_prog_get_info_by_fd failed.
- push error construction up
- make `loaded_programs` opaque
- extract common SyscallError
We currently have 4 copies of this.
- `sys_bpf` takes mut ref
Some syscalls mutate the argument, we can't be passing an immutable
reference here.
- avoid repeating BPF_BTF_LOAD dance
- Return `OwnedFd` for `perf_event_open`.
This fixes a file descriptor leak when creating a link of
BPF_PERF_EVENT attach type.
- better panic messages
Always include operands in failing assertions. Use assert_matches over
manual match + panic.
- Use Arc when loading BTF fd
This fixes an existing file descriptor leak when there is BTF data in
the loaded object.
To avoid lifetime issues while having minimal impact to UX the
`OwnedFd` returned from the BPF_BTF_LOAD syscall will be wrapped in an
`Arc` and shared accross the programs and maps of the loaded BPF
file.
- Make SysResult generic on Ok variant
- bpf_prog_get_fd_by_id returns OwnedFd
- Define dependencies on the workspace level
This way we will avoid version mismatches and make differences in
features across our crates clearer.
- Ignore embedded BTF error if not truely required
This allows fallback to BTF manual relocation when BTF loading fail when not truely required.
- compile C probes using build.rs
- Add libbpf as a submodule. This prevents having to plumb its location
around (which can't be passed to Cargo build scripts) and also
controls the version against which codegen has run.
- Move bpf written in C to the integration-test crate and define
constants for each probe.
- Remove magic; each C source file must be directly enumerated in the
build script and in lib.rs.
- don't allocate static strings
- Make Features part of the public API
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.
- Remove iter_key from LPM Trie API
Based on the discussion in Discord we've decided to drop the
iter_key() API for LPM Trie. According to the kernel self-tests and
experimentation done in Aya, providing a key into bpf_map_get_next_id
will either:
- If key is an EXACT match, proceed iterating through all keys in the
trie from this point
- If key is NOT an EXACT match, proceed iterating through all keys in
the trie starting at the leftmost entry.
An API in Aya could be crafted that gets the LPM match + less specific
matches for a prefix using these semantics BUT it would only apply to
userspace. Therefore we've opted out of fixing this.
- replace os::unix::prelude with os::fd
- allow global value to be optional
This allow to not error out when a global symbol is missing from the object.
- add syscall_prefix and syscall_fnname_add_prefix
These two functions are needed because kernel symbols representing
syscalls have architecture-specific prefixes.
These are the equivalent of bcc's get_syscall_fnname and
get_syscall_prefix.
- Fix uprobe support on 4.16 and lower
Fix uprobe support on Ubuntu 18.04.
- Add support for old ld.so.cache format
This fix uprobe support on Debian 10. (and possibly others)
This implement support to parse the original libc5 format.
- Make probe event_alias unique
This fixes issues when trying to attach the same kernel function multiple times on 4.17 and lower (possibly upper too?)
- Do not create data maps on kernel without global data support
Fix map creation failure when a BPF have a data section on older
kernel. (< 5.2)
If the BPF uses that section, relocation will fail accordingly and
report an error.
- Move program's functions to the same map
- update bitflags requirement from 1.2.1 to 2.2.1
Updates the requirements on [bitflags](https://github.com/bitflags/bitflags) to permit the latest version.
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bitflags/bitflags/compare/1.2.1...2.2.1)
- update object requirement from 0.30 to 0.31
Updates the requirements on [object](https://github.com/gimli-rs/object) to permit the latest version.
- [Release notes](https://github.com/gimli-rs/object/releases)
- [Changelog](https://github.com/gimli-rs/object/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gimli-rs/object/compare/0.30.0...0.31.0)
---
updated-dependencies:
- dependency-name: object
dependency-type: direct:production
...
- flip feature "no_std" to feature "std"
This fixes `cargo build --all-features` by sidestepping the feature
unification problem described in The Cargo Book[0].
Add `cargo hack --feature-powerset` to CI to enforce that this doesn't
regress (and that all combinations of features work).
Since error_in_core is nightly-only, use core-error and a fake std
module to allow aya-obj to build without std on stable.
[0] https://doc.rust-lang.org/cargo/reference/features.html#feature-unification
- Correctly set the kernel code version for Debian kernel
Fix BPF syscall failure related to the kernel code version.
- Correctly set the kernel code version for Ubuntu kernel
Fix BPF syscall failure related to the kernel code version.
- Add sanitize code for kernels without bpf_probe_read_kernel
Required for kernel before 5.5.
Also move Features to aya-obj.
- Do not use unwrap with btf_fd in bpf_create_map
Fixes a crash when trying to create a map of type BPF_MAP_TYPE_PERCPU_ARRAY when btf_fd is None.
Tested on Ubuntu 18.04 (4.15.0-202-generic)
- support relocations across multiple text sections + fixes
Fix R_BPF_64_64 text relocations in sections other than .text (for
instance .text.unlikely). Also fix misc bugs triggered by integration
tests.
- make it possible to use set_global() with slices of Pod(s)
- make it possible to use set_global() with slices of Pod(s)
- Allow to attach XDP probe by interface index
- Fix MapData Clone implementation
The Clone implementation of MapData was previously not storing the
result of the dup operation.
- Add loaded_programs() API to list all loaded programs
This uses a Programs iterator to yield all loaded bpf programs using
bpf_prog_get_next_id.
- MapData should be Borrow, not AsRef
We don't ever do ref-to-ref conversion for MapData so Borrow should
suffice.
- Fix is_perf_link_supported
This was mistakenly comparing the exit code of the syscall, which is
always -1 and not the corresponding error-code. Added unit tests to
ensure we don't regress.
- More discrete feature logging
Just use the Debug formatter vs. printing a message for each probe.
- Enable bpf_link for perf_attach programs
This adds support for bpf_link to PerfEvent, Tracepoint, Kprobe and
Uprobe programs.
- Add probe for bpf_link_create for perf programs
- Make features a lazy_static
- Add support for multibuffer programs
This adds support for loading XDP programs that are multi-buffer
capable, which is signalled using the xdp.frags section name. When this
is set, we should set the BPF_F_XDP_HAS_FRAGS flag when loading the
program into the kernel.
- Add from_pin for Programs
This commit adds from_pin() which allows the creation of a Program
from a path on bpffs. This is useful to be able to call `attach` or
other APIs for programs that are already loaded to the kernel.
This differs from #444 since it implements this on the concrete program
type, not the Program enum, allowing the user to pass in any additional
context that isn't available from bpf_prog_info.
- fix Lru and LruPerCpu hash maps
They were broken by https://github.com/aya-rs/aya/pull/397
- update documentation and versioning info
- Set the version number of `aya-obj` to `0.1.0`.
- Update the description of the `aya-obj` crate.
- Add a section in README and rustdoc warning about the unstable API.
- add basic documentation to public members
Types relevant to maps are moved into aya_obj::maps.
Some members are marked `pub(crate)` again.
- migrate aya::obj into a separate crate
To split the crate into two, several changes were made:
1. Most `pub(crate)` are now `pub` to allow access from Aya;
2. Parts of BpfError are merged into, for example, RelocationError;
3. BTF part of Features is moved into the new crate;
4. `#![deny(missing_docs)]` is removed temporarily;
5. Some other code gets moved into the new crate, mainly:
- aya::{bpf_map_def, BtfMapDef, PinningType},
- aya::programs::{CgroupSock*AttachType},
The new crate is currenly allowing missing_docs. Member visibility
will be adjusted later to minimize exposure of implementation details.
- migrate bindgen destination
- make btf::RelocationError private
- fix regression computing pointer sizes
Computing pointer sizes was broken in #285
- fix detaching links on drop
- add missing TryFrom