[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+WQbwvUcPVWxd8YB_NgEHjfBYr92fD_AkOPGwiG+_uL9cAjCQ@mail.gmail.com>
Date: Tue, 17 May 2022 13:30:37 +0800
From: Geliang Tang <geliangtang@...il.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Mat Martineau <mathew.j.martineau@...ux.intel.com>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
Nicolas Rybowski <nicolas.rybowski@...sares.net>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
MPTCP Upstream <mptcp@...ts.linux.dev>,
Matthieu Baerts <matthieu.baerts@...sares.net>,
Geliang Tang <geliang.tang@...e.com>
Subject: Re: [PATCH bpf-next v4 3/7] selftests/bpf: add MPTCP test base
Andrii Nakryiko <andrii.nakryiko@...il.com> 于2022年5月17日周二 06:43写道:
>
> On Fri, May 13, 2022 at 3:48 PM Mat Martineau
> <mathew.j.martineau@...ux.intel.com> wrote:
> >
> > From: Nicolas Rybowski <nicolas.rybowski@...sares.net>
> >
> > 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@...sares.net>
> > Co-developed-by: Geliang Tang <geliang.tang@...e.com>
> > Signed-off-by: Geliang Tang <geliang.tang@...e.com>
> > Signed-off-by: Nicolas Rybowski <nicolas.rybowski@...sares.net>
> > Signed-off-by: Mat Martineau <mathew.j.martineau@...ux.intel.com>
> > ---
> > 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);
> > +
>
> [...]
>
Powered by blists - more mailing lists