mbox series

[bpf-next,0/4] transition sockmap testing to test_progs

Message ID 20240123223612.1015788-1-john.fastabend@gmail.com (mailing list archive)
Headers show
Series transition sockmap testing to test_progs | expand

Message

John Fastabend Jan. 23, 2024, 10:36 p.m. UTC
Its much easier to write and read tests than it was when sockmap was
originally created. At that time we created a test_sockmap prog that
did sockmap tests. But, its showing its age now. For example it reads
user vars out of maps, is hard to run targetted tests, has a different
format from the familiar test_progs and so on.

I recently thought there was an issue with pop helpers so I created
some tests to try and track it down. It turns out it was a bug in the
BPF program we had not the kernel. But, I think it makes sense to
start deprecating test_sockmap and converting these to the nicer
test_progs.

So this is a first round of test_prog tests for sockmap cork and
pop helpers. I'll add push and pull tests shortly. I think its fine,
maybe preferred to review smaller patchsets, to send these
incrementally as I get them created.

Thanks!

John Fastabend (4):
  bpf: Add modern test for sk_msg prog pop msg header
  bpf: sockmap, add a sendmsg test so we can check that path
  bpf: sockmap, add a cork to force buffering of the scatterlist
  bpf: sockmap test cork and pop combined

 .../bpf/prog_tests/sockmap_helpers.h          |  18 +
 .../bpf/prog_tests/sockmap_msg_helpers.c      | 351 ++++++++++++++++++
 .../bpf/progs/test_sockmap_msg_helpers.c      |  67 ++++
 3 files changed, 436 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/sockmap_msg_helpers.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_sockmap_msg_helpers.c

Comments

John Fastabend Jan. 24, 2024, 2:35 a.m. UTC | #1
John Fastabend wrote:
> Its much easier to write and read tests than it was when sockmap was
> originally created. At that time we created a test_sockmap prog that
> did sockmap tests. But, its showing its age now. For example it reads
> user vars out of maps, is hard to run targetted tests, has a different
> format from the familiar test_progs and so on.
> 
> I recently thought there was an issue with pop helpers so I created
> some tests to try and track it down. It turns out it was a bug in the
> BPF program we had not the kernel. But, I think it makes sense to
> start deprecating test_sockmap and converting these to the nicer
> test_progs.
> 
> So this is a first round of test_prog tests for sockmap cork and
> pop helpers. I'll add push and pull tests shortly. I think its fine,
> maybe preferred to review smaller patchsets, to send these
> incrementally as I get them created.
> 
> Thanks!
> 
> John Fastabend (4):
>   bpf: Add modern test for sk_msg prog pop msg header
>   bpf: sockmap, add a sendmsg test so we can check that path
>   bpf: sockmap, add a cork to force buffering of the scatterlist
>   bpf: sockmap test cork and pop combined
> 
>  .../bpf/prog_tests/sockmap_helpers.h          |  18 +
>  .../bpf/prog_tests/sockmap_msg_helpers.c      | 351 ++++++++++++++++++
>  .../bpf/progs/test_sockmap_msg_helpers.c      |  67 ++++
>  3 files changed, 436 insertions(+)
>  create mode 100644 tools/testing/selftests/bpf/prog_tests/sockmap_msg_helpers.c
>  create mode 100644 tools/testing/selftests/bpf/progs/test_sockmap_msg_helpers.c
> 
> -- 
> 2.33.0
> 

