diff options
author | Lorenz Bauer <lmb@cloudflare.com> | 2020-09-09 17:27:10 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-09-10 12:31:55 -0700 |
commit | 654785a1afe1b1428106c322c7ea650e3f8d29e9 (patch) | |
tree | ee628a555cfd8b69b848cf8516bc647b48bbdff2 /net/core | |
parent | f28ef96d7b04a76575a020a9da4f92358abe68c6 (diff) |
net: sockmap: Remove unnecessary sk_fullsock checks
The lookup paths for sockmap and sockhash currently include a check
that returns NULL if the socket we just found is not a full socket.
However, this check is not necessary. On insertion we ensure that
we have a full socket (caveat around sock_ops), so request sockets
are not a problem. Time-wait sockets are allocated separate from
the original socket and then fed into the hashdance. They don't
affect the sockets already stored in the sockmap.
Suggested-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200909162712.221874-2-lmb@cloudflare.com
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/sock_map.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/core/sock_map.c b/net/core/sock_map.c index 078386d7d9a2..82494810d0ee 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -382,7 +382,7 @@ static void *sock_map_lookup(struct bpf_map *map, void *key) struct sock *sk; sk = __sock_map_lookup_elem(map, *(u32 *)key); - if (!sk || !sk_fullsock(sk)) + if (!sk) return NULL; if (sk_is_refcounted(sk) && !refcount_inc_not_zero(&sk->sk_refcnt)) return NULL; @@ -1110,7 +1110,7 @@ static void *sock_hash_lookup(struct bpf_map *map, void *key) struct sock *sk; sk = __sock_hash_lookup_elem(map, key); - if (!sk || !sk_fullsock(sk)) + if (!sk) return NULL; if (sk_is_refcounted(sk) && !refcount_inc_not_zero(&sk->sk_refcnt)) return NULL; |