Skip to content

Commit 0c6949c

Browse files
Leon Romanovskyjgunthorpe
authored andcommitted
RDMA/cm: Fix missing RDMA_CM_EVENT_REJECTED event after receiving REJ message
The cm_reset_to_idle() call before formatting event changed the CM_ID state from IB_CM_REQ_RCVD to be IB_CM_IDLE. It caused to wrong value of CM_REJ_MESSAGE_REJECTED field. The result of that was that rdma_reject() calls in the passive side didn't generate RDMA_CM_EVENT_REJECTED event in the active side. Fixes: 81ddb41 ("RDMA/cm: Allow ib_send_cm_rej() to be done under lock") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent f70968f commit 0c6949c

File tree

1 file changed

+13
-11
lines changed
  • drivers/infiniband/core

1 file changed

+13
-11
lines changed

drivers/infiniband/core/cm.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,19 +1828,17 @@ static void cm_format_mra(struct cm_mra_msg *mra_msg,
18281828

18291829
static void cm_format_rej(struct cm_rej_msg *rej_msg,
18301830
struct cm_id_private *cm_id_priv,
1831-
enum ib_cm_rej_reason reason,
1832-
void *ari,
1833-
u8 ari_length,
1834-
const void *private_data,
1835-
u8 private_data_len)
1831+
enum ib_cm_rej_reason reason, void *ari,
1832+
u8 ari_length, const void *private_data,
1833+
u8 private_data_len, enum ib_cm_state state)
18361834
{
18371835
lockdep_assert_held(&cm_id_priv->lock);
18381836

18391837
cm_format_mad_hdr(&rej_msg->hdr, CM_REJ_ATTR_ID, cm_id_priv->tid);
18401838
IBA_SET(CM_REJ_REMOTE_COMM_ID, rej_msg,
18411839
be32_to_cpu(cm_id_priv->id.remote_id));
18421840

1843-
switch(cm_id_priv->id.state) {
1841+
switch (state) {
18441842
case IB_CM_REQ_RCVD:
18451843
IBA_SET(CM_REJ_LOCAL_COMM_ID, rej_msg, be32_to_cpu(0));
18461844
IBA_SET(CM_REJ_MESSAGE_REJECTED, rej_msg, CM_MSG_RESPONSE_REQ);
@@ -1905,8 +1903,9 @@ static void cm_dup_req_handler(struct cm_work *work,
19051903
cm_id_priv->private_data_len);
19061904
break;
19071905
case IB_CM_TIMEWAIT:
1908-
cm_format_rej((struct cm_rej_msg *) msg->mad, cm_id_priv,
1909-
IB_CM_REJ_STALE_CONN, NULL, 0, NULL, 0);
1906+
cm_format_rej((struct cm_rej_msg *)msg->mad, cm_id_priv,
1907+
IB_CM_REJ_STALE_CONN, NULL, 0, NULL, 0,
1908+
IB_CM_TIMEWAIT);
19101909
break;
19111910
default:
19121911
goto unlock;
@@ -2904,6 +2903,7 @@ static int cm_send_rej_locked(struct cm_id_private *cm_id_priv,
29042903
u8 ari_length, const void *private_data,
29052904
u8 private_data_len)
29062905
{
2906+
enum ib_cm_state state = cm_id_priv->id.state;
29072907
struct ib_mad_send_buf *msg;
29082908
int ret;
29092909

@@ -2913,7 +2913,7 @@ static int cm_send_rej_locked(struct cm_id_private *cm_id_priv,
29132913
(ari && ari_length > IB_CM_REJ_ARI_LENGTH))
29142914
return -EINVAL;
29152915

2916-
switch (cm_id_priv->id.state) {
2916+
switch (state) {
29172917
case IB_CM_REQ_SENT:
29182918
case IB_CM_MRA_REQ_RCVD:
29192919
case IB_CM_REQ_RCVD:
@@ -2925,7 +2925,8 @@ static int cm_send_rej_locked(struct cm_id_private *cm_id_priv,
29252925
if (ret)
29262926
return ret;
29272927
cm_format_rej((struct cm_rej_msg *)msg->mad, cm_id_priv, reason,
2928-
ari, ari_length, private_data, private_data_len);
2928+
ari, ari_length, private_data, private_data_len,
2929+
state);
29292930
break;
29302931
case IB_CM_REP_SENT:
29312932
case IB_CM_MRA_REP_RCVD:
@@ -2934,7 +2935,8 @@ static int cm_send_rej_locked(struct cm_id_private *cm_id_priv,
29342935
if (ret)
29352936
return ret;
29362937
cm_format_rej((struct cm_rej_msg *)msg->mad, cm_id_priv, reason,
2937-
ari, ari_length, private_data, private_data_len);
2938+
ari, ari_length, private_data, private_data_len,
2939+
state);
29382940
break;
29392941
default:
29402942
pr_debug("%s: local_id %d, cm_id->state: %d\n", __func__,

0 commit comments

Comments
 (0)