Commit 8ee34f93 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

nvmf: fix deprecated "transport" check in decode_rpc_listen_address



The current decoder would always emit the deprecation notice, because even
if user specified 'trtype', it would get stored in ->transport and trigger
the warning.

While here, adjust some of the ERRLOGs to mention 'trtype' instead of
'transport' since that's the name we are using now.

Signed-off-by: default avatarJim Harris <jim.harris@samsung.com>
Change-Id: I6b712e5050ff8d3603faace54e6e0f9ef7d88777
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23361


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 2a3be8dd
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -580,6 +580,7 @@ SPDK_RPC_REGISTER("nvmf_delete_subsystem", rpc_nvmf_delete_subsystem, SPDK_RPC_R

struct rpc_listen_address {
	char *transport;
	char *trtype;
	char *adrfam;
	char *traddr;
	char *trsvcid;
@@ -588,7 +589,7 @@ struct rpc_listen_address {
static const struct spdk_json_object_decoder rpc_listen_address_decoders[] = {
	/* NOTE: "transport" is kept for compatibility; new code should use "trtype" */
	{"transport", offsetof(struct rpc_listen_address, transport), spdk_json_decode_string, true},
	{"trtype", offsetof(struct rpc_listen_address, transport), spdk_json_decode_string, true},
	{"trtype", offsetof(struct rpc_listen_address, trtype), spdk_json_decode_string, true},
	{"adrfam", offsetof(struct rpc_listen_address, adrfam), spdk_json_decode_string, true},
	{"traddr", offsetof(struct rpc_listen_address, traddr), spdk_json_decode_string},
	{"trsvcid", offsetof(struct rpc_listen_address, trsvcid), spdk_json_decode_string, true},
@@ -610,10 +611,18 @@ decode_rpc_listen_address(const struct spdk_json_val *val, void *out)
		return -1;
	}

	if (req->transport && req->trtype) {
		SPDK_ERRLOG("It is invalid to specify both 'transport' and 'trtype'.\n");
		return -1;
	}

	/* Log only once */
	if (req->transport && !g_logged_deprecated_decode_rpc_listen_address) {
		SPDK_LOG_DEPRECATED(decode_rpc_listen_address);
		g_logged_deprecated_decode_rpc_listen_address = true;
		/* Move ->transport to ->trtype since that's one we use now. */
		req->trtype = req->transport;
		req->transport = NULL;
	}

	return 0;
@@ -623,6 +632,7 @@ static void
free_rpc_listen_address(struct rpc_listen_address *r)
{
	free(r->transport);
	free(r->trtype);
	free(r->adrfam);
	free(r->traddr);
	free(r->trsvcid);
@@ -828,13 +838,13 @@ rpc_listen_address_to_trid(const struct rpc_listen_address *address,

	memset(trid, 0, sizeof(*trid));

	if (spdk_nvme_transport_id_populate_trstring(trid, address->transport)) {
		SPDK_ERRLOG("Invalid transport string: %s\n", address->transport);
	if (spdk_nvme_transport_id_populate_trstring(trid, address->trtype)) {
		SPDK_ERRLOG("Invalid trtype string: %s\n", address->trtype);
		return -EINVAL;
	}

	if (spdk_nvme_transport_id_parse_trtype(&trid->trtype, address->transport)) {
		SPDK_ERRLOG("Invalid transport type: %s\n", address->transport);
	if (spdk_nvme_transport_id_parse_trtype(&trid->trtype, address->trtype)) {
		SPDK_ERRLOG("Invalid trtype type: %s\n", address->trtype);
		return -EINVAL;
	}