Message ID | 20201201164357.2623610-2-prankgup@fb.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | Add support to set window_clamp from bpf setsockops | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 45 this patch: 45 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 19 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 45 this patch: 45 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
On Tue, Dec 01, 2020 at 08:43:56AM -0800, Prankur gupta wrote: > Adds a new bpf_setsockopt for TCP sockets, TCP_BPF_WINDOW_CLAMP, > which sets the maximum receiver window size. It will be useful for > limiting receiver window based on RTT. > > Signed-off-by: Prankur gupta <prankgup@fb.com> > --- > net/core/filter.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/net/core/filter.c b/net/core/filter.c > index 2ca5eecebacf..8c52ffae7b0c 100644 > --- a/net/core/filter.c > +++ b/net/core/filter.c > @@ -4910,6 +4910,19 @@ static int _bpf_setsockopt(struct sock *sk, int level, int optname, > tp->notsent_lowat = val; > sk->sk_write_space(sk); > break; > + case TCP_WINDOW_CLAMP: > + if (!val) { > + if (sk->sk_state != TCP_CLOSE) { > + ret = -EINVAL; > + break; > + } > + tp->window_clamp = 0; > + } else { > + tp->window_clamp = > + val < SOCK_MIN_RCVBUF / 2 ? > + SOCK_MIN_RCVBUF / 2 : val; > + } May be extract this logic into a helper instead of copy-paste?
diff --git a/net/core/filter.c b/net/core/filter.c index 2ca5eecebacf..8c52ffae7b0c 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -4910,6 +4910,19 @@ static int _bpf_setsockopt(struct sock *sk, int level, int optname, tp->notsent_lowat = val; sk->sk_write_space(sk); break; + case TCP_WINDOW_CLAMP: + if (!val) { + if (sk->sk_state != TCP_CLOSE) { + ret = -EINVAL; + break; + } + tp->window_clamp = 0; + } else { + tp->window_clamp = + val < SOCK_MIN_RCVBUF / 2 ? + SOCK_MIN_RCVBUF / 2 : val; + } + break; default: ret = -EINVAL; }
Adds a new bpf_setsockopt for TCP sockets, TCP_BPF_WINDOW_CLAMP, which sets the maximum receiver window size. It will be useful for limiting receiver window based on RTT. Signed-off-by: Prankur gupta <prankgup@fb.com> --- net/core/filter.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)