mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
devlink: Allocate devlink directly in requested net namespace
There is no need in extra call indirection and check from impossible flow where someone tries to set namespace without prior call to devlink_alloc(). Instead of this extra logic and additional EXPORT_SYMBOL, use specialized devlink allocation function that receives net namespace as an argument. Such specialized API allows clear view when devlink initialized in wrong net namespace and/or kernel users don't try to change devlink namespace under the hood. Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
05a7f4a8df
commit
2671345504
@@ -1431,10 +1431,10 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev)
|
||||
struct devlink *devlink;
|
||||
int err;
|
||||
|
||||
devlink = devlink_alloc(&nsim_dev_devlink_ops, sizeof(*nsim_dev));
|
||||
devlink = devlink_alloc_ns(&nsim_dev_devlink_ops, sizeof(*nsim_dev),
|
||||
nsim_bus_dev->initial_net);
|
||||
if (!devlink)
|
||||
return -ENOMEM;
|
||||
devlink_net_set(devlink, nsim_bus_dev->initial_net);
|
||||
nsim_dev = devlink_priv(devlink);
|
||||
nsim_dev->nsim_bus_dev = nsim_bus_dev;
|
||||
nsim_dev->switch_id.id_len = sizeof(nsim_dev->switch_id.id);
|
||||
|
||||
Reference in New Issue
Block a user