[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <odr4e7iju2ng5pw6hchbroy2utpabqrjpkf4v64zngzfilqzxx@ghodbng5cful>
Date: Thu, 21 Nov 2024 10:21:05 +0100
From: Stefano Garzarella <sgarzare@...hat.com>
To: Michal Luczaj <mhal@...x.co>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Bobby Eshleman <bobby.eshleman@...edance.com>, "Michael S. Tsirkin" <mst@...hat.com>,
Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>,
Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>,
Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>, Mykola Lysenko <mykolal@...com>,
Shuah Khan <shuah@...nel.org>, netdev@...r.kernel.org, bpf@...r.kernel.org,
linux-kselftest@...r.kernel.org
Subject: Re: [PATCH bpf 2/4] selftest/bpf: Add test for af_vsock poll()
On Mon, Nov 18, 2024 at 10:03:42PM +0100, Michal Luczaj wrote:
>Verify that vsock's poll() notices when sk_psock::ingress_msg isn't empty.
>
>Signed-off-by: Michal Luczaj <mhal@...x.co>
>---
> .../selftests/bpf/prog_tests/sockmap_basic.c | 46 ++++++++++++++++++++++
> 1 file changed, 46 insertions(+)
Acked-by: Stefano Garzarella <sgarzare@...hat.com>
>
>diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
>index 82bfb266741cfaceafa2a407cd2ccc937708c613..21d1e2e2308433e7475952dcab034e92f2f6101a 100644
>--- a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
>+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
>@@ -885,6 +885,50 @@ static void test_sockmap_same_sock(void)
> test_sockmap_pass_prog__destroy(skel);
> }
>
>+static void test_sockmap_skb_verdict_vsock_poll(void)
>+{
>+ struct test_sockmap_pass_prog *skel;
>+ int err, map, conn, peer;
>+ struct bpf_program *prog;
>+ struct bpf_link *link;
>+ char buf = 'x';
>+ int zero = 0;
>+
>+ skel = test_sockmap_pass_prog__open_and_load();
>+ if (!ASSERT_OK_PTR(skel, "open_and_load"))
>+ return;
>+
>+ if (create_pair(AF_VSOCK, SOCK_STREAM, &conn, &peer))
>+ goto destroy;
>+
>+ prog = skel->progs.prog_skb_verdict;
>+ map = bpf_map__fd(skel->maps.sock_map_rx);
>+ link = bpf_program__attach_sockmap(prog, map);
>+ if (!ASSERT_OK_PTR(link, "bpf_program__attach_sockmap"))
>+ goto close;
>+
>+ err = bpf_map_update_elem(map, &zero, &conn, BPF_ANY);
>+ if (!ASSERT_OK(err, "bpf_map_update_elem"))
>+ goto detach;
>+
>+ if (xsend(peer, &buf, 1, 0) != 1)
>+ goto detach;
>+
>+ err = poll_read(conn, IO_TIMEOUT_SEC);
>+ if (!ASSERT_OK(err, "poll"))
>+ goto detach;
>+
>+ if (xrecv_nonblock(conn, &buf, 1, 0) != 1)
>+ FAIL("xrecv_nonblock");
>+detach:
>+ bpf_link__detach(link);
>+close:
>+ xclose(conn);
>+ xclose(peer);
>+destroy:
>+ test_sockmap_pass_prog__destroy(skel);
>+}
>+
> void test_sockmap_basic(void)
> {
> if (test__start_subtest("sockmap create_update_free"))
>@@ -943,4 +987,6 @@ void test_sockmap_basic(void)
> test_skmsg_helpers_with_link(BPF_MAP_TYPE_SOCKMAP);
> if (test__start_subtest("sockhash sk_msg attach sockhash helpers with link"))
> test_skmsg_helpers_with_link(BPF_MAP_TYPE_SOCKHASH);
>+ if (test__start_subtest("sockmap skb_verdict vsock poll"))
>+ test_sockmap_skb_verdict_vsock_poll();
> }
>
>--
>2.46.2
>
Powered by blists - more mailing lists