Skip to content

Commit 565b482

Browse files
Jiri PirkoPaolo Abeni
authored andcommitted
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: 02a68a4 ("net: devlink: track netdev with devlink_port assigned") Signed-off-by: Jiri Pirko <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent bbb253b commit 565b482

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

net/core/devlink.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9979,7 +9979,7 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,
99799979
goto err_xa_alloc;
99809980

99819981
devlink->netdevice_nb.notifier_call = devlink_netdevice_event;
9982-
ret = register_netdevice_notifier_net(net, &devlink->netdevice_nb);
9982+
ret = register_netdevice_notifier(&devlink->netdevice_nb);
99839983
if (ret)
99849984
goto err_register_netdevice_notifier;
99859985

@@ -10171,8 +10171,7 @@ void devlink_free(struct devlink *devlink)
1017110171
xa_destroy(&devlink->snapshot_ids);
1017210172
xa_destroy(&devlink->ports);
1017310173

10174-
WARN_ON_ONCE(unregister_netdevice_notifier_net(devlink_net(devlink),
10175-
&devlink->netdevice_nb));
10174+
WARN_ON_ONCE(unregister_netdevice_notifier(&devlink->netdevice_nb));
1017610175

1017710176
xa_erase(&devlinks, devlink->index);
1017810177

@@ -10503,6 +10502,8 @@ static int devlink_netdevice_event(struct notifier_block *nb,
1050310502
break;
1050410503
case NETDEV_REGISTER:
1050510504
case NETDEV_CHANGENAME:
10505+
if (devlink_net(devlink) != dev_net(netdev))
10506+
return NOTIFY_OK;
1050610507
/* Set the netdev on top of previously set type. Note this
1050710508
* event happens also during net namespace change so here
1050810509
* we take into account netdev pointer appearing in this
@@ -10512,6 +10513,8 @@ static int devlink_netdevice_event(struct notifier_block *nb,
1051210513
netdev);
1051310514
break;
1051410515
case NETDEV_UNREGISTER:
10516+
if (devlink_net(devlink) != dev_net(netdev))
10517+
return NOTIFY_OK;
1051510518
/* Clear netdev pointer, but not the type. This event happens
1051610519
* also during net namespace change so we need to clear
1051710520
* pointer to netdev that is going to another net namespace.

0 commit comments

Comments
 (0)