Will need a v2 to fixup a couple things here. Thanks.
Andrii Nakryiko Jan. 24, 2024, 5:45 p.m. UTC | #2
On Tue, Jan 23, 2024 at 6:35 PM John Fastabend <john.fastabend@gmail.com> wrote:
>
> John Fastabend wrote:
> > Its much easier to write and read tests than it was when sockmap was
> > originally created. At that time we created a test_sockmap prog that
> > did sockmap tests. But, its showing its age now. For example it reads
> > user vars out of maps, is hard to run targetted tests, has a different
> > format from the familiar test_progs and so on.
> >
> > I recently thought there was an issue with pop helpers so I created
> > some tests to try and track it down. It turns out it was a bug in the
> > BPF program we had not the kernel. But, I think it makes sense to
> > start deprecating test_sockmap and converting these to the nicer
> > test_progs.
> >
> > So this is a first round of test_prog tests for sockmap cork and
> > pop helpers. I'll add push and pull tests shortly. I think its fine,
> > maybe preferred to review smaller patchsets, to send these
> > incrementally as I get them created.
> >
> > Thanks!
> >
> > John Fastabend (4):
> >   bpf: Add modern test for sk_msg prog pop msg header
> >   bpf: sockmap, add a sendmsg test so we can check that path
> >   bpf: sockmap, add a cork to force buffering of the scatterlist
> >   bpf: sockmap test cork and pop combined
> >
> >  .../bpf/prog_tests/sockmap_helpers.h          |  18 +
> >  .../bpf/prog_tests/sockmap_msg_helpers.c      | 351 ++++++++++++++++++
> >  .../bpf/progs/test_sockmap_msg_helpers.c      |  67 ++++
> >  3 files changed, 436 insertions(+)
> >  create mode 100644 tools/testing/selftests/bpf/prog_tests/sockmap_msg_helpers.c
> >  create mode 100644 tools/testing/selftests/bpf/progs/test_sockmap_msg_helpers.c
> >
> > --
> > 2.33.0
> >
>
> Will need a v2 to fixup a couple things here. Thanks.
>

Can you please also try compiling selftests with `make RELEASE=1` and
making sure the compiler doesn't complain about uninitialized
variables and such. Unfortunately we don't do this automatically in CI
yet.
John Fastabend Jan. 24, 2024, 5:52 p.m. UTC | #3
Andrii Nakryiko wrote:
> On Tue, Jan 23, 2024 at 6:35 PM John Fastabend <john.fastabend@gmail.com> wrote:
> >
> > John Fastabend wrote:
> > > Its much easier to write and read tests than it was when sockmap was
> > > originally created. At that time we created a test_sockmap prog that
> > > did sockmap tests. But, its showing its age now. For example it reads
> > > user vars out of maps, is hard to run targetted tests, has a different
> > > format from the familiar test_progs and so on.
> > >
> > > I recently thought there was an issue with pop helpers so I created
> > > some tests to try and track it down. It turns out it was a bug in the
> > > BPF program we had not the kernel. But, I think it makes sense to
> > > start deprecating test_sockmap and converting these to the nicer
> > > test_progs.
> > >
> > > So this is a first round of test_prog tests for sockmap cork and
> > > pop helpers. I'll add push and pull tests shortly. I think its fine,
> > > maybe preferred to review smaller patchsets, to send these
> > > incrementally as I get them created.
> > >
> > > Thanks!
> > >
> > > John Fastabend (4):
> > >   bpf: Add modern test for sk_msg prog pop msg header
> > >   bpf: sockmap, add a sendmsg test so we can check that path
> > >   bpf: sockmap, add a cork to force buffering of the scatterlist
> > >   bpf: sockmap test cork and pop combined
> > >
> > >  .../bpf/prog_tests/sockmap_helpers.h          |  18 +
> > >  .../bpf/prog_tests/sockmap_msg_helpers.c      | 351 ++++++++++++++++++
> > >  .../bpf/progs/test_sockmap_msg_helpers.c      |  67 ++++
> > >  3 files changed, 436 insertions(+)
> > >  create mode 100644 tools/testing/selftests/bpf/prog_tests/sockmap_msg_helpers.c
> > >  create mode 100644 tools/testing/selftests/bpf/progs/test_sockmap_msg_helpers.c
> > >
> > > --
> > > 2.33.0
> > >
> >
> > Will need a v2 to fixup a couple things here. Thanks.
> >
> 
> Can you please also try compiling selftests with `make RELEASE=1` and
> making sure the compiler doesn't complain about uninitialized
> variables and such. Unfortunately we don't do this automatically in CI
> yet.

Yep thats what I realized I missed after submitting. Thanks.