LWN: Comments on "BPF comes to firewalls" https://lwn.net/Articles/747551/ This is a special feed containing comments posted to the individual LWN article titled "BPF comes to firewalls". en-us Fri, 19 Sep 2025 21:02:37 +0000 Fri, 19 Sep 2025 21:02:37 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net BPF comes to firewalls https://lwn.net/Articles/794718/ https://lwn.net/Articles/794718/ valentine <div class="FormattedComment"> Hi all,<br> I've some small questions about the post.<br> - What is the relationship between BPF and eBPF?<br> - I still haven't understood how to work BP: are attached at the express data path (XDP) layer, so they are run from the network-interface drivers or not? If yes the NIC drivers must be rewritten?<br> </div> Fri, 26 Jul 2019 20:13:44 +0000 BPF comes to firewalls https://lwn.net/Articles/762507/ https://lwn.net/Articles/762507/ antiphase <div class="FormattedComment"> Use ipset to create address lists instead of using individual per-address rules. It doesn't change the reload behaviour, but it will potentially hugely reduce the number of rules if you're matching in similar ways just with different addresses, and is also faster shifting packets as a bonus.<br> </div> Mon, 13 Aug 2018 16:37:01 +0000 BPF comes to firewalls https://lwn.net/Articles/762446/ https://lwn.net/Articles/762446/ fest3er <div class="FormattedComment"> How many rules are you talking about? In some testing 4-6 years ago, I found that iptables could not handle more than about 20 000 rules at a time. Any more and some rules would be 'lost'. IPtables was happy to add 1 000 000 rules as long as I added them around 15 000 at a time (meaning a COMMIT every 15 000 or so). Adding so many rules wasn't real speedy, but it also wasn't outrageously slow.<br> </div> Mon, 13 Aug 2018 04:07:12 +0000 BPF comes to firewalls https://lwn.net/Articles/752248/ https://lwn.net/Articles/752248/ manhnt <div class="FormattedComment"> Well, as kleptog mentioned, there are cases where iptables update can get lost some rules. I've met such cases. Does anyone know how to solve that properly? What I did was simply retrying until success, which may not be an optimum solution.<br> </div> Thu, 19 Apr 2018 02:26:07 +0000 BPF comes to firewalls https://lwn.net/Articles/748323/ https://lwn.net/Articles/748323/ jengelh <div class="FormattedComment"> <font class="QuotedText">&gt;For instance, nftables involves stringing together commands in a way that highly resembles a run-on sentence:</font><br> &gt;<br> <font class="QuotedText">&gt; nft add rule ip filter forward oifname ppp0 tcp flags syn tcp option maxseg size set 1452</font><br> &gt;<br> <font class="QuotedText">&gt;It's not immediately obvious how the syntax works and what words fit in where in the hierarchy.</font><br> <p> 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.<br> </div> Thu, 01 Mar 2018 11:31:38 +0000 BPF comes to firewalls https://lwn.net/Articles/747953/ https://lwn.net/Articles/747953/ kleptog <div class="FormattedComment"> Well that explains things... I heard someone mumbling about how iptables updates can get lost and I couldn't see how, until now.<br> <p> In any case, if we do firewall rules as BPF we end up with the same problem surely? The performance improvement would be that you can pass your firewall through an compiler/optimiser to make it more efficient, but as a side effect you end up with the same problem, namely, to update a single rule you need to replace the whole program. Only now you've added an optimise step in between.<br> <p> Unless you change your API to transactional one where you can send updates and get a confirmation asynchronously and the backend is smart enough to avoid actually updating the kernel for every change.<br> </div> Sat, 24 Feb 2018 20:07:10 +0000 BPF comes to firewalls https://lwn.net/Articles/747937/ https://lwn.net/Articles/747937/ ofranja <div class="FormattedComment"> <font class="QuotedText">&gt; Developers should be careful, though; this could prove to be a slippery slope leading toward something that starts to look like a microkernel architecture.</font><br> <p> Or, even further, an exokernel architecture.<br> <p> In the original MIT exokernel research (~1995), a packet filter language w/JIT compiler is mentioned as a way to filter and delegate network traffic to userspace with minimal [1] kernel support (although not necessarily using these terms, but the general idea is the same).<br> <p> [1] <a href="https://pdos.csail.mit.edu/archive/exo/exo-slides/sld011.htm">https://pdos.csail.mit.edu/archive/exo/exo-slides/sld011.htm</a><br> </div> Fri, 23 Feb 2018 23:01:57 +0000 BPF comes to firewalls https://lwn.net/Articles/747670/ https://lwn.net/Articles/747670/ pomac <div class="FormattedComment"> I find this really interesting, I've wondered and tried to push a change to bpf for a while but =)<br> <p> Anyway, for those that want to follow the threads in a easier manner:<br> <p> <a href="https://marc.info/?l=linux-netdev&amp;m=151905824829539&amp;w=2">https://marc.info/?l=linux-netdev&amp;m=151905824829539&amp;...</a> - [PATCH RFC PoC 0/3] nftables meets bpf<br> <a href="https://marc.info/?l=netfilter-devel&amp;m=151878844403666&amp;w=2">https://marc.info/?l=netfilter-devel&amp;m=15187884440366...</a> - [PATCH RFC 0/4] net: add bpfilter<br> </div> Wed, 21 Feb 2018 13:26:59 +0000 BPF comes to firewalls https://lwn.net/Articles/747651/ https://lwn.net/Articles/747651/ florianfainelli <div class="FormattedComment"> You would think it would, but this was actually a custom VM, Pablo just posted patches to do exactly that though:<br> <p> <a href="https://www.mail-archive.com/netdev@vger.kernel.org/msg217425.html">https://www.mail-archive.com/netdev@vger.kernel.org/msg21...</a><br> </div> Wed, 21 Feb 2018 00:20:34 +0000 BPF comes to firewalls https://lwn.net/Articles/747650/ https://lwn.net/Articles/747650/ florianfainelli <div class="FormattedComment"> Fortunately we now have extended netlink acks to give you a more meaningful error code...<br> </div> Wed, 21 Feb 2018 00:15:31 +0000 BPF comes to firewalls https://lwn.net/Articles/747631/ https://lwn.net/Articles/747631/ flussence <div class="FormattedComment"> 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…<br> </div> Tue, 20 Feb 2018 16:17:21 +0000 BPF comes to firewalls https://lwn.net/Articles/747632/ https://lwn.net/Articles/747632/ josh <div class="FormattedComment"> It was originally used for filtering of packets for tools like tcpdump, so that when you say "show me traffic on tcp port 80 to this IP" the kernel can very quickly select the data you want and feed it to you at wire speed.<br> </div> Tue, 20 Feb 2018 16:17:13 +0000 BPF comes to firewalls https://lwn.net/Articles/747621/ https://lwn.net/Articles/747621/ ringerc <div class="FormattedComment"> Yeah, it's a lot like someone looked at the "tc" and "ip" commands and thought "what a great UI, lets do that".<br> </div> Tue, 20 Feb 2018 15:25:11 +0000 BPF comes to firewalls https://lwn.net/Articles/747610/ https://lwn.net/Articles/747610/ kooky <div class="FormattedComment"> I thought nftables ruleset already used BPF?<br> <p> I've been using nftables and find it just works now I've got the hang. <br> <p> Tim<br> </div> Tue, 20 Feb 2018 13:40:29 +0000 BPF comes to firewalls https://lwn.net/Articles/747608/ https://lwn.net/Articles/747608/ iq-0 <div class="FormattedComment"> I'm in favor of a jit-able packet filter that might partially be offloaded to hardware.<br> <p> But the real challenges are often not the ruleset overhead, but are related to connection tracking, matching against advanced set datastructures and in the interaction with the rest of the network stack. I feel like here is a basic conflict between calling kernel functions to get better access to advanced algorithms and datastructures and the basic JIT and offloading story of bpfilter.<br> <p> And didn't BPF programs have a size constraint? Or is that something that can be worked around using BPF_MAP_TYPE_PROG_ARRAY?<br> </div> Tue, 20 Feb 2018 12:56:10 +0000 BPF comes to firewalls https://lwn.net/Articles/747607/ https://lwn.net/Articles/747607/ bernat <div class="FormattedComment"> It will download the whole ruleset from the kernel, modify it to add/remove the single rule and upload it again. When your ruleset becomes huge, adding/removing a single rule takes a significant time.<br> </div> Tue, 20 Feb 2018 12:19:19 +0000 BPF comes to firewalls https://lwn.net/Articles/747593/ https://lwn.net/Articles/747593/ vadim <p>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.</p> <p>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.</p> <p>IMO, the other problem with it is that the documentation is still not great, and the syntax leaves a lot to be desired.</p> <p>For instance, nftables involves stringing together commands in a way that highly resembles a run-on sentence:</p> <pre> nft add rule ip filter forward oifname ppp0 tcp flags syn tcp option maxseg size set 1452 </pre> <p>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:</p> <pre> 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 } } </pre> <p>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.</p> <p>I hope that besides the technical details, the makers of BPF also take care of producing a better syntax and good documentation.</p> Tue, 20 Feb 2018 07:51:53 +0000 BPF comes to firewalls https://lwn.net/Articles/747592/ https://lwn.net/Articles/747592/ dgm <div class="FormattedComment"> And the "B" stands for Berkely, where it originated. The Wikipedia article (<a href="https://en.wikipedia.org/wiki/Berkeley_Packet_Filter">https://en.wikipedia.org/wiki/Berkeley_Packet_Filter</a>) is a bit light on details, but you will find them in the original paper (<a href="http://www.tcpdump.org/papers/bpf-usenix93.pdf">http://www.tcpdump.org/papers/bpf-usenix93.pdf</a>).<br> </div> Tue, 20 Feb 2018 07:17:35 +0000 BPF comes to firewalls https://lwn.net/Articles/747591/ https://lwn.net/Articles/747591/ epa <div class="FormattedComment"> So what is the origin of BPF? I thought the PF stood for packet filter because it had originated as a way to compile firewall rules — but according to the article this is the first time it has been used there. <br> </div> Tue, 20 Feb 2018 07:01:02 +0000 BPF comes to firewalls https://lwn.net/Articles/747589/ https://lwn.net/Articles/747589/ kay <div class="FormattedComment"> iptables command can ... but not the API<br> </div> Tue, 20 Feb 2018 06:46:03 +0000 BPF comes to firewalls https://lwn.net/Articles/747586/ https://lwn.net/Articles/747586/ valberg <div class="FormattedComment"> Thanks, Jonathan, for another great article.<br> </div> Tue, 20 Feb 2018 06:42:27 +0000 BPF comes to firewalls https://lwn.net/Articles/747583/ https://lwn.net/Articles/747583/ eahay <div class="FormattedComment"> Iptables can delete or insert a single rule at a time...<br> </div> Tue, 20 Feb 2018 04:35:01 +0000