Re: [PATCH bpf-next v4 3/7] selftests/bpf: add MPTCP test base

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> 于2022年5月17日周二 06:43写道:
>
> On Fri, May 13, 2022 at 3:48 PM Mat Martineau
> <mathew.j.martineau@xxxxxxxxxxxxxxx> wrote:
> >
> > From: Nicolas Rybowski <nicolas.rybowski@xxxxxxxxxxxx>
> >
> > This patch adds a base for MPTCP specific tests.
> >
> > It is currently limited to the is_mptcp field in case of plain TCP
> > connection because there is no easy way to get the subflow sk from a msk
> > in userspace. This implies that we cannot lookup the sk_storage attached
> > to the subflow sk in the sockops program.
> >
> > v4:
> >  - add copyright 2022 (Andrii)
> >  - use ASSERT_* instead of CHECK_FAIL (Andrii)
> >  - drop SEC("version") (Andrii)
> >  - use is_mptcp in tcp_sock, instead of bpf_tcp_sock (Martin & Andrii)
> >
> > Acked-by: Matthieu Baerts <matthieu.baerts@xxxxxxxxxxxx>
> > Co-developed-by: Geliang Tang <geliang.tang@xxxxxxxx>
> > Signed-off-by: Geliang Tang <geliang.tang@xxxxxxxx>
> > Signed-off-by: Nicolas Rybowski <nicolas.rybowski@xxxxxxxxxxxx>
> > Signed-off-by: Mat Martineau <mathew.j.martineau@xxxxxxxxxxxxxxx>
> > ---
> >  MAINTAINERS                                   |   1 +
> >  tools/testing/selftests/bpf/bpf_tcp_helpers.h |   1 +
> >  tools/testing/selftests/bpf/config            |   1 +
> >  tools/testing/selftests/bpf/network_helpers.c |  43 ++++--
> >  tools/testing/selftests/bpf/network_helpers.h |   4 +
> >  .../testing/selftests/bpf/prog_tests/mptcp.c  | 136 ++++++++++++++++++
> >  .../testing/selftests/bpf/progs/mptcp_sock.c  |  53 +++++++
> >  7 files changed, 231 insertions(+), 8 deletions(-)
> >  create mode 100644 tools/testing/selftests/bpf/prog_tests/mptcp.c
> >  create mode 100644 tools/testing/selftests/bpf/progs/mptcp_sock.c
> >
>
> Seems like bpf_core_field_exists() works fine for your use case and CI
> is green. See some selftest-specific issues below, though.
>
> [...]
>
> > +static int run_test(int cgroup_fd, int server_fd, bool is_mptcp)
> > +{
> > +       int client_fd, prog_fd, map_fd, err;
> > +       struct bpf_program *prog;
> > +       struct bpf_object *obj;
> > +       struct bpf_map *map;
> > +
> > +       obj = bpf_object__open("./mptcp_sock.o");
> > +       if (libbpf_get_error(obj))
> > +               return -EIO;
> > +
> > +       err = bpf_object__load(obj);
> > +       if (!ASSERT_OK(err, "bpf_object__load"))
> > +               goto out;
> > +
> > +       prog = bpf_object__find_program_by_name(obj, "_sockops");
>
> can you please use BPF skeleton instead of doing these lookups by
> name? See other tests that are including .skel.h headers for example

Sure, I will update this in v5.

>
> > +       if (!ASSERT_OK_PTR(prog, "bpf_object__find_program_by_name")) {
> > +               err = -EIO;
> > +               goto out;
> > +       }
> > +
>
> [...]
>
> > +void test_base(void)
> > +{
> > +       int server_fd, cgroup_fd;
> > +
> > +       cgroup_fd = test__join_cgroup("/mptcp");
> > +       if (CHECK_FAIL(cgroup_fd < 0))
> > +               return;
> > +
> > +       /* without MPTCP */
> > +       server_fd = start_server(AF_INET, SOCK_STREAM, NULL, 0, 0);
> > +       if (CHECK_FAIL(server_fd < 0))
> > +               goto with_mptcp;
> > +
> > +       CHECK_FAIL(run_test(cgroup_fd, server_fd, false));
>
> please don't add new uses of CHECK_FAIL()
>
> > +
> > +       close(server_fd);
> > +
>
> [...]
>




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux