[PATCH rdma-core] verbs: Do not add device whose uverbs device is not accessible

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

 



From: Parav Pandit <parav@xxxxxxxxxxxx>

When RDMA devices are used in container environment, orchestration
software may choose to not map a uverbs character device to container.

Adding an RDMA device which is not accessible for any verbs operation,
but only accessible via sysfs is not very useful to real world
applications but it just creates confusion.

Therefore, do not add RDMA devices to ib device list, if its respective
character device is not accessible.

Signed-off-by: Parav Pandit <parav@xxxxxxxxxxxx>
Signed-off-by: Yishai Hadas <yishaih@xxxxxxxxxxxx>
---

PR was sent:
https://github.com/linux-rdma/rdma-core/pull/357

 libibverbs/init.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/libibverbs/init.c b/libibverbs/init.c
index cda628b..d925c0e 100644
--- a/libibverbs/init.c
+++ b/libibverbs/init.c
@@ -66,6 +66,20 @@ struct ibv_driver {
 static LIST_HEAD(driver_name_list);
 static LIST_HEAD(driver_list);
 
+static int try_access_device(const struct verbs_sysfs_dev *sysfs_dev)
+{
+	struct stat cdev_stat;
+	char *devpath;
+	int ret;
+
+	if (asprintf(&devpath, "/dev/infiniband/%s", sysfs_dev->sysfs_name) < 0)
+		return ENOMEM;
+
+	ret = stat(devpath, &cdev_stat);
+	free(devpath);
+	return ret;
+}
+
 static int find_sysfs_devs(struct list_head *tmp_sysfs_dev_list)
 {
 	char class_path[IBV_SYSFS_PATH_MAX];
@@ -133,6 +147,9 @@ static int find_sysfs_devs(struct list_head *tmp_sysfs_dev_list)
 			continue;
 		}
 
+		if (try_access_device(sysfs_dev))
+			continue;
+
 		sysfs_dev->time_created = buf.st_mtim;
 
 		if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "abi_version",
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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