Skip to content

Commit e410331

Browse files
paravmellanoxjgunthorpe
authored andcommitted
Revert "RDMA/cma: Simplify rdma_resolve_addr() error flow"
This reverts commit 219d2e9. The call chain below requires the cm_id_priv's destination address to be setup before performing rdma_bind_addr(). Otherwise source port allocation fails as cma_port_is_unique() no longer sees the correct tuple to allow duplicate users of the source port. rdma_resolve_addr() cma_bind_addr() rdma_bind_addr() cma_get_port() cma_alloc_any_port() cma_port_is_unique() <- compared with zero daddr This can result in false failures to connect, particularly if the source port range is restricted. Fixes: 219d2e9 ("RDMA/cma: Simplify rdma_resolve_addr() error flow") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Parav Pandit <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 11a48a5 commit e410331

File tree

1 file changed

+11
-4
lines changed
  • drivers/infiniband/core

1 file changed

+11
-4
lines changed

drivers/infiniband/core/cma.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,19 +3212,26 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
32123212
int ret;
32133213

32143214
id_priv = container_of(id, struct rdma_id_private, id);
3215+
memcpy(cma_dst_addr(id_priv), dst_addr, rdma_addr_size(dst_addr));
32153216
if (id_priv->state == RDMA_CM_IDLE) {
32163217
ret = cma_bind_addr(id, src_addr, dst_addr);
3217-
if (ret)
3218+
if (ret) {
3219+
memset(cma_dst_addr(id_priv), 0,
3220+
rdma_addr_size(dst_addr));
32183221
return ret;
3222+
}
32193223
}
32203224

3221-
if (cma_family(id_priv) != dst_addr->sa_family)
3225+
if (cma_family(id_priv) != dst_addr->sa_family) {
3226+
memset(cma_dst_addr(id_priv), 0, rdma_addr_size(dst_addr));
32223227
return -EINVAL;
3228+
}
32233229

3224-
if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_ADDR_QUERY))
3230+
if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_ADDR_QUERY)) {
3231+
memset(cma_dst_addr(id_priv), 0, rdma_addr_size(dst_addr));
32253232
return -EINVAL;
3233+
}
32263234

3227-
memcpy(cma_dst_addr(id_priv), dst_addr, rdma_addr_size(dst_addr));
32283235
if (cma_any_addr(dst_addr)) {
32293236
ret = cma_resolve_loopback(id_priv);
32303237
} else {

0 commit comments

Comments
 (0)