Commit 167ad6fb authored by zhenwei pi's avatar zhenwei pi Committed by Tomasz Zawadzki
Browse files

iscsi: fix possible login state error



The following steps are expected on iSCSI login:
  Initiator           Target
  login req     ->
                      set CONN STATE INVALID
                <-    login resp
                      ...
                      PDU write cb
                      set CONN STATE RUNNING
  CHAP req      ->
                      Test CONN STATE(expected RUNNING)

Because of socket pending list for asynchronous requests mechanism[1],
unexpected INVALID state maybe hit on CHAP request:
  Initiator           Target
  login req     ->
                      set CONN STATE INVALID
                <-    login resp
  CHAP req      ->
                      Test CONN STATE(unexpected INVALID)
                      ...
                      PDU write cb (delayed)
                      set CONN STATE RUNNING

This leads iscsi_op_login_phase_none() re-entry, a CHAP request
gets error with log "InitiatorName is empty".

In fact, once the target handles LOGIN request and prepare to send
response, it has already becomes RUNNING state. Set RUNNING state
immediately instead of callback funcion, any unlikely error occurs
before callback, EXITING will overwrite the state.

[1]: SPDK commit: ab22d249

Change-Id: Ic41575cf600478496046888b6d5806e6beb09aea
Signed-off-by: default avatarzhenwei pi <pizhenwei@bytedance.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19944


Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
parent c1c889b5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1132,7 +1132,6 @@ iscsi_conn_login_pdu_success_complete(void *arg)
			return;
		}
	}
	conn->state = ISCSI_CONN_STATE_RUNNING;
	if (conn->full_feature != 0) {
		iscsi_conn_schedule(conn);
	}
@@ -2224,6 +2223,7 @@ iscsi_pdu_payload_op_login(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *
		return 0;
	}

	conn->state = ISCSI_CONN_STATE_RUNNING;
	iscsi_op_login_response(conn, rsp_pdu, params, iscsi_conn_login_pdu_success_complete);
	return 0;
}