]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
vxlan: Free vxlan_sock with kfree_rcu().
authorKuniyuki Iwashima <kuniyu@google.com>
Sat, 2 May 2026 03:13:01 +0000 (03:13 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 6 May 2026 00:47:05 +0000 (17:47 -0700)
We will remove synchronize_rcu() in udp_tunnel_sock_release().

We must ensure that vxlan_sock is freed after inflight RX fast path.

Let's free vxlan_sock with kfree_rcu().

Note that vxlan_sock.vni_list[] is 8K and struct rcu_head must
be placed before it.

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260502031401.3557229-9-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/vxlan/vxlan_core.c
include/net/vxlan.h

index ce99da44ea7d834f784489eae78ba59afa86812d..00facbfabced4353ce9cf7911880797e8e9af56f 100644 (file)
@@ -1524,13 +1524,13 @@ static void vxlan_sock_release(struct vxlan_dev *vxlan)
 
        if (__vxlan_sock_release_prep(sock4)) {
                udp_tunnel_sock_release(sock4->sk);
-               kfree(sock4);
+               kfree_rcu(sock4, rcu);
        }
 
 #if IS_ENABLED(CONFIG_IPV6)
        if (__vxlan_sock_release_prep(sock6)) {
                udp_tunnel_sock_release(sock6->sk);
-               kfree(sock6);
+               kfree_rcu(sock6, rcu);
        }
 #endif
 }
index 8b52294b2902714bbbf833c96eca99f09ef26a4d..dfba89695efcfa46cbc56f005763e1086ce67b23 100644 (file)
@@ -186,6 +186,7 @@ struct vxlan_metadata {
 struct vxlan_sock {
        struct hlist_node hlist;
        struct sock       *sk;
+       struct rcu_head   rcu;
        struct hlist_head vni_list[VNI_HASH_SIZE];
        refcount_t        refcnt;
        u32               flags;