[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210830205443.wx3n2bhw44pji2hn@amnesia>
Date: Tue, 31 Aug 2021 00:54:43 +0400
From: Dmitrii Banshchikov <me@...que.spb.ru>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: bpf@...r.kernel.org, ast@...nel.org, davem@...emloft.net,
daniel@...earbox.net, andrii@...nel.org, kafai@...com,
songliubraving@...com, yhs@...com, john.fastabend@...il.com,
kpsingh@...nel.org, netdev@...r.kernel.org, rdna@...com
Subject: Re: [PATCH bpf-next v2 12/13] bpfilter: Add filter table
On Mon, Aug 30, 2021 at 12:45:45PM -0700, Alexei Starovoitov wrote:
> 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?
Sorry, I missed it.
I decided that the large blob looks really ugly and switched to
the smaller one and forgot to cleanup the patchset.
>
> 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 ?
I will add documentation in the next iteration when
bpf_map_for_each() subprog will be introduced.
>
> 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.
libelf was added because libbpf depends on it.
Are you able to build libbpf?
>
> 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?
Yeah, as net namespaces aren't supported using iptables binary
will modify the root namespace. That is the reason why codegen
tests aren't implemented in the end-to-end fashion and rules are
represented by blobs.
--
Dmitrii Banshchikov
Powered by blists - more mailing lists