mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-01 18:22:16 -05:00
Merge branch 'net-followup-series-for-exit_rtnl'
Kuniyuki Iwashima says: ==================== net: Followup series for ->exit_rtnl(). Patch 1 drops the hold_rtnl arg in ops_undo_list() as suggested by Jakub. Patch 2 & 3 apply ->exit_rtnl() to pfcp and ppp. v1: https://lore.kernel.org/20250415022258.11491-1-kuniyu@amazon.com ==================== Link: https://patch.msgid.link/20250418003259.48017-1-kuniyu@amazon.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -245,30 +245,21 @@ static int __net_init pfcp_net_init(struct net *net)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __net_exit pfcp_net_exit(struct net *net)
|
||||
static void __net_exit pfcp_net_exit_rtnl(struct net *net,
|
||||
struct list_head *dev_to_kill)
|
||||
{
|
||||
struct pfcp_net *pn = net_generic(net, pfcp_net_id);
|
||||
struct pfcp_dev *pfcp, *pfcp_next;
|
||||
struct net_device *dev;
|
||||
LIST_HEAD(list);
|
||||
|
||||
rtnl_lock();
|
||||
for_each_netdev(net, dev)
|
||||
if (dev->rtnl_link_ops == &pfcp_link_ops)
|
||||
pfcp_dellink(dev, &list);
|
||||
|
||||
list_for_each_entry_safe(pfcp, pfcp_next, &pn->pfcp_dev_list, list)
|
||||
pfcp_dellink(pfcp->dev, &list);
|
||||
|
||||
unregister_netdevice_many(&list);
|
||||
rtnl_unlock();
|
||||
pfcp_dellink(pfcp->dev, dev_to_kill);
|
||||
}
|
||||
|
||||
static struct pernet_operations pfcp_net_ops = {
|
||||
.init = pfcp_net_init,
|
||||
.exit = pfcp_net_exit,
|
||||
.id = &pfcp_net_id,
|
||||
.size = sizeof(struct pfcp_net),
|
||||
.init = pfcp_net_init,
|
||||
.exit_rtnl = pfcp_net_exit_rtnl,
|
||||
.id = &pfcp_net_id,
|
||||
.size = sizeof(struct pfcp_net),
|
||||
};
|
||||
|
||||
static int __init pfcp_init(void)
|
||||
|
||||
@@ -1131,6 +1131,8 @@ static const struct file_operations ppp_device_fops = {
|
||||
.llseek = noop_llseek,
|
||||
};
|
||||
|
||||
static void ppp_nl_dellink(struct net_device *dev, struct list_head *head);
|
||||
|
||||
static __net_init int ppp_init_net(struct net *net)
|
||||
{
|
||||
struct ppp_net *pn = net_generic(net, ppp_net_id);
|
||||
@@ -1146,28 +1148,20 @@ static __net_init int ppp_init_net(struct net *net)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __net_exit void ppp_exit_rtnl_net(struct net *net,
|
||||
struct list_head *dev_to_kill)
|
||||
{
|
||||
struct ppp_net *pn = net_generic(net, ppp_net_id);
|
||||
struct ppp *ppp;
|
||||
int id;
|
||||
|
||||
idr_for_each_entry(&pn->units_idr, ppp, id)
|
||||
ppp_nl_dellink(ppp->dev, dev_to_kill);
|
||||
}
|
||||
|
||||
static __net_exit void ppp_exit_net(struct net *net)
|
||||
{
|
||||
struct ppp_net *pn = net_generic(net, ppp_net_id);
|
||||
struct net_device *dev;
|
||||
struct net_device *aux;
|
||||
struct ppp *ppp;
|
||||
LIST_HEAD(list);
|
||||
int id;
|
||||
|
||||
rtnl_lock();
|
||||
for_each_netdev_safe(net, dev, aux) {
|
||||
if (dev->netdev_ops == &ppp_netdev_ops)
|
||||
unregister_netdevice_queue(dev, &list);
|
||||
}
|
||||
|
||||
idr_for_each_entry(&pn->units_idr, ppp, id)
|
||||
/* Skip devices already unregistered by previous loop */
|
||||
if (!net_eq(dev_net(ppp->dev), net))
|
||||
unregister_netdevice_queue(ppp->dev, &list);
|
||||
|
||||
unregister_netdevice_many(&list);
|
||||
rtnl_unlock();
|
||||
|
||||
mutex_destroy(&pn->all_ppp_mutex);
|
||||
idr_destroy(&pn->units_idr);
|
||||
@@ -1177,6 +1171,7 @@ static __net_exit void ppp_exit_net(struct net *net)
|
||||
|
||||
static struct pernet_operations ppp_net_ops = {
|
||||
.init = ppp_init_net,
|
||||
.exit_rtnl = ppp_exit_rtnl_net,
|
||||
.exit = ppp_exit_net,
|
||||
.id = &ppp_net_id,
|
||||
.size = sizeof(struct ppp_net),
|
||||
|
||||
@@ -220,17 +220,20 @@ static void ops_free_list(const struct pernet_operations *ops,
|
||||
static void ops_undo_list(const struct list_head *ops_list,
|
||||
const struct pernet_operations *ops,
|
||||
struct list_head *net_exit_list,
|
||||
bool expedite_rcu, bool hold_rtnl)
|
||||
bool expedite_rcu)
|
||||
{
|
||||
const struct pernet_operations *saved_ops;
|
||||
bool hold_rtnl = false;
|
||||
|
||||
if (!ops)
|
||||
ops = list_entry(ops_list, typeof(*ops), list);
|
||||
|
||||
saved_ops = ops;
|
||||
|
||||
list_for_each_entry_continue_reverse(ops, ops_list, list)
|
||||
list_for_each_entry_continue_reverse(ops, ops_list, list) {
|
||||
hold_rtnl |= !!ops->exit_rtnl;
|
||||
ops_pre_exit_list(ops, net_exit_list);
|
||||
}
|
||||
|
||||
/* Another CPU might be rcu-iterating the list, wait for it.
|
||||
* This needs to be before calling the exit() notifiers, so the
|
||||
@@ -257,11 +260,10 @@ static void ops_undo_list(const struct list_head *ops_list,
|
||||
static void ops_undo_single(struct pernet_operations *ops,
|
||||
struct list_head *net_exit_list)
|
||||
{
|
||||
bool hold_rtnl = !!ops->exit_rtnl;
|
||||
LIST_HEAD(ops_list);
|
||||
|
||||
list_add(&ops->list, &ops_list);
|
||||
ops_undo_list(&ops_list, NULL, net_exit_list, false, hold_rtnl);
|
||||
ops_undo_list(&ops_list, NULL, net_exit_list, false);
|
||||
list_del(&ops->list);
|
||||
}
|
||||
|
||||
@@ -452,7 +454,7 @@ static __net_init int setup_net(struct net *net)
|
||||
* for the pernet modules whose init functions did not fail.
|
||||
*/
|
||||
list_add(&net->exit_list, &net_exit_list);
|
||||
ops_undo_list(&pernet_list, ops, &net_exit_list, false, true);
|
||||
ops_undo_list(&pernet_list, ops, &net_exit_list, false);
|
||||
rcu_barrier();
|
||||
goto out;
|
||||
}
|
||||
@@ -681,7 +683,7 @@ static void cleanup_net(struct work_struct *work)
|
||||
list_add_tail(&net->exit_list, &net_exit_list);
|
||||
}
|
||||
|
||||
ops_undo_list(&pernet_list, NULL, &net_exit_list, true, true);
|
||||
ops_undo_list(&pernet_list, NULL, &net_exit_list, true);
|
||||
|
||||
up_read(&pernet_ops_rwsem);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user