From 34cb6a1578820447cef22d934287090f7b37e15a Mon Sep 17 00:00:00 2001 From: Naresh Gottumukkala Date: Mon, 28 Dec 2020 07:06:42 +0000 Subject: [PATCH] nvmf/fc: Validate connection and QPair state. When ever command is recieved, validate connection and qpair state before accepting the command. Signed-off-by: Naresh Gottumukkala Change-Id: I4636b98ab24de9be0fa7fd727c8b80f16922eb2b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5709 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- lib/nvmf/fc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/nvmf/fc.c b/lib/nvmf/fc.c index 40831f08a..64db0865f 100644 --- a/lib/nvmf/fc.c +++ b/lib/nvmf/fc.c @@ -1355,12 +1355,21 @@ nvmf_fc_hwqp_handle_request(struct spdk_nvmf_fc_hwqp *hwqp, struct spdk_nvmf_fc_ } /* If association/connection is being deleted - return */ - if (fc_conn->fc_assoc->assoc_state != SPDK_NVMF_FC_OBJECT_CREATED) { - SPDK_ERRLOG("Association state not valid\n"); + if (fc_conn->fc_assoc->assoc_state != SPDK_NVMF_FC_OBJECT_CREATED) { + SPDK_ERRLOG("Association %ld state = %d not valid\n", + fc_conn->fc_assoc->assoc_id, fc_conn->fc_assoc->assoc_state); return -EACCES; } - if (fc_conn->qpair.state == SPDK_NVMF_QPAIR_ERROR) { + if (fc_conn->conn_state != SPDK_NVMF_FC_OBJECT_CREATED) { + SPDK_ERRLOG("Connection %ld state = %d not valid\n", + rqst_conn_id, fc_conn->conn_state); + return -EACCES; + } + + if (fc_conn->qpair.state != SPDK_NVMF_QPAIR_ACTIVE) { + SPDK_ERRLOG("Connection %ld qpair state = %d not valid\n", + rqst_conn_id, fc_conn->qpair.state); return -EACCES; }