From 33a14041bb4329ab3472334931bbf9a50e1af548 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Wed, 25 Oct 2017 21:14:36 -0700 Subject: [PATCH] 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 Change-Id: I183d59145abb97198984541157522d6483b18e7c Reviewed-on: https://review.gerrithub.io/385495 Reviewed-by: Ben Walker Reviewed-by: Daniel Verkamp Tested-by: SPDK Automated Test System --- etc/spdk/iscsi.conf.in | 2 ++ lib/iscsi/iscsi_subsystem.c | 43 ++++++++++++++++--------------------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/etc/spdk/iscsi.conf.in b/etc/spdk/iscsi.conf.in index bda6dee96..8c11df70d 100644 --- a/etc/spdk/iscsi.conf.in +++ b/etc/spdk/iscsi.conf.in @@ -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 diff --git a/lib/iscsi/iscsi_subsystem.c b/lib/iscsi/iscsi_subsystem.c index bc5fdb56b..8c3013d38 100644 --- a/lib/iscsi/iscsi_subsystem.c +++ b/lib/iscsi/iscsi_subsystem.c @@ -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 */