iscsi: make Mutual infer CHAP for DiscoveryAuthMethod options

Previously users would have to pass CHAP and Mutual as
separate words on the DiscoveryAuthMethod line - but
this was problematic since then we would have to check
that the user did not specify Mutual without CHAP.

So instead just make Mutual infer CHAP.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I183d59145abb97198984541157522d6483b18e7c

Reviewed-on: https://review.gerrithub.io/385495
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Jim Harris 2017-10-25 21:14:36 -07:00 committed by Daniel Verkamp
parent 28544c4bad
commit 33a14041bb
2 changed files with 20 additions and 25 deletions

View File

@ -47,6 +47,8 @@
Timeout 30
# authentication information for discovery session
# Options:
# None, Auto, CHAP and Mutual. Note that Mutual infers CHAP.
DiscoveryAuthMethod Auto
#MaxSessions 128

View File

@ -583,7 +583,6 @@ spdk_iscsi_read_parameters_from_config_file(struct spdk_conf_section *sp)
int flush_timeout = 0;
const char *ag_tag;
int ag_tag_i;
int i;
val = spdk_conf_section_get_val(sp, "Comment");
if (val != NULL) {
@ -704,25 +703,24 @@ spdk_iscsi_read_parameters_from_config_file(struct spdk_conf_section *sp)
}
val = spdk_conf_section_get_val(sp, "DiscoveryAuthMethod");
if (val != NULL) {
g_spdk_iscsi.no_discovery_auth = 0;
for (i = 0; ; i++) {
val = spdk_conf_section_get_nmval(sp, "DiscoveryAuthMethod", 0, i);
if (val == NULL)
break;
if (strcasecmp(val, "CHAP") == 0) {
g_spdk_iscsi.req_discovery_auth = 1;
} else if (strcasecmp(val, "Mutual") == 0) {
g_spdk_iscsi.req_discovery_auth_mutual = 1;
} else if (strcasecmp(val, "Auto") == 0) {
g_spdk_iscsi.req_discovery_auth = 0;
g_spdk_iscsi.req_discovery_auth_mutual = 0;
} else if (strcasecmp(val, "None") == 0) {
g_spdk_iscsi.no_discovery_auth = 1;
g_spdk_iscsi.req_discovery_auth = 0;
g_spdk_iscsi.req_discovery_auth_mutual = 0;
} else {
SPDK_ERRLOG("unknown auth %s, ignoring\n", val);
}
if (strcasecmp(val, "CHAP") == 0) {
g_spdk_iscsi.no_discovery_auth = 0;
g_spdk_iscsi.req_discovery_auth = 1;
g_spdk_iscsi.req_discovery_auth_mutual = 0;
} else if (strcasecmp(val, "Mutual") == 0) {
g_spdk_iscsi.no_discovery_auth = 0;
g_spdk_iscsi.req_discovery_auth = 1;
g_spdk_iscsi.req_discovery_auth_mutual = 1;
} else if (strcasecmp(val, "Auto") == 0) {
g_spdk_iscsi.no_discovery_auth = 0;
g_spdk_iscsi.req_discovery_auth = 0;
g_spdk_iscsi.req_discovery_auth_mutual = 0;
} else if (strcasecmp(val, "None") == 0) {
g_spdk_iscsi.no_discovery_auth = 1;
g_spdk_iscsi.req_discovery_auth = 0;
g_spdk_iscsi.req_discovery_auth_mutual = 0;
} else {
SPDK_ERRLOG("unknown auth %s, ignoring\n", val);
}
}
val = spdk_conf_section_get_val(sp, "DiscoveryAuthGroup");
@ -807,11 +805,6 @@ spdk_iscsi_app_read_parameters(void)
g_spdk_iscsi.flush_timeout *= (spdk_get_ticks_hz() >> 20);
if (g_spdk_iscsi.req_discovery_auth_mutual && !g_spdk_iscsi.req_discovery_auth) {
SPDK_ERRLOG("Mutual specified but not CHAP, disabling mutual\n");
g_spdk_iscsi.req_discovery_auth_mutual = 0;
}
spdk_iscsi_log_globals();
/* portal groups */