Commit Graph

1266 Commits (e95f76a5b348070dd6833d37ea16db04f6afa612)
 

Author SHA1 Message Date
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 bea0e83512
Merge pull request #484 from vadorovsky/update-tokio
Update Tokio and inventory
2 years ago
Michal Rostecki 42c4a8be7c
Merge pull request #487 from vadorovsky/new-map-types
aya-obj: Add new map types
2 years ago
Michal Rostecki 3d03c8a8e0 aya-obj: Add new map types
Include all new map types which were included in the last libbpf update
(5d13fd5aca).

Fixes: cb28533e2f ("aya-obj: Update `BPF_MAP_TYPE_CGROUP_STORAGE` name to `BPF_MAP_TYPE_CGRP_STORAGE`")
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Michal Rostecki 0399991383
Merge pull request #483 from aya-rs/codegen
Update libbpf to 3423d5e7cdab356d115aef7f987b4a1098ede448
2 years ago
Michal Rostecki cb28533e2f aya-obj: Update `BPF_MAP_TYPE_CGROUP_STORAGE` name to `BPF_MAP_TYPE_CGRP_STORAGE`
It changed in libbpf

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
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
alessandrod 5d13fd5aca [codegen] Update libbpf to 3423d5e7cdab356d115aef7f987b4a1098ede448Update libbpf to 3423d5e7cdab356d115aef7f987b4a1098ede448
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_riscv64.rs
M	aya-obj/src/generated/linux_bindings_x86_64.rs
M	bpf/aya-bpf-bindings/src/aarch64/bindings.rs
M	bpf/aya-bpf-bindings/src/aarch64/helpers.rs
M	bpf/aya-bpf-bindings/src/armv7/bindings.rs
M	bpf/aya-bpf-bindings/src/armv7/helpers.rs
M	bpf/aya-bpf-bindings/src/riscv64/bindings.rs
M	bpf/aya-bpf-bindings/src/riscv64/helpers.rs
M	bpf/aya-bpf-bindings/src/x86_64/bindings.rs
M	bpf/aya-bpf-bindings/src/x86_64/helpers.rs
2 years ago
Alessandro Decina 4cc0ea09e0
Merge pull request #467 from MatteoNardi/relocation_tests
Add integration tests for BTF relocations
2 years ago
Matteo Nardi 34e040b8e9 tests: use libtest-mimic and fix CI 2 years ago
Michal Rostecki c0b243930e
Merge pull request #402 from vadorovsky/array-get-ptr
aya-bpf/maps: Add `get_ptr` and `get_mut_ptr` methods to Array
2 years ago
Michal Rostecki 33baf7ef22 aya-bpf/maps: Add `get_ptr` and `get_mut_ptr` methods to Array
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
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
Alessandro Decina 897957ac84
Merge pull request #475 from yesh0/aya-obj
aya-obj: move code for object file loading and relocation into a separate crate
2 years ago
Shenghui Ye 9c451a3357 aya-obj: 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.
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 9ec3447e89 aya-obj: fix rustfmt diffs and typos 2 years ago
Shenghui Ye 30f1fabc05 aya-obj: add no_std feature
The crate has few libstd dependencies. Since it should be platform-
independent in principle, making it no_std like the object crate would
seem reasonable.

However, the feature `error_in_core` is not yet stabilized, and the
thiserror crate currently offers no no_std support. When the feature
no_std is selected, we enable the `error_in_core` feature, switch to
thiserror-core and replace the HashMap with the one in hashbrown.
2 years ago
Shenghui Ye 311ead6760 aya-obj: add integration tests against rbpf 2 years ago
Shenghui Ye e52497cb9c aya-obj: add basic documentation to public members
Types relevant to maps are moved into aya_obj::maps.
Some members are marked `pub(crate)` again.

Refs: #473
2 years ago
Shenghui Ye ac49827e20 aya-obj: 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.

Refs: #473
2 years ago
Shenghui Ye 81bc307dce aya-obj: migrate bindgen destination
Aya::obj depends on bindgen generated files, and we start
by migrating bindgen generated files.

