]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
bpf: Adds support for setting initial cwnd
authorLawrence Brakmo <brakmo@fb.com>
Sat, 1 Jul 2017 03:02:51 +0000 (20:02 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 1 Jul 2017 23:15:14 +0000 (16:15 -0700)
Adds a new bpf_setsockopt for TCP sockets, TCP_BPF_IW, which sets the
initial congestion window. This can be used when the hosts are far
apart (large RTTs) and it is safe to start with a large inital cwnd.

Signed-off-by: Lawrence Brakmo <brakmo@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/uapi/linux/bpf.h
net/core/filter.c

index cc4725982bd843b1dec490e2de32c6dd0d84d20a..32755b538652d0e3614f81fbbe47a157dc9220bf 100644 (file)
@@ -783,4 +783,6 @@ enum {
                                         */
 };
 
+#define TCP_BPF_IW             1001    /* Set TCP initial congestion window */
+
 #endif /* _UAPI__LINUX_BPF_H__ */
index 12df52711fe855c6b173462be732ca4d2ba337c1..794be0a454f54cdf52c8fec80d72923900b172da 100644 (file)
@@ -2732,7 +2732,23 @@ BPF_CALL_5(bpf_setsockopt, struct bpf_sock_ops_kern *, bpf_sock,
                                tcp_reinit_congestion_control(sk,
                                        inet_csk(sk)->icsk_ca_ops);
                } else {
-                       ret = -EINVAL;
+                       struct tcp_sock *tp = tcp_sk(sk);
+
+                       if (optlen != sizeof(int))
+                               return -EINVAL;
+
+                       val = *((int *)optval);
+                       /* Only some options are supported */
+                       switch (optname) {
+                       case TCP_BPF_IW:
+                               if (val <= 0 || tp->data_segs_out > 0)
+                                       ret = -EINVAL;
+                               else
+                                       tp->snd_cwnd = val;
+                               break;
+                       default:
+                               ret = -EINVAL;
+                       }
                }
 #else
                ret = -EINVAL;