[openib-general] [PATCH 2/2] ib_cm: fix REJ due to invalid GID

Arne Redlich arne.redlich at xiranet.com
Tue Jul 18 06:53:41 PDT 2006


Reject a REQ containing invalid GID(s) with appropriate reason codes
instead of IB_CM_CONSUMER_REJ.

Signed-off-by: Arne Redlich <arne.redlich at xiranet.com>

Index: infiniband/core/cm.c
===================================================================
--- infiniband/core/cm.c	(revision 8556)
+++ infiniband/core/cm.c	(working copy)
@@ -1337,7 +1337,7 @@ static int cm_req_handler(struct cm_work
 	struct ib_cm_id *cm_id;
 	struct cm_id_private *cm_id_priv, *listen_cm_id_priv;
 	struct cm_req_msg *req_msg;
-	int ret;
+	int ret, reject;
 
 	req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
 
@@ -1354,6 +1354,7 @@ static int cm_req_handler(struct cm_work
 							    id.local_id);
 	if (IS_ERR(cm_id_priv->timewait_info)) {
 		ret = PTR_ERR(cm_id_priv->timewait_info);
+		reject = 1;
 		goto error1;
 	}
 	cm_id_priv->timewait_info->work.remote_id = req_msg->local_comm_id;
@@ -1363,6 +1364,7 @@ static int cm_req_handler(struct cm_work
 	listen_cm_id_priv = cm_match_req(work, cm_id_priv);
 	if (!listen_cm_id_priv) {
 		ret = -EINVAL;
+		reject = 0;
 		goto error2;
 	}
 
@@ -1373,12 +1375,21 @@ static int cm_req_handler(struct cm_work
 
 	cm_format_paths_from_req(req_msg, &work->path[0], &work->path[1]);
 	ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av);
-	if (ret)
+	if (ret) {
+		cm_issue_rej(work->port, work->mad_recv_wc, IB_CM_INVALID_GID,
+			     CM_MSG_RESPONSE_REQ, NULL, 0);
+		reject = 0;
 		goto error3;
+	}
 	if (req_msg->alt_local_lid) {
 		ret = cm_init_av_by_path(&work->path[1], &cm_id_priv->alt_av);
-		if (ret)
+		if (ret) {
+			cm_issue_rej(work->port, work->mad_recv_wc,
+				     IB_CM_INVALID_ALT_GID, CM_MSG_RESPONSE_REQ,
+				     NULL, 0);
+			reject = 0;
 			goto error3;
+		}
 	}
 	cm_id_priv->tid = req_msg->hdr.tid;
 	cm_id_priv->timeout_ms = cm_convert_to_ms(
@@ -1405,7 +1416,7 @@ error3:	atomic_dec(&cm_id_priv->refcount
 	cm_cleanup_timewait(cm_id_priv->timewait_info);
 error2:	kfree(cm_id_priv->timewait_info);
 	cm_id_priv->timewait_info = NULL;
-error1:	ib_destroy_cm_id(&cm_id_priv->id);
+error1:	cm_destroy_id(&cm_id_priv->id, reject);
 	return ret;
 }
 






More information about the general mailing list