[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d94fd42e02ffeb8dc51ab6cfb4a4025e42ec1aba.camel@chromium.org>
Date: Fri, 04 Dec 2020 12:37:46 +0100
From: Florent Revest <revest@...omium.org>
To: Martin KaFai Lau <kafai@...com>
Cc: bpf@...r.kernel.org, viro@...iv.linux.org.uk, davem@...emloft.net,
kuba@...nel.org, ast@...nel.org, daniel@...earbox.net, yhs@...com,
andrii@...nel.org, kpsingh@...omium.org, revest@...gle.com,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH bpf-next v4 6/6] bpf: Test bpf_sk_storage_get in tcp
iterators
On Thu, 2020-12-03 at 18:05 -0800, Martin KaFai Lau wrote:
> On Wed, Dec 02, 2020 at 09:55:27PM +0100, Florent Revest wrote:
> > This extends the existing bpf_sk_storage_get test where a socket is
> > created and tagged with its creator's pid by a task_file iterator.
> >
> > A TCP iterator is now also used at the end of the test to negate
> > the
> > values already stored in the local storage. The test therefore
> > expects
> > -getpid() to be stored in the local storage.
> >
> > Signed-off-by: Florent Revest <revest@...gle.com>
> > Acked-by: Yonghong Song <yhs@...com>
> > ---
> > .../selftests/bpf/prog_tests/bpf_iter.c | 13 +++++++++++++
> > .../progs/bpf_iter_bpf_sk_storage_helpers.c | 18
> > ++++++++++++++++++
> > 2 files changed, 31 insertions(+)
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> > b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> > index 9336d0f18331..b8362147c9e3 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> > @@ -978,6 +978,8 @@ static void test_bpf_sk_storage_delete(void)
> > /* This creates a socket and its local storage. It then runs a
> > task_iter BPF
> > * program that replaces the existing socket local storage with
> > the tgid of the
> > * only task owning a file descriptor to this socket, this
> > process, prog_tests.
> > + * It then runs a tcp socket iterator that negates the value in
> > the existing
> > + * socket local storage, the test verifies that the resulting
> > value is -pid.
> > */
> > static void test_bpf_sk_storage_get(void)
> > {
> > @@ -994,6 +996,10 @@ static void test_bpf_sk_storage_get(void)
> > if (CHECK(sock_fd < 0, "socket", "errno: %d\n", errno))
> > goto out;
> >
> > + err = listen(sock_fd, 1);
> > + if (CHECK(err != 0, "listen", "errno: %d\n", errno))
> > + goto out;
>
> goto close_socket;
>
> > +
> > map_fd = bpf_map__fd(skel->maps.sk_stg_map);
> >
> > err = bpf_map_update_elem(map_fd, &sock_fd, &val, BPF_NOEXIST);
> > @@ -1007,6 +1013,13 @@ static void test_bpf_sk_storage_get(void)
> > "map value wasn't set correctly (expected %d, got %d,
> > err=%d)\n",
> > getpid(), val, err);
> The failure of this CHECK here should "goto close_socket;" now.
>
> Others LGTM.
>
> Acked-by: Martin KaFai Lau <kafai@...com>
Ah good points, thanks! Fixed in v5 :)
Powered by blists - more mailing lists