diff mbox

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

Message ID 1531152218-22041-1-git-send-email-yishaih@mellanox.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Yishai Hadas July 9, 2018, 4:03 p.m. UTC
From: Parav Pandit <parav@mellanox.com>

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@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---

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

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

Comments

Yishai Hadas July 15, 2018, 1:59 p.m. UTC | #1
On 7/9/2018 7:03 PM, Yishai Hadas wrote:
> From: Parav Pandit <parav@mellanox.com>
> 
> 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@mellanox.com>
> Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
> ---
> 
> PR was sent:
> https://github.com/linux-rdma/rdma-core/pull/357
> 

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

Patch

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",