RDS: check for valid cm_id before initiating connection
authorsantosh.shilimkar@oracle.com <santosh.shilimkar@oracle.com>
Sat, 22 Aug 2015 22:45:35 +0000 (15:45 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 25 Aug 2015 20:35:31 +0000 (13:35 -0700)
Connection could have been dropped while the route is being resolved
so check for valid cm_id before initiating the connection.

Reviewed-by: Ajaykumar Hotchandani <ajaykumar.hotchandani@oracle.com>
Signed-off-by: Santosh Shilimkar <ssantosh@kernel.org>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rds/rdma_transport.c

index 20824083604328fe01359be1818673418490f43b..b9b40af5345b6f42a6ac8e7baea1405ac7c20fda 100644 (file)
@@ -34,6 +34,7 @@
 #include <rdma/rdma_cm.h>
 
 #include "rdma_transport.h"
+#include "ib.h"
 
 static struct rdma_cm_id *rds_rdma_listen_id;
 
@@ -82,8 +83,18 @@ int rds_rdma_cm_event_handler(struct rdma_cm_id *cm_id,
                break;
 
        case RDMA_CM_EVENT_ROUTE_RESOLVED:
-               /* XXX worry about racing with listen acceptance */
-               ret = trans->cm_initiate_connect(cm_id);
+               /* Connection could have been dropped so make sure the
+                * cm_id is valid before proceeding
+                */
+               if (conn) {
+                       struct rds_ib_connection *ibic;
+
+                       ibic = conn->c_transport_data;
+                       if (ibic && ibic->i_cm_id == cm_id)
+                               ret = trans->cm_initiate_connect(cm_id);
+                       else
+                               rds_conn_drop(conn);
+               }
                break;
 
        case RDMA_CM_EVENT_ESTABLISHED: