Commit Graph

346 Commits (98e8c78376286bbdc8c7ee3f0292b878cec24b99)

Author SHA1 Message Date
Michal R 98e8c78376 aya-ebpf: Make use of `Borrow` and `BorrowMut` in map methods
Let callers pass either owned objects or references. We do that already
in the user-space methods.
1 week ago
Tamir Duberstein de42b80c74
aya,ebpf: add BPF_MAP_TYPE_SK_STORAGE
This map type requires BTF, and we can finally do it!
2 weeks ago
Tamir Duberstein 552b69367f
xtask: remove outdated snippet
We handed this to QEMU in e3bfeb9dd6.
2 weeks ago
Tamir Duberstein bb45904b08
xtask: patch gen_init_cpio.c
Recent changes[0][1] have broken compatibility with macOS; add a patch
to conditionally compile these snippets.

Patch and compile the source unconditionally; caching only the network
portion is good enough and less error prone.

[0] ae18b94099
[1] 97169cd6d9
2 weeks ago
dependabot[bot] ace02870f2
build(deps): update cargo_metadata requirement in the cargo-crates group
Updates the requirements on [cargo_metadata](https://github.com/oli-obk/cargo_metadata) to permit the latest version.

Updates `cargo_metadata` to 0.22.0
- [Release notes](https://github.com/oli-obk/cargo_metadata/releases)
- [Changelog](https://github.com/oli-obk/cargo_metadata/blob/main/CHANGELOG.md)
- [Commits](https://github.com/oli-obk/cargo_metadata/compare/0.22.0...0.22.0)

---
updated-dependencies:
- dependency-name: cargo_metadata
  dependency-version: 0.22.0
  dependency-type: direct:production
  dependency-group: cargo-crates
...

Signed-off-by: dependabot[bot] <support@github.com>
3 weeks ago
Tamir Duberstein 5f5305c2a8
lint all crates; enable strict pointer lints 3 weeks ago
Tamir Duberstein ec3eacc1d8
Increase VM memory
Since 6.1.0-40 we're seeing `Initramfs unpacking failed: write error`.
3 weeks ago
tamird 32071bdca7 public-api: regenerate 4 weeks ago
Michal R 0b2a544ddd aya-ebpf: Add BTF array definition
Before this change, Aya supported only legacy BPF map definitions, which
are instances of the `bpf_map_def` struct and end up in the `maps` ELF
section.

This change introduces a BTF map definition for arrays, with custom
structs indicating the metadata of the map, which end up in the `.maps`
section.

Co-authored-by: Tamir Duberstein <tamird@gmail.com>
4 weeks ago
Adam Schreck 263e864cd9 aya: add Map::from_map_data() for pinned map access
Enables creation of Map enum variants directly from MapData instances,
allowing user-space handles to pinned BPF maps without requiring the
original BPF object.

Supports multiple BPF map types.

Motivation:
- Simplifies accessing pinned maps from user space applications.
- Avoids full BPF reloads and potential deadlocks.
- Matches existing ergonomic APIs like LruHashMap::try_from.
- Keeps user code safe and idiomatic.

Closes https://github.com/aya-rs/aya/issues/1305.

Includes test coverage to validate the new API.
1 month ago
Tamir Duberstein 214fe3c367
aya-log-common: seal Argument 1 month ago
Tamir Duberstein 353b83383d
aya-log-ebpf: zero copy! 1 month ago
Tamir Duberstein 3f60168d4b
ring_buf: add RingBufBytes for raw byte slices 1 month ago
Xiaobo Liu 53ec616411 ebpf: add peak() method to Queue and Stack
Add integration tests covering push,pop,peek for both types.

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
1 month ago
Tamir Duberstein b36cbc3eb8
implement load-time log level mask 1 month ago
dependabot[bot] a0b63b8811
build(deps): bump the cargo-crates group with 2 updates (#1333) 2 months ago
Xiaobo Liu 4fe920f761 xtask: add the target method to Architecture
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
2 months ago
Tamir Duberstein 5b8c4ed630
public-api: fix argument comment 3 months ago
Xiaobo Liu 44ec978bd3 aya-log: Implement `AsFd` for `EbpfLogger`
This change implements the `AsFd` trait for the `EbpfLogger` struct.
This allows obtaining a `BorrowedFd` from an `EbpfLogger` instance, which is safer than using `AsRawFd`.

This improves the ergonomics of using `EbpfLogger` with APIs that accept file descriptors.

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
3 months ago
Tamir Duberstein 35332f2288
aya: remove `AsyncPerfEventArray{,Buffer}`
Rather than support N async runtimes, push this to the user. The
relevant types (`PerfEventArrayBuffer` and `RingBuffer`) implement
`As{,Raw}Fd` which is sufficient with integration with tokio, smol, and
other async runtimes.
3 months ago
Tamir Duberstein 61376c4608
aya-log: Remove tokio dep
Require the caller to provide their own executor.
3 months ago
Tamir Duberstein 9be2d723ce
aya-log: Replace AsyncPerfEventArray with RingBuf
This doesn't get us to zero copy because the reserve/submit APIs do not
support DSTs for reasons I don't remember.

Now that it is unused in userspace, move `LOG_BUF_CAPACITY` to
`aya-log-ebpf` by making its type `LogValueLength` which obviates the
need for `log_value_length_sufficient`.
3 months ago
Tamir Duberstein 8fb19264da
aya-log-ebpf: tidy up `macro_support`
Move top level items into and remove unused items from `macro_support`.
3 months ago
Tamir Duberstein f08772ec2f test-distro: enable rust backtrace 3 months ago
dependabot[bot] f96250e80d
build(deps): bump the cargo-crates group with 2 updates
Updates the requirements on [bindgen](https://github.com/rust-lang/rust-bindgen) and [which](https://github.com/harryfei/which-rs) to permit the latest version.

Updates `bindgen` to 0.71.1
- [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.71.0...v0.71.1)

Updates `which` to 7.0.3
- [Release notes](https://github.com/harryfei/which-rs/releases)
- [Changelog](https://github.com/harryfei/which-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/harryfei/which-rs/compare/7.0.0...7.0.3)

---
updated-dependencies:
- dependency-name: bindgen
  dependency-version: 0.71.1
  dependency-type: direct:production
  dependency-group: cargo-crates
- dependency-name: which
  dependency-version: 7.0.3
  dependency-type: direct:production
  dependency-group: cargo-crates
...

Signed-off-by: dependabot[bot] <support@github.com>
4 months ago
dependabot[bot] a7e3e6d4d9
build(deps): bump the cargo-crates group with 2 updates
Updates the requirements on [cargo_metadata](https://github.com/oli-obk/cargo_metadata) and [object](https://github.com/gimli-rs/object) to permit the latest version.

Updates `cargo_metadata` to 0.19.2
- [Release notes](https://github.com/oli-obk/cargo_metadata/releases)
- [Changelog](https://github.com/oli-obk/cargo_metadata/blob/main/CHANGELOG.md)
- [Commits](https://github.com/oli-obk/cargo_metadata/compare/0.19.0...0.19.2)

Updates `object` to 0.36.7
- [Changelog](https://github.com/gimli-rs/object/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gimli-rs/object/compare/0.36.0...0.36.7)

---
updated-dependencies:
- dependency-name: cargo_metadata
  dependency-version: 0.19.2
  dependency-type: direct:production
  dependency-group: cargo-crates
- dependency-name: object
  dependency-version: 0.36.7
  dependency-type: direct:production
  dependency-group: cargo-crates
...

Signed-off-by: dependabot[bot] <support@github.com>
5 months ago
Tamir Duberstein ccf6c4707f aya-ebpf: disable generic_const_exprs
This has recently regressed on nightly.

See https://github.com/rust-lang/rust/issues/141492.
5 months ago
Tamir Duberstein c8e9037ca6 Avoid uncontrolled stdout into cargo
This fixes rebuild on change of C sources by black-holing:
- Output of `make` (harmless).
- Output of `llmv-objcopy` (harmful: binary data).
5 months ago
Mehnaz Yunus 4b5ba53a36 aya: implement TryFrom<[Program Type]> for FdLink for various program types
Implements TryFrom for FdLink for CgroupSkb, CgroupSock, CgroupSockAddr
and SockOps program types. This allows support for link pinning for
these program types, aligning with the documentation for FdLink.

Fixes: #739

Co-authored-by: Benjamin Barzen <bbarzen@amazon.com>
5 months ago
Tyrone Wu 23bc5b5836 aya,aya-obj: cache feat probed info fields
Cached probed for ProgramInfo fields instead of exposing it through
global FEATURE. Probing occurs on cache miss, which happens when first
accessing the field, *and* if the field is 0.
5 months ago
Tyrone Wu bd492860f5 aya: add feature probing for map type
Add API that probes whether kernel supports a map type.
5 months ago
Tyrone Wu ab77decd9a aya,aya-obj: add feature probing program type
Adds API that probes whether kernel supports a program type.
5 months ago
Dave Tucker 7dba5a41ad feat(aya): Make LinkInfo and loaded_links public
We have had loaded_links in the API as `#[doc(hidden)]` for a while.
I've been using it in bpfman and it's been fine. This commit does the
minimal work required to make the API stable.

We expose a `LinkInfo` type - similar to `ProgInfo` - which wraps the
generated type. In this case, `bpf_link_info`.

A few accessor functions have been added for `id`, `link_type` and
`program_id`. There are many more fields that could be (eventually)
made public.

As a convenience, `LinkInfo` can be retrieved from an existing FdLink
by using `FdLink::info()`.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
5 months ago
Tamir Duberstein 583709f6a0 appease `clippy::uninlined-format-args` 6 months ago
Tamir Duberstein 6004fcdb0f aya-ebpf: put mem{set,move,cpy} behind cfg(target_arch = "bpf")
Address some lints while I'm here.
6 months ago
Tamir Duberstein 5732b2c203 test-distro: build without cross toolchain
Make the xz2 dependency optional to allow building without a C cross
compiler. This allows clippy.sh to be used on e.g. macOS more easily:

```
./clippy.sh --target x86_64-unknown-linux-gnu --exclude-features xz2
```
6 months ago
Tamir Duberstein 680402be0c Revert "ci: download gen_init_cpio with authentication"
This removes octorust which takes absolutely ages to compile and also
requires native TLS libraries which in turn require a C toolchain. The
latter is a pain when cross compiling from macOS.

This reverts commit cc2da4a2a4.
6 months ago
dave-tucker 5e4e12ce78 aya-obj, aya-ebpf-bindings: regenerate
libbpf commit: 20ea95b4505c477af3b6ff6ce9d19cee868ddc5d
7 months ago
Dave Tucker 59c02447fa chore: generate bindings for all eBPF insns
The binding for BPF_ADD was missing from codegen.
Use BPF_.* to capture all of these to avoid missing bindings in future.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
7 months ago
Michal Rostecki e229231d88 xtask: Move libbpf header installation logic to a helper function
Before that, the same code was repeated twice in different places.
7 months ago
Thomas Eizinger 6d36fe13d3 aya-build: Allow setting Rust nightly version
At present, `aya_build` will always use `+nightly` to build the
eBPF kernel. This is problematic in environments such as CI, where
tools always need to be installed first. Installing the current
nightly Rust toolchain gives you a new toolchain every day. This
poisones caches and makes CI jobs non-deterministic.

Resolves: #1226
7 months ago
Dave Tucker 2b0dcfbd09 feat: Allow conversions to Program from ProgramInfo
Allow for a ProgramInfo to be converted into one of the program types
that we support. This allows for a user of Aya access to reattach,
pin or unload a program that was either, previously loaded, or was
loaded by another process.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
7 months ago
tamird e96431f07a public-api: regenerate 7 months ago
Dave Tucker 9eecbe9d0e
Merge pull request #1224 from dave-tucker/unused_trait_names
chore(*): set clippy unused_trait_names = warn
7 months ago
Tamir Duberstein 77b1c6194c Add support for Flow Dissector programs
Closes #216.

Co-authored-by: Zenna Allwein <zrallwein@gmail.com>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
7 months ago
Dave Tucker f6c5cb2ad2 chore(*): set clippy unused_trait_names = warn
We have previously tried to import traits anonymously where possible but
enforcing this manually was hard.

Since Rust 1.83 clippy can now enforce this for us.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
7 months ago
Dave Tucker abe5f743a3 feat: Refactor init into test-distro
The init module contains a small init system for running our integration
tests against a kernel. While we don't need a full-blown linux distro,
we do need some utilities.

Once such utility is `modprobe` which allows us to load kernel modules.
Rather than create a new module for this utility, I've instead
refactored `init` into `test-distro` which is a module that contains
multiple binaries.

The xtask code has been adjusted to ensure these binaries are inserted
into the correct places in our cpio archive, as well as bringing in the
kernel modules.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
7 months ago
Tamir Duberstein 49a828ec56 taplo: reorder-keys
Group non-workspace keys before workspace ones for readability.
7 months ago
tamird 75aac18f8a public-api: regenerate 7 months ago
tamird dcf66db845 public-api: regenerate 7 months ago