summaryrefslogtreecommitdiff
path: root/include/net/udp_tunnel.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2023-09-12 12:17:27 +0300
committerPaolo Abeni <pabeni@redhat.com>2023-09-14 17:16:36 +0300
commitac9a7f4ce5dda1472e8f44096f33066c6ec1a3b4 (patch)
tree70a7b9065ac78d7a5825886380984469fab4ca28 /include/net/udp_tunnel.h
parentf5f52f0884a595ff99ab1a608643fe4025fca2d5 (diff)
downloadlinux-ac9a7f4ce5dda1472e8f44096f33066c6ec1a3b4.tar.xz
udp: lockless UDP_ENCAP_L2TPINUDP / UDP_GRO
Move udp->encap_enabled to udp->udp_flags. Add udp_test_and_set_bit() helper to allow lockless udp_tunnel_encap_enable() implementation. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'include/net/udp_tunnel.h')
-rw-r--r--include/net/udp_tunnel.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h
index 0ca9b7a11baf..29251c3519cf 100644
--- a/include/net/udp_tunnel.h
+++ b/include/net/udp_tunnel.h
@@ -174,16 +174,13 @@ static inline int udp_tunnel_handle_offloads(struct sk_buff *skb, bool udp_csum)
}
#endif
-static inline void udp_tunnel_encap_enable(struct socket *sock)
+static inline void udp_tunnel_encap_enable(struct sock *sk)
{
- struct udp_sock *up = udp_sk(sock->sk);
-
- if (up->encap_enabled)
+ if (udp_test_and_set_bit(ENCAP_ENABLED, sk))
return;
- up->encap_enabled = 1;
#if IS_ENABLED(CONFIG_IPV6)
- if (sock->sk->sk_family == PF_INET6)
+ if (READ_ONCE(sk->sk_family) == PF_INET6)
ipv6_stub->udpv6_encap_enable();
#endif
udp_encap_enable();