Commit f8f49eba authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Changpeng Liu
Browse files

lib/iscsi: Check data segment length separately for login request



During login processing, only login request is accepted. So we
can move data segment length check from iscsi_check_data_segment_length()
to iscsi_op_login().

A few patches from this will inline data segment length check into
each opcode handler and then remove iscsi_check_data_segment_length().

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I527ab27e8e0d69a067839b47635584d5262b0e49
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470723


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent f93770c2
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -376,7 +376,7 @@ static bool
iscsi_check_data_segment_length(struct spdk_iscsi_conn *conn,
				struct spdk_iscsi_pdu *pdu, int data_len)
{
	int max_segment_len;
	int max_segment_len = 0;

	/*
	 * Determine the maximum segment length expected for this PDU.
@@ -391,13 +391,7 @@ iscsi_check_data_segment_length(struct spdk_iscsi_conn *conn,
	 *  at runtime.
	 */
	if (conn->sess == NULL) {
		/*
		 * If the connection does not yet have a session, then
		 *  login is not complete and we use the 8KB default
		 *  FirstBurstLength as our maximum data segment length
		 *  value.
		 */
		max_segment_len = SPDK_ISCSI_FIRST_BURST_LENGTH;
		return true;
	} else if (pdu->bhs.opcode == ISCSI_OP_SCSI_DATAOUT ||
		   pdu->bhs.opcode == ISCSI_OP_NOPOUT) {
		max_segment_len = SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH;
@@ -2197,6 +2191,13 @@ iscsi_op_login(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
		return SPDK_ISCSI_CONNECTION_FATAL;
	}

	/* During login processing, use the 8KB default FirstBurstLength as
	 *  our maximum data segment length value.
	 */
	if (pdu->data_segment_len > SPDK_ISCSI_FIRST_BURST_LENGTH) {
		return iscsi_reject(conn, pdu, ISCSI_REASON_PROTOCOL_ERROR);
	}

	rsp_pdu = spdk_get_pdu();
	if (rsp_pdu == NULL) {
		return SPDK_ISCSI_CONNECTION_FATAL;