BPF comes to firewalls
lwn.net
lwn.net
* https://blog.cloudflare.com/bpf-the-forgotten-bytecode/
* https://blog.cloudflare.com/introducing-the-bpf-tools/
* https://blog.cloudflare.com/introducing-the-p0f-bpf-compiler...
We even have a piece of software called "floodgate" which is pretty much a custom runtime for iptables compiled down to BPF. It's using proprietary driver magic to offload the firewall rules engaged during large L3 attacks, and runs them with high performance in userspace. More:
* https://blog.cloudflare.com/meet-gatebot-a-bot-that-allows-u...
More BPF integration in iptables is a very good idea. The interesting bit is how to deal with more complex things like haslimits, limits, ipsets and conntrack integration.
Also, the traditional use of BPF wasn't to filter network traffic, but only to sieve data flowing to userland tools like tcpdump.
The author's argument against using bpf is that it's hard to reproduce the human readable rules from bpf byte code. Wonder how bpfilter is going to should this problem.
Without hacking up everything, like it is done in consumer routers these days.
Will BPF handle that better than nftables?
Tools in iproute2 package are being updated too, so typically you would attach and offload programs to hardware with `tc`- or `ip`-based command lines.
[1] https://www.networkworld.com/article/3016992/security/junipe...
[2] https://www.theregister.co.uk/2015/09/15/compromised_cisco_r...
[3] https://en.wikipedia.org/wiki/Intel_Management_Engine#Securi...
That's an interesting warning. Pushing more tasks out of the kernel would seem like a good idea to me. I thought Torvalds' argument against a microkernel design was more about performance than complexity. Is that incorrect?
If you have questions on BPF and Cilium for advanced firewalling, you can also ask them on the cilium slack: http://www.cilium.io/slack
That said, while BPF syntax is great for simple cases, the boolean logic gets pretty messy in a hurry if you want to do something weird.
Simple case comparision:
iptables: iptables -t filter -A FORWARD -p tcp --dport 80 -j ACCEPT
theoretical bpf: allow forward tcp dst port 80
Note that the capitalization in the first command is not arbitrary, it must be there for the command to work, exactly as shown. Also, I didn't switch to the double dash option on dport frivolously, there is no single dash option for this incredibly common feature. Plus the manpages are split into a bunch of different parts and the SEE ALSO section at the bottom is woefully incomplete, making it difficult to track down exactly the page you need.That said, incorporating all of the features from iptables into a BPF syntax is going to require a considerable expansion over what you get with tcpdump. Things like marked packets, NAT, state tracking, etc... all need to be grafted onto the language somehow. And of course everything needs to be well documented because a lot of sysadmins are going to need to learn this in a hurry and bad documentation will make them hate it and insist on keeping iptables instead, warts and all.
Why? Because it has a well defined structure for me.
For example '-j ACCEPT' signals my brain that I jump to a decision. I can also add after or before that a '-m comment', it will not change the jump decision I made already.
For the proposed bfp syntax it will take me 5 years to remember that the correct syntax is 'allow forward tcp' but not 'tcp forward allow' or any other combination.
(This is also part of the reason I didn't jump to nftables yet)
I've administered only a few production systems, and the firewalls I configured were always very simple. Reject all traffic incoming except for port 22/23, 80/443 and outgoing except for to certain package management systems, that sort of thing.
I admit I've done some slightly more complex things to rewrite things to implement some virtual network thing, but I don't think I did that in production.
https://www.theregister.co.uk/2017/10/18/linux_kernel_commun...
Goshdarnit. I've been trying to get ahead of the curve and have been learning and implimenting nftables, and now you're telling me I might need to learn something else! Such is the life of a sysadmin I suppose.
"The use of BPF enables the writing of firewall rules in C"
Have you seen the rulesets people write in other firewall languages? This seems scary to me.
"One of the core design features for bpfilter is the ability to translate existing iptables rules into BPF programs."
nftables also does this, but I suggest not using it and writing fresh
"even though it would be likely to supplant nftables relatively quickly. Instead, Miller said in the discussion that nftables failed to address the performance problems in Linux's packet-filtering implementation, driving users toward user-space networking technologies instead. There is a real possibility that nftables could end up being one of those experiments that is able to shed some light on the problem space but never takes over in the real world."
Ok, well I have some questions here. First, show me the benchmarks. Also, nftables is still much faster than iptables in my benchmarks, so it has largely delivered. Of course it's difficult to compete with an asic offload, but I do see how there could be lots of potential with bpf if it offloads to the interface. That said, the real potential I see is for nftables and bpf to coexist in the future as a replacement for iptables or for iptables and bpf. nftables solves a lot of real problems and working with it has been really enjoyable for me compared to years of iptables rules (I always refused to use the layer-on-top-of-iptables abstractions, so I'm talking about pure iptables.) A quick glance at bpf seems like it would be worth it for extremely high requirement cases where the investment would be worth it (just noticed the cloudflare comment for example), but for the rest of us mortals in IT deps with limited budgets, time, and knowledge workers, it seems a bit too heavy to just start implimenting.
I could be wrong, but I really hope nft succeeds despite this.
How is one supposed to pick ? Then, there's also nftables. I've only glanced at it, and it looks promising but it seems there are some things that are missing. A comment in the article says that TCP MSS clamping has been added only recently. By the looks of it, it appears to be "almost there" but not quite ... which is a shame.
I'm hoping whatever implementation ends up prevailing will solve the various technical problems (performance, features w.r.t filtering capabilities) but will also provide a sane way to manage it. I feel kind of sad with the current situation. With my developer hat on, I am continuously impressed with the networking features available on Linux (Netfilter, XDP, ...). With my operator hat on, I find the general lack of usable tools as well as the inconsistency maddening.
>A new Linux kernel technology called BPF is at the foundation of Cilium. It supports dynamic insertion of BPF bytecode into the Linux kernel at various integration points such as: network IO, application sockets, and tracepoints to implement security, networking and visibility logic. BPF is highly efficient and flexible.
https://blog.cloudflare.com/bpf-the-forgotten-bytecode/
I wonder if the projects are related.
Apples, Oranges, etc.
If you had stated: "You are comparing apples to oranges here because Dragonfly only exists on BSD, not on Linux, and as such may not be a viable choice for most users." I think you would have received no or substantially fewer downvotes. If you then had in addition to that provided a quick explanation (or more) of what "Dragonfly" is, you would have gotten upvotes instead, because that would have taught a number of us something we did not know yet.
HN has always been like this, at least in the 7+ years I've been on here. Short, one-word or two-word comments are generally not appreciated. People on HN like substantive comments.