Skip to content

Commit 7ee3207

Browse files
q2venkuba-moo
authored andcommitted
ppp: Split ppp_exit_net() to ->exit_rtnl().
ppp_exit_net() unregisters devices related to the netns under RTNL and destroys lists and IDR. Let's use ->exit_rtnl() for the device unregistration part to save RTNL dances for each netns. Note that we delegate the for_each_netdev_safe() part to default_device_exit_batch() and replace unregister_netdevice_queue() with ppp_nl_dellink() to align with bond, geneve, gtp, and pfcp. Signed-off-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 81eccc1 commit 7ee3207

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

drivers/net/ppp/ppp_generic.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,8 @@ static const struct file_operations ppp_device_fops = {
11311131
.llseek = noop_llseek,
11321132
};
11331133

1134+
static void ppp_nl_dellink(struct net_device *dev, struct list_head *head);
1135+
11341136
static __net_init int ppp_init_net(struct net *net)
11351137
{
11361138
struct ppp_net *pn = net_generic(net, ppp_net_id);
@@ -1146,28 +1148,20 @@ static __net_init int ppp_init_net(struct net *net)
11461148
return 0;
11471149
}
11481150

1149-
static __net_exit void ppp_exit_net(struct net *net)
1151+
static __net_exit void ppp_exit_rtnl_net(struct net *net,
1152+
struct list_head *dev_to_kill)
11501153
{
11511154
struct ppp_net *pn = net_generic(net, ppp_net_id);
1152-
struct net_device *dev;
1153-
struct net_device *aux;
11541155
struct ppp *ppp;
1155-
LIST_HEAD(list);
11561156
int id;
11571157

1158-
rtnl_lock();
1159-
for_each_netdev_safe(net, dev, aux) {
1160-
if (dev->netdev_ops == &ppp_netdev_ops)
1161-
unregister_netdevice_queue(dev, &list);
1162-
}
1163-
11641158
idr_for_each_entry(&pn->units_idr, ppp, id)
1165-
/* Skip devices already unregistered by previous loop */
1166-
if (!net_eq(dev_net(ppp->dev), net))
1167-
unregister_netdevice_queue(ppp->dev, &list);
1159+
ppp_nl_dellink(ppp->dev, dev_to_kill);
1160+
}
11681161

1169-
unregister_netdevice_many(&list);
1170-
rtnl_unlock();
1162+
static __net_exit void ppp_exit_net(struct net *net)
1163+
{
1164+
struct ppp_net *pn = net_generic(net, ppp_net_id);
11711165

11721166
mutex_destroy(&pn->all_ppp_mutex);
11731167
idr_destroy(&pn->units_idr);
@@ -1177,6 +1171,7 @@ static __net_exit void ppp_exit_net(struct net *net)
11771171

11781172
static struct pernet_operations ppp_net_ops = {
11791173
.init = ppp_init_net,
1174+
.exit_rtnl = ppp_exit_rtnl_net,
11801175
.exit = ppp_exit_net,
11811176
.id = &ppp_net_id,
11821177
.size = sizeof(struct ppp_net),

0 commit comments

Comments
 (0)