summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorLawrence Brakmo <brakmo@fb.com>2017-07-01 06:02:51 +0300
committerDavid S. Miller <davem@davemloft.net>2017-07-02 02:15:14 +0300
commitfc7478103c84af437ca3bfae71a82631f770bf7e (patch)
tree1206a0518c692212f01c133a8aac0c9385946fc6 /net/core
parentbb56d4449d8b8de1f22a07f007bb91cb30fcc7cc (diff)
downloadlinux-fc7478103c84af437ca3bfae71a82631f770bf7e.tar.xz
bpf: Adds support for setting initial cwnd
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>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/filter.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index 12df52711fe8..794be0a454f5 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -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;