Re: [PATCH rdma-next v1 0/5] Disable device sharing in multiple net namespace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 26, 2019 at 02:01:44PM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> 
> Changelog:
>  v0->v1:
>  * Rebased.
>  * Addressed Doug's Jason's comment to not allow netns system
>    mode change when non init_net namespaces exist.
> 
> >From Parav:
> 
> When there are multiple rdma devices exist in a system, it
> is desired to have per net namespace based devices without any
> compatibility devices.
> 
> Therefore, add a query and set option through which user can disable/enable
> default mode of sharing a rdma device in multiple net namespaces.
> 
> In subsequent series, a new netlink command will be added to change
> the namespace of an rdma device.
> 
> Thanks
> 
> Parav Pandit (5):
>   RDMA/core: Add module param to disable device sharing among net ns
>   RDMA: Check net namespace access for uverbs, umad, cma and nldev
>   RDMA/core: Extend ib_device_get_by_index for net namespace
>   RDMA/core: Add interface to read device namespace sharing mode
>   RDMA/core: Add command to set ib_core device net namspace sharing mode

Applied to for-next, with this hunk as I noted, please check. Thanks

diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index db123b2e9bcf0a..2dbd04739ac6d5 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -1908,6 +1908,9 @@ int ib_enum_all_devs(nldev_callback nldev_cb, struct sk_buff *skb,
 
 	down_read(&devices_rwsem);
 	xa_for_each_marked (&devices, index, dev, DEVICE_REGISTERED) {
+		if (!rdma_dev_access_netns(dev, sock_net(skb->sk)))
+			continue;
+
 		ret = nldev_cb(dev, skb, cb, idx);
 		if (ret)
 			break;
diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index 0d70727920cda0..28b4ed8f9930e3 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -686,14 +686,6 @@ static int _nldev_get_dumpit(struct ib_device *device,
 	if (idx < start)
 		return 0;
 
-	if (!ib_device_try_get(device))
-		return 0;
-
-	if (!rdma_dev_access_netns(device, sock_net(skb->sk))) {
-		ib_device_put(device);
-		return 0;
-	}
-
 	nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
 			RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_GET),
 			0, NLM_F_MULTI);
@@ -707,9 +699,7 @@ static int _nldev_get_dumpit(struct ib_device *device,
 
 	idx++;
 
-out:
-	ib_device_put(device);
-	cb->args[0] = idx;
+out:	cb->args[0] = idx;
 	return skb->len;
 }
 
@@ -889,14 +879,6 @@ static int _nldev_res_get_dumpit(struct ib_device *device,
 	if (idx < start)
 		return 0;
 
-	if (!ib_device_try_get(device))
-		return 0;
-
-	if (!rdma_dev_access_netns(device, sock_net(skb->sk))) {
-		ib_device_put(device);
-		return 0;
-	}
-
 	nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
 			RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_RES_GET),
 			0, NLM_F_MULTI);
@@ -911,7 +893,6 @@ static int _nldev_res_get_dumpit(struct ib_device *device,
 	idx++;
 
 out:
-	ib_device_put(device);
 	cb->args[0] = idx;
 	return skb->len;
 }



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux