[PATCH rdma-next 5/7] RDMA/core: Move rdma device to init_net when net ns is deleted

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

 



From: Parav Pandit <parav@xxxxxxxxxxxx>

When net namespace is deleted, if rdma device(s) exist in such net
namespace, move those rdma devices back to init_net.

Signed-off-by: Parav Pandit <parav@xxxxxxxxxxxx>
Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
---
 drivers/infiniband/core/core_priv.h     | 1 +
 drivers/infiniband/core/device.c        | 2 +-
 drivers/infiniband/core/net_namespace.c | 9 +++++++++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h
index ae4d65359fa7..bd401ed9d119 100644
--- a/drivers/infiniband/core/core_priv.h
+++ b/drivers/infiniband/core/core_priv.h
@@ -362,4 +362,5 @@ void ib_device_cache_update(struct ib_device *device);
 void ib_gid_table_cleanup_one(struct ib_device *device);
 
 int ib_dev_change_net_ns(struct ib_device *device, struct net *net);
+int _ib_dev_change_net_ns(struct ib_device *device, struct net *net);
 #endif /* _CORE_PRIV_H */
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 3758426c8717..06aeababf705 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -787,7 +787,7 @@ void ib_unregister_device(struct ib_device *device)
 }
 EXPORT_SYMBOL(ib_unregister_device);
 
-static int _ib_dev_change_net_ns(struct ib_device *device, struct net *net)
+int _ib_dev_change_net_ns(struct ib_device *device, struct net *net)
 {
 	int ret = -EINVAL;
 
diff --git a/drivers/infiniband/core/net_namespace.c b/drivers/infiniband/core/net_namespace.c
index a2f3bb6b9239..db442f927480 100644
--- a/drivers/infiniband/core/net_namespace.c
+++ b/drivers/infiniband/core/net_namespace.c
@@ -240,8 +240,17 @@ static void rdma_dev_exit_net(struct net *net)
 {
 	struct rdma_dev_net *rdma_net =	net_generic(net, rdma_dev_net_id);
 	struct ib_compat_device *cur, *tmp;
+	struct ib_device *device, *tmpdev;
 
 	mutex_lock(&ib_device_mutex);
+
+	list_for_each_entry_safe(device, tmpdev,
+				 &ib_device_list, core_list) {
+		/* Move the device to init_net */
+		if (net_eq(rdma_dev_net(device), net))
+			_ib_dev_change_net_ns(device, &init_net);
+	}
+
 	down_write(&rdma_net->compat_rwsem);
 	list_for_each_entry_safe(cur, tmp, &rdma_net->compatdev_list, list)
 		remove_one_compatdev(cur);
-- 
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