einat-ebpf icon indicating copy to clipboard operation
einat-ebpf copied to clipboard

Use Aya eBPF loading backend to avoid introducing native dependencies

Open EHfive opened this issue 1 year ago • 0 comments

Currently we use libbpf-sys as eBPF loading backend, however it's C backed and has external native dependencies libelf and zlib. This has complicated our build process by introducing external dependencies on C toolchains for C compiling and linking, which is especially tricky to handle in cross-compilation^1 and is prone to build error^3.

Thus a pure Rust eBPF loading backend, Aya, is preferred to avoid those issues. This also has benefits on safety, code optimization, etc. due to Aya's pure Rust nature.

By using Aya, we can minimize dependencies to Rust toolchain and clang/LLVM(for compiling BPF C code) on build platform, and there would be zero external dependency on target platform except libc.

  • ~~Write an Aya-based eBPF programs skeleton generator similar to libbpf-cargo, this could be loading backend agnostic thus benefits both Aya and libbpf.~~ aya-obj is missing public API to iterate BTF types, so just compile BPF C code using clang in build script.
  • [ ] Allow using either Aya or libbpf as loading backend for einat eBPF programs and maps. We might also decide to drop libbpf backend completely based on evaluation results after switching to Aya.

EHfive avatar Jun 19 '24 20:06 EHfive