diff mbox series

[net-next,v2] selftests: return failure when timestamps can't be reported

Message ID 20240905160035.62407-1-kerneljasonxing@gmail.com (mailing list archive)
State Accepted
Commit a7e387375f22a4fd46c8ffcfa395a0ca8c186f9e
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] selftests: return failure when timestamps can't be reported | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 7 this patch: 7
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-09-07--06-00 (tests: 722)

Commit Message

Jason Xing Sept. 5, 2024, 4 p.m. UTC
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 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>
---
v2
Link: https://lore.kernel.org/all/20240904144446.41274-1-kerneljasonxing@gmail.com/
1. mainly change from "parse" to "report", update the commit message.
---
 tools/testing/selftests/net/txtimestamp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Jakub Kicinski Sept. 9, 2024, 5:23 p.m. UTC | #1
On Fri,  6 Sep 2024 00:00:35 +0800 Jason Xing wrote:
> 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.

Willem, thoughts?
Willem de Bruijn Sept. 9, 2024, 5:38 p.m. UTC | #2
Jakub Kicinski wrote:
> On Fri,  6 Sep 2024 00:00:35 +0800 Jason Xing wrote:
> > 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.
> 
> Willem, thoughts?

Reviewed-by: Willem de Bruijn <willemb@google.com>

Sorry, lost track of this.
patchwork-bot+netdevbpf@kernel.org Sept. 10, 2024, midnight UTC | #3
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri,  6 Sep 2024 00:00:35 +0800 you wrote:
> 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 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.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] selftests: return failure when timestamps can't be reported
    https://git.kernel.org/netdev/net-next/c/a7e387375f22

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c
index ec60a16c9307..d626f22f9550 100644
--- a/tools/testing/selftests/net/txtimestamp.c
+++ b/tools/testing/selftests/net/txtimestamp.c
@@ -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)