Skip to content
kryptonservers

What XDP is, and why it is the fastest place to drop an attack

XDP runs a small, verified program inside the network driver, before the Linux kernel allocates anything. How it works, what it can and cannot do, and what it costs.

Updated 20 November 2026

XDP (eXpress Data Path) is a hook in the Linux network driver where a small program can look at each packet the moment it arrives and decide what happens to it. Because it runs before the kernel builds its usual structures around a packet, dropping a packet there costs almost nothing. That makes it the natural first layer of DDoS protection.

Where XDP sits

When a packet arrives, the network card writes it into memory and the driver hands it up the stack: the kernel allocates a socket buffer, the IP layer checks it, firewall rules run, TCP or UDP looks for a socket, and finally an application reads it. Every step costs CPU time.

An XDP program runs at the very start, inside the driver, on the raw packet. It returns one of a few verdicts:

  • XDP_DROP: discard the packet immediately;
  • XDP_PASS: let it continue up the normal stack;
  • XDP_TX: send a reply straight back out of the same card;
  • XDP_REDIRECT: send it to another interface or CPU.

Dropping in XDP skips everything after the driver. That is why a server can discard millions of packets a second on a fraction of one core.

How a program gets there safely

XDP programs are written in a restricted form of C and compiled to eBPF bytecode. Before the kernel loads one, its verifier proves the program is safe: it cannot loop forever, read memory it should not, or crash the kernel. Programs share state with user space through maps (hash tables, arrays, LRU caches), which is how a ban list or a rate counter is updated while traffic flows.

What XDP is good at

  • Dropping by header: malformed packets, bad fragments, closed ports, banned addresses, protocols you do not serve.
  • Rate limiting per source: counting packets per address in per-CPU maps and dropping the excess.
  • Answering simple handshakes: replying to a TCP SYN with a cookie (XDP_TX) without involving the kernel’s TCP stack, so SYN floods never reach it.
  • Steering: spreading load or redirecting traffic between interfaces.

What XDP is not for

XDP sees one packet at a time, without the reassembled stream. It cannot read an HTTP request split across packets, decrypt TLS, or judge whether a login attempt is suspicious. That is the job of a later layer, such as a proxy with an L7 guard, which can then push its verdict down into XDP so the next packet from that address is dropped early.

Native, generic and offloaded

  • Native XDP runs in the driver of supported cards (Intel ixgbe, i40e, ice; Mellanox mlx5; virtio and many others). This is the fast path.
  • Generic XDP runs a little later in the stack on any interface. It is slower but works everywhere, useful for testing.
  • Offloaded XDP runs on the network card itself, on a few SmartNICs.

What it costs, measured

On our lab servers, our XDP program cost about 367 nanoseconds per packet on established traffic, and a node was cheaper to run with it than with the kernel’s own SYN cookies. It dropped a UDP flood of 11.3 million packets a second at the driver, and answered a SYN flood of two million packets a second while a real client connected without a single failure. The method and raw results are on the technology page.

The limit nobody can program away

XDP makes a server very good at discarding what reaches it. It cannot make the network link bigger. A flood larger than the port in front of the server is stopped upstream or not at all, so any honest protection offer tells you its capacity, and what happens above it.

Questions about your own setup?

Message @kryptonservers