mirror of
https://github.com/torvalds/linux.git
synced 2024-12-29 06:12:08 +00:00
devlink: change port event netdev notifier from per-net to global
Currently only the network namespace of devlink instance is monitored
for port events. If netdev is moved to a different namespace and then
unregistered, NETDEV_PRE_UNINIT is missed which leads to trigger
following WARN_ON in devl_port_unregister().
WARN_ON(devlink_port->type != DEVLINK_PORT_TYPE_NOTSET);
Fix this by changing the netdev notifier from per-net to global so no
event is missed.
Fixes: 02a68a47ea
("net: devlink: track netdev with devlink_port assigned")
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20230206094151.2557264-1-jiri@resnulli.us
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
bbb253b206
commit
565b4824c3
@ -9979,7 +9979,7 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,
|
|||||||
goto err_xa_alloc;
|
goto err_xa_alloc;
|
||||||
|
|
||||||
devlink->netdevice_nb.notifier_call = devlink_netdevice_event;
|
devlink->netdevice_nb.notifier_call = devlink_netdevice_event;
|
||||||
ret = register_netdevice_notifier_net(net, &devlink->netdevice_nb);
|
ret = register_netdevice_notifier(&devlink->netdevice_nb);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_register_netdevice_notifier;
|
goto err_register_netdevice_notifier;
|
||||||
|
|
||||||
@ -10171,8 +10171,7 @@ void devlink_free(struct devlink *devlink)
|
|||||||
xa_destroy(&devlink->snapshot_ids);
|
xa_destroy(&devlink->snapshot_ids);
|
||||||
xa_destroy(&devlink->ports);
|
xa_destroy(&devlink->ports);
|
||||||
|
|
||||||
WARN_ON_ONCE(unregister_netdevice_notifier_net(devlink_net(devlink),
|
WARN_ON_ONCE(unregister_netdevice_notifier(&devlink->netdevice_nb));
|
||||||
&devlink->netdevice_nb));
|
|
||||||
|
|
||||||
xa_erase(&devlinks, devlink->index);
|
xa_erase(&devlinks, devlink->index);
|
||||||
|
|
||||||
@ -10503,6 +10502,8 @@ static int devlink_netdevice_event(struct notifier_block *nb,
|
|||||||
break;
|
break;
|
||||||
case NETDEV_REGISTER:
|
case NETDEV_REGISTER:
|
||||||
case NETDEV_CHANGENAME:
|
case NETDEV_CHANGENAME:
|
||||||
|
if (devlink_net(devlink) != dev_net(netdev))
|
||||||
|
return NOTIFY_OK;
|
||||||
/* Set the netdev on top of previously set type. Note this
|
/* Set the netdev on top of previously set type. Note this
|
||||||
* event happens also during net namespace change so here
|
* event happens also during net namespace change so here
|
||||||
* we take into account netdev pointer appearing in this
|
* we take into account netdev pointer appearing in this
|
||||||
@ -10512,6 +10513,8 @@ static int devlink_netdevice_event(struct notifier_block *nb,
|
|||||||
netdev);
|
netdev);
|
||||||
break;
|
break;
|
||||||
case NETDEV_UNREGISTER:
|
case NETDEV_UNREGISTER:
|
||||||
|
if (devlink_net(devlink) != dev_net(netdev))
|
||||||
|
return NOTIFY_OK;
|
||||||
/* Clear netdev pointer, but not the type. This event happens
|
/* Clear netdev pointer, but not the type. This event happens
|
||||||
* also during net namespace change so we need to clear
|
* also during net namespace change so we need to clear
|
||||||
* pointer to netdev that is going to another net namespace.
|
* pointer to netdev that is going to another net namespace.
|
||||||
|
Loading…
Reference in New Issue
Block a user