Testing eBPF code where it actually runs
This framework is heavily inspired by Cilium’s eBPF testing approach. The overall testing architecture comes from Cilium; this post focuses on implementing those ideas in Rust using Aya. If you’re interested in the original design, I recommend taking a look at Cilium’s testing framework. The implementation described in this post is available in my GitHub repository.
- Cilium: https://github.com/cilium/cilium
- Implementation: https://github.com/erwin-kok/sarena
The problem
When exploring/implementing an eBPF/XDP/TCX dataplane, a question arose:
“How do we actually test this?” For example, when we have an eBPF program
called process_ipv4(), how can we test its functionality? Granted, these
programs are written in Rust (when using Aya), so it looks straightforward
to test them like any other Rust function. However, there are a few
caveats: