Commit 1b987076 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

iscsi: Use chap to variable names for CHAP in discovery session



Current variable names for CHAP in discovery session may not be
clear and long compared with CHAP in login to target nodes.

This patch changes variable names for CHAP in discovery session
from no_discovery_auth, req_discovery_auth, req_discovery_auth_mutual,
and discovery_auth_group to disable_chap, require_chap, mutual_chap,
and chap_group, respectively.

By this patch, the term "discovery" is removed but this will not
cause any confusion because the code of the use case of them is
clear and an new RPC set_iscsi_discovery_auth will be added in the
subsequent patches.

Change-Id: Ia57041b54b28a19d5d2d90ea6c6665937c25fefc
Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/423049


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 75408adc
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -45,10 +45,10 @@ static const struct spdk_json_object_decoder rpc_set_iscsi_opts_decoders[] = {
	{"node_base", offsetof(struct spdk_iscsi_opts, nodebase), spdk_json_decode_string, true},
	{"nop_timeout", offsetof(struct spdk_iscsi_opts, timeout), spdk_json_decode_int32, true},
	{"nop_in_interval", offsetof(struct spdk_iscsi_opts, nopininterval), spdk_json_decode_int32, true},
	{"no_discovery_auth", offsetof(struct spdk_iscsi_opts, no_discovery_auth), spdk_json_decode_bool, true},
	{"req_discovery_auth", offsetof(struct spdk_iscsi_opts, req_discovery_auth), spdk_json_decode_bool, true},
	{"req_discovery_auth_mutual", offsetof(struct spdk_iscsi_opts, req_discovery_auth_mutual), spdk_json_decode_bool, true},
	{"discovery_auth_group", offsetof(struct spdk_iscsi_opts, discovery_auth_group), spdk_json_decode_int32, true},
	{"no_discovery_auth", offsetof(struct spdk_iscsi_opts, disable_chap), spdk_json_decode_bool, true},
	{"req_discovery_auth", offsetof(struct spdk_iscsi_opts, require_chap), spdk_json_decode_bool, true},
	{"req_discovery_auth_mutual", offsetof(struct spdk_iscsi_opts, mutual_chap), spdk_json_decode_bool, true},
	{"discovery_auth_group", offsetof(struct spdk_iscsi_opts, chap_group), spdk_json_decode_int32, true},
	{"max_sessions", offsetof(struct spdk_iscsi_opts, MaxSessions), spdk_json_decode_uint32, true},
	{"max_queue_depth", offsetof(struct spdk_iscsi_opts, MaxQueueDepth), spdk_json_decode_uint32, true},
	{"max_connections_per_session", offsetof(struct spdk_iscsi_opts, MaxConnectionsPerSession), spdk_json_decode_uint32, true},
+4 −4
Original line number Diff line number Diff line
@@ -776,7 +776,7 @@ spdk_iscsi_get_authinfo(struct spdk_iscsi_conn *conn, const char *authuser)
	}
	if (ag_tag < 0) {
		pthread_mutex_lock(&g_spdk_iscsi.mutex);
		ag_tag = g_spdk_iscsi.discovery_auth_group;
		ag_tag = g_spdk_iscsi.chap_group;
		pthread_mutex_unlock(&g_spdk_iscsi.mutex);
	}
	SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "ag_tag=%d\n", ag_tag);
