mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 20:46:48 +02:00
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 <sdf@google.com> Signed-off-by: Philo Lu <lulie@linux.alibaba.com> Link: https://lore.kernel.org/r/20240425161724.73707-3-lulie@linux.alibaba.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
This commit is contained in:
parent
48e2cd3e3d
commit
7eb4f66b38
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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] */
|
||||
};
|
||||
|
||||
struct {
|
||||
|
|
@ -55,5 +58,8 @@ int _sockops(struct bpf_sock_ops *ctx)
|
|||
storage->delivered_ce = tcp_sk->delivered_ce;
|
||||
storage->icsk_retransmits = tcp_sk->icsk_retransmits;
|
||||
|
||||
storage->mrtt_us = ctx->args[0];
|
||||
storage->srtt = ctx->args[1];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user