================================================================
ALOSWALL: Stopping Floods in ~150 Nanoseconds
A deep look at the engineering behind ALOSWALL's in-kernel DDoS
mitigation why it's fast, why it stays fast under attack, and
why we threw out the "standard" way of doing things.
Deciding before the stack even wakes up
Most firewalls make their decisions late. By the time a typical
filtering layer sees a packet, the operating system has already
spent real cycles receiving it, allocating structures for it, and
walking it partway up the network stack. Under normal traffic
that overhead is invisible. Under a denial-of-service flood
tens of millions of packets a second, all designed to waste
exactly those cycles it is the whole ball game.
ALOSWALL takes a different position: it runs directly in the
kernel's earliest packet path (XDP), inspecting and ruling on
every single packet BEFORE the network stack ever touches it. A
hostile packet is identified and dropped at the very edge, having
cost the machine almost nothing. A legitimate packet is waved
through with microscopic overhead. Nothing gets a free ride, and
nothing gets processed twice.
The result is a firewall that decides on a packet in around 150
nanoseconds. To put that in human terms: in the time it takes to
blink, ALOSWALL has made tens of millions of individual
allow-or-drop decisions.
The numbers, and how they scale
That ~150ns-per-packet budget translates to roughly 6 to 7
million packets per second, per thread. And because the design is
built around the kernel's own per-queue, per-thread parallelism,
that figure scales out: give ALOSWALL more threads and more
receive queues, and aggregate capacity grows with the hardware
underneath it.
And it is worth being clear about the hardware that number was
measured on, because it cuts in our favor. We recorded that ~150
nanoseconds on modest, older silicon: a 3.8 GHz Intel Xeon
E3-1270 v6, a 2017-era server chip that is a long way from
anything considered fast today. Put the exact same design on a
modern high-clock processor, a Ryzen 9 or an EPYC, and we would
fully expect the same per-packet work to land around 100
nanoseconds or less. So 150 nanoseconds is our figure on slow-ish
hardware, not a ceiling. The work is fixed; faster silicon simply
gets through it quicker.
This matters because modern volumetric attacks are measured in
packet rate, not just bandwidth. A flood of tiny packets is
designed to overwhelm a target's ability to make decisions, not
to saturate its pipe. A firewall that is fast on bytes but slow
on packets loses that fight. ALOSWALL is built to win it its
budget is spent per packet, exactly where the pressure lands.
Fully stateful, not just a packet sieve
Raw speed is only half the story. A fast firewall that can't tell
a real connection from a spoofed one just drops fast and wrongly.
ALOSWALL is FULLY STATEFUL. It tracks the state of every
connection flowing through it, so it understands the difference
between an established, well-behaved session and a half-open,
spoofed, or abusive one. That context is what turns raw speed
into good judgment it lets ALOSWALL protect the traffic that
should be protected while cutting off the traffic that shouldn't,
instead of applying the same blunt rule to everyone.
Statefulness at this speed is genuinely hard. Every packet has to
find, read, and update per-connection state in nanoseconds, while
millions of other packets are doing the same thing on the same
machine at the same instant. That requirement is what drove one
of the biggest engineering decisions in the whole system more
on that below.
SYN cookies, in the fast path
One of the oldest and most effective volumetric attacks is the
SYN flood: a torrent of connection requests, usually from spoofed
addresses, designed to exhaust a server's connection table before
a single real user gets through.
ALOSWALL answers this with a SYN cookie engine that runs entirely
in the kernel fast path. When a SYN flood arrives, ALOSWALL
handles the handshake itself and cryptographically validates the
response before anything is ever committed. Spoofed sources
which can't complete the handshake are silently discarded at
the edge. Real clients pass through cleanly. The machine behind
ALOSWALL never sees the flood, never allocates state for it, and
never wakes up for it. The attacker burns their resources; you
don't burn yours.
Change the rules live no restart, no downtime
In-kernel firewalls have historically carried an awkward
trade-off. Updating the rules often means tearing the program
down and reloading it which opens a gap in protection at the
exact moment you're trying to respond to an attack.
ALOSWALL removes that trade-off entirely. It supports real-time,
dynamic rule changes with zero downtime. Operators can add,
remove, and tune rules and limits on the fly, and the running
program picks them up instantly WITHOUT ever restarting or
re-attaching the in-kernel program. Protection never blinks, even
while you're actively re-tuning it in the middle of a live event.
In practice this means an operator can watch an attack evolve and
adapt to it in seconds, tightening a limit here or adding a rule
there, with full confidence that the shield stays up the entire
time. The firewall you're adjusting is the same firewall that's
defending you, and it never has to be taken offline to change its
mind.
The part we're proudest of: we dropped LRU maps
Here's where ALOSWALL goes off the beaten path.
The conventional way to hold per-connection state inside the
kernel is an LRU map a general-purpose, off-the-shelf building
block. It's the default choice, and for good reason: it's simple
and it's already there. But "default" and "best under attack" are
not the same thing.
When we put LRU maps under the kind of load a real DDoS event
produces many CPU cores hammering state concurrently, an
enormous rate of writes, and a single hot target getting pounded
millions of times a second they buckled. The standard tool got
SLOWER exactly as the attack got HEAVIER. That's the worst
possible failure mode for a firewall: weakest when you need it
most.
So we built our own. ALOSWALL uses a fully custom BPF map,
designed from scratch for the brutal, concurrent, write-heavy
access pattern of a live attack. In head-to-head benchmarking
across 8 cores running concurrently, the difference is stark:
Updates are effectively free. Writing state back takes
single-digit nanoseconds on our custom map, versus anywhere
from roughly 10 to 80 nanoseconds for standard LRU maps. Under
a flood that updates connection state millions of times a
second, this alone is the difference between keeping up and
falling behind.New-flow inserts run roughly 3x faster about 210
nanoseconds versus around 610 to 630 for LRU based on a spoof flood where every packet creates a new map entry. This is
critical: an attack's signature move is spinning up an
enormous number of brand-new flows all at once, and that's
precisely the operation LRU is slowest at.On a single hot target the classic DDoS scenario, where one
victim IP soaks up the entire flood a combined read-and-
update runs about 2x faster than a shared LRU map: roughly 100
nanoseconds versus around 200.Sustained throughput against that same hot target roughly
doubles, from about 40 million operations per second on a
shared LRU map to around 80 million on ours.
The pattern is consistent and it's the whole point: the
conventional building block degrades under exactly the conditions
an attacker creates, while our purpose-built map holds its speed
under precisely that pressure. We didn't tune LRU. We replaced
it, because the ceiling wasn't high enough.
Why 150 nanoseconds is the honest number
Let's be blunt about the number. For a firewall that is genuinely
stateful, that actually tracks every connection and counts every
packet correctly, there is a real, unavoidable amount of work in
reading a packet, finding its connection state, and updating that
state accurately. You cannot cheat physics on it. Our 150
nanoseconds is what that honest work costs on the modest 2017-era
Xeon we measured on, and it is about as low as the job goes when
it is done correctly on a chip like that. On faster silicon the
number comes down, likely under 100 nanoseconds on a modern Ryzen
or EPYC, but the work itself is the constant; the clock only
decides how quickly you get through it. We have looked, and we have
not found another public project doing truly stateful mitigation at
this speed and doing it correctly.
You will, however, find projects that publish faster numbers.
Search around and you will see open-source XDP firewalls claiming
sub-100-nanosecond, "fully stateful" packet processing. When a
project claims that, one of two things is true: it is not actually
stateful, or its state is quietly wrong. After reading the code
behind several of these claims, it is almost always the second.
Those numbers are not real stateful numbers. They are what you get
by skipping the exact work that makes stateful counting correct,
and then reporting the speed as if nothing was skipped. And here is
the irony: run our correct design on the same modern hardware those
projects benchmark on, and it would itself sit comfortably under
100 nanoseconds. The difference is that ours would be sub-100
nanoseconds done right, while theirs is sub-100 nanoseconds done
wrong.
The counting problem almost no one gets right
Here is the corner that gets cut, and it is more serious than it
sounds.
The naive way to keep counters in XDP is to put them in a single
shared map and bump them with a plain ++. It looks correct and it
benchmarks beautifully on a quiet machine. But a plain ++ is a
read-modify-write: the core reads the value, adds one, and writes
it back. When many cores do that to the same counter at the same
instant, which is exactly what happens under a flood, they all
read the same starting value, all add one, and all write back on
top of each other. Most of those increments collide and simply
vanish. Under real concurrent load we have watched well over half
of them disappear, in the range of 60 to 70 percent lost, and it
gets worse as core count climbs.
Think about what that means for a rate limiter. If your counter is
losing the majority of its increments, your limits are fiction.
Set a per-IP limit of 1,000 packets per second on a firewall built
this way, and an attacker can push past 6,000 before the counter
has "seen" enough of them to ever trip the limit. The rate limit
is silently off by many times over. In our review of popular
public XDP projects, the overwhelming majority, easily nine in
ten, count this way, which means they are not actually enforcing
the limits they advertise.
The textbook fix is atomics, and if you insist on shared counters
you have no choice but to use them. But atomics carry their own
tax. Every atomic add has to take exclusive ownership of the cache
line the counter lives on, and under load the cores end up
fighting over that one line, bouncing it back and forth between
them. Worse, unless every single counter is placed alone on its
own 64-byte cache line, one atomic add effectively locks the whole
line and stalls updates to every other counter that happens to
share it, so you pay to update values you never touched. At load,
we have seen atomics add 50 to 100 nanoseconds to every single
update. That is where the "fast" shared-map designs quietly go
when the traffic gets real.
We took the other road, and we paid for it in memory to do it. In
ALOSWALL, every CPU gets its own private copy of the counters, so
no two cores ever touch the same memory. There is nothing to race
over and nothing to lock. We increment with a plain ++, and
because it is private per core it is both perfectly correct and
instant: no atomics, no cache-line fighting, no lost updates. The
price is RAM, since every core keeps its own copy, and we decided
that trade was well worth making. It is a big part of why our
counter updates are effectively free while shared-map designs are
either paying the atomic tax or, more often, shipping counters
that are simply wrong.
The one requirement we don't hide: the right network card
Going the per-CPU route has one condition attached, and we would
rather be upfront about it than paper over it. Private per-core
counters are only correct for rate limiting if every packet from a
given source IP is handled by the same CPU core, so that one core's
copy sees that address's entire flow. If an attacker's packets get
spread across eight cores, each core only ever sees an eighth of
the real rate, and a per-core limit would let that source send
roughly eight times what you allowed before anything tripped.
By default, network cards work against you here. They steer
incoming packets across cores using a hash of the full connection
tuple, the source and destination IP together with the source and
destination ports. That is ideal for load-balancing an ordinary
server, but it deliberately scatters a single IP's traffic across
every core, which is exactly the wrong behavior for counting a
source correctly.
The fix has to happen in the network card itself. The card has to
be told to steer purely by source IP, ignoring the ports, so that
every packet from one address always lands on the same core and the
same counter, every time. This is a specific hardware and driver
capability, and here is the uncomfortable part: very few cards
actually expose it. In our testing, support is limited to a short
list of higher-end adapters. Intel's E810 family (the ice driver)
and NVIDIA/Mellanox ConnectX cards are the two that handle it
cleanly, with one further Intel family, the 700-series, rounding
out the list. Most consumer cards and plenty of older server NICs
simply reject the setting outright.
So this is a deliberate line in the sand for us. We require a
capable network card, because a capable card is what lets us pin
each source to one core, and pinning each source to one core is
what lets us use per-CPU counters, and per-CPU counters are what
let us count with a plain ++ that is both instant and exactly
right. Cheaper designs skip the hardware requirement, fall back to
shared counters, and quietly inherit every single problem above. We
would rather ask for the right hardware and be correct than run on
anything and be wrong.
Built for the moment the traffic turns hostile
Put it all together and ALOSWALL is a stateful, kernel-native DDoS
firewall that:
decides on every packet in around 150 nanoseconds, before the
OS network stack is ever involved;sustains roughly 6 to 7 million packets per second per thread
on the modest 2017-era hardware we tested on, and scales out
across threads with the hardware;would climb to roughly 9 to 10 million packets per second per
thread on modern silicon, a Ryzen or EPYC at around 100
nanoseconds per packet;tracks every connection's state, so its decisions are informed
rather than blunt;absorbs SYN floods directly in the fast path with in-kernel
SYN cookies, shielding everything behind it;lets operators change rules in real time with zero downtime
and no program restart; andruns on a fully custom, purpose-built data structure that
stays fast under the concurrent, write-heavy load that breaks
everything else.
A lot of security software is fast on a quiet network and slow on
a hostile one. ALOSWALL was engineered for the opposite priority:
to be fast exactly where it counts, stateful exactly where it
matters, and hardest to knock over at the precise moment the
traffic turns hostile.
Fast where it counts. Stateful where it matters. And built, from
the data structures up, for the worst day your network will ever
have.