From 4f71dd1b421d1300237adf546aa14521cdf46355 Mon Sep 17 00:00:00 2001 From: Kuniyuki Iwashima Date: Sat, 2 May 2026 03:13:01 +0000 Subject: [PATCH] vxlan: Free vxlan_sock with kfree_rcu(). 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 Link: https://patch.msgid.link/20260502031401.3557229-9-kuniyu@google.com Signed-off-by: Jakub Kicinski --- drivers/net/vxlan/vxlan_core.c | 4 ++-- include/net/vxlan.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index ce99da44ea7d..00facbfabced 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -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 } diff --git a/include/net/vxlan.h b/include/net/vxlan.h index 8b52294b2902..dfba89695efc 100644 --- a/include/net/vxlan.h +++ b/include/net/vxlan.h @@ -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;