IB/cm: Fix stale connection detection

The ib_cm can incorrectly detect a stale connection (a new connection
request for a QPN that is already connected) as a duplicate connection
request. Separate the handling of potential duplicate REQs from stale
connections.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by

Sean Hefty and committed by
Roland Dreier
d998ccce ec56dc0b

+14 -11
+14 -11
drivers/infiniband/core/cm.c
··· 1297 1297 1298 1298 req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad; 1299 1299 1300 - /* Check for duplicate REQ and stale connections. */ 1300 + /* Check for possible duplicate REQ. */ 1301 1301 spin_lock_irqsave(&cm.lock, flags); 1302 1302 timewait_info = cm_insert_remote_id(cm_id_priv->timewait_info); 1303 - if (!timewait_info) 1304 - timewait_info = cm_insert_remote_qpn(cm_id_priv->timewait_info); 1305 - 1306 1303 if (timewait_info) { 1307 1304 cur_cm_id_priv = cm_get_id(timewait_info->work.local_id, 1308 1305 timewait_info->work.remote_id); 1309 - cm_cleanup_timewait(cm_id_priv->timewait_info); 1310 1306 spin_unlock_irqrestore(&cm.lock, flags); 1311 1307 if (cur_cm_id_priv) { 1312 1308 cm_dup_req_handler(work, cur_cm_id_priv); 1313 1309 cm_deref_id(cur_cm_id_priv); 1314 - } else 1315 - cm_issue_rej(work->port, work->mad_recv_wc, 1316 - IB_CM_REJ_STALE_CONN, CM_MSG_RESPONSE_REQ, 1317 - NULL, 0); 1318 - listen_cm_id_priv = NULL; 1319 - goto out; 1310 + } 1311 + return NULL; 1312 + } 1313 + 1314 + /* Check for stale connections. */ 1315 + timewait_info = cm_insert_remote_qpn(cm_id_priv->timewait_info); 1316 + if (timewait_info) { 1317 + cm_cleanup_timewait(cm_id_priv->timewait_info); 1318 + spin_unlock_irqrestore(&cm.lock, flags); 1319 + cm_issue_rej(work->port, work->mad_recv_wc, 1320 + IB_CM_REJ_STALE_CONN, CM_MSG_RESPONSE_REQ, 1321 + NULL, 0); 1322 + return NULL; 1320 1323 } 1321 1324 1322 1325 /* Find matching listen request. */