From: Jakub Sitnicki <jakub@cloudflare.com>
To: Michal Luczaj <mhal@rbox.co>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>,
Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>,
Mykola Lysenko <mykolal@fb.com>, Shuah Khan <shuah@kernel.org>,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next 2/5] selftests/bpf: sockmap_redir: Fix OOB handling
Date: Fri, 19 Sep 2025 11:49:44 +0200 [thread overview]
Message-ID: <87jz1uu5zb.fsf@cloudflare.com> (raw)
In-Reply-To: <20250905-redir-test-pass-drop-v1-2-9d9e43ff40df@rbox.co> (Michal Luczaj's message of "Fri, 05 Sep 2025 13:11:42 +0200")
Sorry for the super-long time-to-feedback.
On Fri, Sep 05, 2025 at 01:11 PM +02, Michal Luczaj wrote:
> In some test cases, OOB packets might have been left unread. Flush them out
> and introduce additional checks.
>
> Signed-off-by: Michal Luczaj <mhal@rbox.co>
> ---
> tools/testing/selftests/bpf/prog_tests/sockmap_redir.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c b/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c
> index c1bf1076e8152b7d83c3e07e2dce746b5a39cf7e..4997e72c14345b274367f3f2f4115c39d1ae48c9 100644
> --- a/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c
> +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c
> @@ -184,6 +184,19 @@ static void handle_unsupported(int sd_send, int sd_peer, int sd_in, int sd_out,
> FAIL_ERRNO("unsupported: packet missing, retval=%zd", n);
> }
>
> + /* af_unix send("ab", MSG_OOB) spits out 2 packets, but only the latter
> + * ("b") is designated OOB. If the peer is in a sockmap, the OOB packet
> + * will be silently dropped. Otherwise OOB stays in the queue and should
> + * be taken care of.
> + */
> + if ((send_flags & MSG_OOB) && !pass && !drop) {
Nit: There's a similar check a few lines before that:
if (pass == 0 && drop == 0 && (status & UNSUPPORTED_RACY_VERD)) {
For readability it might make sense to introduce a helper flag:
bool no_verdict = !pass && !drop; /* prog didn't run */
> + errno = 0;
> + n = recv_timeout(sd_peer, &recv_buf, 1, MSG_OOB, IO_TIMEOUT_SEC);
> + /* Ignore unsupported sk_msg error */
> + if (n != 1 && errno != EOPNOTSUPP)
> + FAIL_ERRNO("recv(OOB): retval=%zd", n);
> + }
> +
> /* Ensure queues are empty */
> fail_recv("bpf.recv(sd_send)", sd_send, 0);
> if (sd_in != sd_send)
> @@ -192,6 +205,9 @@ static void handle_unsupported(int sd_send, int sd_peer, int sd_in, int sd_out,
> fail_recv("bpf.recv(sd_out)", sd_out, 0);
> if (sd_recv != sd_out)
> fail_recv("bpf.recv(sd_recv)", sd_recv, 0);
> +
> + fail_recv("recv(sd_peer, OOB)", sd_peer, MSG_OOB);
> + fail_recv("recv(sd_out, OOB)", sd_out, MSG_OOB);
> }
>
> static void test_send_redir_recv(int sd_send, int send_flags, int sd_peer,
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
next prev parent reply other threads:[~2025-09-19 9:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 11:11 [PATCH bpf-next 0/5] selftests/bpf: Extend sockmap_redir to test no-redir SK_DROP/SK_PASS Michal Luczaj
2025-09-05 11:11 ` [PATCH bpf-next 1/5] selftests/bpf: sockmap_redir: Simplify try_recv() Michal Luczaj
2025-09-09 9:51 ` Jakub Sitnicki
2025-09-09 10:15 ` Jakub Sitnicki
2025-09-09 21:25 ` Michal Luczaj
2025-09-10 9:43 ` Jakub Sitnicki
2025-09-05 11:11 ` [PATCH bpf-next 2/5] selftests/bpf: sockmap_redir: Fix OOB handling Michal Luczaj
2025-09-05 11:19 ` Michal Luczaj
2025-09-19 11:29 ` Jakub Sitnicki
2025-09-19 9:49 ` Jakub Sitnicki [this message]
2025-09-05 11:11 ` [PATCH bpf-next 3/5] selftests/bpf: sockmap_redir: Rename functions Michal Luczaj
2025-09-19 9:54 ` Jakub Sitnicki
2025-09-05 11:11 ` [PATCH bpf-next 4/5] selftests/bpf: sockmap_redir: Let test specify skel's redirect_type Michal Luczaj
2025-09-19 9:55 ` Jakub Sitnicki
2025-09-05 11:11 ` [PATCH bpf-next 5/5] selftests/bpf: sockmap_redir: Support no-redirect SK_DROP/SK_PASS Michal Luczaj
2025-09-19 11:28 ` Jakub Sitnicki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87jz1uu5zb.fsf@cloudflare.com \
--to=jakub@cloudflare.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mhal@rbox.co \
--cc=mykolal@fb.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.