[openib-general] [PATCH] CM: fix SIDR cleanup

Sean Hefty mshefty at ichips.intel.com
Tue Jan 18 13:27:13 PST 2005


Committing patch to:

* fix cleanup related to SIDR request/reply when user destroys their
  communication identifier
* remove unused SIDR call
* remove call to cleanup SIDR tracking from incorrect state

signed-off-by: Sean Hefty <sean.hefty at intel.com>

- Sean

Index: core/cm.c
===================================================================
--- core/cm.c	(revision 1564)
+++ core/cm.c	(working copy)
@@ -499,31 +499,14 @@
 	return NULL;
 }
 
-static struct cm_id_private * cm_find_id_by_remote_sidr(union ib_gid *port_gid,
-							u32 remote_id)
+static void cm_reject_sidr_req(struct cm_id_private *cm_id_priv,
+			       enum ib_cm_sidr_status status)
 {
-	struct rb_node *node = cm.remote_sidr_table.rb_node;
-	struct cm_id_private *cm_id_priv;
+	struct ib_cm_sidr_rep_param param;
 
-	while (node) {
-		cm_id_priv = rb_entry(node, struct cm_id_private, remote_id_node);
-		if (remote_id < cm_id_priv->id.remote_id)
-			node = node->rb_left;
-		else if (remote_id > cm_id_priv->id.remote_id)
-			node = node->rb_right;
-		else {
-			int cmp;
-			cmp = memcmp(port_gid, &cm_id_priv->remote_port_gid,
-				     sizeof *port_gid);
-			if (cmp < 0)
-				node = node->rb_left;
-			else if (cmp > 0)
-				node = node->rb_right;
-			else
-				return cm_id_priv;
-		}
-	}
-	return NULL;
+	memset(&param, 0, sizeof param);
+	param.status = status;
+	ib_send_cm_sidr_rep(&cm_id_priv->id, &param);
 }
 
 struct ib_cm_id *ib_create_cm_id(ib_cm_handler cm_handler,
@@ -569,11 +552,22 @@
 		spin_lock_irqsave(&cm.lock, flags2);
 		rb_erase(&cm_id_priv->service_node, &cm.service_table);
 		spin_unlock_irqrestore(&cm.lock, flags2);
+		cm_id->state = IB_CM_IDLE;
+		spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+		break;
+	case IB_CM_SIDR_REQ_SENT:
+		cm_id->state = IB_CM_IDLE;
+		spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+		ib_cancel_mad(cm_id_priv->port->mad_agent,
+			      (unsigned long) cm_id_priv->msg);
+		break;
+	case IB_CM_SIDR_REQ_RCVD:
+		spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+		cm_reject_sidr_req(cm_id_priv, IB_SIDR_REJECT);
+		break;
 	default:
 		break;
 	}
-	cm_id->state = IB_CM_IDLE;
-	spin_unlock_irqrestore(&cm_id_priv->lock, flags);
 
 	cm_free_id(cm_id->local_id);
 	atomic_dec(&cm_id_priv->refcount);
@@ -2161,7 +2155,7 @@
 {
 	struct cm_id_private *cm_id_priv;
 	struct ib_cm_event cm_event;
-	unsigned long flags, flags2;
+	unsigned long flags;
 
 	memset(&cm_event, 0, sizeof cm_event);
 	cm_id_priv = msg->cm_id_priv;
@@ -2187,9 +2181,6 @@
 	case IB_CM_SIDR_REQ_SENT:
 		cm_id_priv->id.state = IB_CM_IDLE;
 		cm_event.event = IB_CM_SIDR_REQ_ERROR;
-		spin_lock_irqsave(&cm.lock, flags2);
-		rb_erase(&cm_id_priv->remote_id_node, &cm.remote_sidr_table);
-		spin_unlock_irqrestore(&cm.lock, flags2);
 		break;
 	default:
 		goto discard;



More information about the general mailing list