public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Mustafa Ismail <mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	e1000-rdma-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [RDMA PATCH 03/16] i40iw: Fix refused connections
Date: Thu,  7 Apr 2016 11:30:51 -0500	[thread overview]
Message-ID: <1460046664-552-4-git-send-email-mustafa.ismail@intel.com> (raw)
In-Reply-To: <1460046664-552-1-git-send-email-mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Make sure cm_node is setup before sending SYN packet and
ORD/IRD negotiation.

Signed-off-by: Mustafa Ismail <mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/infiniband/hw/i40iw/i40iw_cm.c | 85 ++++++++++++++++++----------------
 1 file changed, 44 insertions(+), 41 deletions(-)

diff --git a/drivers/infiniband/hw/i40iw/i40iw_cm.c b/drivers/infiniband/hw/i40iw/i40iw_cm.c
index 38f917a..bdd4104 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_cm.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_cm.c
@@ -2852,7 +2852,6 @@ static struct i40iw_cm_node *i40iw_create_cm_node(
 					void *private_data,
 					struct i40iw_cm_info *cm_info)
 {
-	int ret;
 	struct i40iw_cm_node *cm_node;
 	struct i40iw_cm_listener *loopback_remotelistener;
 	struct i40iw_cm_node *loopback_remotenode;
@@ -2922,29 +2921,6 @@ static struct i40iw_cm_node *i40iw_create_cm_node(
 	memcpy(cm_node->pdata_buf, private_data, private_data_len);
 
 	cm_node->state = I40IW_CM_STATE_SYN_SENT;
-	ret = i40iw_send_syn(cm_node, 0);
-
-	if (ret) {
-		if (cm_node->ipv4)
-			i40iw_debug(cm_node->dev,
-				    I40IW_DEBUG_CM,
-				    "Api - connect() FAILED: dest addr=%pI4",
-				    cm_node->rem_addr);
-		else
-			i40iw_debug(cm_node->dev, I40IW_DEBUG_CM,
-				    "Api - connect() FAILED: dest addr=%pI6",
-				    cm_node->rem_addr);
-		i40iw_rem_ref_cm_node(cm_node);
-		cm_node = NULL;
-	}
-
-	if (cm_node)
-		i40iw_debug(cm_node->dev,
-			    I40IW_DEBUG_CM,
-			    "Api - connect(): port=0x%04x, cm_node=%p, cm_id = %p.\n",
-			    cm_node->rem_port,
-			    cm_node,
-			    cm_node->cm_id);
 
 	return cm_node;
 }
@@ -3828,23 +3804,8 @@ int i40iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
 				       conn_param->private_data_len,
 				       (void *)conn_param->private_data,
 				       &cm_info);
