Commit Graph

15 Commits

Author SHA1 Message Date
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
630a767117 Split relocation tests into multiple files
This avoids requiring kernel support for all types of relocations when
testing a specific type.
2025-05-16 10:13:08 -04:00
Michal Rostecki
bf2164c92f feat(aya): Add iterator program type
BPF iterators[0] are a way to dump kernel data into user-space and an
alternative to `/proc` filesystem.

This change adds support for BPF iterators on the user-space side. It
provides a possibility to retrieve the outputs of BPF iterator programs
both from sync and async Rust code.

[0] https://docs.kernel.org/bpf/bpf_iterators.html
2024-11-24 16:27:44 +01:00
Dave Tucker
adf16e2102 test: Reproduce relocation bug
Users have reported issues with programs failing the verifier when they
are attempting to read or write to variables that the compiler places in
the .bss section. Add a test that places variables in each section and
exercises read and write operations on them.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2024-11-01 11:56:56 +00:00
Michal Rostecki
c05a3b69b7 aya-obj: Handle lack of match of enum variants correctly
When comparing `local_spec` with `target_spec` for enum relocations,
we can encounter a situation when a matchinng variant in a candidate
spec doesn't exist.

Before this change, such case wasn't handled explicitly, therefore
resulted in returning currently constructed `target_spec` at the
end. The problem is that such `target_spec` was, due to lack of
match, incomplete. It didn't contain any `accessors` nor `parts`.

Later usage of such incomplete `target_spec` was leading to panics,
since the code operating on enums' `target_spec` expects at least
one `accessor` to be available.

Fixes #868
2024-01-29 11:10:25 +01:00
astoycos
82039144bd integration-test: Add map pinning coverage
Add coverage to the new public api's for
map pinning (pin and unpin) which can be called
on the generic aya::Map type OR explit map types.

Additionally add coverage for the new libbpf
LIBBPF_PIN_BY_NAME behavior.

Signed-off-by: astoycos <astoycos@redhat.com>
2023-10-10 13:12:00 -04:00
Tamir Duberstein
0a144a0e69 integration-test: remove all sleeps 2023-09-11 10:37:57 -04:00
Tamir Duberstein
54c90ec72c integration-test: De-duplicate BTF relocation test 2023-08-09 10:18:06 -04:00
Tamir Duberstein
71bc3ea0b5 integration-test: avoid reliance on kernel headers
This should allow us to build on any system.
2023-08-09 10:18:05 -04:00
Tamir Duberstein
b46fb616be integration-test: fix BTF relocation test
The struct_flavors test previously expected the same thing with and
without relocations. It now expects different values.

Also rename an enum variant "u64" to "S64". This was a typo. Turns out
that U32 is a type that exists in kernel headers, so all enum values are
suffixed with "_VAL".

Remove stdlib.h and the call to exit(). This alone makes the test fail
with a poisoned relocation. Bringing over the map definition makes the
test work again.
2023-08-09 10:13:24 -04:00
Tamir Duberstein
72afd877b5 integration-test: clang-format C files 2023-08-08 10:40:30 -04:00
Dave Tucker
79ea64ca7f aya: Fix (func|line)_info multiple progs in section
This commit fixes the (func|line)_info when we have multiple programs in
the same section. The integration test reloc.bpf.c serves as our test
case here. This required filtering down the (func|line)_info to only
that in scope of the current symbol + then adjusting the offets to
appease the kernel.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2023-08-02 21:03:07 +01:00
Tamir Duberstein
dca5e6c167 integration-test: Remove runtime toolchain deps
Move the use of clang and llvm-objcopy from run-time to build-time. This
allows the integration tests to run on VMs with simpler userlands.

Create a new CI job to build the integration tests separately from
running them. Ship them from that job to the runner job using github
actions artifacts.
2023-08-01 12:28:41 -04:00
Dave Tucker
bf7fdff1ce aya: Find programs using the symbol table
This makes a few changes to the way that Aya reads the ELF object
files.

1. To find programs in a section, we use the symbols table. This allows
   for cases where multiple programs could appear in the same section.
2. When parsing our ELF file we build symbols_by_section_index as an
   optimization as we use it for legacy maps, BTF maps and now programs.

As a result of theses changes the "NAME" used in `bpf.prog_mut("NAME")`
is now ALWAYS the same as the function name in the eBPF code, making the
user experience more consistent.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2023-07-31 17:30:20 +01:00
Tamir Duberstein
8c61fc9ea6 integration-test: compile C probes using build.rs
- Add libbpf as a submodule. This prevents having to plumb its location
  around (which can't be passed to Cargo build scripts) and also
  controls the version against which codegen has run.
- Move bpf written in C to the integration-test crate and define
  constants for each probe.
- Remove magic; each C source file must be directly enumerated in the
  build script and in lib.rs.
2023-07-12 21:43:24 -04:00