From: Mark Zhang <markz@xxxxxxxxxxxx> 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@xxxxxxxxxxxx> Signed-off-by: Mark Zhang <markz@xxxxxxxxxxxx> Reviewed-by: Alex Rosenbaum <alexr@xxxxxxxxxxxx> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- 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