Commit Graph

183 Commits (17c7c7951cb45a5903134b21658df7e989e672ed)

Author SHA1 Message Date
Tamir Duberstein d9704be77d
aya-build: remove cargo_metadata from public API 2 days ago
Tamir Duberstein f610453ec2
ebpf: extract CARGO_CFG_BPF_TARGET_ARCH logic 2 days ago
Tamir Duberstein 05250da20b
aya-ebpf: reduce repetition and excessive traits
The traits `FromBtfArgument`, `FromRawTracepointArgs`, `FromPtRegs` are
all fancy ways of saying `Argument` - so replace these traits with it.

This also removes the use of `bpf_probe_read` which was introduced in
05c1586202 because I can't reproduce the
need for it.
3 days ago
Andrew Werner 03e8487177 aya: rename `set_` methods on `EbpfLoader`
This loader is more of a builder, so these `set_` methods didn't
quite fit. See [this discussion][1] for the motivation.

[1]: https://reviewable.io/reviews/aya-rs/aya/1318#gh-2384180366
7 days ago
Andrew Werner 5802dc7a23 aya: allow specifying a pin path for a named map
This commit extends the EbpfLoader with set_map_pin_path that allows the
caller to associate a named map with a pin path.

One note is that this path is an absolute path, not relative to
`map_pin_path`, and it forces the map to be loaded from that path.
1 week ago
Andrew Werner 1c924bb421 aya: rename map_pin_path to default_map_pin_path
This is the path in which pinned maps are created or resolved. It
isn't actually the path for any specific map itself. This rename
makes way for a method `set_map_pin_path` that actually specifies
the pin path for a specific map.
1 week ago
Tamir Duberstein 0144c0eb22
integration-test: defer cleanup to ensure unpin 2 weeks ago
Tamir Duberstein 2e5f5efbf1
aya: make ProgramInfo a proper enum
This allows us to distinguish between LSM and LSM_CGROUP programs and do
the proper capability check in is_program_supported.
2 weeks ago
Tamir Duberstein 8e9404ecd4
aya-obj: apply enum64-to-union fixup in reloc
This code is just awful.
2 weeks ago
Tamir Duberstein 7224efcad8
aya-obj: patch up 0-size datasec
Use OnceCell for ENUM64 while I'm here as well.
2 weeks ago
Tamir Duberstein 3ade19b869
Promote BTF loading failure to error on BTF relocs 2 weeks ago
Tyrone Wu 3d7fbaad28 aya: enforce valid perf_event type & config combos
Add guardrails for when setting event type and config for perf_event
programs. The `PerfEventConfig` enum now defines the event `type` and
`config` of interest.

Remove public re-exports, and add idiomatic Rust types for:
- perf_hw_id => HardwareEvent
- perf_sw_ids => SoftwareEvent
- perf_hw_cache_id => HwCacheEvent
- perf_hw_cache_op_id => HwCacheOp
- perf_hw_cache_op_result_id => HwCacheResult

The motivation behind this is mainly for the `type` and `config` fields
of `bpf_link_info.perf_event.event`. The newly added enums are planned
to also be used in the `bpf_link_info` metadata.

Although `Breakpoint`/`PERF_TYPE_BREAKPOINT` variant exists, it is not
fully implemented. It's only usage at the moment is in link info.
2 weeks ago
Tamir Duberstein 82aec26963
flow_dissector: add missing impl_try_into_fdlink 2 weeks ago
Christian A. Jacobsen a98b638fa9 feat(log): add support for logging raw pointer types
* Requires the usage of `:p` display hint.
* Will, like stdlib, log with `0x` prefix.
2 weeks ago
Altug Bozkurt fc5387c806
lsm: cgroup attachment type support 3 weeks ago
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.
3 weeks ago
Tamir Duberstein de42b80c74
aya,ebpf: add BPF_MAP_TYPE_SK_STORAGE
This map type requires BTF, and we can finally do it!
3 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>
4 weeks ago
Tamir Duberstein 5f5305c2a8
lint all crates; enable strict pointer lints 4 weeks ago
tamird 32071bdca7 public-api: regenerate 1 month 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>
1 month 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 2 months ago
Tamir Duberstein 353b83383d
aya-log-ebpf: zero copy! 2 months ago
Tamir Duberstein 3f60168d4b
ring_buf: add RingBufBytes for raw byte slices 2 months 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>
2 months ago
Tamir Duberstein b36cbc3eb8
implement load-time log level mask 2 months ago
dependabot[bot] a0b63b8811
build(deps): bump the cargo-crates group with 2 updates (#1333) 2 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.
4 months ago
Tamir Duberstein 61376c4608
aya-log: Remove tokio dep
Require the caller to provide their own executor.
4 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`.
4 months ago
Tamir Duberstein 8fb19264da
aya-log-ebpf: tidy up `macro_support`
Move top level items into and remove unused items from `macro_support`.
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
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>
6 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.
6 months ago
Tyrone Wu bd492860f5 aya: add feature probing for map type
Add API that probes whether kernel supports a map type.
6 months ago
Tyrone Wu ab77decd9a aya,aya-obj: add feature probing program type
Adds API that probes whether kernel supports a program type.
6 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>
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
dave-tucker 5e4e12ce78 aya-obj, aya-ebpf-bindings: regenerate
libbpf commit: 20ea95b4505c477af3b6ff6ce9d19cee868ddc5d
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
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
tamird 75aac18f8a public-api: regenerate 8 months ago
tamird dcf66db845 public-api: regenerate 8 months ago
arctic-alpaca 73a34e1571 aya: Add `XskMap::unset` 8 months ago
Dave Tucker ea76e0f62d aya: parse complete entries from /proc/$pid/maps
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
8 months ago