Commit Graph

2338 Commits

Author SHA1 Message Date
vad 998ad08ba0 maps: Do not anonymize BTF maps
See https://github.com/llvm/llvm-project/pull/164851. This fixup is
not needed.
2026-01-28 05:58:54 +00:00
root 5cfe609872 integration-test: add btf_maps libbpf compatibility tests
Add integration tests to verify that btf_maps generated with the
generalized btf_map_def macro are compatible with libbpf's bpf_map_def.

Also add CI infrastructure for macOS cross-compilation to Linux musl,
including stub headers and autoconf cache variables for libbpf-sys
vendored dependencies.
2026-01-27 14:49:22 +00:00
root 930fa7b8af aya-ebpf: generalize btf_map_def macro type parameters
Modify the btf_map_def! macro to generate flat #[repr(C)] structs
instead of UnsafeCell wrappers. This produces BTF that both aya
and libbpf can parse.

Support type parameters with optional defaults and const generics with
configurable types. Allow trailing commas and improve formatting.

Also remove UnsafeCell traversal code from aya-obj loader since
it is no longer needed with flat struct layout.
2026-01-27 14:49:22 +00:00
dependabot[bot] ecbb7b5272 build(deps): update nix requirement in the cargo-crates group
Updates the requirements on [nix](https://github.com/nix-rust/nix) to permit the latest version.

Updates `nix` to 0.31.1
- [Changelog](https://github.com/nix-rust/nix/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nix-rust/nix/compare/v0.30.1...v0.31.1)

---
updated-dependencies:
- dependency-name: nix
  dependency-version: 0.31.1
  dependency-type: direct:production
  dependency-group: cargo-crates
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-26 11:29:34 -05:00
famfo dc12998268 aya-build: try to build when rustup is not found
In some environments, rustup is not availible but cargo and its targets
are. This changes aya-build to try to continue building if rustup is not
found, even with stable Rust. A warning will now be issued if rustup is
not found but the build will proceed regardless. Add a dependency on
`rustc_version` and condition `-Z build-std=core` on the toolchain being
nightly to allow custom toolchains with prebuilt ebpf sysroots.

Fixes: #1329
2026-01-26 10:38:15 -05:00
Tamir Duberstein e746618143 enable unused_qualifications lint 2026-01-23 11:03:26 -05:00
Tamir Duberstein be872b1cff Use usize::next_multiple_of 2026-01-21 15:20:26 -05:00
Tamir Duberstein 394668806b aya-ebpf: define hash maps via macro 2026-01-21 09:05:51 -05:00
Tamir Duberstein f35f7a3610 aya, aya-ebpf: reduce duplication 2026-01-21 09:05:51 -05:00
vad 388d1f9694 aya-build: Allow to opt out
Allow to opt out from cargo-in-cargo by setting `AYA_BUILD_SKIP`
environment variable to `1` or `true`. That makes it easier for people
using custom toolchains not managed by rustup (e.g. package
maintainers).

Fixes: #1329
2026-01-20 17:17:23 +00:00
Tamir Duberstein 2b424ed8b5 aya-ebpf-macros: split vectors to avoid panicking
Statically avoid panicking branch. While I'm here emit errors for all
unknown macro arguments, not just the first one.
2026-01-20 10:05:40 -05:00
dependabot[bot] 0a5c5e5594 build(deps): update rbpf requirement in the cargo-crates group
Updates the requirements on [rbpf](https://github.com/qmonnet/rbpf) to permit the latest version.

Updates `rbpf` to 0.4.0
- [Commits](https://github.com/qmonnet/rbpf/compare/v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: rbpf
  dependency-version: 0.4.0
  dependency-type: direct:production
  dependency-group: cargo-crates
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-19 11:46:41 -05:00
Lukas Hoehl d022b8dce4 set value_size to 0 if loading ringbuffer (#1443)
Override ring buffer value_size to 0 to allow slightly malformed 
programs to load. This is the same approach taken by Cillium.

Signed-off-by: Lukas Hoehl <lukas.hoehl@stackit.cloud>
2026-01-16 19:07:39 -05:00
Tamir Duberstein 3eb9cacef4 aya-ebpf: add BTF ring buffer
Co-developed-by: Lukas Hoehl <lukas.hoehl@stackit.cloud>
2026-01-13 05:43:45 -05:00
Donghyun Shin 1d10f8751d aya-ebpf: fix redirect_sk_lookup receiver type
The `redirect_sk_lookup` method for SockMap and SockHash
previously required exclusive references.

The documentation for `bpf_map_lookup_elem` makes no
mention of a requirement for exclusive references.

Therefore, `redirect_sk_lookup` has been changed to
receive shared references to SockMap and SockHash.
2026-01-12 10:43:04 -05:00
tamird b8ed06a4cd aya-obj, aya-ebpf-bindings: regenerate
libbpf commit: 20ea95b4505c477af3b6ff6ce9d19cee868ddc5d
2026-01-09 06:14:47 +01:00
Sven Cowart 7cbd816a77 doc(aya): document tcx link pinning for atomic program replacement
Add documentation and integration test for SchedClassifier link pinning,
which enables zero-downtime program updates in production environments.

- Add link pinning example to SchedClassifier::attach_with_options()
  showing atomic replacement workflow for TCX mode (kernel >= 6.6).
- Add pin_tcx_link() integration test verifying link persistence
  across program unload and atomic replacement capability.
2026-01-06 20:18:26 -05:00
cyril 775f42d781 aya: avoid trying to parse paths in proc maps
There are various oddities in how the kernel prints path including
"(deleted)" suffix, bracketed properties e.g. "[vdso]", ashmem and memfd
paths, and possibly others. Rather than try to handle these in
`ProcMapEntry::parse` just leave them as they appear and let the caller
deal with them.

Change splitting behavior to any number of consecutive whitespace
characters between columns to account for padding.

This allows uprobe attachment to succeed in the presence of deleted
mapped files and in more cases of android special attributes.

Rewrite tests using `test_case`.

Co-authored-by: Tamir Duberstein <tamird@gmail.com>
Signed-off-by: cyril <multya77@gmail.com>
2026-01-05 12:23:55 -05:00
Tamir Duberstein eb25e6af2a aya: avoid some allocations
Use `Path::display` in test assertions for better errors.
2026-01-05 12:23:55 -05:00
Tamir Duberstein efecc088b3 aya: trim whitespace just once
Update tests to include the expected trailing newline.
2026-01-05 12:23:55 -05:00
Tamir Duberstein d1f72a580c aya: improve ParseLine as Debug
Print human-readable strings rather than sequences of bytes.
2026-01-05 12:23:54 -05:00
Tamir Duberstein 80d79526a6 aya: move test_resolve_attach_path to tests module 2026-01-05 12:23:53 -05:00
Tamir Duberstein 4984ddc046 aya: use integer::next_multiple_of
See https://github.com/rust-lang/rust-clippy/issues/14144.
2026-01-04 06:57:24 -05:00
Tamir Duberstein a9945b0957 xtask: implement unit tests in VM
This is quite useful when developing on macOS.
2025-12-31 05:01:43 -05:00
Tamir Duberstein 5c0ebe8684 aya-build: Avoid OUT_DIR collisions
When the eBPF package name matches a bin target name, aya-build used
OUT_DIR/<package-name> as Cargo's --target-dir and then tried to copy
the built binary to OUT_DIR/<bin-name>. This makes the destination a
directory and fails with EISDIR.

Put the cargo --target-dir under a dedicated subdirectory inside OUT_DIR
to keep build artifacts separate from copied outputs.

Fixes https://github.com/aya-rs/aya/issues/1432.
2025-12-29 06:55:35 -05:00
Ignacio Espósito 3b28447573 Symlink licenses into aya-log{,-common} 2025-12-27 15:01:43 -05:00
Ignacio Espósito ac85ad27df Symlink licenses into aya log (#1428)
Added symlinks to licences in aya-log in order for it to be packaged into fedora.
2025-12-26 01:27:42 +01:00
swananan eb99da3cbb uprobe: bundle attach location+cookie via UProbeAttachPoint
This follows the #1417 review discussion: by bundling location
+ cookie into a UProbeAttachPoint we get a more idiomatic Into<_>
entry point, keep the one-to-one relationship enforced by the type
system, and make it easier to extend attach with multi-location
support without introducing parallel arrays or a brand new API.
2025-12-23 18:22:42 +01:00
dependabot[bot] 0780eef640 build(deps): bump the github-actions group with 3 updates
Bumps the github-actions group with 3 updates: [DavidAnson/markdownlint-cli2-action](https://github.com/davidanson/markdownlint-cli2-action), [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) and [actions/cache](https://github.com/actions/cache).


Updates `DavidAnson/markdownlint-cli2-action` from 21 to 22
- [Release notes](https://github.com/davidanson/markdownlint-cli2-action/releases)
- [Commits](https://github.com/davidanson/markdownlint-cli2-action/compare/v21...v22)

Updates `peter-evans/create-pull-request` from 7 to 8
- [Release notes](https://github.com/peter-evans/create-pull-request/releases)
- [Commits](https://github.com/peter-evans/create-pull-request/compare/v7...v8)

Updates `actions/cache` from 4 to 5
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v4...v5)

---
updated-dependencies:
- dependency-name: DavidAnson/markdownlint-cli2-action
  dependency-version: '22'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: peter-evans/create-pull-request
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/cache
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-16 11:15:51 +01:00
Tamir Duberstein 5bf66d6127 integration-test: appease clippy
Before this change:
```
warning: manual saturating arithmetic
   --> test/integration-test/src/tests/ring_buf.rs:235:9
    |
235 | /         data.len()
236 | |             .checked_sub(RING_BUF_MAX_ENTRIES - 1)
237 | |             .unwrap_or_default(),
    | |________________________________^ help: consider using `saturating_sub`: `data.len().saturating_sub(RING_BUF_MAX_ENTRIES - 1)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic
    = note: `-W clippy::manual-saturating-arithmetic` implied by `-W clippy::all`
    = help: to override `-W clippy::all` add `#[allow(clippy::manual_saturating_arithmetic)]`

warning: manual saturating arithmetic
   --> test/integration-test/src/tests/ring_buf.rs:244:20
    |
244 |     let min_seen = max_seen.checked_sub(max_dropped).unwrap_or_default();
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `max_seen.saturating_sub(max_dropped)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic

warning: manual saturating arithmetic
   --> test/integration-test/src/tests/ring_buf.rs:245:24
    |
245 |     let min_rejected = max_rejected.checked_sub(dropped).unwrap_or_default();
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `max_rejected.saturating_sub(dropped)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic

warning: `integration-test` (lib test) generated 3 warnings (run `cargo clippy --fix --lib -p integration-test --tests` to apply 3 suggestions)
```
2025-12-16 10:05:38 +01:00
Tamir Duberstein 28ae4b9826 test: properly spell "dependency" 2025-12-10 12:03:13 -05:00
Michal R 800f9f9fea ci/lint: Do not install stable toolchain
We run clippy and miri only with nightly.
2025-12-09 16:34:09 +04:00
Michal R ab187058d8 ci: Enable llvm-link-static feature for bpf-linker
Rust CI does not provide dynamic libLLVM tarballs for macOS—only static
ones. Since recent versions of bpf-linker require explicit linkage
configuration for libLLVM, enable the `llvm-link-static` feature to
ensure correct static linking.

Make sure bpf-linker's build.rs sees the downloaded LLVM by adding it
to PATH. On macOS, set the `{CXXSTDLIB,ZLIB}_PATH` variables to point
to the brew prefixes with static libraries it needs.

Given that now we link statically all libLLVM's dependencies and macOS
provides only dynamic zlib, we need to install static zlib from brew.
2025-12-09 16:34:09 +04:00
Daniel Mellado 7a3c03e178 Add licese for aya-obj
This commit adds a link for the needed licenses in aya-obj for fedora
packaging.

Signed-off-by: Daniel Mellado <dmellado@fedoraproject.org>
2025-11-30 13:58:43 -05:00
dependabot[bot] a22ec3792a build(deps): update object requirement in the cargo-crates group
Updates the requirements on [object](https://github.com/gimli-rs/object) to permit the latest version.

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

---
updated-dependencies:
- dependency-name: object
  dependency-version: 0.38.0
  dependency-type: direct:production
  dependency-group: cargo-crates
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-24 09:45:52 -05:00
dependabot[bot] fc2320bb5d build(deps): bump actions/checkout in the github-actions group
Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout).


Updates `actions/checkout` from 5 to 6
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-24 08:27:31 -05:00
Tamir Duberstein d238b2ea6f Release crates
- aya v0.13.2
- aya-build v0.1.3
- aya-ebpf v0.1.2
- aya-ebpf-bindings v0.1.2
- aya-ebpf-cty v0.2.3
- aya-ebpf-macros v0.1.2
- aya-log v0.2.2
- aya-log-common v0.1.16
- aya-log-ebpf v0.1.2
- aya-log-ebpf-macros v0.1.1
- aya-log-parser v0.1.14
- aya-obj v0.2.2

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
aya-ebpf-bindings-v0.1.2 aya-ebpf-cty-v0.2.3 aya-ebpf-macros-v0.1.2 aya-build-v0.1.3
2025-11-17 14:51:14 -05:00
Dave Tucker acb1ddd2ec docs: Add release documentation
This describes the current process for performing releases from the
aya workspace.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2025-11-17 12:46:10 -05:00
dependabot[bot] 75cd7e835f 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 20 to 21
- [Release notes](https://github.com/davidanson/markdownlint-cli2-action/releases)
- [Commits](https://github.com/davidanson/markdownlint-cli2-action/compare/v20...v21)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-17 09:24:21 -05:00
Tamir Duberstein 7a8ad146f4 Add macos-latest
There's no way to get hardware acceleration on arm64 at all, so let's at
least make sure our stuff keeps working on macOS.
2025-11-13 11:29:15 -05:00
Tamir Duberstein 46221ad11d probe: use RAII to clean up in the error path 2025-11-12 11:55:44 -05:00
Tamir Duberstein 72810f095f aya: ProbeKind is Entry/Return
We already have separate types for KProbe and UProbe.
2025-11-12 11:28:03 -05:00
Tamir Duberstein a4a3c1641f probe: use exhaustive matches 2025-11-12 11:28:03 -05:00
Tamir Duberstein 1944c4aa00 perf_event: refactor perf_event_open_trace_point
Rewrite it in terms of perf_event_open.
2025-11-12 11:28:03 -05:00
Tamir Duberstein d4b2dde78a perf_event: inline perf_event_open_bpf
This function has one caller and provides no abstraction.
2025-11-12 11:28:03 -05:00
Tamir Duberstein 7e07f85edc perf_attach: privatize PerfLink
There's no way to obtain this type externally.
2025-11-12 11:28:03 -05:00
Tamir Duberstein 27c7f1c84f programs: disambiguate fd names 2025-11-12 11:28:02 -05:00
Tamir Duberstein 1791d497d3 programs: remove superfluous type ascription 2025-11-12 11:25:54 -05:00
Tamir Duberstein 14a844256a macros: remove glob imports 2025-11-11 10:19:08 -05:00
Tamir Duberstein 2a33c642de .github: remove push-to-fork
We need to create the fork first.
2025-11-11 09:58:20 -05:00