Commit Graph

2303 Commits

Author SHA1 Message Date
dependabot[bot]
db64fcf73b build(deps): update public-api requirement in the cargo-crates group (#1488)
Updates the requirements on [public-api](https://github.com/cargo-public-api/cargo-public-api) to permit the latest version.

Updates `public-api` to 0.51.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/CHANGELOG.md)
- [Commits](https://github.com/cargo-public-api/cargo-public-api/compare/public-api-v0.50.0...public-api-v0.51.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-02 07:31:25 -08:00
Tamir Duberstein
aa122f319f appease clippy
```
  error: this `if` can be collapsed into the outer `match`
     --> aya-obj/src/btf/btf.rs:743:21
      |
  743 | /                     if !features.btf_enum64 {
  744 | |                         debug!("{kind}: not supported. replacing with UNION");
  ...   |
  798 | |                         *t = BtfType::Union(Union::new(name_offset, size, members, Some(fallback)));
  799 | |                     }
      | |_____________________^
      |
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match
      = note: `-D clippy::collapsible-match` implied by `-D warnings`
      = help: to override `-D warnings` add `#[allow(clippy::collapsible_match)]`
  help: collapse nested if block
      |
  740 ~                 BtfType::Enum64(ty)
  741 |                     // Kernels before 6.0 do not support ENUM64. See
  742 |                     // 6089fb325c.
  743 ~                     if !features.btf_enum64 => {
  744 |                         debug!("{kind}: not supported. replacing with UNION");
  ...
  798 |                         *t = BtfType::Union(Union::new(name_offset, size, members, Some(fallback)));
  799 ~                     }
```
2026-02-27 11:26:34 -05:00
cong-or
c42157f0b5 netlink: fix attachment failure with long program names
The netlink attribute buffer in TcRequest was only 64 bytes, which is
not enough when TC program names get close to the kernel's 256-byte
limit. This led to a misleading no space left error when attaching
programs with longer names.

Bump the buffer size so it can precisely fit all the netlink attributes
and the max-length name.
2026-02-20 14:34:38 -08:00
vad
211bb0da9e maps: Add integration test for BloomFilter 2026-02-16 18:19:28 +00:00
vad
ae8c76d037 maps: Fix BloomFilter::contains method
Require the caller to pass a reference, not the owned value. That makes
sure that the pointer is valid from the beginning.
2026-02-16 18:19:28 +00:00
vad
0bf462d221 maps: Take &self in all methods of BloomFilter 2026-02-16 18:19:28 +00:00
vad
8962fc79c1 aya-ebpf: Use i32 as a type for eBPF helper return codes
The helpers always return a signed 64-bit r0 value, but the JIT that
translates eBPF into native instructions differs by architecture. On
x86_64 the generated code writes the helper result into a 64-bit
register, so the CPU sign-extends negative errnos automatically. On
aarch64 the JIT frequently uses 32-bit operations (w0) when copying the
helper return and only zero-extends into the upper half of x0.

That results in broken errno codes on aarch64. For example, when a map
operation returns `-ENOENT`, which is supposed to be -2, the i64
representation yields something like `0x0000_0000_FFFF_FFFE`
(4294967294) instead of -2. In short: the ARM64 JIT doesn’t preserve the
sign in the upper half of the 64-bit register, and the error code has to
be cast to a 32-bit integer to make the sign visible.

This makes it awkward for users, because that behavior prevents simply
comparing helper error codes with constants like `libc::ENOENT` without
manual casts.

Given that the maximum error code limit `MAX_ERRNO` in the kernel is
4095, which fits in a 32-bit integer, coerce the error codes to be `i32`
and make all helpers return `Result<T, i32>`.
2026-02-16 18:19:28 +00:00
tamird
a30c1496f7 public-api: regenerate 2026-02-16 08:04:48 +00:00
Jamie Hill-Daniel
294e0c1941 ebpf: Add helper for safe loading of globals 2026-02-13 11:13:57 -08:00
dependabot[bot]
baa7ddb381 build(deps): bump the cargo-crates group with 2 updates
Updates the requirements on [libbpf-rs](https://github.com/libbpf/libbpf-rs) and [rand](https://github.com/rust-random/rand) to permit the latest version.

Updates `libbpf-rs` to 0.26.0
- [Release notes](https://github.com/libbpf/libbpf-rs/releases)
- [Commits](https://github.com/libbpf/libbpf-rs/compare/v0.25.0...v0.26.0)

Updates `rand` to 0.10.0
- [Release notes](https://github.com/rust-random/rand/releases)
- [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-random/rand/compare/rand_core-0.9.1...0.10.0)

---
updated-dependencies:
- dependency-name: libbpf-rs
  dependency-version: 0.26.0
  dependency-type: direct:production
  dependency-group: cargo-crates
- dependency-name: rand
  dependency-version: 0.10.0
  dependency-type: direct:production
  dependency-group: cargo-crates
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
2026-02-09 16:09:10 -05:00
Gustavo Noronha Silva
dd9bb520d2 tracepoint: use read_kernel() for read_at()
For most architectures just bpf_probe_read() works, but for those that
have overlapping memory address spaces, like UML, we must use the
specific helper.
2026-02-09 17:34:32 +11:00
Tamir Duberstein
519abffef7 ci: bump bpf-linker llvm to 22 2026-01-31 06:30:33 -05:00
Tamir Duberstein
2f8759cc62 Dial the lints to 100 2026-01-29 10:02:48 -05:00
Tamir Duberstein
d10ed519c3 xtask: move libbpf-sys hacks to Rust
This restores my ability to run integration tests locally.

Replace `clippy.sh` with `cargo xtask clippy`.
2026-01-28 21:08:01 -05:00
vad
ab109e489c ci: Cancel stale PR runs automatically
Add a workflow-level concurrency group so PR workflows share a
`<workflow>-pr-<number>` group and GitHub cancels any in-progress run
when a new push arrives. Non-PR events fall back to the ref name, which
keeps push/cron runs isolated while still preventing multiple runs per
ref from piling up.
2026-01-28 20:03:49 +00:00
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