Commit Graph

64 Commits (6bceb1c3da2d0d71842073a2503810a666ef3caf)

Author SHA1 Message Date
Tamir Duberstein cc2bc0acc1
Remove procfs dependency
Tamir Duberstein b8252f46d9
Skip BPF_F_XDP_HAS_FRAGS tests on unsupported kernels
Tamir Duberstein 91a415f095
Skip relocation tests on unsupported kernels
Tamir Duberstein b0a4ab5f20
xtask: Standardize command logging
Don't run `cargo build --verbose`; it's too noisy.
Tamir Duberstein b611038d5b
Use procfs crate for kernel version parsing
This allows the logic to be shared between aya and the integration tests
without exposing additional public API surface.
Tamir Duberstein 9ca0af1a79
integration-test: Remove integration-test-macros
This doesn't add any value; use `cargo build --tests` with
`--message-format=json` instead; parse the output using `cargo_metadata`
to discover the location of the test binary.

Move test/integration-test/src/tests -> test/integration-test/tests to
conform to
https://doc.rust-lang.org/book/ch11-03-test-organization.html#integration-tests.
Tamir Duberstein 5a2906a6c9
test,xtask: Replace lazy_static with OnceCell
This doesn't affect MSRV because this is testing code.
Tamir Duberstein ff86f1385c
Remove dependency on bpftool in integration tests
Alessandro Decina 11c227743d bpf: improve bpf_probe_read_kernel_str_bytes and bpf_probe_read_user_str_bytes
This change does a few things:

- it fixes a bug in the wrappers, where we were expecting the kernel to
  return len=1 for b"\0" where it instead returns 0 and doesn't write
  out the NULL terminator

- it makes the helpers more robust by hardcoding bound checks in
  assembly so that LLVM optimizations can't transform the checks in a
  way that the verifier can't understand.

