Commit 5d5e4d33 authored by Slawomir Ptak's avatar Slawomir Ptak Committed by Tomasz Zawadzki
Browse files

nvmf/rpc: Fail listener add with different secure channel



Fail the nvmf_subsystem_add_listener RPC, when adding a listener
with the same parameters as an already existing listener, but
different secure channel parameter.

Fixes #3073

Change-Id: Ic4c27515c7465bf2296d6d0b44296da28f20900b
Signed-off-by: default avatarSlawomir Ptak <slawomir.ptak@intel.com>
Signed-off-by: default avatarBoris Glimcher <Boris.Glimcher@emc.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22786


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent 54944c1d
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -758,11 +758,20 @@ nvmf_rpc_listen_paused(struct spdk_nvmf_subsystem *subsystem,
		       void *cb_arg, int status)
{
	struct nvmf_rpc_listener_ctx *ctx = cb_arg;
	struct spdk_nvmf_subsystem_listener *listener;
	int rc;

	switch (ctx->op) {
	case NVMF_RPC_LISTEN_ADD:
		if (nvmf_subsystem_find_listener(subsystem, &ctx->trid)) {
		listener = nvmf_subsystem_find_listener(subsystem, &ctx->trid);
		if (listener) {
			if (ctx->listener_opts.secure_channel != listener->opts.secure_channel) {
				SPDK_ERRLOG("A listener already exists with different secure channel option.");
				spdk_jsonrpc_send_error_response(ctx->request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
								 "Invalid parameters");
				ctx->response_sent = true;
			}

			break;
		}

+3 −0
Original line number Diff line number Diff line
@@ -39,6 +39,9 @@ rpc_cmd << CMD
	nvmf_subsystem_add_host --psk "$key0path" "$subnqn" "$hostnqn"
CMD

# Test, if another listener cannot be added, with different secure channel value
NOT rpc_cmd nvmf_subsystem_add_listener -t tcp -a 127.0.0.1 -s 4420 "$subnqn"

"$rootdir/build/examples/bdevperf" -q 128 -o 4k -w randrw -M 50 -t 1 -m 2 -r "$bperfsock" -z &
bperfpid=$!