From ec39dd62e78dea7db91aaf32fdced46c2a24dec7 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 18 Jul 2016 14:41:29 -0700 Subject: [PATCH] nvmf: fail commands when controller is disabled The host is not allowed to send normal admin or I/O commands until the controller is enabled (via the Fabric Property Set command). Change-Id: Ib62be3a3792fc0b36bace28b4c9afdf78dad3bcd Signed-off-by: Daniel Verkamp --- lib/nvmf/request.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/nvmf/request.c b/lib/nvmf/request.c index 62d09d4c0..ca9ee76a1 100644 --- a/lib/nvmf/request.c +++ b/lib/nvmf/request.c @@ -647,17 +647,21 @@ spdk_nvmf_request_prep_data(struct spdk_nvmf_request *req, int spdk_nvmf_request_exec(struct spdk_nvmf_request *req) { + struct nvmf_session *session = req->conn->sess; struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd; + struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl; bool done; if (cmd->opc == SPDK_NVME_OPC_FABRIC) { done = nvmf_process_fabrics_command(req); + } else if (session == NULL || !session->vcprop.cc.bits.en) { + /* Only Fabric commands are allowed when the controller is disabled */ + SPDK_ERRLOG("Non-Fabric command sent to disabled controller\n"); + rsp->status.sc = SPDK_NVME_SC_COMMAND_SEQUENCE_ERROR; + done = true; } else if (req->conn->type == CONN_TYPE_AQ) { - struct nvmf_session *session; struct spdk_nvmf_subsystem *subsystem; - session = req->conn->sess; - RTE_VERIFY(session != NULL); subsystem = session->subsys; RTE_VERIFY(subsystem != NULL); if (subsystem->subtype == SPDK_NVMF_SUBTYPE_DISCOVERY) {