diff options
author | Martin KaFai Lau <kafai@fb.com> | 2022-08-17 08:18:04 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-08-19 02:06:13 +0200 |
commit | 29003875bd5bab262a29d1c6e76a2124bd07e4c2 (patch) | |
tree | 4dd0e5a07b181664d68234b0613bcf78be41681b /include/net | |
parent | bpf: Embed kernel CONFIG check into the if statement in bpf_setsockopt (diff) | |
download | linux-29003875bd5bab262a29d1c6e76a2124bd07e4c2.tar.xz linux-29003875bd5bab262a29d1c6e76a2124bd07e4c2.zip |
bpf: Change bpf_setsockopt(SOL_SOCKET) to reuse sk_setsockopt()
After the prep work in the previous patches,
this patch removes most of the dup code from bpf_setsockopt(SOL_SOCKET)
and reuses them from sk_setsockopt().
The sock ptr test is added to the SO_RCVLOWAT because
the sk->sk_socket could be NULL in some of the bpf hooks.
The existing optname white-list is refactored into a new
function sol_socket_setsockopt().
Reviewed-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/r/20220817061804.4178920-1-kafai@fb.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/sock.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 13089d88a2e2..ee44b424d952 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1828,6 +1828,8 @@ void sock_pfree(struct sk_buff *skb); #define sock_edemux sock_efree #endif +int sk_setsockopt(struct sock *sk, int level, int optname, + sockptr_t optval, unsigned int optlen); int sock_setsockopt(struct socket *sock, int level, int op, sockptr_t optval, unsigned int optlen); |