linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@mellanox.com>
Cc: Mark Zhang <markz@mellanox.com>,
	Alex Rosenbaum <alexr@mellanox.com>,
	linux-rdma@vger.kernel.org, Parav Pandit <parav@mellanox.com>
Subject: [PATCH rdma-next] IB/cm: Consider local communication ID when check for a stale connection
Date: Thu, 16 Jul 2020 13:41:58 +0300	[thread overview]
Message-ID: <20200716104158.1422501-1-leon@kernel.org> (raw)

From: Mark Zhang <markz@mellanox.com>

Made the check for duplicate/stale CM more strict by adding comparison
for remote communication ID field.

The absence of such strict check causes to the following flows not being
handled properly:
1. Client tries to setup more than one connection with same QP in
   a server (e.g., when use external QP), the client would reject
   the reply.
2. Client node reboots, and when it gets the same QP number as that
   of before the reboot time, the server would rejects the request.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Mark Zhang <markz@mellanox.com>
Reviewed-by: Alex Rosenbaum <alexr@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/core/cm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 0d1377232933..23dfba947357 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -775,12 +775,17 @@ static struct cm_timewait_info * cm_insert_remote_qpn(struct cm_timewait_info
 	struct cm_timewait_info *cur_timewait_info;
 	__be64 remote_ca_guid = timewait_info->remote_ca_guid;
 	__be32 remote_qpn = timewait_info->remote_qpn;
+	__be32 remote_id = timewait_info->work.remote_id;
 
 	while (*link) {
 		parent = *link;
 		cur_timewait_info = rb_entry(parent, struct cm_timewait_info,
 					     remote_qp_node);
-		if (be32_lt(remote_qpn, cur_timewait_info->remote_qpn))
+		if (be32_lt(remote_id, cur_timewait_info->work.remote_id))
+			link = &(*link)->rb_left;
+		else if (be32_gt(remote_id, cur_timewait_info->work.remote_id))
+			link = &(*link)->rb_right;
+		else if (be32_lt(remote_qpn, cur_timewait_info->remote_qpn))
 			link = &(*link)->rb_left;
 		else if (be32_gt(remote_qpn, cur_timewait_info->remote_qpn))
 			link = &(*link)->rb_right;
-- 
2.26.2


             reply	other threads:[~2020-07-16 10:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16 10:41 Leon Romanovsky [this message]
2020-07-31 17:47 ` [PATCH rdma-next] IB/cm: Consider local communication ID when check for a stale connection Jason Gunthorpe

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=20200716104158.1422501-1-leon@kernel.org \
    --to=leon@kernel.org \
    --cc=alexr@mellanox.com \
    --cc=dledford@redhat.com \
    --cc=jgg@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=markz@mellanox.com \
    --cc=parav@mellanox.com \
    /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;
as well as URLs for NNTP newsgroup(s).