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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I527ab27e8e0d69a067839b47635584d5262b0e49 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470723 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
f93770c25d
commit
f8f49eba51
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user