3

I'd like to know about bpfilter. I can't use netfilter (too slow), nftables (doesn't have my feature set).

Kernel says:

CONFIG_BPFILTER: │ │ This builds experimental bpfilter framework that is aiming to │ │ provide netfilter compatible functionality via BPF

Is there any:

  • tooling which allows to configure firewall rules using BPF instead of netfilter?
  • documentation allowing to jump easily into the subject?
  • manual?....

So far I only traced one LWN post explaining how cool bpffilter is, but for admin purposes its useless.

https://lwn.net/Articles/747551/

Is it too new and too sketchy to even care about?

Tedinoz
  • 5,911
  • 3
  • 25
  • 35
Stefan Brudny
  • 31
  • 1
  • 2

2 Answers2

7

As of early 2019, bpfilter is still under development and not usable yet. The basic skeleton is here and may even be activated in 4.18+ kernels, but does not do much for now as it is not complete. The code required for translating iptables rules to BPF bytecode, although submitted along the original RFC, has not made it to the kernel at this time.

Once it gets ready, there should not be any specific tooling required. Bpfilter will likely be enabled with something such as modprobe bpfilter, and then the whole idea is to transparently replace the back end, while leaving the front end untouched: so iptables should be the only tool required for handling the rules, without any particular option required. Additionally, the bpftool allows to inspect the eBPF programs (including iptables rules translated by bpfilter) loaded in the kernel.

You can check this if you want in the following video (disclaimer: by my company), which shows how we used bpfilter with a classic iptables rule (we had patched the kernel with the code from the RFC; and executing the bpfilter.ko in the console will not be necessary on the final version).

You can still attach BPF programs to the XDP hook (at the driver level), even without using bpfilter, to get much better performance than what netfilter offers. However, you would have to completely rewrite your rules as C programs, compile them into eBPF with clang, and load them with e.g. the ip tool (from iproute2). I don't know if this would match your “feature set”. Depending on how strong is your need, another drastic option could be to move your packet processing to user space and to reimplement your setup with the DPDK framework.

Qeole
  • 8,284
  • 1
  • 24
  • 52
0

It looks like there is a tool that does this named bpf-iptables. Better still, it appears to use the normal iptables syntax. I have not yet used it myself, but I think I will try it the next time I have to set up iptables.

MrDrMcCoy
  • 351
  • 4
  • 18