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.
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.
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
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
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>
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.
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.
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>
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.
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.
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.