Commit Graph

1489 Commits (cc48523347c2be5520779ef8eeadc6d3a68649d0)
 

Author SHA1 Message Date
Alessandro Decina 8e9608eedd test/run.sh: output `uname -a` after starting the vm 2 years ago
Alessandro Decina c7b262641b Run integration tests under fedora37 2 years ago
Michal Rostecki d2a999d27a
Merge pull request #504 from vadorovsky/unpin-nightly
Unpin Rust nightly
2 years ago
Michal Rostecki 7d19bde66b Unpin Rust nightly
The issues with core::sync::atomic got fixed.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Alessandro Decina 3e9d85f871
Merge pull request #500 from vadorovsky/bpf-macros-visibility
aya-bpf-macros: Allow to make programs public
2 years ago
Alessandro Decina 7e5637bb9c
Merge pull request #471 from banditopazzo/tracefs_mount_select
add tracefs mount point select function
2 years ago
banditopazzo 48fdf5a250 chore: tracefs review fixes 2 years ago
banditopazzo c6c4ac7eea feat: get_tracefs function 2 years ago
Michal Rostecki 6ad2c3c373 aya-bpf-macros: Allow to make programs public
Allow to define programs as public functions (even in library crates)
and then import them.

For example, we can have library crate with `libfoo/src/lib.rs`
containing:

```rust
pub fn my_xdp_program(ctx: XdpContext) -> u32 {
    xdp_action::XDP_PASS
}
```

And then a binary importing it:

```rust
pub use libfoo::my_xdp_program;
```

This way, commonly used eBPF programs can be distributed as lib crates.

Tested with: https://github.com/vadorovsky/aya-examples/tree/main/pub-progs

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Alessandro Decina 556463a85f ebpf: SkbBuff: add some accessors 2 years ago
Andre Fredette d43879d991 Updates after rebase due to changes in define_link_wrapper
Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette 6766532341 Remove SchedClassifierLink description
It was redundant with the one provided in define_link_wrapper

Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette 2972d462a5 Address review comments
- Rename `new_tc_link` to `attached`
- Simplified example for `attached`

The following was not requested in reviews:
- Moved example from `SchedClassifierLink` tor
  `SchedClassifierLink::attached' since we're only showing an
  example of that one method

Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette 65f5b76593 Address review comments
Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette 849796c420 rename SchedClassifierLink:new() to new_tc_link()
Avoids name confilct with pr #462

Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette 67efc33414 Additional edits to SchedClassifierLink documentation.
Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette 6563e6cc06 Combine updates to SchedClassifierLink example made by Dave Tucker
Co-authored-by: Dave Tucker <dave@dtucker.co.uk>
Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette c3a8400e4d Add example for SchedClassifierLink::new()
Also modified the impl a bit to work as described in the example.

Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette f46fd17cc3 Support reconstruction of `SchedClassifierLink`
This is the proposed solution for Step 2 of issue #414

“For cases where you have done program.take_link() to manage
ownership of TcLink we need an API similar to PinnedLink::from_pin
that can reconstruct a TcLink”

As long as a user application continues to run after executing
`take_link()`, the `SchedClassifierLink` returned can be used to
detach the program.  However, if we want to handle cases where the
application exits or crashes, we need a way to save and reconstruct
the link, and to do that, we also need to know the information
required for the reconstruction -- namely, the `interface`,
`attach_type`, `priority`, and `handle`.  The user knows the first
two because they are required to execute `attach()` in the first
place; however, the user will not know the others if they let the
system choose them.

This pr solves the problems by adding an `impl` for
`SchedClassifierLink` with an accessor for `tc_options` and a `new()`
function.

Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andrew Stoycos 1899d5f4fd Expose inner errors
Currently aya will just report a standard outer level
error on failure.  Ensure that we also report the inner
error condition back to the user

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
2 years ago
Alessandro Decina 9f4ef6f67d Fix lints 2 years ago
Alessandro Decina d33ed21fc4 Pin nightly to nightly-2023-01-10
This until https://github.com/rust-lang/rust/pull/106796 gets fixed
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 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