Skip to content

Commit 9dea9a2

Browse files
tatyana-endledford
authored andcommitted
RDMA/core: Do not use invalid destination in determining port reuse
cma_port_is_unique() allows local port reuse if the quad (source address and port, destination address and port) for this connection is unique. However, if the destination info is zero or unspecified, it can't make a correct decision but still allows port reuse. For example, sometimes rdma_bind_addr() is called with unspecified destination and reusing the port can lead to creating a connection with a duplicate quad, after the destination is resolved. The issue manifests when MPI scale-up tests hang after the duplicate quad is used. Set the destination address family and add checks for zero destination address and port to prevent source port reuse based on invalid destination. Fixes: 19b752a ("IB/cma: Allow port reuse for rdma_id") Reviewed-by: Sean Hefty <[email protected]> Signed-off-by: Tatyana Nikolova <[email protected]> Signed-off-by: Shiraz Saleem <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent f3f134f commit 9dea9a2

File tree

1 file changed

+7
-5
lines changed
  • drivers/infiniband/core

1 file changed

+7
-5
lines changed

drivers/infiniband/core/cma.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,7 +3069,8 @@ static int cma_port_is_unique(struct rdma_bind_list *bind_list,
30693069
continue;
30703070

30713071
/* different dest port -> unique */
3072-
if (!cma_any_port(cur_daddr) &&
3072+
if (!cma_any_port(daddr) &&
3073+
!cma_any_port(cur_daddr) &&
30733074
(dport != cur_dport))
30743075
continue;
30753076

@@ -3080,7 +3081,8 @@ static int cma_port_is_unique(struct rdma_bind_list *bind_list,
30803081
continue;
30813082

30823083
/* different dst address -> unique */
3083-
if (!cma_any_addr(cur_daddr) &&
3084+
if (!cma_any_addr(daddr) &&
3085+
!cma_any_addr(cur_daddr) &&
30843086
cma_addr_cmp(daddr, cur_daddr))
30853087
continue;
30863088

@@ -3378,13 +3380,13 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
33783380
}
33793381
#endif
33803382
}
3383+
daddr = cma_dst_addr(id_priv);
3384+
daddr->sa_family = addr->sa_family;
3385+
33813386
ret = cma_get_port(id_priv);
33823387
if (ret)
33833388
goto err2;
33843389

3385-
daddr = cma_dst_addr(id_priv);
3386-
daddr->sa_family = addr->sa_family;
3387-
33883390
return 0;
33893391
err2:
33903392
if (id_priv->cma_dev)

0 commit comments

Comments
 (0)