← All articles

A firewall in FPGA logic

How a classifier in front of a soft processor drops flood traffic before it costs a DMA descriptor or a CPU cycle.

IronKernel · · Networking

A soft processor running a TCP/IP stack is easy to overload. Every frame it receives costs an interrupt, a DMA descriptor and time in the stack, and a broadcast storm on the network will spend all three. RTLNet puts a classifier in logic between the Ethernet MAC and the processor, so the decision to drop a frame is made before the processor sees it.

Two paths through the stack

RTLNet answers ARP, ping and DHCP in logic and serves bound UDP sockets in logic. That traffic never reaches the processor. Everything else is a candidate for the CPU, where lwIP on a MicroBlaze V provides TCP. The classifier sits on that second path only, in front of the CPU receive queue.

The placement matters for the numbers. The hardware UDP path ran 942 Mb/s into the board with the firewall on, because the firewall is not in that path.

What the classifier matches

EngineMatches
Field tablesMAC address, EtherType, VLAN, IPv4 address and port
IPv4 tuple listIP protocol, masked source and destination addresses, and source and destination port ranges in one entry
Positional rulesMasked byte comparisons within the first 64 bytes of the frame

The core comes out of reset dropping everything. Firmware then selects a mode: drop all, pass all, pass on match or drop on match. The Ethernet firmware's default-deny policy admits ARP and the IPv4 tuples on the allow list. A TCP service needs two things before it is reachable, a listener in lwIP and an allow entry in the classifier. The Nexys Video design has 16 tuple slots and the Arty A7-100T has eight.

Policers for the traffic that is allowed

An allow list does not stop a flood of permitted traffic, such as ARP requests. Four fixed-window policers bound how many frames of each class reach the CPU in an interval. The protection profile allows 10 broadcast, 10 UDP, 20 ARP and 10 ICMP frames per 100 ms window. The counters separate a policy drop from an exhausted budget and from an internal overrun, so a missing packet can be traced to its cause.

Measured

TestResult
Flood, Nexys VideoAt 100,000 offered flood frames/s, the classifier dropped all 1,000,000 flood frames
Firewall checks21 of 21 passed on both boards: allowed services reach their listener, and disallowed traffic is discarded before the CPU
TCP with the firewall on, 1 Gb/s337.7 Mb/s into the board and 280.3 Mb/s out, against 336.0 and 281.0 with it off
TCP echo latency, firewall on0.198 ms round trip for 64 bytes (p99 0.234 ms), through the switch and host

The firewall costs no measurable throughput on the traffic it admits.

What it does not protect

The classifier protects the processor, not the wire. Flood traffic still occupies the physical link, so a saturated link can raise latency for everything on it even while the CPU stays responsive. The measurements apply to the CPU path of the released Ethernet images.

The same classifier at 10 Gb/s

The classifier's datapath is a 64-bit AXI4-Stream that accepts one beat per clock. At 156.25 MHz that is the rate of a 10 Gb/s link. A minimum frame takes eight beats, so the classifier can service 19.53 million minimum frames per second against the 14.88 million a 10 Gb/s link can carry. It closed timing at 156.25 MHz on an XC7A200T-1 with +1.515 ns of setup slack. The released MACs are 1 Gb/s and 100 Mb/s, so a 10 Gb/s design supplies its own MAC and PCS.

Further reading

Putting an FPGA on a network you do not control?

Send the FPGA part, the link speed and the services the board has to offer.