Commit Graph

2204 Commits (47129a9ad627b9f451b2ae3a156868b43d8d9ed6)
 

Author SHA1 Message Date
Friday Ortiz 47129a9ad6
Merge 61e0aef8b6 into 03e8487177 3 weeks 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
3 weeks ago
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
3 weeks 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.
3 weeks 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.
3 weeks ago
Tamir Duberstein 0144c0eb22
integration-test: defer cleanup to ensure unpin 3 weeks ago
Tamir Duberstein e3f69829de
.github: run old kernels first 3 weeks ago
Tamir Duberstein c7d4cd3943
ci: test against 5.10
This is the earliest LTS that still exists on debian mirrors.
3 weeks ago
Tamir Duberstein 907920a629
Skip `cpumap_chain` when attachment fails 3 weeks ago
Tamir Duberstein 54bd3ac202
Skip `lsm_cgroup` when loading fails
squash into proper check
3 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.
3 weeks ago
Tamir Duberstein 3d0b53111f
integration-test: remove skips 3 weeks ago
Tamir Duberstein 8e9404ecd4
aya-obj: apply enum64-to-union fixup in reloc
This code is just awful.
3 weeks ago
Tamir Duberstein 7224efcad8
aya-obj: patch up 0-size datasec
Use OnceCell for ENUM64 while I'm here as well.
3 weeks ago
Tamir Duberstein 166ad2f40f
btf: reduce repetition
This code is bad.
3 weeks ago
Tamir Duberstein 122cf17a43
btf: avoid `unreachable!()` and `unwrap()` 3 weeks ago
Tamir Duberstein 3ade19b869
Promote BTF loading failure to error on BTF relocs 3 weeks ago
Tamir Duberstein b2fd9493a8
integration-test: handle !bpf_perf_link 3 weeks ago
Tamir Duberstein 4c974d33a3
xdp: replace kernel version check with fallback 3 weeks ago
Tamir Duberstein 0ec60c4f23
Skip `bpf_strncmp` on kernel < 5.17 3 weeks ago
Tamir Duberstein 4c22a99cb0
Skip af_xdp when AF_XDP is unsupported 3 weeks ago
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.
3 weeks ago
Friday Ortiz 61e0aef8b6
.github,aya,test: clean up interface and script per review comments
- .github: Ensure we only download the debug package that matches the kernel we
  downloaded.
- aya: Constrain the breakpoint interface to only valid combinations of
  options.
- test: Document what the test is actually doing for future readers who might
  be unfamiliar with modprobe_path.
3 weeks ago
Tamir Duberstein e5306901a0
Skip `test_uprobe_cookie` on kernel < 5.15 3 weeks ago
Friday Ortiz 38e3f7fce2
Merge branch 'main' into feature/breakpoint-support 3 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.
3 weeks ago
Tamir Duberstein 08cf90881f
integration-test: extract run_pin_program_lifecycle_test 3 weeks ago
Tamir Duberstein fe43f776c3
integration-test: extract from_pin 3 weeks ago
Tamir Duberstein 0840faf6b1
integration-test: extract pin paths 3 weeks ago
Tamir Duberstein 0f1c975632
integration-test: extract run_unload_program_test 3 weeks ago
Tamir Duberstein a6458804fc
integration-test: extract types 3 weeks ago
Tamir Duberstein a2f4951cce
integration-test: remove errant semicolons 3 weeks ago
Tamir Duberstein 89d746ad1b
integration-test: extract attach fns 3 weeks ago
Tamir Duberstein 48300b6498
integration-test: extract program names 3 weeks ago
Tamir Duberstein 4041fe9293
integration-test: move memmove out of pin tests 3 weeks ago
Tamir Duberstein c2fb7fed6c
Remove useless impl 3 weeks ago
Tamir Duberstein f76fdf9da5
Improve error output
- Use consistent casing.
- Emit syscall return value.
3 weeks ago
Tamir Duberstein 82aec26963
flow_dissector: add missing impl_try_into_fdlink 3 weeks ago
Tamir Duberstein 0cb52e850a
xtask: tolerate curl failure when possible
Codex sandbox forbids network access.
3 weeks ago
Tamir Duberstein 667790e103
xtask: avoid `git submodule update` when possible
`git submodule update` fails when running in a codex sandbox:

```
  error: could not lock config file /Users/tamird/src/aya/.git/modules/libbpf/config: Operation not permitted
```

so just avoid it when not necessary.
3 weeks ago
Tamir Duberstein 6fc06b9fcf
Remove unused error variant 3 weeks ago
Tamir Duberstein 4ce1e29804
clippy.sh: build for BPF after everything else
In cases where I run `./clippy.sh ... -p <crate>` I really want the
results for that crate to come quickly.
3 weeks ago
Tamir Duberstein 57a75dfd61
.vscode: always use linux in rust-analyzer 3 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.
3 weeks ago
Friday Ortiz 4545feec9a
aya,test,xtask: add breakpoint support to enforced perf_event config combo branch
* 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.

* add breakpoint support to perf_event config interface

---------

Co-authored-by: Tyrone Wu <wudevelops@gmail.com>
4 weeks ago
Friday Ortiz 22d6f58e9b
test: use gunzip symbol to determine kaslr offset
This symbol should appear in both kallsyms and System.map, whereas
the _text symbol does not.
4 weeks ago
Friday Ortiz c6718e7882
Merge branch 'main' into feature/breakpoint-support 4 weeks ago
Friday Ortiz 51d97a4303
test,xtask: include debug symbols for attaching breakpoints in tests
For some reason, the aarch64 6.1 debian kernel was not compiled with
CONFIG_KALLSYMS_ALL=y, 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.

- .github: pull the corresponding debug packages down as well as regular
  kernels
- test: attach the perf_event_bp test breakpoint to the modprobe_path address
  in kallsyms if present, or by applying the kaslr offset to the System.map
  address if not found
- xtask: preferentially extract the System.map file from the debug package, if
  available
4 weeks ago
Friday Ortiz 8b58fc13fc
test: add a perf_event breakpoint test
Test perf_event breakpoints by attaching a RW breakpoint to
modprobe_path and triggering a read from procfs, asserting that the tgid
of the program triggering the breakpoint matches the test program.
4 weeks ago
Tamir Duberstein 29dc775535
test-distro: appease unreachable code check
See https://github.com/rust-lang/rust/commit/ff6dc928c5e33ce8e65c6911a7.
4 weeks ago