Commit Graph

823 Commits

Author SHA1 Message Date
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
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
Jamie Hill-Daniel
294e0c1941 ebpf: Add helper for safe loading of globals 2026-02-13 11:13:57 -08:00
Tamir Duberstein
2f8759cc62 Dial the lints to 100 2026-01-29 10:02:48 -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
f35f7a3610 aya, aya-ebpf: reduce duplication 2026-01-21 09:05:51 -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
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
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
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>
2025-11-17 14:51:14 -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
Friday Ortiz
ab38afe95d perf_event: support hardware breakpoints
Implement `PerfEventConfig::Breakpoint`, allowing users to attach
hardware breakpoints. Generate `HW_BREAKPOINT_*` and `struct
bpf_perf_event_data` in support of this feature and update the type of
`PerfEventContext` accordingly.

Add a test exercising R, W, RW, and X breakpoints. Note that R
breakpoints are unsupported on x86, and this is asserted in the test.

Extend the VM integration test harness and supporting infrastructure
(e.g. `download_kernel_images.sh`) to download kernel debug packages and
mount `System.map` in initramfs. This is needed (at least) on the aarch
6.1 Debian kernel which was not compiled with `CONFIG_KALLSYMS_ALL=y`
for some reason, and the locations of globals are not available in
kallsyms. To attach breakpoints to these symbols in the test pipeline,
we need to read them from System.map and apply the KASLR offset to get
their real address. The `System.map` file is not provided in the kernel
package by default, so we need to extract it from the corresponding
debug package. The KASLR offset is computed using `gunzip` which appears
in kallsyms on all Debian kernels tested.

Co-authored-by: Tamir Duberstein <tamird@gmail.com>
2025-11-10 16:33:54 -05:00
JPaja
d8f5497884 feat: add Ebpf::maps_disjoint_mut
Implemented using `HashMap::get_disjoint_mut` introduced in Rust 1.86.0.
2025-11-10 14:12:04 -05:00
Tamir Duberstein
112ab47fcd Add clippy coverage for doctests 2025-11-09 18:26:39 -05:00
Tamir Duberstein
18c7f7ccd6 perf_event: push down type safety
This makes it more difficult to mishandle callers of `perf_event_open`.

Change `wakeup_events = 0` to 1; per `man 2 perf_event_open`:

  Prior to Linux 3.0, setting wakeup_events to 0 resulted in
  no overflow notifications; more recent kernels treat 0 the
  same as 1.
2025-11-09 17:50:53 -05:00
Tamir Duberstein
7e405c216e perf_event: simplify PerfEventScope 2025-11-09 13:20:41 -05:00
swananan
4fbce44b6a aya: tolerate proc map trailing newline
Proc maps terminate with a newline so split(b'\n') yields an empty
slice at the end. Filter it out before parsing so the absolute-path
fallback for pid-scoped attach doesn't get short-circuited by a
ProcMap::ParseLine error.
2025-11-05 22:37:43 -05:00
Alessandro Decina
3a3c451009 aya: restore must_exist argument to set_global
In
03e8487177
we deprecated set_global but accidentally broke its API by deleting the
must_exist argument.
2025-10-29 13:01:34 +01:00
Tamir Duberstein
d73c65caae Add some type ascription 2025-10-26 11:42:32 -04:00
Tamir Duberstein
17c7c7951c lints: enable clippy::as_underscore 2025-10-26 11:36:51 -04:00
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
2025-10-22 00:05:20 -04:00
Andrew Werner
17171647f7 aya/maps/ring_buf: fix producer position initialization
The RingBuf caches the last value it read of the producer so it doesn't
need to constantly contend on the actual producer cache line if lots of
messages have yet to be consumed. It was bogus to initialize this cache
at 0. This patch initializes it properly and adds testing.

Fixes: #1309
2025-10-21 08:30:20 -04:00
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.
2025-10-21 08:30:20 -04:00
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.
2025-10-21 08:30:20 -04:00
Tamir Duberstein
0144c0eb22 integration-test: defer cleanup to ensure unpin 2025-10-17 22:16:28 -04:00
Tamir Duberstein
907920a629 Skip cpumap_chain when attachment fails 2025-10-17 22:16:28 -04:00
Tamir Duberstein
54bd3ac202 Skip lsm_cgroup when loading fails
squash into proper check
2025-10-17 22:16:28 -04:00
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.
2025-10-17 22:16:28 -04:00
Tamir Duberstein
7224efcad8 aya-obj: patch up 0-size datasec
Use OnceCell for ENUM64 while I'm here as well.
2025-10-17 15:28:22 -04:00
Tamir Duberstein
3ade19b869 Promote BTF loading failure to error on BTF relocs 2025-10-17 15:28:22 -04:00
Tamir Duberstein
4c974d33a3 xdp: replace kernel version check with fallback 2025-10-17 15:28:21 -04:00
Tamir Duberstein
984a0501c6 Raise RLIMIT_MEMLOCK on kernel version < 5.11.0
See https://github.com/cilium/ebpf/blob/main/docs/ebpf/concepts/rlimit.md.
2025-10-17 15:28:20 -04:00
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.
2025-10-16 09:51:10 -04:00
Tamir Duberstein
c2fb7fed6c Remove useless impl 2025-10-16 06:20:43 -04:00
Tamir Duberstein
f76fdf9da5 Improve error output
- Use consistent casing.
- Emit syscall return value.
2025-10-16 06:20:43 -04:00
Tamir Duberstein
82aec26963 flow_dissector: add missing impl_try_into_fdlink 2025-10-16 06:20:43 -04:00