diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 615977771..f54d01b1f 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -2484,8 +2484,11 @@ iscsi_pdu_hdr_op_logout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu reqh->reason, task_tag, cid); if (conn->sess != NULL) { - if (reqh->reason != 0 && conn->sess->session_type == SESSION_TYPE_DISCOVERY) { - SPDK_ERRLOG("only logout with close the session reason can be in discovery session\n"); + if (conn->sess->session_type == SESSION_TYPE_DISCOVERY && + reqh->reason != ISCSI_LOGOUT_REASON_CLOSE_SESSION) { + SPDK_ERRLOG("Target can accept logout only with reason \"close the session\" " + "on discovery session. %d is not acceptable reason.\n", + reqh->reason); return SPDK_ISCSI_CONNECTION_FATAL; } diff --git a/lib/iscsi/iscsi.h b/lib/iscsi/iscsi.h index 863fa434e..3de512b7a 100644 --- a/lib/iscsi/iscsi.h +++ b/lib/iscsi/iscsi.h @@ -358,6 +358,11 @@ struct spdk_iscsi_globals { #define ISCSI_NSG_RESERVED_CODE 2 #define ISCSI_FULL_FEATURE_PHASE 3 +/* logout reason */ +#define ISCSI_LOGOUT_REASON_CLOSE_SESSION 0 +#define ISCSI_LOGOUT_REASON_CLOSE_CONNECTION 1 +#define ISCSI_LOGOUT_REASON_REMOVE_CONN_FOR_RECOVERY 2 + enum spdk_error_codes { SPDK_ISCSI_CONNECTION_FATAL = -1, SPDK_PDU_FATAL = -2,