lib/iscsi: Separate initializing login response and getting incoming login params
Including getting incoming login parameters into iscsi_op_login_rsp_init() was not so intuitive. Initializing login response done in iscsi_op_login_rsp_init() can be done before reading data segment but getting incoming login parameters can be done only after reading data segment. As a preparation to separate PDU header and payload handling for Login Request PDU, extract getting incoming login parameters from iscsi_op_login_rsp_init() into an new function iscsi_op_login_store_incoming_params(). Besides, refine a few pointer and return code handling to make the code a little clearer. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I6b677bf6e93b830e6e6fead24c8b78d9d9bc1df4 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471467 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ziye Yang <ziye.yang@intel.com>
This commit is contained in:
parent
a82748513a
commit
71f8a7d742
@ -1790,11 +1790,10 @@ iscsi_op_login_phase_none(struct spdk_iscsi_conn *conn,
|
|||||||
static int
|
static int
|
||||||
iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn,
|
iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn,
|
||||||
struct spdk_iscsi_pdu *pdu, struct spdk_iscsi_pdu *rsp_pdu,
|
struct spdk_iscsi_pdu *pdu, struct spdk_iscsi_pdu *rsp_pdu,
|
||||||
struct iscsi_param **params, int *alloc_len, int *cid)
|
int *alloc_len, int *cid)
|
||||||
{
|
{
|
||||||
struct iscsi_bhs_login_req *reqh;
|
struct iscsi_bhs_login_req *reqh;
|
||||||
struct iscsi_bhs_login_rsp *rsph;
|
struct iscsi_bhs_login_rsp *rsph;
|
||||||
int rc;
|
|
||||||
|
|
||||||
rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
|
rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
|
||||||
rsph->opcode = ISCSI_OP_LOGIN_RSP;
|
rsph->opcode = ISCSI_OP_LOGIN_RSP;
|
||||||
@ -1892,7 +1891,21 @@ iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn,
|
|||||||
return SPDK_ISCSI_LOGIN_ERROR_RESPONSE;
|
return SPDK_ISCSI_LOGIN_ERROR_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store incoming parameters */
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
iscsi_op_login_store_incoming_params(struct spdk_iscsi_conn *conn,
|
||||||
|
struct spdk_iscsi_pdu *pdu, struct spdk_iscsi_pdu *rsp_pdu,
|
||||||
|
struct iscsi_param **params)
|
||||||
|
{
|
||||||
|
struct iscsi_bhs_login_req *reqh;
|
||||||
|
struct iscsi_bhs_login_rsp *rsph;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
reqh = (struct iscsi_bhs_login_req *)&pdu->bhs;
|
||||||
|
rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
|
||||||
|
|
||||||
rc = spdk_iscsi_parse_params(params, pdu->data,
|
rc = spdk_iscsi_parse_params(params, pdu->data,
|
||||||
pdu->data_segment_len, ISCSI_BHS_LOGIN_GET_CBIT(reqh->flags),
|
pdu->data_segment_len, ISCSI_BHS_LOGIN_GET_CBIT(reqh->flags),
|
||||||
&conn->partial_text_parameter);
|
&conn->partial_text_parameter);
|
||||||
@ -1902,6 +1915,7 @@ iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn,
|
|||||||
rsph->status_detail = ISCSI_LOGIN_INITIATOR_ERROR;
|
rsph->status_detail = ISCSI_LOGIN_INITIATOR_ERROR;
|
||||||
return SPDK_ISCSI_LOGIN_ERROR_PARAMETER;
|
return SPDK_ISCSI_LOGIN_ERROR_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2175,10 +2189,15 @@ iscsi_op_login(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
|||||||
if (rsp_pdu == NULL) {
|
if (rsp_pdu == NULL) {
|
||||||
return SPDK_ISCSI_CONNECTION_FATAL;
|
return SPDK_ISCSI_CONNECTION_FATAL;
|
||||||
}
|
}
|
||||||
rc = iscsi_op_login_rsp_init(conn, pdu, rsp_pdu, ¶ms,
|
rc = iscsi_op_login_rsp_init(conn, pdu, rsp_pdu, &alloc_len, &cid);
|
||||||
&alloc_len, &cid);
|
if (rc < 0) {
|
||||||
if (rc == SPDK_ISCSI_LOGIN_ERROR_RESPONSE || rc == SPDK_ISCSI_LOGIN_ERROR_PARAMETER) {
|
iscsi_op_login_response(conn, rsp_pdu, NULL);
|
||||||
iscsi_op_login_response(conn, rsp_pdu, params);
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = iscsi_op_login_store_incoming_params(conn, pdu, rsp_pdu, ¶ms);
|
||||||
|
if (rc < 0) {
|
||||||
|
iscsi_op_login_response(conn, rsp_pdu, NULL);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user