Skip to content

Commit f4b57b9

Browse files
Eric Dumazetkuba-moo
authored andcommitted
geneve: use exit_batch_rtnl() method
exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair, and one unregister_netdevice_many() call. Note: it should be possible to remove the synchronize_net() call from geneve_sock_release() in a future patch. v4: move WARN_ON_ONCE(!list_empty(&gn->sock_list)) into geneve_exit_net(), after devices have been unregistered. (Antoine Tenart feedback) Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: Antoine Tenart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 669966b commit f4b57b9

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

drivers/net/geneve.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,29 +1900,26 @@ static void geneve_destroy_tunnels(struct net *net, struct list_head *head)
19001900
}
19011901
}
19021902

1903-
static void __net_exit geneve_exit_batch_net(struct list_head *net_list)
1903+
static void __net_exit geneve_exit_batch_rtnl(struct list_head *net_list,
1904+
struct list_head *dev_to_kill)
19041905
{
19051906
struct net *net;
1906-
LIST_HEAD(list);
19071907

1908-
rtnl_lock();
19091908
list_for_each_entry(net, net_list, exit_list)
1910-
geneve_destroy_tunnels(net, &list);
1911-
1912-
/* unregister the devices gathered above */
1913-
unregister_netdevice_many(&list);
1914-
rtnl_unlock();
1909+
geneve_destroy_tunnels(net, dev_to_kill);
1910+
}
19151911

1916-
list_for_each_entry(net, net_list, exit_list) {
1917-
const struct geneve_net *gn = net_generic(net, geneve_net_id);
1912+
static void __net_exit geneve_exit_net(struct net *net)
1913+
{
1914+
const struct geneve_net *gn = net_generic(net, geneve_net_id);
19181915

1919-
WARN_ON_ONCE(!list_empty(&gn->sock_list));
1920-
}
1916+
WARN_ON_ONCE(!list_empty(&gn->sock_list));
19211917
}
19221918

19231919
static struct pernet_operations geneve_net_ops = {
19241920
.init = geneve_init_net,
1925-
.exit_batch = geneve_exit_batch_net,
1921+
.exit_batch_rtnl = geneve_exit_batch_rtnl,
1922+
.exit = geneve_exit_net,
19261923
.id = &geneve_net_id,
19271924
.size = sizeof(struct geneve_net),
19281925
};

0 commit comments

Comments
 (0)