Skip to main content

Lab 4: Intro to XDP Programming

In this lab, you'll write a basic XDP program and deploy it as a CNF on a node.

Goals

  • Compile an XDP program that drops packets.
  • Load it on a cluster node (or any Linux host on the network).
  • Measure the effect on traffic throughput.

Steps

  1. Write XDP program: Use the skeleton from the reference to create xdp_drop.c that drops all traffic.
  2. Compile: clang -O2 -target bpf -c xdp_drop.c -o xdp_drop.o.
  3. Load program: On a Talos worker or any Linux box with our fabric connectivity, run:
    bpftool prog load xdp_drop.o /sys/fs/bpf/xdp_drop type xdp dev <iface>
    replacing <iface> with the interface (e.g., eth0 on a worker).
  4. Test throughput: Run an iperf3 from another host through this node to a service (or even just ping flood it). Observe CPU usage (top) on the node.

Verification

  • bpftool prog show should list the XDP program attached.
  • Packets counter: use bpftool perf or add a map counter to count drops, and see that it increments.
  • Throughput comparison: Remove the XDP program (bpftool prog detach dev <iface> xdp) and rerun iperf – you should see lower CPU usage but of course traffic passes normally. With XDP drop, the throughput as seen by iperf will be zero (all dropped) but the node should handle it without high CPU, demonstrating efficiency.

Detailed step-by-step and example outputs will be added soon.