Commit bb61fabf authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

lib/iscsi: Clarify only logout with reason "close the session" is acceptable on discovery session



Based on the following description in Chapter 4.3 "iSCSI Session Types in
iSCSI specification

      b) Discovery session - a session only opened for target discovery.
         The target MUST ONLY accept Text Requests with the SendTargets
         key and a Logout Request with reason "close the session".  All
         other requests MUST be rejected.

update the comment slightly, add macro constants for iSCSI logout
reason, and change the ordering of checks to be session type and then
logout reason.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ifc2ecc5b6dde546700662d3cda59d8cc465fd83a
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472672


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarZiye Yang <ziye.yang@intel.com>
parent 9c3c488e
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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;
		}

+5 −0
Original line number Diff line number Diff line
@@ -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,