From nobody Wed Sep 10 01:47:55 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F23F346A0D for ; Fri, 5 Sep 2025 11:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757070731; cv=none; b=f2ejx2fsrPsxQoLEySDQoAtCzx5gUB/w4M8nX34nqR2R49VcSfdTOPU6anNzAlc0eb0a8yHfTp9Rnie5hU3K2YbW8ItUYamgMT5ICQVKL0DsRkqdLruaSMFbzlkDmieYoOHOHmjEFU53p/iCqhkyvTp6K0+VLvQ60IsLyXZJhno= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757070731; c=relaxed/simple; bh=7Tsy7ROVoOHxxVMAnzKBn0Y5eMA7rE7joEcmL2lJBVk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p1/tcMRf6IY+0UNydQYcQJPHoQSvpf08PwSFn4Dvzc9T3Ke39A2va4N4/NIH+5MQxRWE8zUkmywpyzazcC7F0B+d+0uRNnUo6Fm7sT6HV8lQXPR17I3cu8QsM6GtHXAnrpO+zqcbMpp3UDm5CeE4NzwZI0Off82LB1ALVFyOjeQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rbox.co; spf=pass smtp.mailfrom=rbox.co; dkim=pass (2048-bit key) header.d=rbox.co header.i=@rbox.co header.b=daZ+R/x2; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rbox.co Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rbox.co Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rbox.co header.i=@rbox.co header.b="daZ+R/x2" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1uuUMQ-003THx-A3; Fri, 05 Sep 2025 13:12:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rbox.co; s=selector1; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From; bh=+pRX1EHWIu4uVLS1iKQ0e4UmcUny8V+/+FbSvwtoeV8=; b=daZ+R/x2+DfqwfHt7UmEv0f802 4zzpGOT3I0NOlRE6zmjhR4NBnX5u67d99vXvu0HMVURiQzhp/IOOAMGkwxSolHYkqHDwcipT3n6hC r9cAo/E2e93lksbAf92fBlQWLAjZYwFfxd0gQiouIs3Jo0ky9sPZY7GFx7NbegiBxJcJswT9nk0K8 bUNpMG0+NDLYRhDcqieQ1ScSvg9ZcRj1x6fQcbLYp6Wp+oKvBc9CtGX1C7Xm9HPZUCOGzbC8Ao6Yi V4URgJKchAebB+b8xMDbgKIVhmPnept/zuSZ7Y/rq/qUx8rZSCIFzcafJoUllhOl0/xQRPv2yt+pP 96BvdtYg==; Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1uuUMP-0002Jd-OB; Fri, 05 Sep 2025 13:12:06 +0200 Received: by submission02.runbox with esmtpsa [Authenticated ID (604044)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1uuUMA-002yZ1-19; Fri, 05 Sep 2025 13:11:50 +0200 From: Michal Luczaj Date: Fri, 05 Sep 2025 13:11:41 +0200 Subject: [PATCH bpf-next 1/5] selftests/bpf: sockmap_redir: Simplify try_recv() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250905-redir-test-pass-drop-v1-1-9d9e43ff40df@rbox.co> References: <20250905-redir-test-pass-drop-v1-0-9d9e43ff40df@rbox.co> In-Reply-To: <20250905-redir-test-pass-drop-v1-0-9d9e43ff40df@rbox.co> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Michal Luczaj X-Mailer: b4 0.14.2 try_recv() was meant to support both @expect_success cases, but all the callers use @expect_success=3Dfalse anyway. Drop the unused logic and fold = in MSG_DONTWAIT. Adapt callers. Subtle change here: recv() return value of 0 will also be considered (an unexpected) success. Signed-off-by: Michal Luczaj Reviewed-by: Jakub Sitnicki --- .../selftests/bpf/prog_tests/sockmap_redir.c | 25 +++++++++---------= ---- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c b/tools= /testing/selftests/bpf/prog_tests/sockmap_redir.c index 9c461d93113db20de65ac353f92dfdbe32ffbd3b..c1bf1076e8152b7d83c3e07e2dc= e746b5a39cf7e 100644 --- a/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c @@ -144,17 +144,14 @@ static void get_redir_params(struct redir_spec *redir, *redirect_flags =3D 0; } =20 -static void try_recv(const char *prefix, int fd, int flags, bool expect_su= ccess) +static void fail_recv(const char *prefix, int fd, int more_flags) { ssize_t n; char buf; =20 - errno =3D 0; - n =3D recv(fd, &buf, 1, flags); - if (n < 0 && expect_success) - FAIL_ERRNO("%s: unexpected failure: retval=3D%zd", prefix, n); - if (!n && !expect_success) - FAIL("%s: expected failure: retval=3D%zd", prefix, n); + n =3D recv(fd, &buf, 1, MSG_DONTWAIT | more_flags); + if (n >=3D 0) + FAIL("%s: unexpected success: retval=3D%zd", prefix, n); } =20 static void handle_unsupported(int sd_send, int sd_peer, int sd_in, int sd= _out, @@ -188,13 +185,13 @@ static void handle_unsupported(int sd_send, int sd_pe= er, int sd_in, int sd_out, } =20 /* Ensure queues are empty */ - try_recv("bpf.recv(sd_send)", sd_send, MSG_DONTWAIT, false); + fail_recv("bpf.recv(sd_send)", sd_send, 0); if (sd_in !=3D sd_send) - try_recv("bpf.recv(sd_in)", sd_in, MSG_DONTWAIT, false); + fail_recv("bpf.recv(sd_in)", sd_in, 0); =20 - try_recv("bpf.recv(sd_out)", sd_out, MSG_DONTWAIT, false); + fail_recv("bpf.recv(sd_out)", sd_out, 0); if (sd_recv !=3D sd_out) - try_recv("bpf.recv(sd_recv)", sd_recv, MSG_DONTWAIT, false); + fail_recv("bpf.recv(sd_recv)", sd_recv, 0); } =20 static void test_send_redir_recv(int sd_send, int send_flags, int sd_peer, @@ -257,15 +254,13 @@ static void test_send_redir_recv(int sd_send, int sen= d_flags, int sd_peer, =20 if (send_flags & MSG_OOB) { /* Fail reading OOB while in sockmap */ - try_recv("bpf.recv(sd_out, MSG_OOB)", sd_out, - MSG_OOB | MSG_DONTWAIT, false); + fail_recv("bpf.recv(sd_out, MSG_OOB)", sd_out, MSG_OOB); =20 /* Remove sd_out from sockmap */ xbpf_map_delete_elem(maps->out, &u32(0)); =20 /* Check that OOB was dropped on redirect */ - try_recv("recv(sd_out, MSG_OOB)", sd_out, - MSG_OOB | MSG_DONTWAIT, false); + fail_recv("recv(sd_out, MSG_OOB)", sd_out, MSG_OOB); =20 goto del_in; } --=20 2.50.1