RDMA/srp: Make the SRP sysfs class net namespace aware

Tag srp_class by the RDMA device's net namespace so SRP hosts derived from
same-named RDMA devices can coexist across namespaces.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Link: https://patch.msgid.link/20260716132316.1495242-8-jiri@resnulli.us
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
Jiri Pirko 2026-07-16 15:23:08 +02:00 committed by Leon Romanovsky
parent 47b9ef3c00
commit e9153a2671

View File

@ -3189,10 +3189,24 @@ static struct attribute *srp_class_attrs[];
ATTRIBUTE_GROUPS(srp_class);
/*
* SRP hosts are named after their ib device, so tag the class by the ib
* device's net namespace.
*/
static const struct ns_common *srp_net_namespace(const struct device *dev)
{
struct srp_host *host = container_of(dev, struct srp_host, dev);
struct net *net = rdma_dev_net(host->srp_dev->dev);
return net ? to_ns_common(net) : NULL;
}
static struct class srp_class = {
.name = "infiniband_srp",
.dev_groups = srp_class_groups,
.dev_release = srp_release_dev
.dev_release = srp_release_dev,
.ns_type = &net_ns_type_operations,
.namespace = srp_net_namespace,
};
/**