Commit 3ff4de8f authored by Avihai Horon's avatar Avihai Horon Committed by Jason Gunthorpe

RDMA/core: Change rdma_get_gid_attr returned error code

Change the error code returned from rdma_get_gid_attr when the GID entry
is invalid but the GID index is in the gid table size range to -ENODATA
instead of -EINVAL.

This change is done in order to provide a more accurate error reporting to
be used by the new GID query API in user space. Nevertheless, -EINVAL is
still returned from sysfs in the aforementioned case to maintain
compatibility with user space that expects -EINVAL.

Link: https://lore.kernel.org/r/20200923165015.2491894-2-leon@kernel.orgSigned-off-by: default avatarAvihai Horon <avihaih@nvidia.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent a4947e84
...@@ -1220,7 +1220,7 @@ EXPORT_SYMBOL(ib_get_cached_port_state); ...@@ -1220,7 +1220,7 @@ EXPORT_SYMBOL(ib_get_cached_port_state);
const struct ib_gid_attr * const struct ib_gid_attr *
rdma_get_gid_attr(struct ib_device *device, u8 port_num, int index) rdma_get_gid_attr(struct ib_device *device, u8 port_num, int index)
{ {
const struct ib_gid_attr *attr = ERR_PTR(-EINVAL); const struct ib_gid_attr *attr = ERR_PTR(-ENODATA);
struct ib_gid_table *table; struct ib_gid_table *table;
unsigned long flags; unsigned long flags;
......
...@@ -387,7 +387,8 @@ static ssize_t _show_port_gid_attr( ...@@ -387,7 +387,8 @@ static ssize_t _show_port_gid_attr(
gid_attr = rdma_get_gid_attr(p->ibdev, p->port_num, tab_attr->index); gid_attr = rdma_get_gid_attr(p->ibdev, p->port_num, tab_attr->index);
if (IS_ERR(gid_attr)) if (IS_ERR(gid_attr))
return PTR_ERR(gid_attr); /* -EINVAL is returned for user space compatibility reasons. */
return -EINVAL;
ret = print(gid_attr, buf); ret = print(gid_attr, buf);
rdma_put_gid_attr(gid_attr); rdma_put_gid_attr(gid_attr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment