iscsi: Adjust variable's name to JSON for iSCSI CHAP
During converting type of CHAP params of target from int to bool for JSON, changed names of them to be consistent with others. In this patch, adjust variable name of struct to of JSON. Change-Id: I1ccbfa11d57479dc55680835eb80e111bd24d9a3 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/400928 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
36fc9b2d09
commit
afe51a1556
@ -770,7 +770,7 @@ spdk_iscsi_get_authinfo(struct spdk_iscsi_conn *conn, const char *authuser)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (conn->sess->target != NULL) {
|
if (conn->sess->target != NULL) {
|
||||||
ag_tag = conn->sess->target->auth_group;
|
ag_tag = conn->sess->target->chap_group;
|
||||||
} else {
|
} else {
|
||||||
ag_tag = -1;
|
ag_tag = -1;
|
||||||
}
|
}
|
||||||
@ -1291,14 +1291,14 @@ spdk_iscsi_op_login_negotiate_chap_param(struct spdk_iscsi_conn *conn,
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (target->auth_chap_disabled) {
|
if (target->disable_chap) {
|
||||||
conn->req_auth = 0;
|
conn->req_auth = 0;
|
||||||
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod",
|
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod",
|
||||||
"None", "None");
|
"None", "None");
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
} else if (target->auth_chap_required) {
|
} else if (target->require_chap) {
|
||||||
conn->req_auth = 1;
|
conn->req_auth = 1;
|
||||||
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod",
|
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod",
|
||||||
"CHAP", "CHAP");
|
"CHAP", "CHAP");
|
||||||
@ -1307,7 +1307,7 @@ spdk_iscsi_op_login_negotiate_chap_param(struct spdk_iscsi_conn *conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target->auth_chap_mutual) {
|
if (target->mutual_chap) {
|
||||||
conn->req_mutual = 1;
|
conn->req_mutual = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,16 +393,16 @@ dump_target_node(struct spdk_json_write_ctx *w, struct spdk_iscsi_tgt_node *tgtn
|
|||||||
spdk_json_write_int32(w, tgtnode->queue_depth);
|
spdk_json_write_int32(w, tgtnode->queue_depth);
|
||||||
|
|
||||||
spdk_json_write_name(w, "disable_chap");
|
spdk_json_write_name(w, "disable_chap");
|
||||||
spdk_json_write_bool(w, tgtnode->auth_chap_disabled);
|
spdk_json_write_bool(w, tgtnode->disable_chap);
|
||||||
|
|
||||||
spdk_json_write_name(w, "require_chap");
|
spdk_json_write_name(w, "require_chap");
|
||||||
spdk_json_write_bool(w, tgtnode->auth_chap_required);
|
spdk_json_write_bool(w, tgtnode->require_chap);
|
||||||
|
|
||||||
spdk_json_write_name(w, "mutual_chap");
|
spdk_json_write_name(w, "mutual_chap");
|
||||||
spdk_json_write_bool(w, tgtnode->auth_chap_mutual);
|
spdk_json_write_bool(w, tgtnode->mutual_chap);
|
||||||
|
|
||||||
spdk_json_write_name(w, "chap_group");
|
spdk_json_write_name(w, "chap_group");
|
||||||
spdk_json_write_int32(w, tgtnode->auth_group);
|
spdk_json_write_int32(w, tgtnode->chap_group);
|
||||||
|
|
||||||
spdk_json_write_name(w, "header_digest");
|
spdk_json_write_name(w, "header_digest");
|
||||||
spdk_json_write_bool(w, tgtnode->header_digest);
|
spdk_json_write_bool(w, tgtnode->header_digest);
|
||||||
|
@ -271,18 +271,18 @@ spdk_iscsi_config_dump_target_nodes(FILE *fp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target->auth_chap_disabled) {
|
if (target->disable_chap) {
|
||||||
authmethod = "None";
|
authmethod = "None";
|
||||||
} else if (!target->auth_chap_required) {
|
} else if (!target->require_chap) {
|
||||||
authmethod = "Auto";
|
authmethod = "Auto";
|
||||||
} else if (target->auth_chap_mutual) {
|
} else if (target->mutual_chap) {
|
||||||
authmethod = "CHAP Mutual";
|
authmethod = "CHAP Mutual";
|
||||||
} else {
|
} else {
|
||||||
authmethod = "CHAP";
|
authmethod = "CHAP";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target->auth_group > 0) {
|
if (target->chap_group > 0) {
|
||||||
snprintf(authgroup, sizeof(authgroup), "AuthGroup%d", target->auth_group);
|
snprintf(authgroup, sizeof(authgroup), "AuthGroup%d", target->chap_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target->header_digest) {
|
if (target->header_digest) {
|
||||||
|
@ -844,20 +844,20 @@ spdk_check_iscsi_name(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
spdk_iscsi_check_chap_params(bool disabled, bool required, bool mutual, int group)
|
spdk_iscsi_check_chap_params(bool disable, bool require, bool mutual, int group)
|
||||||
{
|
{
|
||||||
if (group < 0) {
|
if (group < 0) {
|
||||||
SPDK_ERRLOG("Invalid auth group ID (%d)\n", group);
|
SPDK_ERRLOG("Invalid auth group ID (%d)\n", group);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((!disabled && !required && !mutual) || /* Auto */
|
if ((!disable && !require && !mutual) || /* Auto */
|
||||||
(disabled && !required && !mutual) || /* None */
|
(disable && !require && !mutual) || /* None */
|
||||||
(!disabled && required && !mutual) || /* CHAP */
|
(!disable && require && !mutual) || /* CHAP */
|
||||||
(!disabled && required && mutual)) { /* CHAP Mutual */
|
(!disable && require && mutual)) { /* CHAP Mutual */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SPDK_ERRLOG("Invalid combination of CHAP params (d=%d,r=%d,m=%d)\n",
|
SPDK_ERRLOG("Invalid combination of CHAP params (d=%d,r=%d,m=%d)\n",
|
||||||
disabled, required, mutual);
|
disable, require, mutual);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -867,15 +867,15 @@ spdk_iscsi_tgt_node_construct(int target_index,
|
|||||||
int *pg_tag_list, int *ig_tag_list, uint16_t num_maps,
|
int *pg_tag_list, int *ig_tag_list, uint16_t num_maps,
|
||||||
const char *bdev_name_list[], int *lun_id_list, int num_luns,
|
const char *bdev_name_list[], int *lun_id_list, int num_luns,
|
||||||
int queue_depth,
|
int queue_depth,
|
||||||
bool auth_chap_disabled, bool auth_chap_required, bool auth_chap_mutual, int auth_group,
|
bool disable_chap, bool require_chap, bool mutual_chap, int chap_group,
|
||||||
bool header_digest, bool data_digest)
|
bool header_digest, bool data_digest)
|
||||||
{
|
{
|
||||||
char fullname[MAX_TMPBUF];
|
char fullname[MAX_TMPBUF];
|
||||||
struct spdk_iscsi_tgt_node *target;
|
struct spdk_iscsi_tgt_node *target;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!spdk_iscsi_check_chap_params(auth_chap_disabled, auth_chap_required,
|
if (!spdk_iscsi_check_chap_params(disable_chap, require_chap,
|
||||||
auth_chap_mutual, auth_group)) {
|
mutual_chap, chap_group)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -954,10 +954,10 @@ spdk_iscsi_tgt_node_construct(int target_index,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
target->auth_chap_disabled = auth_chap_disabled;
|
target->disable_chap = disable_chap;
|
||||||
target->auth_chap_required = auth_chap_required;
|
target->require_chap = require_chap;
|
||||||
target->auth_chap_mutual = auth_chap_mutual;
|
target->mutual_chap = mutual_chap;
|
||||||
target->auth_group = auth_group;
|
target->chap_group = chap_group;
|
||||||
target->header_digest = header_digest;
|
target->header_digest = header_digest;
|
||||||
target->data_digest = data_digest;
|
target->data_digest = data_digest;
|
||||||
|
|
||||||
@ -989,9 +989,9 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
|
|||||||
const char *alias, *pg_tag, *ig_tag;
|
const char *alias, *pg_tag, *ig_tag;
|
||||||
const char *ag_tag;
|
const char *ag_tag;
|
||||||
const char *val, *name;
|
const char *val, *name;
|
||||||
int target_num, auth_group, pg_tag_i, ig_tag_i;
|
int target_num, chap_group, pg_tag_i, ig_tag_i;
|
||||||
bool header_digest, data_digest;
|
bool header_digest, data_digest;
|
||||||
bool auth_chap_disabled, auth_chap_required, auth_chap_mutual;
|
bool disable_chap, require_chap, mutual_chap;
|
||||||
int i;
|
int i;
|
||||||
int lun_id_list[SPDK_SCSI_DEV_MAX_LUN];
|
int lun_id_list[SPDK_SCSI_DEV_MAX_LUN];
|
||||||
const char *bdev_name_list[SPDK_SCSI_DEV_MAX_LUN];
|
const char *bdev_name_list[SPDK_SCSI_DEV_MAX_LUN];
|
||||||
@ -1056,9 +1056,9 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
|
|||||||
|
|
||||||
/* Setup AuthMethod */
|
/* Setup AuthMethod */
|
||||||
val = spdk_conf_section_get_val(sp, "AuthMethod");
|
val = spdk_conf_section_get_val(sp, "AuthMethod");
|
||||||
auth_chap_disabled = false;
|
disable_chap = false;
|
||||||
auth_chap_required = false;
|
require_chap = false;
|
||||||
auth_chap_mutual = false;
|
mutual_chap = false;
|
||||||
if (val != NULL) {
|
if (val != NULL) {
|
||||||
for (i = 0; ; i++) {
|
for (i = 0; ; i++) {
|
||||||
val = spdk_conf_section_get_nmval(sp, "AuthMethod", 0, i);
|
val = spdk_conf_section_get_nmval(sp, "AuthMethod", 0, i);
|
||||||
@ -1066,61 +1066,60 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (strcasecmp(val, "CHAP") == 0) {
|
if (strcasecmp(val, "CHAP") == 0) {
|
||||||
auth_chap_required = true;
|
require_chap = true;
|
||||||
} else if (strcasecmp(val, "Mutual") == 0) {
|
} else if (strcasecmp(val, "Mutual") == 0) {
|
||||||
auth_chap_mutual = true;
|
mutual_chap = true;
|
||||||
} else if (strcasecmp(val, "Auto") == 0) {
|
} else if (strcasecmp(val, "Auto") == 0) {
|
||||||
auth_chap_disabled = false;
|
disable_chap = false;
|
||||||
auth_chap_required = false;
|
require_chap = false;
|
||||||
auth_chap_mutual = false;
|
mutual_chap = false;
|
||||||
} else if (strcasecmp(val, "None") == 0) {
|
} else if (strcasecmp(val, "None") == 0) {
|
||||||
auth_chap_disabled = true;
|
disable_chap = true;
|
||||||
auth_chap_required = false;
|
require_chap = false;
|
||||||
auth_chap_mutual = false;
|
mutual_chap = false;
|
||||||
} else {
|
} else {
|
||||||
SPDK_ERRLOG("tgt_node%d: unknown auth\n", target_num);
|
SPDK_ERRLOG("tgt_node%d: unknown auth\n", target_num);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (auth_chap_mutual && !auth_chap_required) {
|
if (mutual_chap && !require_chap) {
|
||||||
SPDK_ERRLOG("tgt_node%d: Mutual but not CHAP\n", target_num);
|
SPDK_ERRLOG("tgt_node%d: Mutual but not CHAP\n", target_num);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (auth_chap_disabled) {
|
if (disable_chap) {
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthMethod None\n");
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthMethod None\n");
|
||||||
} else if (!auth_chap_required) {
|
} else if (!require_chap) {
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthMethod Auto\n");
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthMethod Auto\n");
|
||||||
} else {
|
} else {
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthMethod CHAP %s\n",
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthMethod CHAP %s\n",
|
||||||
auth_chap_mutual ? "Mutual" : "");
|
mutual_chap ? "Mutual" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
val = spdk_conf_section_get_val(sp, "AuthGroup");
|
val = spdk_conf_section_get_val(sp, "AuthGroup");
|
||||||
if (val == NULL) {
|
if (val == NULL) {
|
||||||
auth_group = 0;
|
chap_group = 0;
|
||||||
} else {
|
} else {
|
||||||
ag_tag = val;
|
ag_tag = val;
|
||||||
if (strcasecmp(ag_tag, "None") == 0) {
|
if (strcasecmp(ag_tag, "None") == 0) {
|
||||||
auth_group = 0;
|
chap_group = 0;
|
||||||
} else {
|
} else {
|
||||||
if (strncasecmp(ag_tag, "AuthGroup",
|
if (strncasecmp(ag_tag, "AuthGroup",
|
||||||
strlen("AuthGroup")) != 0
|
strlen("AuthGroup")) != 0
|
||||||
|| sscanf(ag_tag, "%*[^0-9]%d", &auth_group) != 1) {
|
|| sscanf(ag_tag, "%*[^0-9]%d", &chap_group) != 1) {
|
||||||
SPDK_ERRLOG("tgt_node%d: auth group error\n", target_num);
|
SPDK_ERRLOG("tgt_node%d: auth group error\n", target_num);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (auth_group == 0) {
|
if (chap_group == 0) {
|
||||||
SPDK_ERRLOG("tgt_node%d: invalid auth group 0\n", target_num);
|
SPDK_ERRLOG("tgt_node%d: invalid auth group 0\n", target_num);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (auth_group == 0) {
|
if (chap_group == 0) {
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthGroup None\n");
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthGroup None\n");
|
||||||
} else {
|
} else {
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthGroup AuthGroup%d\n",
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthGroup AuthGroup%d\n", chap_group);
|
||||||
auth_group);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val = spdk_conf_section_get_val(sp, "UseDigest");
|
val = spdk_conf_section_get_val(sp, "UseDigest");
|
||||||
@ -1180,8 +1179,7 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
|
|||||||
target = spdk_iscsi_tgt_node_construct(target_num, name, alias,
|
target = spdk_iscsi_tgt_node_construct(target_num, name, alias,
|
||||||
pg_tag_list, ig_tag_list, num_target_maps,
|
pg_tag_list, ig_tag_list, num_target_maps,
|
||||||
bdev_name_list, lun_id_list, num_luns, queue_depth,
|
bdev_name_list, lun_id_list, num_luns, queue_depth,
|
||||||
auth_chap_disabled, auth_chap_required,
|
disable_chap, require_chap, mutual_chap, chap_group,
|
||||||
auth_chap_mutual, auth_group,
|
|
||||||
header_digest, data_digest);
|
header_digest, data_digest);
|
||||||
|
|
||||||
if (target == NULL) {
|
if (target == NULL) {
|
||||||
|
@ -66,10 +66,10 @@ struct spdk_iscsi_tgt_node {
|
|||||||
|
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
|
|
||||||
bool auth_chap_disabled;
|
bool disable_chap;
|
||||||
bool auth_chap_required;
|
bool require_chap;
|
||||||
bool auth_chap_mutual;
|
bool mutual_chap;
|
||||||
int auth_group;
|
int chap_group;
|
||||||
bool header_digest;
|
bool header_digest;
|
||||||
bool data_digest;
|
bool data_digest;
|
||||||
int queue_depth;
|
int queue_depth;
|
||||||
@ -112,7 +112,7 @@ spdk_iscsi_tgt_node_construct(int target_index,
|
|||||||
int *pg_tag_list, int *ig_tag_list, uint16_t num_maps,
|
int *pg_tag_list, int *ig_tag_list, uint16_t num_maps,
|
||||||
const char *bdev_name_list[], int *lun_id_list, int num_luns,
|
const char *bdev_name_list[], int *lun_id_list, int num_luns,
|
||||||
int queue_depth,
|
int queue_depth,
|
||||||
bool no_auth_chap, bool auth_chap, bool auth_chap_mutual, int auth_group,
|
bool disable_chap, bool require_chap, bool mutual_chap, int chap_group,
|
||||||
bool header_digest, bool data_digest);
|
bool header_digest, bool data_digest);
|
||||||
|
|
||||||
int spdk_iscsi_tgt_node_add_pg_ig_maps(struct spdk_iscsi_tgt_node *target,
|
int spdk_iscsi_tgt_node_add_pg_ig_maps(struct spdk_iscsi_tgt_node *target,
|
||||||
|
@ -796,8 +796,8 @@ allow_iscsi_name_multi_maps_case(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* static bool
|
* static bool
|
||||||
* spdk_iscsi_check_chap_params(bool auth_chap_disabled, bool auth_chap_required,
|
* spdk_iscsi_check_chap_params(bool disable_chap, bool require_chap,
|
||||||
* bool auth_chap_mutual, int auth_group);
|
* bool mutual_chap, int chap_group);
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
chap_param_test_cases(void)
|
chap_param_test_cases(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user