mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 03:35:32 -04:00
Merge branch 'pfcp-support-per-netns-device-unregistration'
Kuniyuki Iwashima says: ==================== pfcp: Support per-netns device unregistration. Patch 1 adds a per-netns mutex for pfcp_net.pfcp_dev_list. Patch 2 supports per-netns netdev unreg by using unregister_netdevice_queue_net(). ==================== Link: https://patch.msgid.link/20260731224406.2444121-1-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -29,6 +29,7 @@ static unsigned int pfcp_net_id __read_mostly;
|
||||
|
||||
struct pfcp_net {
|
||||
struct list_head pfcp_dev_list;
|
||||
struct mutex lock;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -209,7 +210,10 @@ static int pfcp_newlink(struct net_device *dev,
|
||||
}
|
||||
|
||||
pn = net_generic(link_net, pfcp_net_id);
|
||||
|
||||
mutex_lock(&pn->lock);
|
||||
list_add(&pfcp->list, &pn->pfcp_dev_list);
|
||||
mutex_unlock(&pn->lock);
|
||||
|
||||
netdev_dbg(dev, "registered new PFCP interface\n");
|
||||
|
||||
@@ -223,12 +227,26 @@ static int pfcp_newlink(struct net_device *dev,
|
||||
return err;
|
||||
}
|
||||
|
||||
static void pfcp_dellink(struct net_device *dev, struct list_head *head)
|
||||
static void __pfcp_dellink(struct net *net, struct net_device *dev,
|
||||
struct list_head *head)
|
||||
{
|
||||
struct pfcp_dev *pfcp = netdev_priv(dev);
|
||||
|
||||
list_del(&pfcp->list);
|
||||
unregister_netdevice_queue(dev, head);
|
||||
list_del_init(&pfcp->list);
|
||||
unregister_netdevice_queue_net(net, dev, head);
|
||||
}
|
||||
|
||||
static void pfcp_dellink(struct net_device *dev, struct list_head *head)
|
||||
{
|
||||
struct pfcp_dev *pfcp = netdev_priv(dev);
|
||||
struct pfcp_net *pn;
|
||||
|
||||
pn = net_generic(pfcp->net, pfcp_net_id);
|
||||
|
||||
mutex_lock(&pn->lock);
|
||||
if (!list_empty(&pfcp->list))
|
||||
__pfcp_dellink(dev_net(dev), dev, head);
|
||||
mutex_unlock(&pn->lock);
|
||||
}
|
||||
|
||||
static struct rtnl_link_ops pfcp_link_ops __read_mostly = {
|
||||
@@ -244,6 +262,8 @@ static int __net_init pfcp_net_init(struct net *net)
|
||||
struct pfcp_net *pn = net_generic(net, pfcp_net_id);
|
||||
|
||||
INIT_LIST_HEAD(&pn->pfcp_dev_list);
|
||||
mutex_init(&pn->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -253,8 +273,12 @@ static void __net_exit pfcp_net_exit_rtnl(struct net *net,
|
||||
struct pfcp_net *pn = net_generic(net, pfcp_net_id);
|
||||
struct pfcp_dev *pfcp, *pfcp_next;
|
||||
|
||||
mutex_lock(&pn->lock);
|
||||
|
||||
list_for_each_entry_safe(pfcp, pfcp_next, &pn->pfcp_dev_list, list)
|
||||
pfcp_dellink(pfcp->dev, dev_to_kill);
|
||||
__pfcp_dellink(net, pfcp->dev, dev_to_kill);
|
||||
|
||||
mutex_unlock(&pn->lock);
|
||||
}
|
||||
|
||||
static struct pernet_operations pfcp_net_ops = {
|
||||
|
||||
Reference in New Issue
Block a user