IB/core: Honor port_num while resolving GID for IB link layer

ah_attr contains the port number to which cm_id is bound. However, while
searching for GID table for matching GID entry, the port number is
ignored.

This could cause the wrong GID to be used when the ah_attr is converted to
an AH.

Reviewed-by: Daniel Jurgens <danielj@mellanox.com>
Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
Parav Pandit 2018-03-13 16:06:14 +02:00 committed by Jason Gunthorpe
parent 6d337179f2
commit 563c4ba3bd
1 changed files with 11 additions and 13 deletions

View File

@ -724,21 +724,19 @@ int ib_init_ah_from_mcmember(struct ib_device *device, u8 port_num,
{ {
int ret; int ret;
u16 gid_index; u16 gid_index;
u8 p;
if (rdma_protocol_roce(device, port_num)) { /* GID table is not based on the netdevice for IB link layer,
ret = ib_find_cached_gid_by_port(device, &rec->port_gid, * so ignore ndev during search.
gid_type, port_num, */
ndev, if (rdma_protocol_ib(device, port_num))
&gid_index); ndev = NULL;
} else if (rdma_protocol_ib(device, port_num)) { else if (!rdma_protocol_roce(device, port_num))
ret = ib_find_cached_gid(device, &rec->port_gid, return -EINVAL;
IB_GID_TYPE_IB, NULL, &p,
ret = ib_find_cached_gid_by_port(device, &rec->port_gid,
gid_type, port_num,
ndev,
&gid_index); &gid_index);
} else {
ret = -EINVAL;
}
if (ret) if (ret)
return ret; return ret;