Commit 08842c43 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

udp: no longer touch sk->sk_refcnt in early demux

After commits ca065d0c ("udp: no longer use SLAB_DESTROY_BY_RCU")
and 7ae215d2 ("bpf: Don't refcount LISTEN sockets in sk_assign()")
UDP early demux no longer need to grab a refcount on the UDP socket.

This save two atomic operations per incoming packet for connected
sockets.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Joe Stringer <joe@wand.net.nz>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>
Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e996401e
......@@ -2568,11 +2568,12 @@ int udp_v4_early_demux(struct sk_buff *skb)
uh->source, iph->saddr, dif, sdif);
}
if (!sk || !refcount_inc_not_zero(&sk->sk_refcnt))
if (!sk)
return 0;
skb->sk = sk;
skb->destructor = sock_efree;
DEBUG_NET_WARN_ON_ONCE(sk_is_refcounted(sk));
skb->destructor = sock_pfree;
dst = rcu_dereference(sk->sk_rx_dst);
if (dst)
......
......@@ -1098,11 +1098,12 @@ void udp_v6_early_demux(struct sk_buff *skb)
else
return;
if (!sk || !refcount_inc_not_zero(&sk->sk_refcnt))
if (!sk)
return;
skb->sk = sk;
skb->destructor = sock_efree;
DEBUG_NET_WARN_ON_ONCE(sk_is_refcounted(sk));
skb->destructor = sock_pfree;
dst = rcu_dereference(sk->sk_rx_dst);
if (dst)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment