* [PATCH net-next v2 0/2] selftests: net: improve error handling in passive TFO test
@ 2026-01-13 14:11 Yohei Kojima
2026-01-13 14:11 ` [PATCH net-next v2 1/2] selftests: net: fix passive TFO test to fail if child processes failed Yohei Kojima
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Yohei Kojima @ 2026-01-13 14:11 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Shuah Khan
Cc: Yohei Kojima, netdev, linux-kselftest, linux-kernel, Andrew Lunn,
Markus Elfring
This series improves error handling in the passive TFO test by (1)
fixing a broken behavior when the child processes failed (or timed out),
and (2) adding more error handlng code in the test program.
The first patch fixes the behavior that the test didn't report failure
even if the server or the client process exited with non-zero status.
The second patch adds error handling code in the test program to improve
reliability of the test.
This series was split out from the following series to address the
feedback from Andrew Lunn:
https://lore.kernel.org/netdev/cover.1767032397.git.yk@y-koj.net/
ChangeLog
=========
v2 (this version):
- Fix a typo in the patch description
- Rephrase the patch description in imperative mood
- Add error handling for fprintf() reflecting Markus Elfring's feedback
v1: https://lore.kernel.org/netdev/cover.1768207347.git.yk@y-koj.net/
Yohei Kojima (2):
selftests: net: fix passive TFO test to fail if child processes failed
selftests: net: improve error handling in passive TFO test
tools/testing/selftests/net/tfo.c | 13 +++++++++----
tools/testing/selftests/net/tfo_passive.sh | 13 ++++++++++++-
2 files changed, 21 insertions(+), 5 deletions(-)
--
2.52.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next v2 1/2] selftests: net: fix passive TFO test to fail if child processes failed
2026-01-13 14:11 [PATCH net-next v2 0/2] selftests: net: improve error handling in passive TFO test Yohei Kojima
@ 2026-01-13 14:11 ` Yohei Kojima
2026-01-13 14:11 ` [PATCH net-next v2 2/2] selftests: net: improve error handling in passive TFO test Yohei Kojima
2026-01-19 14:19 ` [PATCH net-next v2 0/2] " patchwork-bot+netdevbpf
2 siblings, 0 replies; 8+ messages in thread
From: Yohei Kojima @ 2026-01-13 14:11 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Shuah Khan
Cc: Yohei Kojima, Andrew Lunn, Markus Elfring, netdev,
linux-kselftest, linux-kernel
Improve the passive TFO test to report failure if the server or the
client timed out or exited with non-zero status.
Before this commit, TFO test didn't fail even if exit(EXIT_FAILURE) is
added to the first line of the run_server() and run_client() functions.
Signed-off-by: Yohei Kojima <yk@y-koj.net>
---
tools/testing/selftests/net/tfo_passive.sh | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/tfo_passive.sh b/tools/testing/selftests/net/tfo_passive.sh
index a4550511830a..f116f888b794 100755
--- a/tools/testing/selftests/net/tfo_passive.sh
+++ b/tools/testing/selftests/net/tfo_passive.sh
@@ -85,12 +85,15 @@ timeout -k 1s 30s ip netns exec nssv ./tfo \
-s \
-p ${SERVER_PORT} \
-o ${out_file}&
+server_pid="$!"
wait_local_port_listen nssv ${SERVER_PORT} tcp
ip netns exec nscl ./tfo -c -h ${SERVER_IP} -p ${SERVER_PORT}
+client_exit_status="$?"
-wait
+wait "$server_pid"
+server_exit_status="$?"
res=$(cat $out_file)
rm $out_file
@@ -101,6 +104,14 @@ if [ "$res" = "0" ]; then
exit 1
fi
+if [ "$client_exit_status" -ne 0 ] || [ "$server_exit_status" -ne 0 ]; then
+ # Note: timeout(1) exits with 124 if it timed out
+ echo "client exited with ${client_exit_status}"
+ echo "server exited with ${server_exit_status}"
+ cleanup_ns
+ exit 1
+fi
+
echo "$NSIM_SV_FD:$NSIM_SV_IFIDX" > $NSIM_DEV_SYS_UNLINK
echo $NSIM_CL_ID > $NSIM_DEV_SYS_DEL
--
2.52.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v2 2/2] selftests: net: improve error handling in passive TFO test
2026-01-13 14:11 [PATCH net-next v2 0/2] selftests: net: improve error handling in passive TFO test Yohei Kojima
2026-01-13 14:11 ` [PATCH net-next v2 1/2] selftests: net: fix passive TFO test to fail if child processes failed Yohei Kojima
@ 2026-01-13 14:11 ` Yohei Kojima
2026-01-13 14:48 ` Markus Elfring
2026-01-14 8:33 ` Markus Elfring
2026-01-19 14:19 ` [PATCH net-next v2 0/2] " patchwork-bot+netdevbpf
2 siblings, 2 replies; 8+ messages in thread
From: Yohei Kojima @ 2026-01-13 14:11 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Shuah Khan
Cc: Yohei Kojima, Andrew Lunn, Markus Elfring, netdev,
linux-kselftest, linux-kernel
Improve the error handling in passive TFO test to check the return value
from sendto(), and to fail if read() or fprintf() failed.
Signed-off-by: Yohei Kojima <yk@y-koj.net>
---
tools/testing/selftests/net/tfo.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/net/tfo.c b/tools/testing/selftests/net/tfo.c
index 8d82140f0f76..3b1ee2d3d417 100644
--- a/tools/testing/selftests/net/tfo.c
+++ b/tools/testing/selftests/net/tfo.c
@@ -82,8 +82,10 @@ static void run_server(void)
error(1, errno, "getsockopt(SO_INCOMING_NAPI_ID)");
if (read(connfd, buf, 64) < 0)
- perror("read()");
- fprintf(outfile, "%d\n", opt);
+ error(1, errno, "read()");
+
+ if (fprintf(outfile, "%d\n", opt) < 0)
+ error(1, errno, "fprintf()");
fclose(outfile);
close(connfd);
@@ -92,14 +94,17 @@ static void run_server(void)
static void run_client(void)
{
- int fd;
+ int fd, ret;
char *msg = "Hello, world!";
fd = socket(AF_INET6, SOCK_STREAM, 0);
if (fd == -1)
error(1, errno, "socket()");
- sendto(fd, msg, strlen(msg), MSG_FASTOPEN, (struct sockaddr *)&cfg_addr, sizeof(cfg_addr));
+ ret = sendto(fd, msg, strlen(msg), MSG_FASTOPEN,
+ (struct sockaddr *)&cfg_addr, sizeof(cfg_addr));
+ if (ret < 0)
+ error(1, errno, "sendto()");
close(fd);
}
--
2.52.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v2 2/2] selftests: net: improve error handling in passive TFO test
2026-01-13 14:11 ` [PATCH net-next v2 2/2] selftests: net: improve error handling in passive TFO test Yohei Kojima
@ 2026-01-13 14:48 ` Markus Elfring
2026-01-13 15:57 ` Yohei Kojima
2026-01-14 8:33 ` Markus Elfring
1 sibling, 1 reply; 8+ messages in thread
From: Markus Elfring @ 2026-01-13 14:48 UTC (permalink / raw)
To: Yohei Kojima, linux-kselftest, netdev
Cc: LKML, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Shuah Khan
…
> +++ b/tools/testing/selftests/net/tfo.c
> @@ -82,8 +82,10 @@ static void run_server(void)
…
> if (read(connfd, buf, 64) < 0)
> - perror("read()");
> - fprintf(outfile, "%d\n", opt);
> + error(1, errno, "read()");
> +
> + if (fprintf(outfile, "%d\n", opt) < 0)
> + error(1, errno, "fprintf()");
>
> fclose(outfile);
> close(connfd);
…
Why was error detection omitted for close() calls here so far?
https://pubs.opengroup.org/onlinepubs/9799919799/functions/fclose.html
Regards,
Markus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v2 2/2] selftests: net: improve error handling in passive TFO test
2026-01-13 14:48 ` Markus Elfring
@ 2026-01-13 15:57 ` Yohei Kojima
0 siblings, 0 replies; 8+ messages in thread
From: Yohei Kojima @ 2026-01-13 15:57 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-kselftest, netdev, LKML, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Shuah Khan
On Tue, Jan 13, 2026 at 03:48:11PM +0100, Markus Elfring wrote:
> …
> > +++ b/tools/testing/selftests/net/tfo.c
> > @@ -82,8 +82,10 @@ static void run_server(void)
> …
> > if (read(connfd, buf, 64) < 0)
> > - perror("read()");
> > - fprintf(outfile, "%d\n", opt);
> > + error(1, errno, "read()");
> > +
> > + if (fprintf(outfile, "%d\n", opt) < 0)
> > + error(1, errno, "fprintf()");
> >
> > fclose(outfile);
> > close(connfd);
> …
>
> Why was error detection omitted for close() calls here so far?
Because I believe that checking the return value of fclose() would not
provide additional value in this test case, which is focused on testing
the behavior of passive TFO.
I understand that fclose() could fail there, but considering the
trade-off between test reliability and code complexity (which increases
review and maintenance costs), I think checking the return value there
does not provide benefits to justify the added complexity. In fact, as
far as I can see, none of the existing tests in selftests/net check the
fclose() return value.
Thank you,
Yohei
>
> https://pubs.opengroup.org/onlinepubs/9799919799/functions/fclose.html
>
> Regards,
> Markus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v2 2/2] selftests: net: improve error handling in passive TFO test
2026-01-13 14:11 ` [PATCH net-next v2 2/2] selftests: net: improve error handling in passive TFO test Yohei Kojima
2026-01-13 14:48 ` Markus Elfring
@ 2026-01-14 8:33 ` Markus Elfring
2026-01-15 16:21 ` Yohei Kojima
1 sibling, 1 reply; 8+ messages in thread
From: Markus Elfring @ 2026-01-14 8:33 UTC (permalink / raw)
To: Yohei Kojima, linux-kselftest, netdev
Cc: kernel-janitors, LKML, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Shuah Khan, Simon Horman
> Improve the error handling in passive TFO test to check the return value
> from sendto(), and to fail if read() or fprintf() failed.
You propose to adjust error detection and corresponding exception handling another bit.
How do you think about to take also another look if further function implementations
would be similarly affected?
Regards,
Markus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v2 2/2] selftests: net: improve error handling in passive TFO test
2026-01-14 8:33 ` Markus Elfring
@ 2026-01-15 16:21 ` Yohei Kojima
0 siblings, 0 replies; 8+ messages in thread
From: Yohei Kojima @ 2026-01-15 16:21 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-kselftest, netdev, kernel-janitors, LKML, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Shuah Khan, Simon Horman
On Wed, Jan 14, 2026 at 09:33:12AM +0100, Markus Elfring wrote:
> > Improve the error handling in passive TFO test to check the return value
> > from sendto(), and to fail if read() or fprintf() failed.
>
> You propose to adjust error detection and corresponding exception handling another bit.
> How do you think about to take also another look if further function implementations
> would be similarly affected?
Thank you for the suggestion. The first objective of this series is to
fix the misleading behavior that was caused by the following bug.
Therefore, I intentionally limited the scope of this patch to the
affected or closely related functions.
https://lore.kernel.org/netdev/602c9e1ba5bb2ee1997bb38b1d866c9c3b807ae9.1767624906.git.yk@y-koj.net/
I believe this is sufficient to prevent it from showing misleading error
messages when the test fails.
Thank you,
Yohei
>
> Regards,
> Markus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v2 0/2] selftests: net: improve error handling in passive TFO test
2026-01-13 14:11 [PATCH net-next v2 0/2] selftests: net: improve error handling in passive TFO test Yohei Kojima
2026-01-13 14:11 ` [PATCH net-next v2 1/2] selftests: net: fix passive TFO test to fail if child processes failed Yohei Kojima
2026-01-13 14:11 ` [PATCH net-next v2 2/2] selftests: net: improve error handling in passive TFO test Yohei Kojima
@ 2026-01-19 14:19 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-19 14:19 UTC (permalink / raw)
To: Yohei Kojima
Cc: davem, edumazet, kuba, pabeni, horms, shuah, netdev,
linux-kselftest, linux-kernel, andrew+netdev, Markus.Elfring
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 13 Jan 2026 23:11:53 +0900 you wrote:
> This series improves error handling in the passive TFO test by (1)
> fixing a broken behavior when the child processes failed (or timed out),
> and (2) adding more error handlng code in the test program.
>
> The first patch fixes the behavior that the test didn't report failure
> even if the server or the client process exited with non-zero status.
> The second patch adds error handling code in the test program to improve
> reliability of the test.
>
> [...]
Here is the summary with links:
- [net-next,v2,1/2] selftests: net: fix passive TFO test to fail if child processes failed
https://git.kernel.org/netdev/net-next/c/52b485973043
- [net-next,v2,2/2] selftests: net: improve error handling in passive TFO test
https://git.kernel.org/netdev/net-next/c/342e31254f02
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] 8+ messages in thread
end of thread, other threads:[~2026-01-19 14:23 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-13 14:11 [PATCH net-next v2 0/2] selftests: net: improve error handling in passive TFO test Yohei Kojima
2026-01-13 14:11 ` [PATCH net-next v2 1/2] selftests: net: fix passive TFO test to fail if child processes failed Yohei Kojima
2026-01-13 14:11 ` [PATCH net-next v2 2/2] selftests: net: improve error handling in passive TFO test Yohei Kojima
2026-01-13 14:48 ` Markus Elfring
2026-01-13 15:57 ` Yohei Kojima
2026-01-14 8:33 ` Markus Elfring
2026-01-15 16:21 ` Yohei Kojima
2026-01-19 14:19 ` [PATCH net-next v2 0/2] " 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