aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/prog_tests/tcp_rtt.c
diff options
context:
space:
mode:
authorPhilo Lu <[email protected]>2024-04-25 16:17:24 +0000
committerMartin KaFai Lau <[email protected]>2024-04-25 21:09:05 +0000
commit7eb4f66b38069eec9c86c9d115f0bba1cf73ef2c (patch)
tree90f30033f73d8801ca45d1ac453134c80b65b4db /tools/testing/selftests/bpf/prog_tests/tcp_rtt.c
parentbpf: add mrtt and srtt as BPF_SOCK_OPS_RTT_CB args (diff)
downloadkernel-7eb4f66b38069eec9c86c9d115f0bba1cf73ef2c.tar.gz
kernel-7eb4f66b38069eec9c86c9d115f0bba1cf73ef2c.zip
selftests/bpf: extend BPF_SOCK_OPS_RTT_CB test for srtt and mrtt_us
Because srtt and mrtt_us are added as args in bpf_sock_ops at BPF_SOCK_OPS_RTT_CB, a simple check is added to make sure they are both non-zero. $ ./test_progs -t tcp_rtt #373 tcp_rtt:OK Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED Suggested-by: Stanislav Fomichev <[email protected]> Signed-off-by: Philo Lu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin KaFai Lau <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/tcp_rtt.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/tcp_rtt.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/tcp_rtt.c b/tools/testing/selftests/bpf/prog_tests/tcp_rtt.c
index 8fe84da1b9b4..f2b99d95d916 100644
--- a/tools/testing/selftests/bpf/prog_tests/tcp_rtt.c
+++ b/tools/testing/selftests/bpf/prog_tests/tcp_rtt.c
@@ -10,6 +10,9 @@ struct tcp_rtt_storage {
__u32 delivered;
__u32 delivered_ce;
__u32 icsk_retransmits;
+
+ __u32 mrtt_us; /* args[0] */
+ __u32 srtt; /* args[1] */
};
static void send_byte(int fd)
@@ -83,6 +86,17 @@ static int verify_sk(int map_fd, int client_fd, const char *msg, __u32 invoked,
err++;
}
+ /* Precise values of mrtt and srtt are unavailable, just make sure they are nonzero */
+ if (val.mrtt_us == 0) {
+ log_err("%s: unexpected bpf_tcp_sock.args[0] (mrtt_us) %u == 0", msg, val.mrtt_us);
+ err++;
+ }
+
+ if (val.srtt == 0) {
+ log_err("%s: unexpected bpf_tcp_sock.args[1] (srtt) %u == 0", msg, val.srtt);
+ err++;
+ }
+
return err;
}