Two important arguments in RTT estimation, mrtt and srtt, are passed to tcp_bpf_rtt(), so that bpf programs get more information about RTT computation in BPF_SOCK_OPS_RTT_CB. The difference between bpf_sock_ops->srtt_us and the srtt here is: the former is an old rtt before update, while srtt passed by tcp_bpf_rtt() is that after update.
Unified · Split
| @@ -2706,10 +2706,10 @@ static inline bool tcp_bpf_ca_needs_ecn(struct sock *sk) · 2705 unmodified lines | |||
| 2706 | return (tcp_call_bpf(sk, BPF_SOCK_OPS_NEEDS_ECN, 0, NULL) == 1); | 2706 | return (tcp_call_bpf(sk, BPF_SOCK_OPS_NEEDS_ECN, 0, NULL) == 1); |
| 2707 | } | 2707 | } |
| 2708 | 2708 | ||
| 2709 | static inline void tcp_bpf_rtt(struct sock *sk) | 2709 | static inline void tcp_bpf_rtt(struct sock *sk, long mrtt, u32 srtt) |
| 2710 | { | 2710 | { |
| 2711 | if (BPF_SOCK_OPS_TEST_FLAG(tcp_sk(sk), BPF_SOCK_OPS_RTT_CB_FLAG)) | 2711 | if (BPF_SOCK_OPS_TEST_FLAG(tcp_sk(sk), BPF_SOCK_OPS_RTT_CB_FLAG)) |
| 2712 | tcp_call_bpf(sk, BPF_SOCK_OPS_RTT_CB, 0, NULL); | 2712 | tcp_call_bpf_2arg(sk, BPF_SOCK_OPS_RTT_CB, mrtt, srtt); |
| 2713 | } | 2713 | } |
| 2714 | 2714 | ||
| 2715 | #if IS_ENABLED(CONFIG_SMC) | 2715 | #if IS_ENABLED(CONFIG_SMC) |
| @@ -6947,6 +6947,8 @@ enum { · 6946 unmodified lines | |||
| 6947 | * socket transition to LISTEN state. | 6947 | * socket transition to LISTEN state. |
| 6948 | */ | 6948 | */ |
| 6949 | BPF_SOCK_OPS_RTT_CB, /* Called on every RTT. | 6949 | BPF_SOCK_OPS_RTT_CB, /* Called on every RTT. |
| 6950 | * Arg1: measured RTT input (mrtt) | ||
| 6951 | * Arg2: updated srtt | ||
| 6950 | */ | 6952 | */ |
| 6951 | BPF_SOCK_OPS_PARSE_HDR_OPT_CB, /* Parse the header option. | 6953 | BPF_SOCK_OPS_PARSE_HDR_OPT_CB, /* Parse the header option. |
| 6952 | * It will be called to handle | 6954 | * It will be called to handle |
| @@ -911,7 +911,7 @@ static void tcp_rtt_estimator(struct sock *sk, long mrtt_us) · 910 unmodified lines | |||
| 911 | tp->rtt_seq = tp->snd_nxt; | 911 | tp->rtt_seq = tp->snd_nxt; |
| 912 | tp->mdev_max_us = tcp_rto_min_us(sk); | 912 | tp->mdev_max_us = tcp_rto_min_us(sk); |
| 913 | 913 | ||
| 914 | tcp_bpf_rtt(sk); | 914 | tcp_bpf_rtt(sk, mrtt_us, srtt); |
| 915 | } | 915 | } |
| 916 | } else { | 916 | } else { |
| 917 | /* no previous measure. */ | 917 | /* no previous measure. */ |
| @@ -921,7 +921,7 @@ static void tcp_rtt_estimator(struct sock *sk, long mrtt_us) · 3 unmodified lines | |||
| 921 | tp->mdev_max_us = tp->rttvar_us; | 921 | tp->mdev_max_us = tp->rttvar_us; |
| 922 | tp->rtt_seq = tp->snd_nxt; | 922 | tp->rtt_seq = tp->snd_nxt; |
| 923 | 923 | ||
| 924 | tcp_bpf_rtt(sk); | 924 | tcp_bpf_rtt(sk, mrtt_us, srtt); |
| 925 | } | 925 | } |
| 926 | tp->srtt_us = max(1U, srtt); | 926 | tp->srtt_us = max(1U, srtt); |
| 927 | } | 927 | } |
| @@ -6947,6 +6947,8 @@ enum { · 6946 unmodified lines | |||
| 6947 | * socket transition to LISTEN state. | 6947 | * socket transition to LISTEN state. |
| 6948 | */ | 6948 | */ |
| 6949 | BPF_SOCK_OPS_RTT_CB, /* Called on every RTT. | 6949 | BPF_SOCK_OPS_RTT_CB, /* Called on every RTT. |
| 6950 | * Arg1: measured RTT input (mrtt) | ||
| 6951 | * Arg2: updated srtt | ||
| 6950 | */ | 6952 | */ |
| 6951 | BPF_SOCK_OPS_PARSE_HDR_OPT_CB, /* Parse the header option. | 6953 | BPF_SOCK_OPS_PARSE_HDR_OPT_CB, /* Parse the header option. |
| 6952 | * It will be called to handle | 6954 | * It will be called to handle |