Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tcp: Add new args for cong_control in tcp_congestion_ops

This patch adds two new arguments for cong_control of struct
tcp_congestion_ops:
- ack
- flag
These two arguments are inherited from the caller tcp_cong_control in
tcp_intput.c. One use case of them is to update cwnd and pacing rate
inside cong_control based on the info they provide. For example, the
flag can be used to decide if it is the right time to raise or reduce a
sender's cwnd.

Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Miao Xu <miaxu@meta.com>
Link: https://lore.kernel.org/r/20240502042318.801932-2-miaxu@meta.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>

authored by

Miao Xu and committed by
Martin KaFai Lau
57bfc760 f8c423d1

+8 -7
+1 -1
include/net/tcp.h
··· 1172 1172 /* call when packets are delivered to update cwnd and pacing rate, 1173 1173 * after all the ca_state processing. (optional) 1174 1174 */ 1175 - void (*cong_control)(struct sock *sk, const struct rate_sample *rs); 1175 + void (*cong_control)(struct sock *sk, u32 ack, int flag, const struct rate_sample *rs); 1176 1176 1177 1177 1178 1178 /* new value of cwnd after loss (required) */
+2 -1
net/ipv4/bpf_tcp_ca.c
··· 307 307 return 0; 308 308 } 309 309 310 - static void bpf_tcp_ca_cong_control(struct sock *sk, const struct rate_sample *rs) 310 + static void bpf_tcp_ca_cong_control(struct sock *sk, u32 ack, int flag, 311 + const struct rate_sample *rs) 311 312 { 312 313 } 313 314
+1 -1
net/ipv4/tcp_bbr.c
··· 1024 1024 bbr_update_gains(sk); 1025 1025 } 1026 1026 1027 - __bpf_kfunc static void bbr_main(struct sock *sk, const struct rate_sample *rs) 1027 + __bpf_kfunc static void bbr_main(struct sock *sk, u32 ack, int flag, const struct rate_sample *rs) 1028 1028 { 1029 1029 struct bbr *bbr = inet_csk_ca(sk); 1030 1030 u32 bw;
+1 -1
net/ipv4/tcp_input.c
··· 3541 3541 const struct inet_connection_sock *icsk = inet_csk(sk); 3542 3542 3543 3543 if (icsk->icsk_ca_ops->cong_control) { 3544 - icsk->icsk_ca_ops->cong_control(sk, rs); 3544 + icsk->icsk_ca_ops->cong_control(sk, ack, flag, rs); 3545 3545 return; 3546 3546 } 3547 3547
+3 -3
tools/testing/selftests/bpf/progs/tcp_ca_kfunc.c
··· 5 5 #include <bpf/bpf_tracing.h> 6 6 7 7 extern void bbr_init(struct sock *sk) __ksym; 8 - extern void bbr_main(struct sock *sk, const struct rate_sample *rs) __ksym; 8 + extern void bbr_main(struct sock *sk, u32 ack, int flag, const struct rate_sample *rs) __ksym; 9 9 extern u32 bbr_sndbuf_expand(struct sock *sk) __ksym; 10 10 extern u32 bbr_undo_cwnd(struct sock *sk) __ksym; 11 11 extern void bbr_cwnd_event(struct sock *sk, enum tcp_ca_event event) __ksym; ··· 42 42 } 43 43 44 44 SEC("struct_ops/cong_control") 45 - void BPF_PROG(cong_control, struct sock *sk, const struct rate_sample *rs) 45 + void BPF_PROG(cong_control, struct sock *sk, u32 ack, int flag, const struct rate_sample *rs) 46 46 { 47 - bbr_main(sk, rs); 47 + bbr_main(sk, ack, flag, rs); 48 48 } 49 49 50 50 SEC("struct_ops/cong_avoid")