Commit Graph

1851 Commits (b01bc3f49be4e1099601a8f682bc52b54eb1f960)
 

Author SHA1 Message Date
Dave Tucker c3f0c7dc3f chore: Prepare for aya-log-ebpf release
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 months ago
Dave Tucker 59082f572c Release aya-ebpf-cty v0.2.2, aya-ebpf-bindings v0.1.1, aya-ebpf-macros v0.1.1, aya-ebpf v0.1.1
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 months ago
Dave Tucker c169b727e6 Release aya-obj v0.2.0, aya v0.13.0, safety bump aya v0.13.0
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 months ago
astoycos 5478cac008 feat(aya): 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.

Signed-off-by: astoycos <astoycos@redhat.com>
Co-authored-by: Andre Fredette <afredette@redhat.com>
Co-authored-by: Dave Tucker <dave@dtucker.co.uk>
Co-authored-by: Tamir Duberstein <tamird@gmail.com>
3 months ago
dependabot[bot] 1d272f38bd build(deps): update hashbrown requirement in the cargo-crates group
Updates the requirements on [hashbrown](https://github.com/rust-lang/hashbrown) to permit the latest version.

Updates `hashbrown` to 0.15.0
- [Changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/hashbrown/compare/v0.14.3...v0.15.0)

---
updated-dependencies:
- dependency-name: hashbrown
  dependency-type: direct:production
  dependency-group: cargo-crates
...

Signed-off-by: dependabot[bot] <support@github.com>
3 months ago
Tamir Duberstein aa240baadf Appease clippy
```
error: the following explicit lifetimes could be elided: 'data, 'file
    --> aya-obj/src/obj.rs:1083:6
     |
1083 | impl<'data, 'file, 'a> TryFrom<&'a ObjSection<'data, 'file>> for Section<'a> {
     |      ^^^^^  ^^^^^                             ^^^^^  ^^^^^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
```
4 months ago
GrigorenkoPV 55ed9e0546
fix(aya-log): print &[u8] using full width (#1008)
Otherwise `&[1u8, 0u8]` cannot be distinguished from `&[0x10u8]` (they both become 10)
4 months ago
Vladimir Petrzhikovskii d05110fd86 perf: cache `nr_cpus` in a thread_local 4 months ago
Tamir Duberstein afd777b705 Clarify `Arc` usage
Absent this it's easy to miss that there's an `Arc` being cloned here.
4 months ago
Tamir Duberstein e992c280cb Replace `Arc` with `&'static` 4 months ago
Tamir Duberstein 0e867572ff Avoid intermediate allocations in parse_cpu_ranges 4 months ago
Tamir Duberstein f3b2744072 Reduce duplication in `{nr,possible}_cpus` 4 months ago
Tamir Duberstein 2b299d4fba Replace `lazy_static` with `std::sync::LazyLock` 4 months ago
Tamir Duberstein 0f163633e3 Appease clippy
See https://github.com/rust-lang/rust/pull/130778.

```
warning: empty line after doc comment
  --> test/integration-ebpf/build.rs:16:1
   |
16 | / /// [bindeps]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html?highlight=feature#artifact-dependencies
17 | |
   | |_
18 |   fn main() {
   |   --------- the comment documents this function
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
   = note: `#[warn(clippy::empty_line_after_doc_comments)]` on by default
   = help: if the empty line is unintentional remove it

error: empty line after doc comment
  --> aya/src/maps/bloom_filter.rs:34:1
   |
34 | / /// ```
35 | |
   | |_
...
38 |   pub struct BloomFilter<T, V: Pod> {
   |   --------------------------------- the comment documents this struct
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
note: the lint level is defined here
  --> aya/src/lib.rs:41:5
   |
41 |     clippy::all,
   |     ^^^^^^^^^^^
   = note: `#[deny(clippy::empty_line_after_doc_comments)]` implied by `#[deny(clippy::all)]`
   = help: if the empty line is unintentional remove it

error: empty line after doc comment
  --> aya/src/maps/lpm_trie.rs:46:1
   |
46 | / /// ```
47 | |
   | |_
...
50 |   pub struct LpmTrie<T, K, V> {
   |   --------------------------- the comment documents this struct
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
   = help: if the empty line is unintentional remove it

warning: empty line after doc comment
  --> test/integration-test/build.rs:38:1
   |
38 | / /// [bindeps]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html?highlight=feature#artifact-dependencies
39 | |
   | |_
40 |   fn main() {
   |   --------- the comment documents this function
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
   = note: `#[warn(clippy::empty_line_after_doc_comments)]` on by default
   = help: if the empty line is unintentional remove it

warning: calling `CStr::new` with a byte string literal
  --> test/integration-test/src/tests/xdp.rs:45:20
   |
45 |         .from_name(CStr::from_bytes_with_nul(b"lo\0").unwrap())
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"lo"`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_c_str_literals
   = note: `#[warn(clippy::manual_c_str_literals)]` on by default
```
4 months ago
Michal Rostecki 045032bff0 ci: Use libLLVM from Rust CI tarball
Instead of relying on Homebrew for macOS (which ships older LLVM
versions) and `apt.llvm.org` for Linux (which often has bugs at the
packaging level), we now use the tarball from Rust CI to provide
`libLLVM`. This ensures it always matches the version used by the latest
Rust nightly.

This removes our reliance on homebrew shipping LLVM versions matching
those used by rustc.
4 months ago
Tamir Duberstein f498a1b7a9 Remove assertion that doesn't work in macOS HVF 4 months ago
Tamir Duberstein 59a153076a ci: use {clang,llvm}-15 on ubuntu-22.04
These come preinstalled, we just need to add them to $GITHUB_PATH.
4 months ago
Tamir Duberstein 5b29008691 Appease `static_mut_refs`
Made stricter in https://github.com/rust-lang/rust/commit/5ba6db1b648d9.
4 months ago
Tamir Duberstein 48ca623a1f Update public-api to 0.38.0 4 months ago
dependabot[bot] 5f91efdf43 build(deps): bump DavidAnson/markdownlint-cli2-action
Bumps the github-actions group with 1 update: [DavidAnson/markdownlint-cli2-action](https://github.com/davidanson/markdownlint-cli2-action).


Updates `DavidAnson/markdownlint-cli2-action` from 16 to 17
- [Release notes](https://github.com/davidanson/markdownlint-cli2-action/releases)
- [Commits](https://github.com/davidanson/markdownlint-cli2-action/compare/v16...v17)

---
updated-dependencies:
- dependency-name: DavidAnson/markdownlint-cli2-action
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
4 months ago
dependabot[bot] 11d953fee8 build(deps): bump the cargo-crates group with 2 updates
Updates the requirements on [rbpf](https://github.com/qmonnet/rbpf) and [network-types](https://github.com/vadorovsky/network-types) to permit the latest version.

Updates `rbpf` to 0.2.0
- [Commits](https://github.com/qmonnet/rbpf/compare/v0.2.0...v0.2.0)

Updates `network-types` to 0.0.7
- [Release notes](https://github.com/vadorovsky/network-types/releases)
- [Changelog](https://github.com/vadorovsky/network-types/blob/main/CHANGELOG.md)
- [Commits](https://github.com/vadorovsky/network-types/compare/v0.0.6...v0.0.7)

---
updated-dependencies:
- dependency-name: rbpf
  dependency-type: direct:production
  dependency-group: cargo-crates
- dependency-name: network-types
  dependency-type: direct:production
  dependency-group: cargo-crates
...

Signed-off-by: dependabot[bot] <support@github.com>
4 months ago
Alessandro Decina b87f4b9642
Merge pull request #1029 from aya-rs/fix/ci-linux-kernel-version
Fix linux kernel version in gh ci runners
4 months ago
Davide Bertola e775f8329b Fix linux kernel version in gh ci runners 4 months ago
Alessandro Decina 2cd35769dc
Merge pull request #1023 from l2dy/fdlink/sockops
aya: use FdLink in SockOps programs
4 months ago
Zero King c44f8b0f5b aya: use FdLink in SockOps programs
See: https://github.com/aya-rs/aya/issues/987
4 months ago
tyrone-wu 02d1db5fc0 aya: remove unwrap and NonZero* in info
Addresses the feedback from #1007:
- remove panic from `unwrap` and `expect`
- Option<NonZero*> => Option<int> with `0` mapping to `None`

Refs: #1007
4 months ago
Alessandro Decina 635ed3baed
Merge pull request #1020 from l2dy/sockops-ctx
aya-ebpf: Add set_reply accessor to SockOpsContext
5 months ago
Zero King 95e1763e30 aya-ebpf: Add set_reply accessor to SockOpsContext 5 months ago
Alessandro Decina 40f303205f
Merge pull request #985 from reyzell/main
Add the option to support multiple and overrideable programs per cgroup
5 months ago
Harvo Jones f790685d75 Add the option to support multiple and overrideable programs per cgroup
This change allows multiple BPF programs to attach to a cgroup (via the option
`CgroupAttachMode::AllowMultiple`), and allows a program to specify that it can be
overridden by one in a sub-cgroup (via the option `CgroupAttachMode::AllowOverride`).
5 months ago
Alessandro Decina 9406601cf9
Merge pull request #1018 from tyrone-wu/codegen/bpf_perf_event_type
codegen: add `bpf_perf_event_type` enum bindings
5 months ago
tyrone-wu ea1130449b
codegen: add `bpf_perf_event_type` enum bindings
Adds the `bpf_perf_event_type` enum to FFI bindings, which is being used
in the `perf_event.type` field in `bpf_link_info`.
5 months ago
Alessandro Decina 15eb935bce
Merge pull request #1007 from tyrone-wu/aya/info-api
aya,aya-obj,integration-test: add better support in `ProgramInfo` & `MapInfo` for old kernels
5 months ago
tyrone-wu fbb09304a2
aya,int-test: 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<NonZero*>` 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.
5 months ago
tyrone-wu 88f5ac3114
aya,obj,int-test: 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<NonZero*>`
  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.

`aya::programs::Programs::prog_type(&self)` now returns `ProgramType`
instead of the generated FFI from aya-obj.

Also previously, `loaded_programs()` could be accessed either through
`aya` or `aya::programs`. To avoid confusion and duplicate export of
the item, the function should now only be exposed through
`aya::programs`.
5 months ago
tyrone-wu 1634fa7188
aya-obj: 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<T>` 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`.
5 months ago
tyrone-wu cb8e478800
aya,integration-test: 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
5 months ago
Alessandro Decina ab000ad7c3
Merge pull request #959 from tyrone-wu/aya/program_info_stats
aya,aya-obj: expose run_time_ns & run_cnt fields, and add bpf_enable_stats util function
5 months ago
Alessandro Decina ab5e688fd4
Merge pull request #974 from Billy99/billy99-arch-ppc64-s390x
aya: add archs powerpc64 and s390x to aya
5 months ago
Billy McFall 4dc4b5ccd4 test: adjust test to not use byte arrays
Where possible, replace the hardcoded byte arrays in the tests with the
structs they represent, then convert the structs to byte arrays.

Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
5 months ago
Billy McFall cd1db86fd4 aya: 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.

Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
5 months ago
Billy McFall b513af12e8 aya: add archs powerpc64 and s390x to aya
bpfman, a project using aya, has a requirement to support powerpc64 and
s390x architectures. Adding these two architectures to aya.

Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
5 months ago
Billy McFall eef7346fb2 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.

Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
5 months ago
Tamir Duberstein 4362020691 Simplify doctest 5 months ago
Tamir Duberstein bce3c4fb1d Appease nightly clippy
```
error: first doc comment paragraph is too long
  --> aya/src/programs/raw_trace_point.rs:12:1
   |
12 | / /// A program that can be attached at a pre-defined kernel trace point, but also
13 | | /// has an access to kernel internal arguments of trace points, which
14 | | /// differentiates them from traditional tracepoint eBPF programs.
15 | | ///
16 | | /// The kernel provides a set of pre-defined trace points that eBPF programs can
   | |_
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_long_first_doc_paragraph

error: first doc comment paragraph is too long
  --> ebpf/aya-ebpf/src/helpers.rs:1:1
   |
1  | / //! This module contains kernel helper functions that may be exposed to specific BPF
2  | | //! program types. These helpers can be used to perform common tasks, query and operate on
3  | | //! data exposed by the kernel, and perform some operations that would normally be denied
4  | | //! by the BPF verifier.
5  | | //!
6  | | //! Here, we provide some higher-level wrappers around the underlying kernel helpers, but
   | |_
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_long_first_doc_paragraph
```
5 months ago
Andrew Stoycos 47b0dde395
Merge pull request #1013 from astoycos/bump-int
Add a 6.10 linux kernel to the virtualized testing in CI
5 months ago
astoycos 25beb14ff0
run virtualized CI on multiple kernels
Ensure we download multiple kernel versions to run
our virtualized CI against.

Bump xdpilone version to fix bug on latest kernel.

Signed-off-by: astoycos <astoycos@gmail.com>
5 months ago
tyrone-wu a25f501ece
aya: 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.
5 months ago
tyrone-wu fa6af6a204
aya,aya-obj: 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.
5 months ago
dependabot[bot] a54532f848 build(deps): bump the cargo-crates group across 1 directory with 2 updates
Updates the requirements on [bindgen](https://github.com/rust-lang/rust-bindgen) and [public-api](https://github.com/cargo-public-api/cargo-public-api) to permit the latest version.

Updates `bindgen` to 0.69.4
- [Release notes](https://github.com/rust-lang/rust-bindgen/releases)
- [Changelog](https://github.com/rust-lang/rust-bindgen/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/rust-bindgen/compare/v0.69.0...v0.69.4)

Updates `public-api` to 0.36.0
- [Release notes](https://github.com/cargo-public-api/cargo-public-api/releases)
- [Changelog](https://github.com/cargo-public-api/cargo-public-api/blob/main/rustdoc-json/CHANGELOG.md)
- [Commits](https://github.com/cargo-public-api/cargo-public-api/compare/public-api-v0.36.0...public-api-v0.36.0)

---
updated-dependencies:
- dependency-name: bindgen
  dependency-type: direct:production
  dependency-group: cargo-crates
- dependency-name: public-api
  dependency-type: direct:production
  dependency-group: cargo-crates
...

Signed-off-by: dependabot[bot] <support@github.com>
5 months ago