From 5b27db6268cbf16f11abf19b4b1e933d1bbdf142 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Wed, 2 Sep 2020 06:50:24 +0900 Subject: [PATCH] lib/nvmf: Check if I/O qpair is on the same listener as admin qpair We will have ANA state per listener and per subsystem. On the other hand, NVMe specification defines ANA state per controller. However, it is possible that I/O qpair and admin qpair are different listeners on a single controller. Let's check if I/O qpair is on the same listener as admin qpair if ANA reporting is enabled. The case that I/O qpair is on a different listener from admin qpair is not usual and so the purpose of this check is just to guard SPDK from any unexpected behavior. Signed-off-by: Shuhei Matsumoto Change-Id: Idb8d255de7f998e45a59a120c2ed5803258873f4 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4026 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- lib/nvmf/ctrlr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index c84c56e37..1658063b4 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -512,6 +512,7 @@ _nvmf_ctrlr_add_io_qpair(void *ctx) struct spdk_nvmf_qpair *admin_qpair; struct spdk_nvmf_tgt *tgt = qpair->transport->tgt; struct spdk_nvmf_subsystem *subsystem; + const struct spdk_nvmf_subsystem_listener *listener; SPDK_DEBUGLOG(SPDK_LOG_NVMF, "Connect I/O Queue for controller id 0x%x\n", data->cntlid); @@ -535,6 +536,17 @@ _nvmf_ctrlr_add_io_qpair(void *ctx) return; } + /* If ANA reporting is enabled, check if I/O connect is on the same listener. */ + if (subsystem->ana_reporting) { + listener = nvmf_subsystem_find_listener(subsystem, qpair->trid); + if (listener != ctrlr->listener) { + SPDK_ERRLOG("I/O connect is on a listener different from admin connect\n"); + SPDK_NVMF_INVALID_CONNECT_CMD(rsp, qid); + spdk_nvmf_request_complete(req); + return; + } + } + admin_qpair = ctrlr->admin_qpair; qpair->ctrlr = ctrlr; spdk_thread_send_msg(admin_qpair->group->thread, nvmf_ctrlr_add_io_qpair, req);