- it adds integration tests
dependabot[bot] fa3dd4bef2
build(deps): update rbpf requirement from 0.1.0 to 0.2.0
Updates the requirements on [rbpf](https://github.com/qmonnet/rbpf) to permit the latest version.
- [Commits](https://github.com/qmonnet/rbpf/compare/v0.1.0...v0.2.0)

---
updated-dependencies:
- dependency-name: rbpf
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Mary 85ad0197e0
Merge pull request from marysaka/fix/reloc-less-strict
aya-obj: Make relocations less strict
Mary 35eaa50736 aya-obj: Make relocations less strict
Missing relocations at load time shouldn't cause an error in aya-obj
but instead poison related instructions.

This makes struct flavors work.
Alessandro Decina 3a9a54fd9b
Merge pull request from marysaka/fix/btf-reloc-all-functions
aya: Apply BTF relocations to all functions
Mary c4e721f3d3 aya: Apply BTF relocations to all functions
This fix aya wrong logic causing non entrypoint functions to not have
any BTF relocations working.

Also fix missing section_offset computation for instruction offset in
multiple spots.
Tamir Duberstein d9f966ec9e
aya-log-common: support logging byte slices
These only support LowerHex and UpperHex hints for now.
Mary 9e1109b3ce aya: Move program's functions to the same map
Michal Rostecki 5fa17a192b integration-test: Add tests for aya-log
Michal Rostecki d31a1805da integration-test: Add `tokio_integration_test` macro
This new macro runs a test in a Tokio runtime and it can be used for
asynchronous tests (defined as `async fn`).
dependabot[bot] 4c78f7f1a0
build(deps): 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
...

Signed-off-by: dependabot[bot] <support@github.com>
Alessandro Decina 3a8380df26 integration-test: expand full path for IntegrationTest
Alessandro Decina 93ac3e94bc aya: 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.
Alessandro Decina b2b9bd2edf integration tests: add relocation tests
Alessandro Decina bc8f4ef1c8 integration-tests: rename relocations to btf_relocations
In preparation of adding actual ELF relocation tests
Michal Rostecki ed9c2a1780 integration-tests: Build eBPF programs always with release profile
Also, add the `codegen-unit` option to the profile.
Dave Tucker 7a720ab0c1 aya: 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  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.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Alessandro Decina 9a6f8143a1 aya: btf: add support for BTF_KIND_ENUM64
Alessandro Decina 4482db42d8 aya: btf: fix relocations for signed enums (32 bits)
Enums now carry a signed bit in the info flags. Take it into account
when applying enum relocations.
Alessandro Decina d6b976c6f1 aya: btf: switch ComputedRelocationValue::value to u64
This is in preparation of adding Enum64 relocation support
Alessandro Decina 405c6a8533
Merge pull request from MatteoNardi/remove_libbpf_dependency
Remove libbpf dependency from relocation tests
Michal Rostecki e2b3be6b31
Merge pull request from vadorovsky/integration-smoke-fix-version-check
integration-test: Fix the kernel version chceck for smoke test
Michal Rostecki 75336e5a35 integration-test: Fix the kernel version chceck for smoke test
Before this chane, the check was always negative if the minor version
was less then 9. So, for example, the smoke test was skipped for kernel
6.1:

```
skipping as 6.1 does not meet version requirement of 5.9
```

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Matteo Nardi 3000949bcc Remove libbpf dependency from relocation tests
Simplifiy the relocation tests build process by removing the need for libbpf
at runtime. Its usage is replaced with local `__builtin_*` attributes.
This removes the need for the `LIBBPF_INCLUDE` env variable.
Michal Rostecki dad75f45ac Update Tokio and inventory
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Matteo Nardi 34e040b8e9 tests: use libtest-mimic and fix CI
Matteo Nardi 27f22f205d Make relocations tests actually pass
Matteo Nardi 702f77b565 tests: explain libbpf env variable
Matteo Nardi b72abcc7de tests: add pointer relocation test
Matteo Nardi 7e6a7d9005 btf: add integration tests for relocations
Add new integrations tests for BTF relocations.
Shenghui Ye 772af170ae aya-obj: add documentation on program names
This commit adds documentation on how program names are parsed from
section names, as is used by `aya_obj::Object.programs` as HashMap keys,
and updates the examples into using program names.
Shenghui Ye 311ead6760 aya-obj: add integration tests against rbpf
Alessandro Decina b3ae7786d3 aya: fix detaching links on drop
https://github.com/aya-rs/aya/pull/366 broke detaching links on drop for
everything but FdLink. This restores detach on drop for all links.
Alessandro Decina 9ce1530695 tests: skip tests that assume bpf_link based XDP on older kernels
Dmitry Savintsev 22340764a3 upgrade clap to 4.x
Michal Rostecki 1ded0e61cd
Merge pull request from aya-rs/dependabot/cargo/object-0.30
build(deps): update object requirement from 0.29 to 0.30
dependabot[bot] 1c8088b16c
build(deps): update env_logger requirement from 0.9 to 0.10
Updates the requirements on [env_logger](https://github.com/rust-cli/env_logger) to permit the latest version.
- [Release notes](https://github.com/rust-cli/env_logger/releases)
- [Changelog](https://github.com/rust-cli/env_logger/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-cli/env_logger/compare/v0.9.0...v0.10.0)

---
updated-dependencies:
- dependency-name: env_logger
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
dependabot[bot] 1fe7bba070
build(deps): update object requirement from 0.29 to 0.30
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.29.0...0.30.0)

---
updated-dependencies:
- dependency-name: object
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Dmitry Savintsev 82773f46c8 Make the integration tests handle errors internally.
Instead of returning anyhow>>Result<()> handle errors
'in-place' with unwrap or panic, for more informative
and user-friendly error messages on test failures.

Fixes .

Signed-off-by: Dmitry Savintsev <dsavints@gmail.com>
Andrew Stoycos f3262e87bd Make map APIs return an option
switch map() and map_mut() from returning a
`Result` to an `Option` since it's just getting
a value from a Hashmap, and to stay in line with
the Programs API.

Remove `MapError::MapNotFound`

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
Andrew Stoycos 1aefa2e5e6 Core refactor of Map API
Build completing tests passing

Refactor the Map API to better align
with the aya programs API.  Specifically
remove all internal locking mechanisms
and custom Deref/DerefMut implementations.
They are replaced with a Map enum
and AsRef/AsMut implementations.

All Try_From implementations have been moved
to standardized enums, with a slightly
special one for PerfEventArray's.

Also cleanup/fix all associated tests and
documentation.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
abhijeetbhagat c83d012c51 preserve existing behavior and avoid changes to gh workflows/xtask