tcp: Add new args for cong_control in tcp_congestion_ops
authorMiao Xu <miaxu@meta.com>
Thu, 2 May 2024 04:23:16 +0000 (21:23 -0700)
committerMartin KaFai Lau <martin.lau@kernel.org>
Thu, 2 May 2024 23:26:56 +0000 (16:26 -0700)
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>
include/net/tcp.h
net/ipv4/bpf_tcp_ca.c
net/ipv4/tcp_bbr.c
net/ipv4/tcp_input.c
tools/testing/selftests/bpf/progs/tcp_ca_kfunc.c

index fe98fb01879bf524c3aa356ff1ea8d3680f80b76..7294da8fb7808f757923cc7df867772fad5b8a15 100644 (file)
@@ -1172,7 +1172,7 @@ struct tcp_congestion_ops {
        /* call when packets are delivered to update cwnd and pacing rate,
         * after all the ca_state processing. (optional)
         */
-       void (*cong_control)(struct sock *sk, const struct rate_sample *rs);
+       void (*cong_control)(struct sock *sk, u32 ack, int flag, const struct rate_sample *rs);
 
 
        /* new value of cwnd after loss (required) */
index 7f518ea5f4ac7d47f67e63c3e499d7b3e58f5636..6bd7f8db189a96e5da54e4aa2864358318c2483a 100644 (file)
@@ -307,7 +307,8 @@ static u32 bpf_tcp_ca_min_tso_segs(struct sock *sk)
        return 0;
 }
 
-static void bpf_tcp_ca_cong_control(struct sock *sk, const struct rate_sample *rs)
+static void bpf_tcp_ca_cong_control(struct sock *sk, u32 ack, int flag,
+                                   const struct rate_sample *rs)
 {
 }
 
index 7e52ab24e40ae297a252fe1efa19bea374fe7502..760941e55153e6614e1043f674a720ad46fa9169 100644 (file)
@@ -1024,7 +1024,7 @@ static void bbr_update_model(struct sock *sk, const struct rate_sample *rs)
        bbr_update_gains(sk);
 }
 
-__bpf_kfunc static void bbr_main(struct sock *sk, const struct rate_sample *rs)
+__bpf_kfunc static void bbr_main(struct sock *sk, u32 ack, int flag, const struct rate_sample *rs)
 {
        struct bbr *bbr = inet_csk_ca(sk);
        u32 bw;
index 53e1150f706fdd00fc1908985ca6b4f201d7d717..23ccfc7b1d3cb6e8c2e5f56db3b09ba4003ebe0e 100644 (file)
@@ -3541,7 +3541,7 @@ static void tcp_cong_control(struct sock *sk, u32 ack, u32 acked_sacked,
        const struct inet_connection_sock *icsk = inet_csk(sk);
 
        if (icsk->icsk_ca_ops->cong_control) {
-               icsk->icsk_ca_ops->cong_control(sk, rs);
+               icsk->icsk_ca_ops->cong_control(sk, ack, flag, rs);
                return;
        }
 
index fcfbfe0336b4448c8a192e433baa91d11f1bdf16..52b610357309caf992444c181cd98137b89b1797 100644 (file)
@@ -5,7 +5,7 @@
 #include <bpf/bpf_tracing.h>
 
 extern void bbr_init(struct sock *sk) __ksym;
-extern void bbr_main(struct sock *sk, const struct rate_sample *rs) __ksym;
+extern void bbr_main(struct sock *sk, u32 ack, int flag, const struct rate_sample *rs) __ksym;
 extern u32 bbr_sndbuf_expand(struct sock *sk) __ksym;
 extern u32 bbr_undo_cwnd(struct sock *sk) __ksym;
 extern void bbr_cwnd_event(struct sock *sk, enum tcp_ca_event event) __ksym;
@@ -42,9 +42,9 @@ void BPF_PROG(in_ack_event, struct sock *sk, u32 flags)
 }
 
 SEC("struct_ops/cong_control")
-void BPF_PROG(cong_control, struct sock *sk, const struct rate_sample *rs)
+void BPF_PROG(cong_control, struct sock *sk, u32 ack, int flag, const struct rate_sample *rs)
 {
-       bbr_main(sk, rs);
+       bbr_main(sk, ack, flag, rs);
 }
 
 SEC("struct_ops/cong_avoid")