Skip to content

Commit 93b1f29

Browse files
Jack Wangdledford
authored andcommitted
RDMA/cma: resolve to first active ib port
When we try to resolve a dest addr, if we don't give src addr, cma core will try to resolve to our source ib device automatically. The current logic only checks if a given port has the same subnet_prefix as our dest, which is not enough if we use default well known subnet_prefix on our active port, as it will be the same as the subnet_prefix on inactive ports and we might match against an inactive port by accident. To resolve this, we should also check if port is active before we resolve it as a suitable src address for a given dest. Signed-off-by: Jack Wang <jinpu.wang@profitbricks.com> Reviewed-by: Michael Wang <yun.wang@profitbricks.com> Acked-by: Sean Hefty <sean.hefty@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 9e2c3f1 commit 93b1f29

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • drivers/infiniband/core

‎drivers/infiniband/core/cma.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
709709
union ib_gid gid, sgid, *dgid;
710710
u16 pkey, index;
711711
u8 p;
712+
enum ib_port_state port_state;
712713
int i;
713714

714715
cma_dev = NULL;
@@ -724,6 +725,8 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
724725
if (ib_find_cached_pkey(cur_dev->device, p, pkey, &index))
725726
continue;
726727

728+
if (ib_get_cached_port_state(cur_dev->device, p, &port_state))
729+
continue;
727730
for (i = 0; !ib_get_cached_gid(cur_dev->device, p, i,
728731
&gid, NULL);
729732
i++) {
@@ -735,7 +738,8 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
735738
}
736739

737740
if (!cma_dev && (gid.global.subnet_prefix ==
738-
dgid->global.subnet_prefix)) {
741+
dgid->global.subnet_prefix) &&
742+
port_state == IB_PORT_ACTIVE) {
739743
cma_dev = cur_dev;
740744
sgid = gid;
741745
id_priv->id.port_num = p;

0 commit comments

Comments
 (0)