Commit f89013f6 authored by Lawrence Brakmo's avatar Lawrence Brakmo Committed by Alexei Starovoitov

bpf: Add sock_ops RTO callback

Adds an optional call to sock_ops BPF program based on whether the
BPF_SOCK_OPS_RTO_CB_FLAG is set in bpf_sock_ops_flags.
The BPF program is passed 2 arguments: icsk_retransmits and whether the
RTO has expired.
Signed-off-by: default avatarLawrence Brakmo <brakmo@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent b13d8807
...@@ -982,7 +982,8 @@ struct bpf_sock_ops { ...@@ -982,7 +982,8 @@ struct bpf_sock_ops {
}; };
/* Definitions for bpf_sock_ops_cb_flags */ /* Definitions for bpf_sock_ops_cb_flags */
#define BPF_SOCK_OPS_ALL_CB_FLAGS 0 /* Mask of all currently #define BPF_SOCK_OPS_RTO_CB_FLAG (1<<0)
#define BPF_SOCK_OPS_ALL_CB_FLAGS 0x1 /* Mask of all currently
* supported cb flags * supported cb flags
*/ */
...@@ -1019,6 +1020,11 @@ enum { ...@@ -1019,6 +1020,11 @@ enum {
* a congestion threshold. RTTs above * a congestion threshold. RTTs above
* this indicate congestion * this indicate congestion
*/ */
BPF_SOCK_OPS_RTO_CB, /* Called when an RTO has triggered.
* Arg1: value of icsk_retransmits
* Arg2: value of icsk_rto
* Arg3: whether RTO has expired
*/
}; };
#define TCP_BPF_IW 1001 /* Set TCP initial congestion window */ #define TCP_BPF_IW 1001 /* Set TCP initial congestion window */
......
...@@ -213,11 +213,18 @@ static int tcp_write_timeout(struct sock *sk) ...@@ -213,11 +213,18 @@ static int tcp_write_timeout(struct sock *sk)
icsk->icsk_user_timeout); icsk->icsk_user_timeout);
} }
tcp_fastopen_active_detect_blackhole(sk, expired); tcp_fastopen_active_detect_blackhole(sk, expired);
if (BPF_SOCK_OPS_TEST_FLAG(tp, BPF_SOCK_OPS_RTO_CB_FLAG))
tcp_call_bpf_3arg(sk, BPF_SOCK_OPS_RTO_CB,
icsk->icsk_retransmits,
icsk->icsk_rto, (int)expired);
if (expired) { if (expired) {
/* Has it gone just too far? */ /* Has it gone just too far? */
tcp_write_err(sk); tcp_write_err(sk);
return 1; return 1;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment