]> git.dujemihanovic.xyz Git - linux.git/commitdiff
selftests: return failure when timestamps can't be reported
authorJason Xing <kernelxing@tencent.com>
Thu, 5 Sep 2024 16:00:35 +0000 (00:00 +0800)
committerJakub Kicinski <kuba@kernel.org>
Mon, 9 Sep 2024 23:42:28 +0000 (16:42 -0700)
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 error:
I succeeded to generate timestamp stored in the skb but later failed
to report it to the userspace (which means failed to put css into cmsg).
It can happen when someone writes buggy codes in __sock_recv_timestamp(),
for example.

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

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

In the future, it will help us detect whether the new coming patch has
bugs or not.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20240905160035.62407-1-kerneljasonxing@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/txtimestamp.c

index ec60a16c93074ec78eb0bdf3d67c7a074a2d85fa..d626f22f955090f889defeb836d853fae15a0b4f 100644 (file)
@@ -356,8 +356,12 @@ static void __recv_errmsg_cmsg(struct msghdr *msg, int payload_len)
                }
        }
 
-       if (batch > 1)
+       if (batch > 1) {
                fprintf(stderr, "batched %d timestamps\n", batch);
+       } else if (!batch) {
+               fprintf(stderr, "Failed to report timestamps\n");
+               test_failed = true;
+       }
 }
 
 static int recv_errmsg(int fd)