Netdev List
 help / color / mirror / Atom feed
From: Dmitrii Banshchikov <me@ubique.spb.ru>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, davem@davemloft.net,
	daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com,
	songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com,
	kpsingh@kernel.org, netdev@vger.kernel.org, rdna@fb.com
Subject: Re: [PATCH bpf-next v2 12/13] bpfilter: Add filter table
Date: Tue, 31 Aug 2021 16:52:40 +0400	[thread overview]
Message-ID: <20210831125240.sm3ouie6hxur5cyb@amnesia> (raw)
In-Reply-To: <20210830234515.ncvsdswj4lalgpo3@ast-mbp.dhcp.thefacebook.com>

On Mon, Aug 30, 2021 at 04:45:15PM -0700, Alexei Starovoitov wrote:
> On Tue, Aug 31, 2021 at 12:54:43AM +0400, Dmitrii Banshchikov wrote:
> > 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?
> 
> make proceeds to build libbpf just fine, but then it stops with above message.
> I manually removed -lelf from Makefile. Then run make to see it fail linking
> and then manually copy pasted gcc command to build it with additional -lelf
> command line.
> fwiw make -v
> GNU Make 4.2.1

Will take a look on it. Thanks.

> 
> > > 
> > > 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.
> 
> I think when ifindex is no longer hardcoded the netns support
> doesn't have to be gating. The generic xdp attached to veth in netns
> should work to do end-to-end test. bpftiler would need to do a bit of magic
> to figure out the right ifindex. Or we can extend kernel with ifindex-less
> generic XDP.

Is it ok to add an external dependency to tests? The unit test
will need to execute iptables binary.


-- 

Dmitrii Banshchikov

  reply	other threads:[~2021-08-31 12:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-29 18:35 [PATCH bpf-next v2 00/13] bpfilter Dmitrii Banshchikov
2021-08-29 18:35 ` [PATCH bpf-next v2 01/13] bpfilter: Add types for usermode helper Dmitrii Banshchikov
2021-08-29 18:35 ` [PATCH bpf-next v2 02/13] bpfilter: Add logging facility Dmitrii Banshchikov
2021-08-29 18:35 ` [PATCH bpf-next v2 03/13] tools: Add bpfilter usermode helper header Dmitrii Banshchikov
2021-08-29 18:35 ` [PATCH bpf-next v2 04/13] bpfilter: Add map container Dmitrii Banshchikov
2021-08-29 18:36 ` [PATCH bpf-next v2 05/13] bpfilter: Add codegen infrastructure Dmitrii Banshchikov
2021-08-29 18:36 ` [PATCH bpf-next v2 06/13] bpfilter: Add struct match Dmitrii Banshchikov
2021-08-29 18:36 ` [PATCH bpf-next v2 07/13] bpfilter: Add struct target Dmitrii Banshchikov
2021-08-29 18:36 ` [PATCH bpf-next v2 08/13] bpfilter: Add struct rule Dmitrii Banshchikov
2021-08-29 18:36 ` [PATCH bpf-next v2 09/13] bpfilter: Add struct table Dmitrii Banshchikov
2021-08-29 18:36 ` [PATCH bpf-next v2 10/13] bpfilter: Add table codegen Dmitrii Banshchikov
2021-08-29 18:36 ` [PATCH bpf-next v2 11/13] bpfilter: Add handling of setsockopt() calls Dmitrii Banshchikov
2021-08-29 18:36 ` [PATCH bpf-next v2 12/13] bpfilter: Add filter table Dmitrii Banshchikov
2021-08-30 19:45   ` Alexei Starovoitov
2021-08-30 20:54     ` Dmitrii Banshchikov
2021-08-30 23:45       ` Alexei Starovoitov
2021-08-31 12:52         ` Dmitrii Banshchikov [this message]
2021-08-31 15:45           ` Alexei Starovoitov
2021-08-29 18:36 ` [PATCH bpf-next v2 13/13] bpfilter: Handle setsockopts Dmitrii Banshchikov
2021-08-31  1:56 ` [PATCH bpf-next v2 00/13] bpfilter Jamal Hadi Salim
2021-08-31 12:48   ` Dmitrii Banshchikov
2021-08-31 13:38     ` Jamal Hadi Salim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210831125240.sm3ouie6hxur5cyb@amnesia \
    --to=me@ubique.spb.ru \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rdna@fb.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox