iscsi: Factor out negotiation of CHAP params from discovery and normal session
Factor out negotiation of CHAP params from discovery session and normal session. Additionally separate negotiation of digest params from CHAP params. Change-Id: If3419262c88b95de5c7c1ec7057bcbaa67e9df62 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/437055 Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ziye Yang <optimistyzy@gmail.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
af017d1f70
commit
36325127b5
@ -1165,6 +1165,32 @@ spdk_iscsi_op_login_update_param(struct spdk_iscsi_conn *conn,
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_iscsi_negotiate_chap_param(struct spdk_iscsi_conn *conn, bool disable_chap,
|
||||
bool require_chap, bool mutual_chap)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (disable_chap) {
|
||||
conn->req_auth = 0;
|
||||
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod", "None", "None");
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
} else if (require_chap) {
|
||||
conn->req_auth = 1;
|
||||
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod", "CHAP", "CHAP");
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
if (mutual_chap) {
|
||||
conn->req_mutual = 1;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* The function which is used to handle the part of session discovery
|
||||
* return:
|
||||
@ -1174,26 +1200,9 @@ spdk_iscsi_op_login_update_param(struct spdk_iscsi_conn *conn,
|
||||
static int
|
||||
spdk_iscsi_op_login_session_discovery_chap(struct spdk_iscsi_conn *conn)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (g_spdk_iscsi.disable_chap) {
|
||||
conn->req_auth = 0;
|
||||
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod", "None", "None");
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
} else if (g_spdk_iscsi.require_chap) {
|
||||
conn->req_auth = 1;
|
||||
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod", "CHAP", "CHAP");
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
if (g_spdk_iscsi.mutual_chap) {
|
||||
conn->req_mutual = 1;
|
||||
}
|
||||
|
||||
return rc;
|
||||
return spdk_iscsi_negotiate_chap_param(conn, g_spdk_iscsi.disable_chap,
|
||||
g_spdk_iscsi.require_chap,
|
||||
g_spdk_iscsi.mutual_chap);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1204,29 +1213,19 @@ spdk_iscsi_op_login_session_discovery_chap(struct spdk_iscsi_conn *conn)
|
||||
*/
|
||||
static int
|
||||
spdk_iscsi_op_login_negotiate_chap_param(struct spdk_iscsi_conn *conn,
|
||||
struct spdk_iscsi_pdu *rsp_pdu,
|
||||
struct spdk_iscsi_tgt_node *target)
|
||||
{
|
||||
return spdk_iscsi_negotiate_chap_param(conn, target->disable_chap,
|
||||
target->require_chap,
|
||||
target->mutual_chap);
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_iscsi_op_login_negotiate_digest_param(struct spdk_iscsi_conn *conn,
|
||||
struct spdk_iscsi_tgt_node *target)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (target->disable_chap) {
|
||||
conn->req_auth = 0;
|
||||
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod", "None", "None");
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
} else if (target->require_chap) {
|
||||
conn->req_auth = 1;
|
||||
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod", "CHAP", "CHAP");
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
if (target->mutual_chap) {
|
||||
conn->req_mutual = 1;
|
||||
}
|
||||
|
||||
if (target->header_digest) {
|
||||
/*
|
||||
* User specified header digests, so update the list of
|
||||
@ -1397,10 +1396,14 @@ spdk_iscsi_op_login_session_normal(struct spdk_iscsi_conn *conn,
|
||||
|
||||
/* force target flags */
|
||||
pthread_mutex_lock(&((*target)->mutex));
|
||||
rc = spdk_iscsi_op_login_negotiate_chap_param(conn, rsp_pdu, *target);
|
||||
rc = spdk_iscsi_op_login_negotiate_chap_param(conn, *target);
|
||||
pthread_mutex_unlock(&((*target)->mutex));
|
||||
|
||||
return rc;
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
return spdk_iscsi_op_login_negotiate_digest_param(conn, *target);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user