This commit adds the new aya-obj crate to the workplace
and migrates generated files into the crate. We use core
instead of std in an effort to make the final crate no_std.

Bindgen was run against libbpf v1.0.1.

Refs: #473
2 years ago
Alessandro Decina c6f93b1775 btf relocs: don't panic on failed relocation
Error out instead of panicing when we can't find a compatible target
candidate for a relocation.
2 years ago
Alessandro Decina aba99ea4b1 btf: make btf::RelocationError private
BpfError::RelocationError type erases the inner error so no need to
export the type.
2 years ago
Alessandro Decina 63bbef46da Fix lints 2 years ago
Alessandro Decina 12e422b211 btf: fix regression computing pointer sizes
Computing pointer sizes was broken in #285
2 years ago
Tuetuopay 890e8c9340 bpf: fix set_mark by not copying __sk_buff
Such an assignment in two parts (first deref in `unsafe`, then field
access outside of `unsafe`) is bogus: the deref "returned" by the
`unsafe` block actually creates a copy of the `__sk_buff` struct because
it implements `Copy`. The mark value is written to the `mark` field of
the copy, and not the real `__sk_buff`.

Change it to do it all in the `unsafe` block.

The same is done for the `.len()` getter to avoid copying the whole
`__sk_buff` struct for a 32 bit field. Although such a copy should be
optimized out by the compiler, it's better to help it do so.
2 years ago
ajwerner 12927cf699 Don't panic in init when bpf programs don't log
This was broken in d6cb1a16ad.
2 years ago
ajwerner 1a22792ee7 Resolve symbol address for PIE executables
See https://github.com/foniod/redbpf/pull/308 for a similar change.
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
Michal Rostecki 9f5d157628
Merge pull request #461 from FallingSnow/main
Add ability to iterate over LpmTrie keys and matches
2 years ago
Ayrton Sparling 10ac5957c1
Fix LpnTrieKeys -> LpmTrieKeys typo 2 years ago
Alessandro Decina d1919a83ed
Merge pull request #466 from bpfdeploy-io/ml/cgroup-device
Add support for BPF_PROG_TYPE_CGROUP_DEVICE
2 years ago
Milan 925504f230 Fix doctest issue 2 years ago
Milan 4b6d97e4db Fix CI, clippy and feedback
Signed-off-by: Milan <milan@mdaverde.com>
2 years ago
Milan 8f1163a400 Add support for BPF_PROG_TYPE_CGROUP_DEVICE
Kernel 4.15 added a new eBPF program that can
be used with cgroup v2 to control & observe device
access (e.g. read, write, mknod) - `BPF_PROG_TYPE_CGROUP_DEVICE`.

We add the ability to create these programs with the `cgroup_device`
proc macro which creates the `cgroup/dev` link section. Device
details are available to the eBPF program in `DeviceContext`.

The userspace representation is provided with the `CgroupDevice`
structure.

Fixes: #212
Signed-off-by: Milan <milan@mdaverde.com>
2 years ago
Alessandro Decina 9ce1530695 tests: skip tests that assume bpf_link based XDP on older kernels 2 years ago
Ayrton Sparling a44f054bec fix formatting 2 years ago
Alessandro Decina 66d435fc7c
Merge pull request #460 from Tuetuopay/owned-per-cpu-hash-map
maps: add missing TryFrom<Map> for HashMap, PerCpuHashMap and LpmTrie
2 years ago
Ayrton Sparling 1368eb94e7 Remove old test 2 years ago
Ayrton Sparling 9a3682e793 Add ability to iterate over lpmtrie key matches 2 years ago
Ayrton Sparling 8fe64aef1f Fix lpmtrie iter returning nothing 2 years ago
Alexis Bauvin 51bb50ed8e maps: add missing TryFrom<Map> for HashMap, PerCpuHashMap and LpmTrie 2 years ago
Ayrton Sparling e4182a9eab Iterate lpmtrie 2 years ago
Michal Rostecki 16b029ed37
Merge pull request #456 from dmitris/uninlined_format_args
autofix clippy uninlined_format_args issues
2 years ago