* [PATCH bpf-next 1/2] bpf: allow to retrieve sol_socket opts from sock_addr progs @ 2021-01-11 16:17 Daniel Borkmann 2021-01-11 16:17 ` [PATCH bpf-next 2/2] bpf: extend bind v4/v6 selftests for mark/prio/bindtoifindex Daniel Borkmann 2021-01-11 20:03 ` [PATCH bpf-next 1/2] bpf: allow to retrieve sol_socket opts from sock_addr progs Yonghong Song 0 siblings, 2 replies; 6+ messages in thread From: Daniel Borkmann @ 2021-01-11 16:17 UTC (permalink / raw) To: ast; +Cc: yhs, bpf, netdev, Daniel Borkmann The _bpf_setsockopt() is able to set some of the SOL_SOCKET level options, however, _bpf_getsockopt() has little support to actually retrieve them. This small patch adds few misc options such as SO_MARK, SO_PRIORITY and SO_BINDTOIFINDEX. For the latter getter and setter are added. The mark and priority in particular allow to retrieve the options from BPF cgroup hooks to then implement custom behavior / settings on the syscall hooks compared to other sockets that stick to the defaults, for example. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> --- net/core/filter.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index 255aeee72402..9ab94e90d660 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -4770,6 +4770,10 @@ static int _bpf_setsockopt(struct sock *sk, int level, int optname, ifindex = dev->ifindex; dev_put(dev); } + fallthrough; + case SO_BINDTOIFINDEX: + if (optname == SO_BINDTOIFINDEX) + ifindex = val; ret = sock_bindtoindex(sk, ifindex, false); break; case SO_KEEPALIVE: @@ -4932,8 +4936,25 @@ static int _bpf_getsockopt(struct sock *sk, int level, int optname, sock_owned_by_me(sk); + if (level == SOL_SOCKET) { + if (optlen != sizeof(int)) + goto err_clear; + + switch (optname) { + case SO_MARK: + *((int *)optval) = sk->sk_mark; + break; + case SO_PRIORITY: + *((int *)optval) = sk->sk_priority; + break; + case SO_BINDTOIFINDEX: + *((int *)optval) = sk->sk_bound_dev_if; + break; + default: + goto err_clear; + } #ifdef CONFIG_INET - if (level == SOL_TCP && sk->sk_prot->getsockopt == tcp_getsockopt) { + } else if (level == SOL_TCP && sk->sk_prot->getsockopt == tcp_getsockopt) { struct inet_connection_sock *icsk; struct tcp_sock *tp; @@ -4986,12 +5007,12 @@ static int _bpf_getsockopt(struct sock *sk, int level, int optname, default: goto err_clear; } +#endif #endif } else { goto err_clear; } return 0; -#endif err_clear: memset(optval, 0, optlen); return -EINVAL; -- 2.21.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH bpf-next 2/2] bpf: extend bind v4/v6 selftests for mark/prio/bindtoifindex 2021-01-11 16:17 [PATCH bpf-next 1/2] bpf: allow to retrieve sol_socket opts from sock_addr progs Daniel Borkmann @ 2021-01-11 16:17 ` Daniel Borkmann 2021-01-11 20:15 ` Yonghong Song 2021-01-11 20:03 ` [PATCH bpf-next 1/2] bpf: allow to retrieve sol_socket opts from sock_addr progs Yonghong Song 1 sibling, 1 reply; 6+ messages in thread From: Daniel Borkmann @ 2021-01-11 16:17 UTC (permalink / raw) To: ast; +Cc: yhs, bpf, netdev, Daniel Borkmann Extend existing cgroup bind4/bind6 tests to add coverage for setting and retrieving SO_MARK, SO_PRIORITY and SO_BINDTOIFINDEX at the bind hook. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> --- .../testing/selftests/bpf/progs/bind4_prog.c | 41 +++++++++++++++++-- .../testing/selftests/bpf/progs/bind6_prog.c | 41 +++++++++++++++++-- 2 files changed, 74 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/bind4_prog.c b/tools/testing/selftests/bpf/progs/bind4_prog.c index c6520f21f5f5..4479ac27b1d3 100644 --- a/tools/testing/selftests/bpf/progs/bind4_prog.c +++ b/tools/testing/selftests/bpf/progs/bind4_prog.c @@ -29,18 +29,47 @@ static __inline int bind_to_device(struct bpf_sock_addr *ctx) char veth2[IFNAMSIZ] = "test_sock_addr2"; char missing[IFNAMSIZ] = "nonexistent_dev"; char del_bind[IFNAMSIZ] = ""; + int veth1_idx, veth2_idx; if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, - &veth1, sizeof(veth1))) + &veth1, sizeof(veth1))) + return 1; + if (bpf_getsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, + &veth1_idx, sizeof(veth1_idx)) || !veth1_idx) return 1; if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, - &veth2, sizeof(veth2))) + &veth2, sizeof(veth2))) + return 1; + if (bpf_getsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, + &veth2_idx, sizeof(veth2_idx)) || !veth2_idx || + veth1_idx == veth2_idx) return 1; if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, - &missing, sizeof(missing)) != -ENODEV) + &missing, sizeof(missing)) != -ENODEV) + return 1; + if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, + &veth1_idx, sizeof(veth1_idx))) return 1; if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, - &del_bind, sizeof(del_bind))) + &del_bind, sizeof(del_bind))) + return 1; + + return 0; +} + +static __inline int misc_opts(struct bpf_sock_addr *ctx, int opt) +{ + int old, tmp, new = 0xeb9f; + + if (bpf_getsockopt(ctx, SOL_SOCKET, opt, &old, sizeof(old)) || + old == new) + return 1; + if (bpf_setsockopt(ctx, SOL_SOCKET, opt, &new, sizeof(new))) + return 1; + if (bpf_getsockopt(ctx, SOL_SOCKET, opt, &tmp, sizeof(tmp)) || + tmp != new) + return 1; + if (bpf_setsockopt(ctx, SOL_SOCKET, opt, &old, sizeof(old))) return 1; return 0; @@ -93,6 +122,10 @@ int bind_v4_prog(struct bpf_sock_addr *ctx) if (bind_to_device(ctx)) return 0; + /* Test for misc socket options. */ + if (misc_opts(ctx, SO_MARK) || misc_opts(ctx, SO_PRIORITY)) + return 0; + ctx->user_ip4 = bpf_htonl(SERV4_REWRITE_IP); ctx->user_port = bpf_htons(SERV4_REWRITE_PORT); diff --git a/tools/testing/selftests/bpf/progs/bind6_prog.c b/tools/testing/selftests/bpf/progs/bind6_prog.c index 4358e44dcf47..1b4142fcdd4b 100644 --- a/tools/testing/selftests/bpf/progs/bind6_prog.c +++ b/tools/testing/selftests/bpf/progs/bind6_prog.c @@ -35,18 +35,47 @@ static __inline int bind_to_device(struct bpf_sock_addr *ctx) char veth2[IFNAMSIZ] = "test_sock_addr2"; char missing[IFNAMSIZ] = "nonexistent_dev"; char del_bind[IFNAMSIZ] = ""; + int veth1_idx, veth2_idx; if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, - &veth1, sizeof(veth1))) + &veth1, sizeof(veth1))) + return 1; + if (bpf_getsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, + &veth1_idx, sizeof(veth1_idx)) || !veth1_idx) return 1; if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, - &veth2, sizeof(veth2))) + &veth2, sizeof(veth2))) + return 1; + if (bpf_getsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, + &veth2_idx, sizeof(veth2_idx)) || !veth2_idx || + veth1_idx == veth2_idx) return 1; if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, - &missing, sizeof(missing)) != -ENODEV) + &missing, sizeof(missing)) != -ENODEV) + return 1; + if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, + &veth1_idx, sizeof(veth1_idx))) return 1; if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, - &del_bind, sizeof(del_bind))) + &del_bind, sizeof(del_bind))) + return 1; + + return 0; +} + +static __inline int misc_opts(struct bpf_sock_addr *ctx, int opt) +{ + int old, tmp, new = 0xeb9f; + + if (bpf_getsockopt(ctx, SOL_SOCKET, opt, &old, sizeof(old)) || + old == new) + return 1; + if (bpf_setsockopt(ctx, SOL_SOCKET, opt, &new, sizeof(new))) + return 1; + if (bpf_getsockopt(ctx, SOL_SOCKET, opt, &tmp, sizeof(tmp)) || + tmp != new) + return 1; + if (bpf_setsockopt(ctx, SOL_SOCKET, opt, &old, sizeof(old))) return 1; return 0; @@ -107,6 +136,10 @@ int bind_v6_prog(struct bpf_sock_addr *ctx) if (bind_to_device(ctx)) return 0; + /* Test for misc socket options. */ + if (misc_opts(ctx, SO_MARK) || misc_opts(ctx, SO_PRIORITY)) + return 0; + ctx->user_ip6[0] = bpf_htonl(SERV6_REWRITE_IP_0); ctx->user_ip6[1] = bpf_htonl(SERV6_REWRITE_IP_1); ctx->user_ip6[2] = bpf_htonl(SERV6_REWRITE_IP_2); -- 2.21.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next 2/2] bpf: extend bind v4/v6 selftests for mark/prio/bindtoifindex 2021-01-11 16:17 ` [PATCH bpf-next 2/2] bpf: extend bind v4/v6 selftests for mark/prio/bindtoifindex Daniel Borkmann @ 2021-01-11 20:15 ` Yonghong Song 2021-01-11 21:01 ` Daniel Borkmann 0 siblings, 1 reply; 6+ messages in thread From: Yonghong Song @ 2021-01-11 20:15 UTC (permalink / raw) To: Daniel Borkmann, ast; +Cc: bpf, netdev On 1/11/21 8:17 AM, Daniel Borkmann wrote: > Extend existing cgroup bind4/bind6 tests to add coverage for setting and > retrieving SO_MARK, SO_PRIORITY and SO_BINDTOIFINDEX at the bind hook. > > Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Ack with a minor comments below. Acked-by: Yonghong Song <yhs@fb.com> > --- > .../testing/selftests/bpf/progs/bind4_prog.c | 41 +++++++++++++++++-- > .../testing/selftests/bpf/progs/bind6_prog.c | 41 +++++++++++++++++-- > 2 files changed, 74 insertions(+), 8 deletions(-) > > diff --git a/tools/testing/selftests/bpf/progs/bind4_prog.c b/tools/testing/selftests/bpf/progs/bind4_prog.c > index c6520f21f5f5..4479ac27b1d3 100644 > --- a/tools/testing/selftests/bpf/progs/bind4_prog.c > +++ b/tools/testing/selftests/bpf/progs/bind4_prog.c > @@ -29,18 +29,47 @@ static __inline int bind_to_device(struct bpf_sock_addr *ctx) > char veth2[IFNAMSIZ] = "test_sock_addr2"; > char missing[IFNAMSIZ] = "nonexistent_dev"; > char del_bind[IFNAMSIZ] = ""; > + int veth1_idx, veth2_idx; > > if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, > - &veth1, sizeof(veth1))) > + &veth1, sizeof(veth1))) > + return 1; > + if (bpf_getsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, > + &veth1_idx, sizeof(veth1_idx)) || !veth1_idx) > return 1; > if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, > - &veth2, sizeof(veth2))) > + &veth2, sizeof(veth2))) > + return 1; > + if (bpf_getsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, > + &veth2_idx, sizeof(veth2_idx)) || !veth2_idx || > + veth1_idx == veth2_idx) > return 1; > if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, > - &missing, sizeof(missing)) != -ENODEV) > + &missing, sizeof(missing)) != -ENODEV) > + return 1; > + if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, > + &veth1_idx, sizeof(veth1_idx))) > return 1; > if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, > - &del_bind, sizeof(del_bind))) > + &del_bind, sizeof(del_bind))) > + return 1; > + > + return 0; > +} > + > +static __inline int misc_opts(struct bpf_sock_addr *ctx, int opt) > +{ > + int old, tmp, new = 0xeb9f; > + > + if (bpf_getsockopt(ctx, SOL_SOCKET, opt, &old, sizeof(old)) || > + old == new) > + return 1; Here, we assume old never equals to new. it would be good to add a comment to explicitly state this is true. Maybe in the future somebody will try to add more misc_opts which might have conflict here. Alternatively, you could pass in "new" values from user space with global variables for each option, but that may be an overkill. > + if (bpf_setsockopt(ctx, SOL_SOCKET, opt, &new, sizeof(new))) > + return 1; > + if (bpf_getsockopt(ctx, SOL_SOCKET, opt, &tmp, sizeof(tmp)) || > + tmp != new) > + return 1; > + if (bpf_setsockopt(ctx, SOL_SOCKET, opt, &old, sizeof(old))) > return 1; > > return 0; > @@ -93,6 +122,10 @@ int bind_v4_prog(struct bpf_sock_addr *ctx) > if (bind_to_device(ctx)) > return 0; > > + /* Test for misc socket options. */ > + if (misc_opts(ctx, SO_MARK) || misc_opts(ctx, SO_PRIORITY)) > + return 0; > + > ctx->user_ip4 = bpf_htonl(SERV4_REWRITE_IP); > ctx->user_port = bpf_htons(SERV4_REWRITE_PORT); > > diff --git a/tools/testing/selftests/bpf/progs/bind6_prog.c b/tools/testing/selftests/bpf/progs/bind6_prog.c > index 4358e44dcf47..1b4142fcdd4b 100644 > --- a/tools/testing/selftests/bpf/progs/bind6_prog.c > +++ b/tools/testing/selftests/bpf/progs/bind6_prog.c > @@ -35,18 +35,47 @@ static __inline int bind_to_device(struct bpf_sock_addr *ctx) > char veth2[IFNAMSIZ] = "test_sock_addr2"; > char missing[IFNAMSIZ] = "nonexistent_dev"; > char del_bind[IFNAMSIZ] = ""; > + int veth1_idx, veth2_idx; > > if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, > - &veth1, sizeof(veth1))) > + &veth1, sizeof(veth1))) > + return 1; > + if (bpf_getsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, > + &veth1_idx, sizeof(veth1_idx)) || !veth1_idx) > return 1; > if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, > - &veth2, sizeof(veth2))) > + &veth2, sizeof(veth2))) > + return 1; > + if (bpf_getsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, > + &veth2_idx, sizeof(veth2_idx)) || !veth2_idx || > + veth1_idx == veth2_idx) > return 1; > if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, > - &missing, sizeof(missing)) != -ENODEV) > + &missing, sizeof(missing)) != -ENODEV) > + return 1; > + if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, > + &veth1_idx, sizeof(veth1_idx))) > return 1; > if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, > - &del_bind, sizeof(del_bind))) > + &del_bind, sizeof(del_bind))) > + return 1; > + > + return 0; > +} > + > +static __inline int misc_opts(struct bpf_sock_addr *ctx, int opt) > +{ > + int old, tmp, new = 0xeb9f; > + > + if (bpf_getsockopt(ctx, SOL_SOCKET, opt, &old, sizeof(old)) || > + old == new) > + return 1; > + if (bpf_setsockopt(ctx, SOL_SOCKET, opt, &new, sizeof(new))) > + return 1; > + if (bpf_getsockopt(ctx, SOL_SOCKET, opt, &tmp, sizeof(tmp)) || > + tmp != new) > + return 1; > + if (bpf_setsockopt(ctx, SOL_SOCKET, opt, &old, sizeof(old))) > return 1; > > return 0; > @@ -107,6 +136,10 @@ int bind_v6_prog(struct bpf_sock_addr *ctx) > if (bind_to_device(ctx)) > return 0; > > + /* Test for misc socket options. */ > + if (misc_opts(ctx, SO_MARK) || misc_opts(ctx, SO_PRIORITY)) > + return 0; > + > ctx->user_ip6[0] = bpf_htonl(SERV6_REWRITE_IP_0); > ctx->user_ip6[1] = bpf_htonl(SERV6_REWRITE_IP_1); > ctx->user_ip6[2] = bpf_htonl(SERV6_REWRITE_IP_2); > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next 2/2] bpf: extend bind v4/v6 selftests for mark/prio/bindtoifindex 2021-01-11 20:15 ` Yonghong Song @ 2021-01-11 21:01 ` Daniel Borkmann 0 siblings, 0 replies; 6+ messages in thread From: Daniel Borkmann @ 2021-01-11 21:01 UTC (permalink / raw) To: Yonghong Song, ast; +Cc: bpf, netdev On 1/11/21 9:15 PM, Yonghong Song wrote: > On 1/11/21 8:17 AM, Daniel Borkmann wrote: >> Extend existing cgroup bind4/bind6 tests to add coverage for setting and >> retrieving SO_MARK, SO_PRIORITY and SO_BINDTOIFINDEX at the bind hook. >> >> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> > > Ack with a minor comments below. > > Acked-by: Yonghong Song <yhs@fb.com> > >> --- >> .../testing/selftests/bpf/progs/bind4_prog.c | 41 +++++++++++++++++-- >> .../testing/selftests/bpf/progs/bind6_prog.c | 41 +++++++++++++++++-- >> 2 files changed, 74 insertions(+), 8 deletions(-) >> >> diff --git a/tools/testing/selftests/bpf/progs/bind4_prog.c b/tools/testing/selftests/bpf/progs/bind4_prog.c >> index c6520f21f5f5..4479ac27b1d3 100644 >> --- a/tools/testing/selftests/bpf/progs/bind4_prog.c >> +++ b/tools/testing/selftests/bpf/progs/bind4_prog.c >> @@ -29,18 +29,47 @@ static __inline int bind_to_device(struct bpf_sock_addr *ctx) >> char veth2[IFNAMSIZ] = "test_sock_addr2"; >> char missing[IFNAMSIZ] = "nonexistent_dev"; >> char del_bind[IFNAMSIZ] = ""; >> + int veth1_idx, veth2_idx; >> if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, >> - &veth1, sizeof(veth1))) >> + &veth1, sizeof(veth1))) >> + return 1; >> + if (bpf_getsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, >> + &veth1_idx, sizeof(veth1_idx)) || !veth1_idx) >> return 1; >> if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, >> - &veth2, sizeof(veth2))) >> + &veth2, sizeof(veth2))) >> + return 1; >> + if (bpf_getsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, >> + &veth2_idx, sizeof(veth2_idx)) || !veth2_idx || >> + veth1_idx == veth2_idx) >> return 1; >> if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, >> - &missing, sizeof(missing)) != -ENODEV) >> + &missing, sizeof(missing)) != -ENODEV) >> + return 1; >> + if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, >> + &veth1_idx, sizeof(veth1_idx))) >> return 1; >> if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, >> - &del_bind, sizeof(del_bind))) >> + &del_bind, sizeof(del_bind))) >> + return 1; >> + >> + return 0; >> +} >> + >> +static __inline int misc_opts(struct bpf_sock_addr *ctx, int opt) >> +{ >> + int old, tmp, new = 0xeb9f; >> + >> + if (bpf_getsockopt(ctx, SOL_SOCKET, opt, &old, sizeof(old)) || >> + old == new) >> + return 1; > > Here, we assume old never equals to new. it would be good to add > a comment to explicitly state this is true. Maybe in the future > somebody will try to add more misc_opts which might have conflict > here. I thought it's obvious, but yes I can add a comment. > Alternatively, you could pass in "new" values > from user space with global variables for each option, > but that may be an overkill. Agree, that's overkill. Thanks, Daniel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next 1/2] bpf: allow to retrieve sol_socket opts from sock_addr progs 2021-01-11 16:17 [PATCH bpf-next 1/2] bpf: allow to retrieve sol_socket opts from sock_addr progs Daniel Borkmann 2021-01-11 16:17 ` [PATCH bpf-next 2/2] bpf: extend bind v4/v6 selftests for mark/prio/bindtoifindex Daniel Borkmann @ 2021-01-11 20:03 ` Yonghong Song 1 sibling, 0 replies; 6+ messages in thread From: Yonghong Song @ 2021-01-11 20:03 UTC (permalink / raw) To: Daniel Borkmann, ast; +Cc: bpf, netdev On 1/11/21 8:17 AM, Daniel Borkmann wrote: > The _bpf_setsockopt() is able to set some of the SOL_SOCKET level options, > however, _bpf_getsockopt() has little support to actually retrieve them. > This small patch adds few misc options such as SO_MARK, SO_PRIORITY and > SO_BINDTOIFINDEX. For the latter getter and setter are added. The mark and > priority in particular allow to retrieve the options from BPF cgroup hooks > to then implement custom behavior / settings on the syscall hooks compared > to other sockets that stick to the defaults, for example. > > Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Yonghong Song <yhs@fb.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next 1/2] bpf: allow to retrieve sol_socket opts from sock_addr progs
@ 2021-01-11 21:51 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-01-11 21:51 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 22162 bytes --]
CC: kbuild-all(a)lists.01.org
In-Reply-To: <9dbbf51e7f6868b3e9c8610a8d49b4493fb1b50f.1610381606.git.daniel@iogearbox.net>
References: <9dbbf51e7f6868b3e9c8610a8d49b4493fb1b50f.1610381606.git.daniel@iogearbox.net>
TO: Daniel Borkmann <daniel@iogearbox.net>
TO: ast(a)kernel.org
CC: yhs(a)fb.com
CC: bpf(a)vger.kernel.org
CC: netdev(a)vger.kernel.org
CC: Daniel Borkmann <daniel@iogearbox.net>
Hi Daniel,
I love your patch! Perhaps something to improve:
[auto build test WARNING on bpf-next/master]
url: https://github.com/0day-ci/linux/commits/Daniel-Borkmann/bpf-allow-to-retrieve-sol_socket-opts-from-sock_addr-progs/20210112-002246
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
"cppcheck warnings: (new ones prefixed by >>)"
net/core/filter.c:612:12: warning: Pointer addition with NULL pointer. [nullPointerArithmetic]
new_insn += 3;
^
net/core/filter.c:560:43: note: Assignment 'first_insn=NULL', assigned value is 0
struct bpf_insn *new_insn, *first_insn = NULL;
^
net/core/filter.c:580:13: note: Assignment 'new_insn=first_insn', assigned value is 0
new_insn = first_insn;
^
net/core/filter.c:612:3: note: Compound assignment '+=', assigned value is 3
new_insn += 3;
^
net/core/filter.c:612:12: note: Null pointer addition
new_insn += 3;
^
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
net/core/filter.c:8419:7: warning: Return value of function offsetof() is not used. [ignoredReturnValue]
case offsetof(struct __sk_buff, cb[0]) ...
^
net/core/filter.c:8544:7: warning: Return value of function offsetof() is not used. [ignoredReturnValue]
case offsetof(struct __sk_buff, remote_ip6[0]) ...
^
net/core/filter.c:8564:7: warning: Return value of function offsetof() is not used. [ignoredReturnValue]
case offsetof(struct __sk_buff, local_ip6[0]) ...
^
net/core/filter.c:9231:7: warning: Return value of function offsetof() is not used. [ignoredReturnValue]
case offsetof(struct bpf_sock_ops, replylong[0]) ...
^
net/core/filter.c:9283:7: warning: Return value of function offsetof() is not used. [ignoredReturnValue]
case offsetof(struct bpf_sock_ops, remote_ip6[0]) ...
^
net/core/filter.c:9304:7: warning: Return value of function offsetof() is not used. [ignoredReturnValue]
case offsetof(struct bpf_sock_ops, local_ip6[0]) ...
^
net/core/filter.c:9591:7: warning: Return value of function offsetof() is not used. [ignoredReturnValue]
case offsetof(struct sk_msg_md, remote_ip6[0]) ...
^
net/core/filter.c:9612:7: warning: Return value of function offsetof() is not used. [ignoredReturnValue]
case offsetof(struct sk_msg_md, local_ip6[0]) ...
^
>> net/core/filter.c:4777:8: warning: Variable 'ret' is reassigned a value before the old one has been used. 'break;' missing? [redundantAssignInSwitch]
ret = sock_bindtoindex(sk, ifindex, false);
^
net/core/filter.c:4764:9: note: Variable 'ret' is reassigned a value before the old one has been used. 'break;' missing?
ret = -ENODEV;
^
net/core/filter.c:4777:8: note: Variable 'ret' is reassigned a value before the old one has been used. 'break;' missing?
ret = sock_bindtoindex(sk, ifindex, false);
^
vim +4777 net/core/filter.c
6acc5c2910689fc6 Chenbo Feng 2017-03-22 4696
beecf11bc2188067 Stanislav Fomichev 2020-04-30 4697 static int _bpf_setsockopt(struct sock *sk, int level, int optname,
5cdc744caab7cb0d Neal Cardwell 2020-09-10 4698 char *optval, int optlen)
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4699 {
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4700 char devname[IFNAMSIZ];
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4701 int val, valbool;
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4702 struct net *net;
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4703 int ifindex;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4704 int ret = 0;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4705
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4706 if (!sk_fullsock(sk))
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4707 return -EINVAL;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4708
beecf11bc2188067 Stanislav Fomichev 2020-04-30 4709 sock_owned_by_me(sk);
beecf11bc2188067 Stanislav Fomichev 2020-04-30 4710
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4711 if (level == SOL_SOCKET) {
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4712 if (optlen != sizeof(int) && optname != SO_BINDTODEVICE)
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4713 return -EINVAL;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4714 val = *((int *)optval);
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4715 valbool = val ? 1 : 0;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4716
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4717 /* Only some socketops are supported */
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4718 switch (optname) {
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4719 case SO_RCVBUF:
c9e4576743eeda8d Yafang Shao 2019-01-23 4720 val = min_t(u32, val, sysctl_rmem_max);
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4721 sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
ebb3b78db7bf8422 Eric Dumazet 2019-10-10 4722 WRITE_ONCE(sk->sk_rcvbuf,
ebb3b78db7bf8422 Eric Dumazet 2019-10-10 4723 max_t(int, val * 2, SOCK_MIN_RCVBUF));
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4724 break;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4725 case SO_SNDBUF:
c9e4576743eeda8d Yafang Shao 2019-01-23 4726 val = min_t(u32, val, sysctl_wmem_max);
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4727 sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
e292f05e0df73f9f Eric Dumazet 2019-10-10 4728 WRITE_ONCE(sk->sk_sndbuf,
e292f05e0df73f9f Eric Dumazet 2019-10-10 4729 max_t(int, val * 2, SOCK_MIN_SNDBUF));
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4730 break;
76a9ebe811fb3d06 Eric Dumazet 2018-10-15 4731 case SO_MAX_PACING_RATE: /* 32bit version */
e224c390a6259c52 Yuchung Cheng 2019-01-17 4732 if (val != ~0U)
e224c390a6259c52 Yuchung Cheng 2019-01-17 4733 cmpxchg(&sk->sk_pacing_status,
e224c390a6259c52 Yuchung Cheng 2019-01-17 4734 SK_PACING_NONE,
e224c390a6259c52 Yuchung Cheng 2019-01-17 4735 SK_PACING_NEEDED);
700465fd338fe5df Ke Li 2020-10-22 4736 sk->sk_max_pacing_rate = (val == ~0U) ?
700465fd338fe5df Ke Li 2020-10-22 4737 ~0UL : (unsigned int)val;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4738 sk->sk_pacing_rate = min(sk->sk_pacing_rate,
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4739 sk->sk_max_pacing_rate);
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4740 break;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4741 case SO_PRIORITY:
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4742 sk->sk_priority = val;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4743 break;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4744 case SO_RCVLOWAT:
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4745 if (val < 0)
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4746 val = INT_MAX;
eac66402d1c342f0 Eric Dumazet 2019-10-09 4747 WRITE_ONCE(sk->sk_rcvlowat, val ? : 1);
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4748 break;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4749 case SO_MARK:
f4924f24da8c7ef6 Peter Oskolkov 2019-01-16 4750 if (sk->sk_mark != val) {
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4751 sk->sk_mark = val;
f4924f24da8c7ef6 Peter Oskolkov 2019-01-16 4752 sk_dst_reset(sk);
f4924f24da8c7ef6 Peter Oskolkov 2019-01-16 4753 }
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4754 break;
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4755 case SO_BINDTODEVICE:
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4756 optlen = min_t(long, optlen, IFNAMSIZ - 1);
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4757 strncpy(devname, optval, optlen);
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4758 devname[optlen] = 0;
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4759
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4760 ifindex = 0;
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4761 if (devname[0] != '\0') {
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4762 struct net_device *dev;
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4763
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4764 ret = -ENODEV;
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4765
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4766 net = sock_net(sk);
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4767 dev = dev_get_by_name(net, devname);
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4768 if (!dev)
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4769 break;
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4770 ifindex = dev->ifindex;
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4771 dev_put(dev);
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4772 }
03f510703daae949 Daniel Borkmann 2021-01-11 4773 fallthrough;
03f510703daae949 Daniel Borkmann 2021-01-11 4774 case SO_BINDTOIFINDEX:
03f510703daae949 Daniel Borkmann 2021-01-11 4775 if (optname == SO_BINDTOIFINDEX)
03f510703daae949 Daniel Borkmann 2021-01-11 4776 ifindex = val;
70c58997c1e864c9 Ferenc Fejes 2020-05-30 @4777 ret = sock_bindtoindex(sk, ifindex, false);
70c58997c1e864c9 Ferenc Fejes 2020-05-30 4778 break;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4779 case SO_KEEPALIVE:
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4780 if (sk->sk_prot->keepalive)
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4781 sk->sk_prot->keepalive(sk, valbool);
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4782 sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool);
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4783 break;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4784 default:
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4785 ret = -EINVAL;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4786 }
a5192c52377e6d28 Lawrence Brakmo 2017-07-02 4787 #ifdef CONFIG_INET
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4788 } else if (level == SOL_IP) {
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4789 if (optlen != sizeof(int) || sk->sk_family != AF_INET)
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4790 return -EINVAL;
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4791
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4792 val = *((int *)optval);
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4793 /* Only some options are supported */
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4794 switch (optname) {
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4795 case IP_TOS:
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4796 if (val < -1 || val > 0xff) {
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4797 ret = -EINVAL;
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4798 } else {
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4799 struct inet_sock *inet = inet_sk(sk);
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4800
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4801 if (val == -1)
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4802 val = 0;
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4803 inet->tos = val;
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4804 }
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4805 break;
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4806 default:
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4807 ret = -EINVAL;
6f5c39fa5cd4a78c Nikita V. Shirokov 2018-03-26 4808 }
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4809 #if IS_ENABLED(CONFIG_IPV6)
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4810 } else if (level == SOL_IPV6) {
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4811 if (optlen != sizeof(int) || sk->sk_family != AF_INET6)
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4812 return -EINVAL;
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4813
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4814 val = *((int *)optval);
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4815 /* Only some options are supported */
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4816 switch (optname) {
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4817 case IPV6_TCLASS:
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4818 if (val < -1 || val > 0xff) {
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4819 ret = -EINVAL;
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4820 } else {
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4821 struct ipv6_pinfo *np = inet6_sk(sk);
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4822
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4823 if (val == -1)
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4824 val = 0;
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4825 np->tclass = val;
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4826 }
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4827 break;
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4828 default:
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4829 ret = -EINVAL;
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4830 }
6f9bd3d731aac0d2 Lawrence Brakmo 2018-01-25 4831 #endif
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4832 } else if (level == SOL_TCP &&
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4833 sk->sk_prot->setsockopt == tcp_setsockopt) {
91b5b21c7c16899a Lawrence Brakmo 2017-06-30 4834 if (optname == TCP_CONGESTION) {
91b5b21c7c16899a Lawrence Brakmo 2017-06-30 4835 char name[TCP_CA_NAME_MAX];
91b5b21c7c16899a Lawrence Brakmo 2017-06-30 4836
91b5b21c7c16899a Lawrence Brakmo 2017-06-30 4837 strncpy(name, optval, min_t(long, optlen,
91b5b21c7c16899a Lawrence Brakmo 2017-06-30 4838 TCP_CA_NAME_MAX-1));
91b5b21c7c16899a Lawrence Brakmo 2017-06-30 4839 name[TCP_CA_NAME_MAX-1] = 0;
29a949325c6c90f1 Neal Cardwell 2020-09-10 4840 ret = tcp_set_congestion_control(sk, name, false, true);
91b5b21c7c16899a Lawrence Brakmo 2017-06-30 4841 } else {
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4842 struct inet_connection_sock *icsk = inet_csk(sk);
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4843 struct tcp_sock *tp = tcp_sk(sk);
2b8ee4f05d4f6a6c Martin KaFai Lau 2020-08-20 4844 unsigned long timeout;
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4845
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4846 if (optlen != sizeof(int))
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4847 return -EINVAL;
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4848
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4849 val = *((int *)optval);
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4850 /* Only some options are supported */
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4851 switch (optname) {
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4852 case TCP_BPF_IW:
31aa6503a15ba001 Yuchung Cheng 2019-01-08 4853 if (val <= 0 || tp->data_segs_out > tp->syn_data)
91b5b21c7c16899a Lawrence Brakmo 2017-06-30 4854 ret = -EINVAL;
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4855 else
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4856 tp->snd_cwnd = val;
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4857 break;
13bf96411ad2bd16 Lawrence Brakmo 2017-06-30 4858 case TCP_BPF_SNDCWND_CLAMP:
13bf96411ad2bd16 Lawrence Brakmo 2017-06-30 4859 if (val <= 0) {
13bf96411ad2bd16 Lawrence Brakmo 2017-06-30 4860 ret = -EINVAL;
13bf96411ad2bd16 Lawrence Brakmo 2017-06-30 4861 } else {
13bf96411ad2bd16 Lawrence Brakmo 2017-06-30 4862 tp->snd_cwnd_clamp = val;
13bf96411ad2bd16 Lawrence Brakmo 2017-06-30 4863 tp->snd_ssthresh = val;
13bf96411ad2bd16 Lawrence Brakmo 2017-06-30 4864 }
6d3f06a0042ebd59 Colin Ian King 2017-07-04 4865 break;
2b8ee4f05d4f6a6c Martin KaFai Lau 2020-08-20 4866 case TCP_BPF_DELACK_MAX:
2b8ee4f05d4f6a6c Martin KaFai Lau 2020-08-20 4867 timeout = usecs_to_jiffies(val);
2b8ee4f05d4f6a6c Martin KaFai Lau 2020-08-20 4868 if (timeout > TCP_DELACK_MAX ||
2b8ee4f05d4f6a6c Martin KaFai Lau 2020-08-20 4869 timeout < TCP_TIMEOUT_MIN)
2b8ee4f05d4f6a6c Martin KaFai Lau 2020-08-20 4870 return -EINVAL;
2b8ee4f05d4f6a6c Martin KaFai Lau 2020-08-20 4871 inet_csk(sk)->icsk_delack_max = timeout;
2b8ee4f05d4f6a6c Martin KaFai Lau 2020-08-20 4872 break;
ca584ba070864c60 Martin KaFai Lau 2020-08-20 4873 case TCP_BPF_RTO_MIN:
ca584ba070864c60 Martin KaFai Lau 2020-08-20 4874 timeout = usecs_to_jiffies(val);
ca584ba070864c60 Martin KaFai Lau 2020-08-20 4875 if (timeout > TCP_RTO_MIN ||
ca584ba070864c60 Martin KaFai Lau 2020-08-20 4876 timeout < TCP_TIMEOUT_MIN)
ca584ba070864c60 Martin KaFai Lau 2020-08-20 4877 return -EINVAL;
ca584ba070864c60 Martin KaFai Lau 2020-08-20 4878 inet_csk(sk)->icsk_rto_min = timeout;
ca584ba070864c60 Martin KaFai Lau 2020-08-20 4879 break;
1e215300f1384072 Nikita V. Shirokov 2018-08-30 4880 case TCP_SAVE_SYN:
1e215300f1384072 Nikita V. Shirokov 2018-08-30 4881 if (val < 0 || val > 1)
1e215300f1384072 Nikita V. Shirokov 2018-08-30 4882 ret = -EINVAL;
1e215300f1384072 Nikita V. Shirokov 2018-08-30 4883 else
1e215300f1384072 Nikita V. Shirokov 2018-08-30 4884 tp->save_syn = val;
1e215300f1384072 Nikita V. Shirokov 2018-08-30 4885 break;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4886 case TCP_KEEPIDLE:
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4887 ret = tcp_sock_set_keepidle_locked(sk, val);
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4888 break;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4889 case TCP_KEEPINTVL:
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4890 if (val < 1 || val > MAX_TCP_KEEPINTVL)
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4891 ret = -EINVAL;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4892 else
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4893 tp->keepalive_intvl = val * HZ;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4894 break;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4895 case TCP_KEEPCNT:
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4896 if (val < 1 || val > MAX_TCP_KEEPCNT)
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4897 ret = -EINVAL;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4898 else
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4899 tp->keepalive_probes = val;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4900 break;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4901 case TCP_SYNCNT:
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4902 if (val < 1 || val > MAX_TCP_SYNCNT)
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4903 ret = -EINVAL;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4904 else
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4905 icsk->icsk_syn_retries = val;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4906 break;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4907 case TCP_USER_TIMEOUT:
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4908 if (val < 0)
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4909 ret = -EINVAL;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4910 else
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4911 icsk->icsk_user_timeout = val;
f9bcf96837f158db Dmitry Yakunin 2020-06-20 4912 break;
eca43ee6c46db92d Nikita V. Shirokov 2020-10-09 4913 case TCP_NOTSENT_LOWAT:
eca43ee6c46db92d Nikita V. Shirokov 2020-10-09 4914 tp->notsent_lowat = val;
eca43ee6c46db92d Nikita V. Shirokov 2020-10-09 4915 sk->sk_write_space(sk);
eca43ee6c46db92d Nikita V. Shirokov 2020-10-09 4916 break;
cb81110997d1f509 Prankur gupta 2020-12-02 4917 case TCP_WINDOW_CLAMP:
cb81110997d1f509 Prankur gupta 2020-12-02 4918 ret = tcp_set_window_clamp(sk, val);
cb81110997d1f509 Prankur gupta 2020-12-02 4919 break;
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4920 default:
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4921 ret = -EINVAL;
fc7478103c84af43 Lawrence Brakmo 2017-06-30 4922 }
91b5b21c7c16899a Lawrence Brakmo 2017-06-30 4923 }
91b5b21c7c16899a Lawrence Brakmo 2017-06-30 4924 #endif
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4925 } else {
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4926 ret = -EINVAL;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4927 }
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4928 return ret;
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4929 }
8c4b4c7e9ff04479 Lawrence Brakmo 2017-06-30 4930
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-01-11 21:51 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-01-11 16:17 [PATCH bpf-next 1/2] bpf: allow to retrieve sol_socket opts from sock_addr progs Daniel Borkmann 2021-01-11 16:17 ` [PATCH bpf-next 2/2] bpf: extend bind v4/v6 selftests for mark/prio/bindtoifindex Daniel Borkmann 2021-01-11 20:15 ` Yonghong Song 2021-01-11 21:01 ` Daniel Borkmann 2021-01-11 20:03 ` [PATCH bpf-next 1/2] bpf: allow to retrieve sol_socket opts from sock_addr progs Yonghong Song 2021-01-11 21:51 kernel test robot
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.