-	if (!cm_node) {
-		i40iw_manage_qhash(iwdev,
-				   &cm_info,
-				   I40IW_QHASH_TYPE_TCP_ESTABLISHED,
-				   I40IW_QHASH_MANAGE_TYPE_DELETE,
-				   NULL,
-				   false);
-
-		if (apbvt_set && !i40iw_listen_port_in_use(&iwdev->cm_core,
-							   cm_info.loc_port))
-			i40iw_manage_apbvt(iwdev,
-					   cm_info.loc_port,
-					   I40IW_MANAGE_APBVT_DEL);
-		cm_id->rem_ref(cm_id);
-		iwdev->cm_core.stats_connect_errs++;
-		return -ENOMEM;
-	}
+	if (!cm_node)
+		goto err;
 
 	i40iw_record_ird_ord(cm_node, (u16)conn_param->ird, (u16)conn_param->ord);
 	if (cm_node->send_rdma0_op == SEND_RDMA_READ_ZERO &&
@@ -3857,7 +3818,49 @@ int i40iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
 	cm_node->iwqp = iwqp;
 	iwqp->cm_id = cm_id;
 	i40iw_add_ref(&iwqp->ibqp);
+
+	if (cm_node->state == I40IW_CM_STATE_SYN_SENT) {
+		if (i40iw_send_syn(cm_node, 0)) {
+			i40iw_rem_ref_cm_node(cm_node);
+			goto err;
+		}
+	}
+
+	i40iw_debug(cm_node->dev,
+		    I40IW_DEBUG_CM,
+		    "Api - connect(): port=0x%04x, cm_node=%p, cm_id = %p.\n",
+		    cm_node->rem_port,
+		    cm_node,
+		    cm_node->cm_id);
 	return 0;
+
+err:
+	if (cm_node) {
+		if (cm_node->ipv4)
+			i40iw_debug(cm_node->dev,
+				    I40IW_DEBUG_CM,
+				    "Api - connect() FAILED: dest addr=%pI4",
+				    cm_node->rem_addr);
+		else
+			i40iw_debug(cm_node->dev, I40IW_DEBUG_CM,
+				    "Api - connect() FAILED: dest addr=%pI6",
+				    cm_node->rem_addr);
+	}
+	i40iw_manage_qhash(iwdev,
+			   &cm_info,
+			   I40IW_QHASH_TYPE_TCP_ESTABLISHED,
+			   I40IW_QHASH_MANAGE_TYPE_DELETE,
+			   NULL,
+			   false);
+
+	if (apbvt_set && !i40iw_listen_port_in_use(&iwdev->cm_core,
+						   cm_info.loc_port))
+		i40iw_manage_apbvt(iwdev,
+				   cm_info.loc_port,
+				   I40IW_MANAGE_APBVT_DEL);
+	cm_id->rem_ref(cm_id);
+	iwdev->cm_core.stats_connect_errs++;
+	return -ENOMEM;
 }
 
 /**
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-04-07 16:30 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-07 16:30 [RDMA PATCH 00/16] Intel X722 iWARP driver update Mustafa Ismail
     [not found] ` <1460046664-552-1-git-send-email-mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-04-07 16:30   ` [RDMA PATCH 01/16] i40iw: Fix overflow of region length Mustafa Ismail
     [not found]     ` <1460046664-552-2-git-send-email-mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-04-11  9:23       ` Leon Romanovsky
     [not found]         ` <20160411092324.GG20252-2ukJVAZIZ/Y@public.gmane.org>
2016-04-12 18:09           ` Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 02/16] i40iw: Correct QP size calculation Mustafa Ismail
2016-04-07 16:30   ` Mustafa Ismail [this message]
2016-04-07 16:30   ` [RDMA PATCH 04/16] i40iw: Correct max message size in query port Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 05/16] i40iw: Do not set self-referencing pointer to NULL after free Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 06/16] i40iw: Add qp table lock around AE processing Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 07/16] i40iw: Set vendor_err only if there is an actual error Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 08/16] i40iw: Populate vendor_id and vendor_part_id fields Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 09/16] i40iw: Remove unused code and fix warning Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 10/16] i40iw: Add virtual channel message queue Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 11/16] i40iw: Correct return code check in add_pble_pool Mustafa Ismail
2016-04-07 16:31   ` [RDMA PATCH 12/16] i40iw: Initialize max enabled vfs variable Mustafa Ismail
2016-04-07 16:31   ` [RDMA PATCH 13/16] i40iw: Add base memory management extensions Mustafa Ismail
     [not found]     ` <1460046664-552-14-git-send-email-mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-04-12 14:07       ` Christoph Hellwig
     [not found]         ` <20160412140739.GA23302-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2016-04-12 18:13           ` Mustafa Ismail
2016-04-07 16:31   ` [RDMA PATCH 14/16] i40iw: Fix endian issues and warnings Mustafa Ismail
2016-04-07 16:31   ` [RDMA PATCH 15/16] i40iw: Fix SD calculation for initial HMC creation Mustafa Ismail
2016-04-07 16:31   ` [RDMA PATCH 16/16] i40iw: Adding queue drain functions Mustafa Ismail
     [not found]     ` <1460046664-552-17-git-send-email-mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-04-08  0:46       ` Leon Romanovsky
     [not found]         ` <20160408004638.GD20252-2ukJVAZIZ/Y@public.gmane.org>
2016-04-08 18:44           ` Mustafa Ismail
2016-04-08 22:15             ` Steve Wise
2016-04-10 19:26               ` Sagi Grimberg
     [not found]                 ` <570AA8D0.2060404-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2016-04-11  4:50                   ` 'Leon Romanovsky'
2016-04-12 10:27   ` [RDMA PATCH 00/16] Intel X722 iWARP driver update Or Gerlitz
     [not found] ` <CALq1K=L4fdgLxL+-2vNfX0SUvrS9ShTgS=vDOpZyJDyK8EHB=Q@mail.gmail.com>
2016-04-12  4:33   ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460046664-552-4-git-send-email-mustafa.ismail@intel.com \
    --to=mustafa.ismail-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=e1000-rdma-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox