* [PATCH net-next] selftests: tls: avoid flakiness in data_steal
@ 2026-01-06 20:02 Jakub Kicinski
2026-01-08 15:43 ` Sabrina Dubroca
2026-01-10 1:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Kicinski @ 2026-01-06 20:02 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, Jakub Kicinski,
sd, shuah, linux-kselftest
We see the following failure a few times a week:
# RUN global.data_steal ...
# tls.c:3280:data_steal:Expected recv(cfd, buf2, sizeof(buf2), MSG_DONTWAIT) (10000) == -1 (-1)
# data_steal: Test failed
# FAIL global.data_steal
not ok 8 global.data_steal
The 10000 bytes read suggests that the child process did a recv()
of half of the data using the TLS ULP and we're now getting the
remaining half. The intent of the test is to get the child to
enter _TCP_ recvmsg handler, so it needs to enter the syscall before
parent installed the TLS recvmsg with setsockopt(SOL_TLS).
Instead of the 10msec sleep send 1 byte of data and wait for the
child to consume it.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: sd@queasysnail.net
CC: shuah@kernel.org
CC: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/net/tls.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
index a4d16a460fbe..9e2ccea13d70 100644
--- a/tools/testing/selftests/net/tls.c
+++ b/tools/testing/selftests/net/tls.c
@@ -3260,17 +3260,25 @@ TEST(data_steal) {
ASSERT_EQ(setsockopt(cfd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls")), 0);
/* Spawn a child and get it into the read wait path of the underlying
- * TCP socket.
+ * TCP socket (before kernel .recvmsg is replaced with the TLS one).
*/
pid = fork();
ASSERT_GE(pid, 0);
if (!pid) {
- EXPECT_EQ(recv(cfd, buf, sizeof(buf) / 2, MSG_WAITALL),
- sizeof(buf) / 2);
+ EXPECT_EQ(recv(cfd, buf, sizeof(buf) / 2 + 1, MSG_WAITALL),
+ sizeof(buf) / 2 + 1);
exit(!__test_passed(_metadata));
}
- usleep(10000);
+ /* Send a sync byte and poll until it's consumed to ensure
+ * the child is in recv() before we proceed to install TLS.
+ */
+ ASSERT_EQ(send(fd, buf, 1, 0), 1);
+ do {
+ usleep(500);
+ } while (recv(cfd, buf, 1, MSG_PEEK | MSG_DONTWAIT) == 1);
+ EXPECT_EQ(errno, EAGAIN);
+
ASSERT_EQ(setsockopt(fd, SOL_TLS, TLS_TX, &tls, tls.len), 0);
ASSERT_EQ(setsockopt(cfd, SOL_TLS, TLS_RX, &tls, tls.len), 0);
--
2.52.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] selftests: tls: avoid flakiness in data_steal
2026-01-06 20:02 [PATCH net-next] selftests: tls: avoid flakiness in data_steal Jakub Kicinski
@ 2026-01-08 15:43 ` Sabrina Dubroca
2026-01-10 1:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Sabrina Dubroca @ 2026-01-08 15:43 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, shuah,
linux-kselftest
2026-01-06, 12:02:05 -0800, Jakub Kicinski wrote:
> We see the following failure a few times a week:
>
> # RUN global.data_steal ...
> # tls.c:3280:data_steal:Expected recv(cfd, buf2, sizeof(buf2), MSG_DONTWAIT) (10000) == -1 (-1)
> # data_steal: Test failed
> # FAIL global.data_steal
> not ok 8 global.data_steal
>
> The 10000 bytes read suggests that the child process did a recv()
> of half of the data using the TLS ULP and we're now getting the
> remaining half. The intent of the test is to get the child to
> enter _TCP_ recvmsg handler, so it needs to enter the syscall before
> parent installed the TLS recvmsg with setsockopt(SOL_TLS).
>
> Instead of the 10msec sleep send 1 byte of data and wait for the
> child to consume it.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: sd@queasysnail.net
> CC: shuah@kernel.org
> CC: linux-kselftest@vger.kernel.org
> ---
> tools/testing/selftests/net/tls.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
--
Sabrina
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] selftests: tls: avoid flakiness in data_steal
2026-01-06 20:02 [PATCH net-next] selftests: tls: avoid flakiness in data_steal Jakub Kicinski
2026-01-08 15:43 ` Sabrina Dubroca
@ 2026-01-10 1:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-10 1:40 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, sd, shuah,
linux-kselftest
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 6 Jan 2026 12:02:05 -0800 you wrote:
> We see the following failure a few times a week:
>
> # RUN global.data_steal ...
> # tls.c:3280:data_steal:Expected recv(cfd, buf2, sizeof(buf2), MSG_DONTWAIT) (10000) == -1 (-1)
> # data_steal: Test failed
> # FAIL global.data_steal
> not ok 8 global.data_steal
>
> [...]
Here is the summary with links:
- [net-next] selftests: tls: avoid flakiness in data_steal
https://git.kernel.org/netdev/net-next/c/96ea4fa60c45
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-10 1:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-06 20:02 [PATCH net-next] selftests: tls: avoid flakiness in data_steal Jakub Kicinski
2026-01-08 15:43 ` Sabrina Dubroca
2026-01-10 1:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox