nvmf: enforce fabric command order and type rules
Only allow Connect on a new connection (one that has no associated session yet), and only allow Propert Set/Get on admin queues. Change-Id: Iae22379ee47b095333372e6d151a7a1509acf654 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
2d1c3419ad
commit
b794135bb1
@ -450,23 +450,44 @@ nvmf_process_connect(struct spdk_nvmf_request *req)
|
|||||||
static bool
|
static bool
|
||||||
nvmf_process_fabrics_command(struct spdk_nvmf_request *req)
|
nvmf_process_fabrics_command(struct spdk_nvmf_request *req)
|
||||||
{
|
{
|
||||||
|
struct spdk_nvmf_conn *conn = req->conn;
|
||||||
struct spdk_nvmf_capsule_cmd *cap_hdr;
|
struct spdk_nvmf_capsule_cmd *cap_hdr;
|
||||||
|
|
||||||
cap_hdr = &req->cmd->nvmf_cmd;
|
cap_hdr = &req->cmd->nvmf_cmd;
|
||||||
|
|
||||||
|
if (conn->sess == NULL) {
|
||||||
|
/* No session established yet; the only valid command is Connect */
|
||||||
|
if (cap_hdr->fctype == SPDK_NVMF_FABRIC_COMMAND_CONNECT) {
|
||||||
|
return nvmf_process_connect(req);
|
||||||
|
} else {
|
||||||
|
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Got fctype 0x%x, expected Connect\n",
|
||||||
|
cap_hdr->fctype);
|
||||||
|
req->rsp->nvme_cpl.status.sc = SPDK_NVME_SC_COMMAND_SEQUENCE_ERROR;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (conn->type == CONN_TYPE_AQ) {
|
||||||
|
/*
|
||||||
|
* Session is established, and this is an admin queue.
|
||||||
|
* Disallow Connect and allow other fabrics commands.
|
||||||
|
*/
|
||||||
switch (cap_hdr->fctype) {
|
switch (cap_hdr->fctype) {
|
||||||
case SPDK_NVMF_FABRIC_COMMAND_PROPERTY_SET:
|
case SPDK_NVMF_FABRIC_COMMAND_PROPERTY_SET:
|
||||||
return nvmf_process_property_set(req);
|
return nvmf_process_property_set(req);
|
||||||
case SPDK_NVMF_FABRIC_COMMAND_PROPERTY_GET:
|
case SPDK_NVMF_FABRIC_COMMAND_PROPERTY_GET:
|
||||||
return nvmf_process_property_get(req);
|
return nvmf_process_property_get(req);
|
||||||
case SPDK_NVMF_FABRIC_COMMAND_CONNECT:
|
|
||||||
return nvmf_process_connect(req);
|
|
||||||
default:
|
default:
|
||||||
SPDK_TRACELOG(SPDK_TRACE_DEBUG, "recv capsule header type invalid [%x]!\n",
|
SPDK_TRACELOG(SPDK_TRACE_NVMF, "recv capsule header type invalid [%x]!\n",
|
||||||
cap_hdr->fctype);
|
cap_hdr->fctype);
|
||||||
req->rsp->nvme_cpl.status.sc = SPDK_NVME_SC_INVALID_OPCODE;
|
req->rsp->nvme_cpl.status.sc = SPDK_NVME_SC_INVALID_OPCODE;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/* Session is established, and this is an I/O queue */
|
||||||
|
/* For now, no I/O-specific Fabrics commands are implemented (other than Connect) */
|
||||||
|
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Unexpected I/O fctype 0x%x\n", cap_hdr->fctype);
|
||||||
|
req->rsp->nvme_cpl.status.sc = SPDK_NVME_SC_INVALID_OPCODE;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user