[PATCH rdma-next 1/6] RDMA/core: Prepare to not share rdma device in multiple net namespaces

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

 



From: Parav Pandit <parav@xxxxxxxxxxxx>

Prepare device structure and compat device code to optionally avoid
sharing rdma device in multiple net namespaces.

Signed-off-by: Parav Pandit <parav@xxxxxxxxxxxx>
Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
---
 drivers/infiniband/core/device.c        | 1 +
 drivers/infiniband/core/net_namespace.c | 3 +++
 include/rdma/ib_verbs.h                 | 6 ++++++
 3 files changed, 10 insertions(+)

diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index ea39a4c09774..4801e73e764e 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -647,6 +647,7 @@ int ib_register_device(struct ib_device *device, const char *name,
 		goto cg_cleanup;
 	}
 
+	device->netns_shared = 1;
 	/* Perform this under device mutex lock, so that it can synchronize
 	 * with _init_net() to avoid duplicate additions for a given device.
 	 */
diff --git a/drivers/infiniband/core/net_namespace.c b/drivers/infiniband/core/net_namespace.c
index a836fe71289b..569049dd4216 100644
--- a/drivers/infiniband/core/net_namespace.c
+++ b/drivers/infiniband/core/net_namespace.c
@@ -49,6 +49,9 @@ static void rdma_compatdev_create(struct ib_device *device, struct net *net)
 	struct ib_compat_device *cdev;
 	int ret;
 
+	if (!device->netns_shared)
+		return;
+
 	cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
 	if (!cdev)
 		return;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 7956f28cbb27..01ae9ec1d412 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2597,6 +2597,12 @@ struct ib_device {
 	 */
 	refcount_t refcount;
 	struct completion unreg_completion;
+
+	/*
+	 * When set, it indicates that this device is shared among multiple net
+	 * namespaces.
+	 */
+	u8 netns_shared : 1;
 };
 
 struct ib_client {
-- 
2.19.1




[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