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

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>

authored by

Jack Wang and committed by
Doug Ledford
93b1f29d 9e2c3f1c

+5 -1
+5 -1
drivers/infiniband/core/cma.c
··· 709 709 union ib_gid gid, sgid, *dgid; 710 710 u16 pkey, index; 711 711 u8 p; 712 + enum ib_port_state port_state; 712 713 int i; 713 714 714 715 cma_dev = NULL; ··· 725 724 if (ib_find_cached_pkey(cur_dev->device, p, pkey, &index)) 726 725 continue; 727 726 727 + if (ib_get_cached_port_state(cur_dev->device, p, &port_state)) 728 + continue; 728 729 for (i = 0; !ib_get_cached_gid(cur_dev->device, p, i, 729 730 &gid, NULL); 730 731 i++) { ··· 738 735 } 739 736 740 737 if (!cma_dev && (gid.global.subnet_prefix == 741 - dgid->global.subnet_prefix)) { 738 + dgid->global.subnet_prefix) && 739 + port_state == IB_PORT_ACTIVE) { 742 740 cma_dev = cur_dev; 743 741 sgid = gid; 744 742 id_priv->id.port_num = p;