Commit Graph

94 Commits (17f25a67934ad10443a4fbb62a563b5f6edcaa5f)

Author SHA1 Message Date
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.
1 year ago
Alessandro Decina b2b9bd2edf integration tests: add relocation tests 1 year ago
Alessandro Decina bc8f4ef1c8 integration-tests: rename relocations to btf_relocations
In preparation of adding actual ELF relocation tests
1 year ago
Michal Rostecki ed9c2a1780 integration-tests: Build eBPF programs always with release profile
Also, add the `codegen-unit` option to the profile.
1 year ago
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 #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.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Alessandro Decina 9a6f8143a1 aya: btf: add support for BTF_KIND_ENUM64 2 years ago
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.
2 years ago
Alessandro Decina d6b976c6f1 aya: btf: switch ComputedRelocationValue::value to u64
This is in preparation of adding Enum64 relocation support
2 years ago
Alessandro Decina 405c6a8533
Merge pull request #485 from MatteoNardi/remove_libbpf_dependency
Remove libbpf dependency from relocation tests
2 years ago
Michal Rostecki e2b3be6b31
Merge pull request #486 from vadorovsky/integration-smoke-fix-version-check
integration-test: Fix the kernel version chceck for smoke test
2 years ago
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>
2 years ago
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.
2 years ago
Michal Rostecki dad75f45ac Update Tokio and inventory
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Matteo Nardi 34e040b8e9 tests: use libtest-mimic and fix CI 2 years ago
Matteo Nardi 27f22f205d Make relocations tests actually pass 2 years ago
Matteo Nardi 702f77b565 tests: explain libbpf env variable 2 years ago
Matteo Nardi b72abcc7de tests: add pointer relocation test 2 years ago
Matteo Nardi 7e6a7d9005 btf: add integration tests for relocations
Add new integrations tests for BTF relocations.
2 years ago
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.
2 years ago
Shenghui Ye 311ead6760 aya-obj: add integration tests against rbpf 2 years ago
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.
2 years ago
Alessandro Decina 9ce1530695 tests: skip tests that assume bpf_link based XDP on older kernels 2 years ago
Dmitry Savintsev 22340764a3 upgrade clap to 4.x 2 years ago
Michal Rostecki 1ded0e61cd
Merge pull request #450 from aya-rs/dependabot/cargo/object-0.30
build(deps): update object requirement from 0.29 to 0.30
2 years ago
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>
2 years ago
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>
2 years ago
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 #421.

Signed-off-by: Dmitry Savintsev <dsavints@gmail.com>
2 years ago
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>
2 years ago
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>
2 years ago
abhijeetbhagat c83d012c51 preserve existing behavior and avoid changes to gh workflows/xtask 2 years ago
abhijeetbhagat 7499661670 fix formatting 2 years ago
abhijeetbhagat 638cf514fb use macro to log, execute test and handle error 2 years ago
abhijeetbhagat 5b3e0ee856 add list, run cli flags to integration tests.
fixes: #338
2 years ago
Michal Rostecki b15e1f8226 integration-test: Change `assert_loaded` to a macro with timeouts
We often need to wait a bit until the program or link gets unloaded
after dropping.

Also, using a macro makes it clear in which particular test the panic
happened.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Michal Rostecki 325391892c integration-test: Remove multimap C test
libbpf 1.0 doesn't support multimaps defined in `maps` section, it
supports only BTF maps.

At the same time, we already test multimaps loading with the Rust
example (`integration-ebpf/src/bpf/map_test.rs`), so we can just remove
the failing C test.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Dave Tucker 5693fb9941 aya: Rename from_pinned and from_path to from_pin
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 7c244e1f65 tests: Add integration test for pinning lifecycle
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 8305ee1eca test: Fix clippy lint
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 4826bf7f74
Merge pull request #366 from dave-tucker/pin-redux-2
aya: Fix Link Pinning
2 years ago
Dave Tucker 4c1d645aa6 aya: Fix Link Pinning
1. Removes OwnedLink
2. Allows Links to be converted into FdLink
3. Introduces a PinnedLink type to handle wrap FdLink when pinned and
   support un-pinning

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Michal Rostecki 944d6b8a16 Change from Rust edition 2018 to 2021
Rust 2021 adds more core prelude imports, including `TryFrom` and
`TryInto`.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Michal Rostecki 3664e1ea0d aya-log, test: Switch from simplelog to env_logger
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Dave Tucker f976229477 Support BTF Maps
This commit allows for BTF maps in the .maps ELF section to be parsed.
It reads the necessary information from the BTF section of the ELF file.
While the btf_ids of Keys and Values types are stored, they are not (yet)
used.

When creating a BTF map, we pass the btf_key_type_id and
btf_value_type_id.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 79101e748a test: Replace RTF with Rust
This commit replaces the existing RTF test runner with a simple rust
binary package called - integration-test.

integration-test depends on integration-ebpf, which contains test eBPF
code written in Rust and C. `cargo xtask build-integration-test-ebpf`
can be used to build this code and supress rust-analyzer warnings. It
does require `bpf-linker`, but that is highly likely to be available to
developers of Aya. It also requires a checkout of `libbpf` to extract
headers like bpf-helpers.h.

Since everything is compiled into a single binary, it can be run
be run locally using `cargo xtask integration-test` or remotely using
`./run.sh` which re-uses the bash script from the old test framework
to spawn a VM in which to run the tests.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago