Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/core: Let ib_find_gid() continue search even after empty entry

Currently, ib_find_gid() will stop searching after encountering the first
empty GID table entry. This behavior is wrong since neither IB nor RoCE
spec enforce tightly packed GID tables.

For example, when a valid GID entry exists at index N, and if a GID entry
is empty at index N-1, ib_find_gid() will fail to find the valid entry.

Fix it by making ib_find_gid() continue searching even after encountering
missing entries.

Fixes: 5eb620c81ce3 ("IB/core: Add helpers for uncached GID and P_Key searches")
Link: https://lore.kernel.org/r/e55d331b96cecfc2cf19803d16e7109ea966882d.1639055490.git.leonro@nvidia.com
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Mark Zhang <markzhang@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Avihai Horon and committed by
Jason Gunthorpe
483d8051 109f2d39

+2 -1
+2 -1
drivers/infiniband/core/device.c
··· 2461 2461 ++i) { 2462 2462 ret = rdma_query_gid(device, port, i, &tmp_gid); 2463 2463 if (ret) 2464 - return ret; 2464 + continue; 2465 + 2465 2466 if (!memcmp(&tmp_gid, gid, sizeof *gid)) { 2466 2467 *port_num = port; 2467 2468 if (index)