@@ -1255,20 +1255,20 @@ spdk_iscsi_op_login_session_discovery_chap(struct spdk_iscsi_conn *conn)
{
	int rc = 0;

	if (g_spdk_iscsi.no_discovery_auth) {
	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.req_discovery_auth) {
	} 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.req_discovery_auth_mutual) {
	if (g_spdk_iscsi.mutual_chap) {
		conn->req_mutual = 1;
	}

+8 −8
Original line number Diff line number Diff line
@@ -270,10 +270,10 @@ struct spdk_iscsi_opts {
	char *nodebase;
	int32_t timeout;
	int32_t nopininterval;
	bool no_discovery_auth;
	bool req_discovery_auth;
	bool req_discovery_auth_mutual;
	int32_t discovery_auth_group;
	bool disable_chap;
	bool require_chap;
	bool mutual_chap;
	int32_t chap_group;
	uint32_t MaxSessions;
	uint32_t MaxConnectionsPerSession;
	uint32_t MaxConnections;
@@ -297,10 +297,10 @@ struct spdk_iscsi_globals {

	int32_t timeout;
	int32_t nopininterval;
	bool no_discovery_auth;
	bool req_discovery_auth;
	bool req_discovery_auth_mutual;
	int32_t discovery_auth_group;
	bool disable_chap;
	bool require_chap;
	bool mutual_chap;
	int32_t chap_group;

	uint32_t MaxSessions;
	uint32_t MaxConnectionsPerSession;
+43 −45
Original line number Diff line number Diff line
@@ -95,16 +95,16 @@ spdk_iscsi_globals_config_text(FILE *fp)
		return;
	}

	if (g_spdk_iscsi.req_discovery_auth) {
	if (g_spdk_iscsi.require_chap) {
		authmethod = "CHAP";
	} else if (g_spdk_iscsi.req_discovery_auth_mutual) {
	} else if (g_spdk_iscsi.mutual_chap) {
		authmethod = "CHAP Mutual";
	} else if (!g_spdk_iscsi.no_discovery_auth) {
	} else if (!g_spdk_iscsi.disable_chap) {
		authmethod = "Auto";
	}

	if (g_spdk_iscsi.discovery_auth_group) {
		snprintf(authgroup, sizeof(authgroup), "AuthGroup%d", g_spdk_iscsi.discovery_auth_group);
	if (g_spdk_iscsi.chap_group) {
		snprintf(authgroup, sizeof(authgroup), "AuthGroup%d", g_spdk_iscsi.chap_group);
	}

	fprintf(fp, ISCSI_CONFIG_TMPL,
@@ -351,26 +351,26 @@ spdk_iscsi_log_globals(void)
	SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Timeout %d\n", g_spdk_iscsi.timeout);
	SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "NopInInterval %d\n",
		      g_spdk_iscsi.nopininterval);
	if (g_spdk_iscsi.no_discovery_auth) {
	if (g_spdk_iscsi.disable_chap) {
		SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
			      "DiscoveryAuthMethod None\n");
	} else if (!g_spdk_iscsi.req_discovery_auth) {
	} else if (!g_spdk_iscsi.require_chap) {
		SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
			      "DiscoveryAuthMethod Auto\n");
	} else {
		SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
			      "DiscoveryAuthMethod %s %s\n",
			      g_spdk_iscsi.req_discovery_auth ? "CHAP" : "",
			      g_spdk_iscsi.req_discovery_auth_mutual ? "Mutual" : "");
			      g_spdk_iscsi.require_chap ? "CHAP" : "",
			      g_spdk_iscsi.mutual_chap ? "Mutual" : "");
	}

	if (g_spdk_iscsi.discovery_auth_group == 0) {
	if (g_spdk_iscsi.chap_group == 0) {
		SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
			      "DiscoveryAuthGroup None\n");
	} else {
		SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
			      "DiscoveryAuthGroup AuthGroup%d\n",
			      g_spdk_iscsi.discovery_auth_group);
			      g_spdk_iscsi.chap_group);
	}

	SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "MinConnectionsPerCore%d\n",
@@ -390,10 +390,10 @@ spdk_iscsi_opts_init(struct spdk_iscsi_opts *opts)
	opts->ErrorRecoveryLevel = DEFAULT_ERRORRECOVERYLEVEL;
	opts->timeout = DEFAULT_TIMEOUT;
	opts->nopininterval = DEFAULT_NOPININTERVAL;
	opts->no_discovery_auth = false;
	opts->req_discovery_auth = false;
	opts->req_discovery_auth_mutual = false;
	opts->discovery_auth_group = 0;
	opts->disable_chap = false;
	opts->require_chap = false;
	opts->mutual_chap = false;
	opts->chap_group = 0;
	opts->authfile = NULL;
	opts->nodebase = NULL;
	opts->min_connections_per_core = DEFAULT_CONNECTIONS_PER_LCORE;
@@ -464,10 +464,10 @@ spdk_iscsi_opts_copy(struct spdk_iscsi_opts *src)
	dst->ErrorRecoveryLevel = src->ErrorRecoveryLevel;
	dst->timeout = src->timeout;
	dst->nopininterval = src->nopininterval;
	dst->no_discovery_auth = src->no_discovery_auth;
	dst->req_discovery_auth = src->req_discovery_auth;
	dst->req_discovery_auth_mutual = src->req_discovery_auth_mutual;
	dst->discovery_auth_group = src->discovery_auth_group;
	dst->disable_chap = src->disable_chap;
	dst->require_chap = src->require_chap;
	dst->mutual_chap = src->mutual_chap;
	dst->chap_group = src->chap_group;
	dst->min_connections_per_core = src->min_connections_per_core;

	return dst;
