Xtables2 vs. nftables
Posted Jan 14, 2013 21:26 UTC (Mon) by
intgr (subscriber, #39733)
In reply to:
Xtables2 vs. nftables by malor
Parent article:
Xtables2 vs. nftables
Disclaimer: I'm not a kernel developer, this is simply my understanding of things based on experience with iptables.
> what would the specific advantages be?
Because that's the natural way people want to write firewall rules.
Right now each firewall rule has to stand on its own and you get no control over which order certain terms are evaluated. For example, if you want to whitelist SSH connections from 3 different IP addresses, you basically have to write the firewall like:
if (net_layer == IP && ip_address == 1.2.3.4 && transport_layer == TCP && tcp_port == 22) { ACCEPT; }
if (net_layer == IP && ip_address == 2.2.2.2 && transport_layer == TCP && tcp_port == 22) { ACCEPT; }
if (net_layer == IP && ip_address == 3.3.3.3 && transport_layer == TCP && tcp_port == 22) { ACCEPT; }
if (net_layer == IP && transport_layer == TCP && tcp_port == 22) { DROP; }
Not only is this annoying to write and manage, but it's also very inefficient. Clearly any sane person would instead write:
if(net_layer == IP && transport_layer == TCP && tcp_port == 22) {
if (ip_address == 1.2.3.4 || ip_address == 2.2.2.2 || ip_address == 3.3.3.3) { ACCEPT; }
DROP;
}
And while you can use separate rule chains to abstract out these patterns, that's like going back in time many decades of computer programming and using "goto" statements for all your control logic.
For this particular use case, you could also use the iptables "ipset" module (which can match a set of IP addresses in one rule), but that's more of a workaround for the shortcomings of iptables: It requires a separate user space utility then to manage these custom named IP address sets via a separate kernel API. There are tons and tons of these special case modules.
There's also the problem that currently, every different kind of rule requires support in user space (to parse the command line and serialize it for the kernel) AND in the kernel (to deserialize the data and do the matching specific to this rule). Basically 95% boilerplate and 5% substance -- waste of developer resources, memory, CPU cache, etc.
It would be a lot more flexible to provide an abstract virtual machine in the kernel and let the user space generate whatever code it needs to support the protocol it wants. That's how bpf already works in the kernel, for packet capture and seccomp system call filters.
> iptables, even with its internal warts, is one of the best features in Linux, both powerful and extremely fast.
As a programmer, I would say extremely contrived and inefficient. I'm genuinely surprised it has survived for this long.
(
Log in to post comments)