BlogsCloudflareXDP Packet Capture

XDP Packet Capture

XDP Packet Capture

1
posts
2019

Cloudflare is developing tools to enhance debugging and visibility for its eXpress Data Path (XDP) implementations. This includes the creation of xdpcap, a replacement for tcpdump that operates within the XDP environment, and the open-sourcing of cbpfc, a compiler for converting classic BPF (cBPF) filters to eBPF. These tools enable developers to capture and analyze packets that would otherwise be invisible to traditional debugging methods, facilitating the development and troubleshooting of XDP-based network processing.

2019

xdpcap: XDP Packet Capture

4/24/2019

This post introduces xdpcap, a new tool for capturing packets processed by XDP programs, and open-sources the cbpfc compiler. xdpcap allows users to apply tcpdump-like filters to XDP-processed packets, writing them to pcap files or stdout. It achieves this by converting cBPF filters to eBPF using cbpfc and instrumenting XDP programs with tail-call hooks. Matching packets are exposed to userspace via perf events. The post details the architecture of xdpcap, including its filter conversion pipeline, instrumentation strategy using tail-calls and eBPF maps, and packet exposure mechanism via perf event ring buffers.