netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] selftests: return failure when timestamps can't be parsed
@ 2024-09-04 14:44 Jason Xing
  2024-09-04 21:16 ` Willem de Bruijn
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Xing @ 2024-09-04 14:44 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, shuah, willemdebruijn.kernel
  Cc: linux-kselftest, netdev, Jason Xing

From: Jason Xing <kernelxing@tencent.com>

When I was trying to modify the tx timestamping feature, I found that
running "./txtimestamp -4 -C -L 127.0.0.1" didn't reflect the fact
properly.

In this selftest file, we respectively test three tx generation flags.
With the generation and report flag enabled, we expect that the timestamp
must be returned to the userspace unless 1) generating the timestamp
fails, 2) reporting the timestamp fails. So we should test if the
timestamps can be read and parsed succuessfuly in txtimestamp.c, or
else there is a bug in the kernel.

After adding the check so that running ./txtimestamp will reflect the
result correctly like this if there is an error in kernel:
protocol:     TCP
payload:      10
server port:  9000

family:       INET
test SND
    USR: 1725458477 s 667997 us (seq=0, len=0)
Failed to parse timestamps
    USR: 1725458477 s 718128 us (seq=0, len=0)
Failed to parse timestamps
    USR: 1725458477 s 768273 us (seq=0, len=0)
Failed to parse timestamps
    USR: 1725458477 s 818416 us (seq=0, len=0)
Failed to parse timestamps
...

Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
I'm not sure if I should also check if the cur->tv_sec or cur->tv_nsec
is zero in __print_timestamp(). Could it be valid when either of
them is zero?
---
 tools/testing/selftests/net/txtimestamp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c
index ec60a16c9307..b69aae840a67 100644
--- a/tools/testing/selftests/net/txtimestamp.c
+++ b/tools/testing/selftests/net/txtimestamp.c
@@ -358,6 +358,10 @@ static void __recv_errmsg_cmsg(struct msghdr *msg, int payload_len)
 
 	if (batch > 1)
 		fprintf(stderr, "batched %d timestamps\n", batch);
+	else if (!batch) {
+		fprintf(stderr, "Failed to parse timestamps\n");
+		test_failed = true;
+	}
 }
 
 static int recv_errmsg(int fd)
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-09-05 13:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-04 14:44 [PATCH net-next] selftests: return failure when timestamps can't be parsed Jason Xing
2024-09-04 21:16 ` Willem de Bruijn
2024-09-04 21:49   ` Jason Xing
2024-09-05 11:04   ` Jason Xing
2024-09-05 13:40     ` Jason Xing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).