diff options
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/iscsi.c | 5 | ||||
| -rw-r--r-- | src/server/iscsi.h | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/server/iscsi.c b/src/server/iscsi.c index 1b29dbe..b7aacec 100644 --- a/src/server/iscsi.c +++ b/src/server/iscsi.c @@ -2764,8 +2764,11 @@ static int iscsi_connection_handle_logout_req(iscsi_connection *conn, const iscs { iscsi_logout_req_packet *logout_req_pkt = (iscsi_logout_req_packet *) request_pdu->bhs_pkt; - if ( (conn->state == ISCSI_CONNECT_STATE_NEW) || (logout_req_pkt->reason_code != ISCSI_LOGOUT_REQ_REASON_CODE_CLOSE_SESSION) ) + if ( (conn->state == ISCSI_CONNECT_STATE_NEW) + || ((logout_req_pkt->reason_code & ISCSI_LOGOUT_REQ_REASON_CODE_MASK) != ISCSI_LOGOUT_REQ_REASON_CODE_CLOSE_SESSION) ) { + logadd( LOG_DEBUG1, "Invalid logout request in state %d, reason_code %d", conn->state, logout_req_pkt->reason_code ); return ISCSI_CONNECT_PDU_READ_ERR_FATAL; + } iscsi_pdu CLEANUP_PDU response_pdu; if ( !iscsi_connection_pdu_init( &response_pdu, 0, false ) ) diff --git a/src/server/iscsi.h b/src/server/iscsi.h index 53c4b0e..8c5831c 100644 --- a/src/server/iscsi.h +++ b/src/server/iscsi.h @@ -4105,6 +4105,8 @@ typedef struct __attribute__((packed)) iscsi_login_response_packet { /// Logout request reason code: Remove the connection for recovery. The connection is closed, and all commands associated with it, if any, are to be prepared for a new allegiance. #define ISCSI_LOGOUT_REQ_REASON_CODE_REMOVE_CONNECTION_RECOVERY 0x02 +/// Mask to get the logout reason from the reason_code field (lower 7 bits) +#define ISCSI_LOGOUT_REQ_REASON_CODE_MASK 0x7f /** * @brief Logout request implicit reason code: Session reinstatement. @@ -4236,7 +4238,7 @@ typedef struct __attribute__((packed)) iscsi_logout_req_packet { * I_T_L nexus with the status of CHECK CONDITION, the ASC/ASCQ value * of 0x47 / 0x7F ("SOME COMMANDS CLEARED BY ISCSI PROTOCOL EVENT"), etc. */ - int8_t reason_code; + uint8_t reason_code; /// Reserved for future usage, always MUST be 0. uint16_t reserved; |
