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
        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;
        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;