|
|
Log in / Subscribe / Register

BPF comes to firewalls

BPF comes to firewalls

Posted Feb 20, 2018 7:51 UTC (Tue) by vadim (subscriber, #35271)
Parent article: BPF comes to firewalls

nftables is a quite nice idea. I think the problem with it was that they were slow at implementing the last few features that were actually quite important.

For instance, nftables can do MSS clamping only since kernel 4.14. This was released this November. nftables has been around since 2014, like this article says. MSS clamping is a feature in wide use for DSL and fiber setups, and this is important precisely to the kinds of people that want to run their own firewall.

IMO, the other problem with it is that the documentation is still not great, and the syntax leaves a lot to be desired.

For instance, nftables involves stringing together commands in a way that highly resembles a run-on sentence:

    nft add rule ip filter forward oifname ppp0 tcp flags syn tcp option maxseg size set 1452

It's not immediately obvious how the syntax works and what words fit in where in the hierarchy. The way "ppp0" is not quoted or delimited in any way also makes it hard to tell apart commands from data, though this can be done as seen below. There's a C-ish form that looks a bit nicer, but then when you run into a command that starts with "nft add" it's not obvious how to put that into your config file, which looks like:

table ip filter {
	# allow packets from LAN to WAN, and WAN to LAN if LAN initiated the connection
	chain forward {
		iifname "lan0" oifname "wan0" accept
        }
}

Note how it is subtly different: we go from "ip filter" to "table ip filter", and from "forward" to "chain forward", and for someone not familiar with the syntax it's not really apparent that "oifname" in the first example is the point where you'd want to start copy/pasting.

I hope that besides the technical details, the makers of BPF also take care of producing a better syntax and good documentation.


to post comments

BPF comes to firewalls

Posted Feb 20, 2018 15:25 UTC (Tue) by ringerc (subscriber, #3071) [Link] (2 responses)

Yeah, it's a lot like someone looked at the "tc" and "ip" commands and thought "what a great UI, lets do that".

BPF comes to firewalls

Posted Feb 20, 2018 16:17 UTC (Tue) by flussence (guest, #85566) [Link] (1 responses)

I've got a working (AFAIK) nftables setup. The end result looks pretty after months of tweaking, but I completely agree on how unnecessarily painful it was to get there. Spitting nothing but strerror(-ENOENT) at the user whenever any module is missing from the kernel is a nasty thing to do…

BPF comes to firewalls

Posted Feb 21, 2018 0:15 UTC (Wed) by florianfainelli (subscriber, #61952) [Link]

Fortunately we now have extended netlink acks to give you a more meaningful error code...

BPF comes to firewalls

Posted Mar 1, 2018 11:31 UTC (Thu) by jengelh (subscriber, #33263) [Link]

>For instance, nftables involves stringing together commands in a way that highly resembles a run-on sentence:
>
> nft add rule ip filter forward oifname ppp0 tcp flags syn tcp option maxseg size set 1452
>
>It's not immediately obvious how the syntax works and what words fit in where in the hierarchy.

This is where the iptables UI excels - the tokens for "options" and tokens for "values" never ever overlap, I am tempted to say *context-free*. The nft "tcp" instead could either mean "-p tcp" or "--tcp-flags ..." depending on where it's located, and what makes the bpf/ip/tc/nft syntax so terrible.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds