The XDP Mode Discrepancy Problem
Extended Berkeley Packet Filter (XDP) offers powerful kernel-level packet processing, but a significant operational risk lurks: native XDP and generic SKB-mode XDP are not functionally equivalent. A BPF program that passes the kernel's verifier can exhibit divergent behavior depending on whether it runs in native mode (directly in the driver) or generic mode (fallback via the SKB path). This divergence can manifest as variations in verdicts, differing frame byte interpretations, or altered metadata, even with identical bytecode.
The implications are substantial. Network functions like firewalls or rate-limiters, meticulously validated under the high-performance native XDP, can unexpectedly degrade in performance or alter their logic when falling back to generic mode. This fallback can occur on drivers that don't fully support native XDP, on virtual interfaces like veth, or even after a kernel reload. Developers often deploy these programs believing their behavior is static, only to discover subtle, undocumented functional shifts that can compromise security or performance without clear error indicators.
This post introduces a solution: an open-source differential test harness designed to expose these discrepancies. The harness, coupled with a curated eleven-packet corpus and a straightforward classification method for identified differences, provides a reproducible baseline. A tagged release enables users to replicate the virtio/veth baseline on Linux kernel 6.8, offering concrete evidence of the problem and a tool to verify fixes.

The Test Harness Methodology
The core of the solution is a test harness that orchestrates a systematic comparison between native and generic XDP execution. The process begins with a corpus of carefully selected network packets. This corpus is designed to exercise various packet types, sizes, and potential edge cases that might trigger mode-specific behavior. For each packet in the corpus, the harness performs the following steps:
- Injection: The packet is injected onto the network interface's receive (RX) path.
- Native XDP Sweep: The BPF program is loaded and executed in native XDP mode. The resulting packet captures, along with any metadata or verdicts, are recorded.
- Generic SKB-Mode XDP Sweep: The same BPF program is then loaded and executed in generic SKB-mode. Again, the resulting packet captures and associated data are meticulously recorded.
- Capture with
xdpdump: A specialized tool,xdpdump, is used to capture the raw packet data as it exits the XDP processing stage in both modes. This ensures an accurate representation of the data that subsequent network layers would receive. - Comparison with
compare.py: A Python script,compare.py, then analyzes the captured packet data from both sweeps. It generates a manifest detailing any differences found, whether in the packet payload, headers, or any XDP-specific metadata that was passed along.
This structured approach ensures that any divergence in how the BPF program is processed – from packet parsing to the final disposition (e.g., accept, drop, redirect) – is systematically identified. The eleven-packet corpus is not arbitrary; it represents a minimum set found to trigger known differences on common network configurations, providing a focused yet effective test suite.
Reproducible Baseline and Future Work
The release includes a tagged version that allows for the reproduction of a specific baseline. This baseline was established using the virtio/veth network interface pair on Linux kernel version 6.8. By providing this reproducible setup, the project empowers the community to verify the harness's effectiveness and to test their own XDP programs against known behavioral gaps.
The immediate goal is to provide a clear, demonstrable baseline of the differences. This serves as a critical starting point for developers and network engineers. Understanding these discrepancies is the first step toward mitigating the operational risks associated with XDP deployment. The project aims to foster greater confidence and predictability in XDP-based network functions.
Looking ahead, the development team intends to expand the corpus and enhance the classification of differences. A more sophisticated classification system could automatically categorize discrepancies by type (e.g., packet corruption, metadata loss, verdict alteration) and severity. Furthermore, exploring how these differences impact specific use cases like intrusion detection systems, load balancers, and DDoS mitigation tools will be crucial. The ultimate vision is to contribute to a more robust and reliable XDP ecosystem, where developers can deploy BPF programs with assurance, knowing their behavior is consistent across different XDP modes.
The open-sourcing of this harness is a significant contribution to the XDP community. It addresses a subtle yet critical issue that has, until now, been difficult to quantify and reproduce. By providing a concrete methodology and a working tool, the project lowers the barrier to entry for understanding and addressing XDP mode-specific behavior.
