net: devlink: move netdev notifier block to dest namespace during reload

The notifier block tracking netdev changes in devlink is registered
during devlink_alloc() per-net, it is then unregistered
in devlink_free(). When devlink moves from net namespace to another one,
the notifier block needs to move along.

Fix this by adding forgotten call to move the block.

Reported-by: Ido Schimmel <idosch@idosch.org>
Fixes: 02a68a47ea ("net: devlink: track netdev with devlink_port assigned")
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Tested-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jiri Pirko 2022-11-08 14:22:07 +01:00 committed by Jakub Kicinski
parent 3e52fba03a
commit 15feb56e30
1 changed files with 4 additions and 1 deletions

View File

@ -4502,8 +4502,11 @@ static int devlink_reload(struct devlink *devlink, struct net *dest_net,
if (err)
return err;
if (dest_net && !net_eq(dest_net, curr_net))
if (dest_net && !net_eq(dest_net, curr_net)) {
move_netdevice_notifier_net(curr_net, dest_net,
&devlink->netdevice_nb);
write_pnet(&devlink->_net, dest_net);
}
err = devlink->ops->reload_up(devlink, action, limit, actions_performed, extack);
devlink_reload_failed_set(devlink, !!err);