diff mbox

[rdma-rc,v1] RDMA/core: Do not use invalid destination in determining port reuse

Message ID 20180312221402.14424-1-shiraz.saleem@intel.com (mailing list archive)
State Accepted
Headers show

Commit Message

Saleem, Shiraz March 12, 2018, 10:14 p.m. UTC
From: Tatyana Nikolova <tatyana.e.nikolova@intel.com>

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: 19b752a19dce ("IB/cma: Allow port reuse for rdma_id")
Reviewed-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
---
v0->v1:
    - Undo unnecessary reordering of if-statements
    - Set the destination address family in rdma_bind_addr() to avoid AF_UNSPEC

 drivers/infiniband/core/cma.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Doug Ledford March 14, 2018, 7:58 p.m. UTC | #1
On Mon, 2018-03-12 at 17:14 -0500, Shiraz Saleem wrote:
> From: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
> 
> 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: 19b752a19dce ("IB/cma: Allow port reuse for rdma_id")
> Reviewed-by: Sean Hefty <sean.hefty@intel.com>
> Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
> Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>

Thanks, applied.
diff mbox

Patch

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 6294a70..a7a1ad2 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -3013,7 +3013,8 @@  static int cma_port_is_unique(struct rdma_bind_list *bind_list,
 			continue;
 
 		/* different dest port -> unique */
-		if (!cma_any_port(cur_daddr) &&
+		if (!cma_any_port(daddr) &&
+		    !cma_any_port(cur_daddr) &&
 		    (dport != cur_dport))
 			continue;
 
@@ -3024,7 +3025,8 @@  static int cma_port_is_unique(struct rdma_bind_list *bind_list,
 			continue;
 
 		/* different dst address -> unique */
-		if (!cma_any_addr(cur_daddr) &&
+		if (!cma_any_addr(daddr) &&
+		    !cma_any_addr(cur_daddr) &&
 		    cma_addr_cmp(daddr, cur_daddr))
 			continue;
 
@@ -3322,13 +3324,13 @@  int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
 		}
 #endif
 	}
+	daddr = cma_dst_addr(id_priv);
+	daddr->sa_family = addr->sa_family;
+
 	ret = cma_get_port(id_priv);
 	if (ret)
 		goto err2;
 
-	daddr = cma_dst_addr(id_priv);
-	daddr->sa_family = addr->sa_family;
-
 	return 0;
 err2:
 	if (id_priv->cma_dev)