Message ID | 20221107145213.913178-2-jiri@resnulli.us (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: devlink: move netdev notifier block to dest namespace during reload | expand |
On Mon, 7 Nov 2022 15:52:12 +0100 Jiri Pirko wrote: > +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); > +} 'static' missing > +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(); > +} > +EXPORT_SYMBOL(move_netdevice_notifier_net); Do we need to export this? Maybe let's wait for a module user?
Tue, Nov 08, 2022 at 05:29:37AM CET, kuba@kernel.org wrote: >On Mon, 7 Nov 2022 15:52:12 +0100 Jiri Pirko wrote: >> +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); >> +} > >'static' missing Yep. > >> +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(); >> +} >> +EXPORT_SYMBOL(move_netdevice_notifier_net); > >Do we need to export this? Maybe let's wait for a module user? Ah, right.
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index d45713a06568..6be93b59cfea 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2828,6 +2828,8 @@ int unregister_netdevice_notifier(struct notifier_block *nb); int register_netdevice_notifier_net(struct net *net, struct notifier_block *nb); int unregister_netdevice_notifier_net(struct net *net, 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, struct notifier_block *nb, struct netdev_net_notifier *nn); diff --git a/net/core/dev.c b/net/core/dev.c index 3bacee3bee78..762d7255065d 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1876,6 +1876,22 @@ int unregister_netdevice_notifier_net(struct net *net, } EXPORT_SYMBOL(unregister_netdevice_notifier_net); +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(); +} +EXPORT_SYMBOL(move_netdevice_notifier_net); + int register_netdevice_notifier_dev_net(struct net_device *dev, struct notifier_block *nb, struct netdev_net_notifier *nn) @@ -1912,10 +1928,8 @@ static void move_netdevice_notifiers_dev_net(struct net_device *dev, { struct netdev_net_notifier *nn; - list_for_each_entry(nn, &dev->net_notifier_list, list) { - __unregister_netdevice_notifier_net(dev_net(dev), nn->nb); - __register_netdevice_notifier_net(net, nn->nb, true); - } + list_for_each_entry(nn, &dev->net_notifier_list, list) + __move_netdevice_notifier_net(dev_net(dev), net, nn->nb); } /**