Commit 219d2e9d authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

RDMA/cma: Simplify rdma_resolve_addr() error flow

Currently dst address is first set and later on cleared on either of the
3 error conditions are met.
However none of the APIs or checks are supposed to refer to the
destination address of the cm_id.
Therefore, set the destination address after necessary checks pass which
simplifies the error flow.
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent e11fef9f
...@@ -2971,25 +2971,19 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr, ...@@ -2971,25 +2971,19 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
int ret; int ret;
id_priv = container_of(id, struct rdma_id_private, id); id_priv = container_of(id, struct rdma_id_private, id);
memcpy(cma_dst_addr(id_priv), dst_addr, rdma_addr_size(dst_addr));
if (id_priv->state == RDMA_CM_IDLE) { if (id_priv->state == RDMA_CM_IDLE) {
ret = cma_bind_addr(id, src_addr, dst_addr); ret = cma_bind_addr(id, src_addr, dst_addr);
if (ret) { if (ret)
memset(cma_dst_addr(id_priv), 0, rdma_addr_size(dst_addr));
return ret; return ret;
} }
}
if (cma_family(id_priv) != dst_addr->sa_family) { if (cma_family(id_priv) != dst_addr->sa_family)
memset(cma_dst_addr(id_priv), 0, rdma_addr_size(dst_addr));
return -EINVAL; return -EINVAL;
}
if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_ADDR_QUERY)) { if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_ADDR_QUERY))
memset(cma_dst_addr(id_priv), 0, rdma_addr_size(dst_addr));
return -EINVAL; return -EINVAL;
}
memcpy(cma_dst_addr(id_priv), dst_addr, rdma_addr_size(dst_addr));
atomic_inc(&id_priv->refcount); atomic_inc(&id_priv->refcount);
if (cma_any_addr(dst_addr)) { if (cma_any_addr(dst_addr)) {
ret = cma_resolve_loopback(id_priv); ret = cma_resolve_loopback(id_priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment