Commit 84e4df8c authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

nvmf: add spdk_nvmf_subsystem_add_host_ext()



We'll want to add more host options in the future (DH-HMAC-CHAP keys),
so an extendable version of spdk_nvmf_subsystem_add_host() will be
useful.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I89cd582c439d854ff1d925691d3b5e5e9d417468
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22652


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Community-CI: Mellanox Build Bot
parent 1afe03c4
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -610,6 +610,25 @@ int spdk_nvmf_ns_remove_host(struct spdk_nvmf_subsystem *subsystem,
int spdk_nvmf_subsystem_add_host(struct spdk_nvmf_subsystem *subsystem,
				 const char *hostnqn, const struct spdk_json_val *params);

struct spdk_nvmf_host_opts {
	/** Size of this structure */
	size_t				size;
	/** Transport specific parameters */
	const struct spdk_json_val	*params;
};

/**
 * Allow the given host to connect to the given subsystem.
 *
 * \param subsystem Subsystem to add host to.
 * \param hostnqn Host's NQN.
 * \param opts Host's options.
 *
 * \return 0 on success, or negated errno value on failure.
 */
int spdk_nvmf_subsystem_add_host_ext(struct spdk_nvmf_subsystem *subsystem,
				     const char *hostnqn, struct spdk_nvmf_host_opts *opts);

/**
 * Remove the given host NQN from the list of allowed hosts.
 *
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
	spdk_nvmf_ns_add_host;
	spdk_nvmf_ns_remove_host;
	spdk_nvmf_subsystem_add_host;
	spdk_nvmf_subsystem_add_host_ext;
	spdk_nvmf_subsystem_remove_host;
	spdk_nvmf_subsystem_disconnect_host;
	spdk_nvmf_subsystem_set_allow_any_host;
+16 −3
Original line number Diff line number Diff line
@@ -968,8 +968,8 @@ nvmf_subsystem_find_host(struct spdk_nvmf_subsystem *subsystem, const char *host
}

int
spdk_nvmf_subsystem_add_host(struct spdk_nvmf_subsystem *subsystem, const char *hostnqn,
			     const struct spdk_json_val *params)
spdk_nvmf_subsystem_add_host_ext(struct spdk_nvmf_subsystem *subsystem,
				 const char *hostnqn, struct spdk_nvmf_host_opts *opts)
{
	struct spdk_nvmf_host *host;
	struct spdk_nvmf_transport *transport;
@@ -1006,7 +1006,8 @@ spdk_nvmf_subsystem_add_host(struct spdk_nvmf_subsystem *subsystem, const char *
	for (transport = spdk_nvmf_transport_get_first(subsystem->tgt); transport;
	     transport = spdk_nvmf_transport_get_next(transport)) {
		if (transport->ops->subsystem_add_host) {
			rc = transport->ops->subsystem_add_host(transport, subsystem, hostnqn, params);
			rc = transport->ops->subsystem_add_host(transport, subsystem, hostnqn,
								SPDK_GET_FIELD(opts, params, NULL));
			if (rc) {
				SPDK_ERRLOG("Unable to add host to %s transport\n", transport->ops->name);
				/* Remove this host from all transports we've managed to add it to. */
@@ -1022,6 +1023,18 @@ spdk_nvmf_subsystem_add_host(struct spdk_nvmf_subsystem *subsystem, const char *
	return 0;
}

int
spdk_nvmf_subsystem_add_host(struct spdk_nvmf_subsystem *subsystem, const char *hostnqn,
			     const struct spdk_json_val *params)
{
	struct spdk_nvmf_host_opts opts = {};

	opts.size = SPDK_SIZEOF(&opts, params);
	opts.params = params;

	return spdk_nvmf_subsystem_add_host_ext(subsystem, hostnqn, &opts);
}

int
spdk_nvmf_subsystem_remove_host(struct spdk_nvmf_subsystem *subsystem, const char *hostnqn)
{