Skip to content

Commit 392aea0

Browse files
author
Xin Long
committed
net: tipc: remove one synchronize_net() from tipc_nametbl_stop()
JIRA: https://issues.redhat.com/browse/RHEL-115652 Tested: compile only commit 6c36b5c Author: Eric Dumazet <edumazet@google.com> Date: Wed Dec 4 21:02:34 2024 +0000 net: tipc: remove one synchronize_net() from tipc_nametbl_stop() tipc_exit_net() is very slow and is abused by syzbot. tipc_nametbl_stop() is called for each netns being dismantled. Calling synchronize_net() right before freeing tn->nametbl is a big hammer. Replace this with kfree_rcu(). Note that RCU is not properly used here, otherwise tn->nametbl should be cleared before the synchronize_net() or kfree_rcu(), or even before the cleanup loop. We might need to fix this at some point. Also note tipc uses other synchronize_rcu() calls, more work is needed to make tipc_exit_net() much faster. List of remaining calls to synchronize_rcu() tipc_detach_loopback() (dev_remove_pack()) tipc_bcast_stop() tipc_sk_rht_destroy() Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20241204210234.319484-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Xin Long <lxin@redhat.com>
1 parent 6d87b50 commit 392aea0

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

net/tipc/name_table.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,8 +949,8 @@ void tipc_nametbl_stop(struct net *net)
949949
}
950950
spin_unlock_bh(&tn->nametbl_lock);
951951

952-
synchronize_net();
953-
kfree(nt);
952+
/* TODO: clear tn->nametbl, implement proper RCU rules ? */
953+
kfree_rcu(nt, rcu);
954954
}
955955

956956
static int __tipc_nl_add_nametable_publ(struct tipc_nl_msg *msg,

net/tipc/name_table.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct publication {
9090

9191
/**
9292
* struct name_table - table containing all existing port name publications
93+
* @rcu: RCU callback head used for deferred freeing
9394
* @services: name sequence hash lists
9495
* @node_scope: all local publications with node scope
9596
* - used by name_distr during re-init of name table
@@ -102,6 +103,7 @@ struct publication {
102103
* @snd_nxt: next sequence number to be used
103104
*/
104105
struct name_table {
106+
struct rcu_head rcu;
105107
struct hlist_head services[TIPC_NAMETBL_SIZE];
106108
struct list_head node_scope;
107109
struct list_head cluster_scope;

0 commit comments

Comments
 (0)