Thread (24 messages) 24 messages, 4 authors, 2021-08-31

Re: [PATCH bpf-next v2 12/13] bpfilter: Add filter table

From: Alexei Starovoitov <hidden>
Date: 2021-08-30 19:45:52
Also in: netdev

On Sun, Aug 29, 2021 at 10:36:07PM +0400, Dmitrii Banshchikov wrote:
 /*
- * # Generated by iptables-save v1.8.2 on Sat May  8 05:22:41 2021
+ *  Generated by iptables-save v1.8.2 on Sat May  8 05:22:41 2021
  * *filter
...
- * -A LOCAL -s 10.32.0.0/11 -j FROMDC
- * -A LOCAL -s 10.144.0.0/12 -j FROMDC
- * -A LOCAL -s 10.160.0.0/12 -j FROMDC
- * -A LOCAL -s 10.0.0.0/12 -j FROMDC
- * -A LOCAL -s 10.248.0.0/24 -j FROMDC
- * -A LOCAL -s 10.232.0.0/16 -j FROMDC
- * -A LOCAL -s 10.1.146.131/32 -p udp -m udp --dport 161 -j ACCEPT
- * -A LOCAL -s 10.149.118.14/32 -p udp -m udp --dport 161 -j ACCEPT
- * -A LOCAL -p icmp -j ACCEPT
+ * :INPUT ACCEPT [0:0]
+ * :FORWARD ACCEPT [0:0]
+ * :OUTPUT ACCEPT [0:0]
+ * -A INPUT -s 1.1.1.1/32 -d 2.2.2.2/32 -j DROP
+ * -A INPUT -s 2.2.0.0/16 -d 3.0.0.0/8 -j DROP
+ * -A INPUT -p udp -m udp --sport 100 --dport 500 -j DROP
  * COMMIT
  */
Patch 10 adds this test, but then patch 12 removes most of it?
Keep both?

Also hit this on my system with older glibc:

../net/bpfilter/codegen.c: In function ‘codegen_push_subprog’:
../net/bpfilter/codegen.c:67:4: warning: implicit declaration of function ‘reallocarray’ [-Wimplicit-function-declaration]
   67 |    reallocarray(codegen->subprogs, subprogs_max, sizeof(codegen->subprogs[0]));
      |    ^~~~~~~~~~~~
../net/bpfilter/codegen.c:66:12: warning: assignment to ‘struct codegen_subprog_desc **’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
   66 |   subprogs =
      |            ^

In libbpf we have libbpf_reallocarray() for this reason.

Could you provide an example of generated bpf program?
And maybe add Documentation/bpf/bpfilter_design.rst ?

The tests don't build for me:
$ cd selftests/bpf/bpfilter; make
make: *** No rule to make target '-lelf', needed by '.../selftests/bpf/bpfilter/test_match'.  Stop.

The unit tests are great, btw. test_codegen is not end-to-end, right?
Could you add a full test with iptable command line?
or netns support is a prerequisite for it?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help