Message ID | 1531152218-22041-1-git-send-email-yishaih@mellanox.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
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 --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",