@@ -562,21 +562,21 @@ spdk_iscsi_read_config_file_params(struct spdk_conf_section *sp,
	val = spdk_conf_section_get_val(sp, "DiscoveryAuthMethod");
	if (val != NULL) {
		if (strcasecmp(val, "CHAP") == 0) {
			opts->no_discovery_auth = false;
			opts->req_discovery_auth = true;
			opts->req_discovery_auth_mutual = false;
			opts->disable_chap = false;
			opts->require_chap = true;
			opts->mutual_chap = false;
		} else if (strcasecmp(val, "Mutual") == 0) {
			opts->no_discovery_auth = false;
			opts->req_discovery_auth = true;
			opts->req_discovery_auth_mutual = true;
			opts->disable_chap = false;
			opts->require_chap = true;
			opts->mutual_chap = true;
		} else if (strcasecmp(val, "Auto") == 0) {
			opts->no_discovery_auth = false;
			opts->req_discovery_auth = false;
			opts->req_discovery_auth_mutual = false;
			opts->disable_chap = false;
			opts->require_chap = false;
			opts->mutual_chap = false;
		} else if (strcasecmp(val, "None") == 0) {
			opts->no_discovery_auth = true;
			opts->req_discovery_auth = false;
			opts->req_discovery_auth_mutual = false;
			opts->disable_chap = true;
			opts->require_chap = false;
			opts->mutual_chap = false;
		} else {
			SPDK_ERRLOG("unknown auth %s, ignoring\n", val);
		}
@@ -585,7 +585,7 @@ spdk_iscsi_read_config_file_params(struct spdk_conf_section *sp,
	if (val != NULL) {
		ag_tag = val;
		if (strcasecmp(ag_tag, "None") == 0) {
			opts->discovery_auth_group = 0;
			opts->chap_group = 0;
		} else {
			if (strncasecmp(ag_tag, "AuthGroup",
					strlen("AuthGroup")) != 0
@@ -593,7 +593,7 @@ spdk_iscsi_read_config_file_params(struct spdk_conf_section *sp,
			    || ag_tag_i == 0) {
				SPDK_ERRLOG("invalid auth group %s, ignoring\n", ag_tag);
			} else {
				opts->discovery_auth_group = ag_tag_i;
				opts->chap_group = ag_tag_i;
			}
		}
	}
@@ -670,9 +670,8 @@ spdk_iscsi_opts_verify(struct spdk_iscsi_opts *opts)
		return -EINVAL;
	}

	if (!spdk_iscsi_check_chap_params(opts->no_discovery_auth, opts->req_discovery_auth,
					  opts->req_discovery_auth_mutual,
					  opts->discovery_auth_group)) {
	if (!spdk_iscsi_check_chap_params(opts->disable_chap, opts->require_chap,
					  opts->mutual_chap, opts->chap_group)) {
		SPDK_ERRLOG("CHAP params in opts are illegal combination\n");
		return -EINVAL;
	}
@@ -743,10 +742,10 @@ spdk_iscsi_set_global_params(struct spdk_iscsi_opts *opts)
	g_spdk_iscsi.ErrorRecoveryLevel = opts->ErrorRecoveryLevel;
	g_spdk_iscsi.timeout = opts->timeout;
	g_spdk_iscsi.nopininterval = opts->nopininterval;
	g_spdk_iscsi.no_discovery_auth = opts->no_discovery_auth;
	g_spdk_iscsi.req_discovery_auth = opts->req_discovery_auth;
	g_spdk_iscsi.req_discovery_auth_mutual = opts->req_discovery_auth_mutual;
	g_spdk_iscsi.discovery_auth_group = opts->discovery_auth_group;
	g_spdk_iscsi.disable_chap = opts->disable_chap;
	g_spdk_iscsi.require_chap = opts->require_chap;
	g_spdk_iscsi.mutual_chap = opts->mutual_chap;
	g_spdk_iscsi.chap_group = opts->chap_group;

	spdk_iscsi_conn_set_min_per_core(opts->min_connections_per_core);

@@ -1039,11 +1038,10 @@ spdk_iscsi_opts_info_json(struct spdk_json_write_ctx *w)
	spdk_json_write_named_int32(w, "nop_timeout", g_spdk_iscsi.timeout);
	spdk_json_write_named_int32(w, "nop_in_interval", g_spdk_iscsi.nopininterval);

	spdk_json_write_named_bool(w, "no_discovery_auth", g_spdk_iscsi.no_discovery_auth);
	spdk_json_write_named_bool(w, "req_discovery_auth", g_spdk_iscsi.req_discovery_auth);
	spdk_json_write_named_bool(w, "req_discovery_auth_mutual",
				   g_spdk_iscsi.req_discovery_auth_mutual);
	spdk_json_write_named_int32(w, "discovery_auth_group", g_spdk_iscsi.discovery_auth_group);
	spdk_json_write_named_bool(w, "no_discovery_auth", g_spdk_iscsi.disable_chap);
	spdk_json_write_named_bool(w, "req_discovery_auth", g_spdk_iscsi.require_chap);
	spdk_json_write_named_bool(w, "req_discovery_auth_mutual", g_spdk_iscsi.mutual_chap);
	spdk_json_write_named_int32(w, "discovery_auth_group", g_spdk_iscsi.chap_group);

	spdk_json_write_named_uint32(w, "min_connections_per_core",
				     spdk_iscsi_conn_get_min_per_core());