Commit 3e52fba0 authored by Jiri Pirko's avatar Jiri Pirko Committed by Jakub Kicinski

net: introduce a helper to move notifier block to different namespace

Currently, net_dev() netdev notifier variant follows the netdev with
per-net notifier from namespace to namespace. This is implemented
by move_netdevice_notifiers_dev_net() helper.

For devlink it is needed to re-register per-net notifier during
devlink reload. Introduce a new helper called
move_netdevice_notifier_net() and share the unregister/register code
with existing move_netdevice_notifiers_dev_net() helper.
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 154ba79c
...@@ -2826,6 +2826,8 @@ int unregister_netdevice_notifier(struct notifier_block *nb); ...@@ -2826,6 +2826,8 @@ int unregister_netdevice_notifier(struct notifier_block *nb);
int register_netdevice_notifier_net(struct net *net, struct notifier_block *nb); int register_netdevice_notifier_net(struct net *net, struct notifier_block *nb);
int unregister_netdevice_notifier_net(struct net *net, int unregister_netdevice_notifier_net(struct net *net,
struct notifier_block *nb); struct notifier_block *nb);
void move_netdevice_notifier_net(struct net *src_net, struct net *dst_net,
struct notifier_block *nb);
int register_netdevice_notifier_dev_net(struct net_device *dev, int register_netdevice_notifier_dev_net(struct net_device *dev,
struct notifier_block *nb, struct notifier_block *nb,
struct netdev_net_notifier *nn); struct netdev_net_notifier *nn);
......
...@@ -1861,6 +1861,22 @@ int unregister_netdevice_notifier_net(struct net *net, ...@@ -1861,6 +1861,22 @@ int unregister_netdevice_notifier_net(struct net *net,
} }
EXPORT_SYMBOL(unregister_netdevice_notifier_net); EXPORT_SYMBOL(unregister_netdevice_notifier_net);
static void __move_netdevice_notifier_net(struct net *src_net,
struct net *dst_net,
struct notifier_block *nb)
{
__unregister_netdevice_notifier_net(src_net, nb);
__register_netdevice_notifier_net(dst_net, nb, true);
}
void move_netdevice_notifier_net(struct net *src_net, struct net *dst_net,
struct notifier_block *nb)
{
rtnl_lock();
__move_netdevice_notifier_net(src_net, dst_net, nb);
rtnl_unlock();
}
int register_netdevice_notifier_dev_net(struct net_device *dev, int register_netdevice_notifier_dev_net(struct net_device *dev,
struct notifier_block *nb, struct notifier_block *nb,
struct netdev_net_notifier *nn) struct netdev_net_notifier *nn)
...@@ -1897,10 +1913,8 @@ static void move_netdevice_notifiers_dev_net(struct net_device *dev, ...@@ -1897,10 +1913,8 @@ static void move_netdevice_notifiers_dev_net(struct net_device *dev,
{ {
struct netdev_net_notifier *nn; struct netdev_net_notifier *nn;
list_for_each_entry(nn, &dev->net_notifier_list, list) { list_for_each_entry(nn, &dev->net_notifier_list, list)
__unregister_netdevice_notifier_net(dev_net(dev), nn->nb); __move_netdevice_notifier_net(dev_net(dev), net, nn->nb);
__register_netdevice_notifier_net(net, nn->nb, true);
}
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment