Commit Graph

2338 Commits

Author SHA1 Message Date
Tamir Duberstein 595910c410 Set fixed expected attach types
Load cgroup_{device,sysctl}, flow_dissector, lirc_mode2, sk_msg,
sock_ops programs with their fixed expected attach types instead of
omitting them.

These program types already use the same constants when attaching.
2026-04-03 11:22:00 -04:00
Tamir Duberstein 2c927581fe Remove duplicate attach type state
Pass the kernel attach type into the shared loader from each typed
wrapper instead of storing a second mutable copy in `ProgramData`.

This removes the from_pin repair pattern, avoids stale shadow state, and
keeps attach paths driven by wrapper-owned typed attach metadata or
fixed constants.

Also simplify `{sk,cgroup}_skb` section parsing by representing all
variants as `ProgramSection::SkSkb { kind }` and
`ProgramSection::CgroupSkb { attach_type }` respectively, with the
attach type enums shared from aya-obj.
2026-04-03 11:21:32 -04:00
Tamir Duberstein 48f9e00c2e util: make Align not pub
This has no effect, so drop it. Tidy up a bit while I'm here and explain
the use of const refernces.
2026-04-02 17:35:36 -04:00
Kirill Lykov a7144b9a6e Align by 8b in include_bytes_aligned.
The max alignment required by ELF files is 8 bytes. There is no need to
use 32b alignment.
2026-04-01 17:41:36 +00:00
dependabot[bot] 3992977502 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.39.0
- [Changelog](https://github.com/gimli-rs/object/blob/main/CHANGELOG.md)
- [Commits](https://github.com/gimli-rs/object/compare/0.38.0...v0.39.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-30 15:38:33 -04:00
dependabot[bot] fe7b9d3e50 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 22 to 23
- [Release notes](https://github.com/davidanson/markdownlint-cli2-action/releases)
- [Commits](https://github.com/davidanson/markdownlint-cli2-action/compare/v22...v23)

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

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-30 11:03:23 -04:00
Amit Prasad dbe559b1a2 Add aya-ebpf-cty to workspace manifest 2026-03-29 07:14:34 +00:00
vad 746a4e9523 ci: Install bpf-linker with --force
In some CI jobs, `cargo binstall` is convinced that bpf-linker is
already installed:

```
INFO resolve: bpf-linker v0.10.2 is already installed, use --force to override
```

When in reality, it's not there. Not sure what's the source of this
delusion, but let's just install it with `--force`.
2026-03-27 09:09:53 +01:00
Weixie Cui 5bce2b7e29 aya-obj: mask Func linkage with 16 bits
Match `Func::new` and `set_linkage`, which store linkage in the low
16 bits of `info`; reading with 0xFFF dropped the high nibble of that
field.
2026-03-26 14:55:27 +01:00
Weixie Cui 8f690b7734 aya-obj: fix line_info.num_info when linking functions
Set num_info from the merged line_info table length, matching func_info
handling and BTF line_info record counts.
2026-03-26 09:23:25 +00:00
vad 3ae75f6171 ci: Install bpf-linker with cargo-binstall 2026-03-25 15:44:06 +00:00
vad bddbcfbfc8 .github: Make pull request template markdownlint2-compatible
Lower the template headings from level 1 to level 3 to satisfy the
`single-title` rule.

Disable `first-line-heading` as well, since the template intentionally
does not include a top-level document title.
2026-03-23 11:19:29 +00:00
vad a7a3f3ff18 .github: Remove the "Summary" and "Related Issues" sections from the PR template
I find them annoying and they're usually an obvious sign of LLM misuse.
Keep only the sections for additional questions from us, that follow
the summary.
2026-03-23 11:19:29 +00:00
vad 1210f34225 .github: Rephrase issue linking guidance
Recommend *Fixes:* over *Closes:*, since it is the tag most commonly used
to close issues when a pull request is merged.

Remove the mention of *Relates To*, since it is not part of any of the
documented conventions. Clarify that non-closing issue references can be
included anywhere in the summary.
2026-03-23 11:19:29 +00:00
vad 3641e8f752 .github: Rephrase pull request summary guidance
* Recommend using the commit message as the PR description for
  single-commit PRs.
* Fix the typo: thing -> think.
2026-03-23 11:19:29 +00:00
vad 5144de70a4 .github: Make the identation of markdown comments consistent 2026-03-23 11:19:29 +00:00
Mary Guillemard 6cf45a094b Remove myself from the active maintainers list (#1500)
I have been inactive for quite some years since I left HarfangLab.

I do not have much interest in working on ancient kernels support or
feature parity with libbpf anymore.

I also want to note here that I am deeply concerned by the apparent
full support and acceptance of LLMs based tools.

Signed-off-by: Mary Guillemard <mary@mary.zone>
2026-03-22 16:02:46 +01:00
Dave Tucker 22b975ea63 Add project governance documentation
Explains how Maintainers are selected and their responsibilities.
Explains the Pull Request review workflow.
Adds config for Mergify to enforce this workflow.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2026-03-22 14:10:45 +00:00
Aurélien DEROIDE 8aeec41eec aya-ebpf: Add bpf_f_adj_room_encap_l2
This function is needed to properly add a L2 header when using `bpf_skb_adjust_room` [1].
As it is originally a C macro, it isn't automatically generated in the `bindings` cratea

[1]: https://docs.ebpf.io/linux/helper-function/bpf_skb_adjust_room/
2026-03-20 10:07:09 +00:00
Afonso Quintas a826cc92c9 aya-ebpf: use &self for store, set_mark and set_reply
Currently, the API for calling kernel helpers on `TcContext`, `SkBuff`,
and `SockOpsContext` has inconsistent semantics. Methods like `store`,
`set_mark`, and `set_reply` require a mutable reference (`&mut self`),
while others that also modify the underlying state take a read-only
reference (`&self`).

This commit resolves the inconsistency reported in #1442 by changing
`store`, `set_mark`, and `set_reply` to take `&self` across `SkBuff`,
`SkBuffContext`, `TcContext`, and `SockOpsContext`.

The `cb_mut` method is intentionally left unchanged because returning
a mutable slice (`&mut [u32]`) from an immutable reference would
violate Rust's aliasing rules.

Fixes: #1442
2026-03-18 11:23:34 -04:00
Tamir Duberstein 98960db18a netlink: avoid some allocations 2026-03-16 16:50:42 -04:00
Tamir Duberstein ed516b3ec0 netlink: advance through write buffers
Refactor netlink attribute writers to consume and return the remaining
buffer instead of passing offsets through helper calls.
2026-03-16 16:50:42 -04:00
Tamir Duberstein 52c33ebdf8 netlink: use constants more consistently
Use returned lengths where possible rather than hard coding constants.
2026-03-16 16:50:42 -04:00
Tamir Duberstein 68be4b7297 netlink: use checked accessors 2026-03-16 16:50:42 -04:00
Tamir Duberstein f49ef401a7 netlink: avoid repeating NLA_ALIGNTO everywhere 2026-03-16 16:50:39 -04:00
Tamir Duberstein d43d8a9674 Remove no-longer-firing lint expectations
This was fixed in cargo.

Link: https://github.com/rust-lang/cargo/commit/36505e2282142866b3a2fd6c0b4384b70fa77821
2026-03-14 20:37:14 -04:00
Miroslav Hruz 4cc14020fb aya-build: honor RUSTC_BOOTSTRAP
Use `RUSTC_BOOTSTRAP` when deciding whether to pass `-Zbuild-std=core`.

This keeps eBPF builds working in environments without rustup where a
stable toolchain is used with bootstrap enabled to allow unstable
features. It also preserves `-1` as an explicit opt-out and accepts
crate-scoped bootstrap values.
2026-03-09 11:04:17 -07:00
Tamir Duberstein b93ee8c26e Use plain arrays in ring buf tests
Store ring buffer accounting in plain arrays instead of per-CPU arrays
and use atomic increments in the eBPF test program where concurrent
writers still share the counters.

Co-authored-by: Codex <noreply@openai.com>
2026-03-06 11:30:47 -05:00
Tamir Duberstein b9cb76b302 Rename EbpfGlobal to Global
Rename the eBPF global wrapper type to `Global` and update its
downstream uses and API snapshot so the public surface matches the new
name.

Co-authored-by: Codex <noreply@openai.com>
2026-03-06 11:20:10 -05:00
Alessandro Decina 197f8a5394 ci: arm64: use cortex-a72 cpu
ERROR:target/arm/internals.h:767:regime_is_user: code should not be
reached Bail out! ERROR:target/arm/internals.h:767:regime_is_user: code
should not be reached Error: "qemu-system-aarch64" "-machine" "virt"
"-cpu" "max" "-accel" "kvm" "-accel" "hvf" "-accel" "tcg" "-no-reboot"
"-nographic" "-m" "1024M" "-smp" "2" "-append" "console=ttyAMA0
init.arg=--test-threads=1 noapic" "-kernel"
"/tmp/.tmpROemqg/kernel-archive-0-image/./boot/vmlinuz-6.17.13+deb13-cloud-arm64"
"-initrd" "/tmp/.tmpNJFz3n/qemu-initramfs.img" failed
2026-03-07 03:18:03 +11:00
Alessandro Decina cdfa52de6e lsm_cgroup: fix attach on 6.17
For LSM programs the target_btf_id is set at load time not attach time.

Starting from
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1209339844601ec1766f4ff430673fbcfe42bb51
setting it at attach time results in EINVAL, because it happens to be
interpreted as bits of the mprog part of the union.
2026-03-07 03:18:03 +11:00
Alessandro Decina 82b8485098 test-distro: improve depmod alias generation
The depmod implementation used to scan for _symbols_ in the .modinfo
section containing "alias" in the name. That stopped working from kernel
6.17 and broke the smoke::modprobe test.

The aliases can be parsed from the .modinfo section itself, no need to
look at symbols at all.

Fixes integration tests on 6.17.
2026-03-07 03:18:03 +11:00
Alessandro Decina 352243f2f4 ci: run integration tests on 6.17 2026-03-07 03:18:03 +11:00
Alessandro Decina c9e96f78e5 test: add integration test for kprobes 2026-03-07 02:27:04 +11:00
Tamir Duberstein ab7f96dafb aya-ebpf: document nul termination
See https://docs.ebpf.io/linux/helper-function/bpf_get_current_comm/.
2026-03-03 12:59:09 -05:00
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 |                     // https://github.com/torvalds/linux/commit/6089fb325cf737eeb2c4d236c94697112ca860da.
  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