mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00: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
@@ -1540,8 +1540,18 @@ static inline struct devlink *netdev_to_devlink(struct net_device *dev)
|
||||
struct ib_device;
|
||||
|
||||
struct net *devlink_net(const struct devlink *devlink);
|
||||
void devlink_net_set(struct devlink *devlink, struct net *net);
|
||||
struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size);
|
||||
/* This call is intended for software devices that can create
|
||||
* devlink instances in other namespaces than init_net.
|
||||
*
|
||||
* Drivers that operate on real HW must use devlink_alloc() instead.
|
||||
*/
|
||||
struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,
|
||||
size_t priv_size, struct net *net);
|
||||
static inline struct devlink *devlink_alloc(const struct devlink_ops *ops,
|
||||
size_t priv_size)
|
||||
{
|
||||
return devlink_alloc_ns(ops, priv_size, &init_net);
|
||||
}
|
||||
int devlink_register(struct devlink *devlink, struct device *dev);
|
||||
void devlink_unregister(struct devlink *devlink);
|
||||
void devlink_reload_enable(struct devlink *devlink);
|
||||
|
||||
Reference in New Issue
Block a user