diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index eba365f7ad3e..9f49db2ad935 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -892,15 +892,39 @@ iscsi_pdu_handle_scsi_response(struct icl_pdu *response) } ccb = io->io_ccb; - if (ntohl(bhssr->bhssr_expdatasn) != io->io_datasn) { - ISCSI_SESSION_WARN(is, - "ExpDataSN mismatch in SCSI Response (%u vs %u)", - ntohl(bhssr->bhssr_expdatasn), io->io_datasn); - icl_pdu_free(response); - iscsi_session_reconnect(is); - ISCSI_SESSION_UNLOCK(is); - return; + if (bhssr->bhssr_response == BHSSR_RESPONSE_COMMAND_COMPLETED) { + if (ntohl(bhssr->bhssr_expdatasn) != io->io_datasn) { + ISCSI_SESSION_WARN(is, + "ExpDataSN mismatch in SCSI Response (%u vs %u)", + ntohl(bhssr->bhssr_expdatasn), io->io_datasn); + + /* + * XXX: Permit an ExpDataSN of zero for errors. + * + * This doesn't conform to RFC 7143, but some + * targets seem to do this. + */ + if (bhssr->bhssr_status != 0 && + bhssr->bhssr_expdatasn == htonl(0)) + goto skip_expdatasn; + + icl_pdu_free(response); + iscsi_session_reconnect(is); + ISCSI_SESSION_UNLOCK(is); + return; + } + } else { + if (bhssr->bhssr_expdatasn != htonl(0)) { + ISCSI_SESSION_WARN(is, + "ExpDataSN mismatch in SCSI Response (%u vs 0)", + ntohl(bhssr->bhssr_expdatasn)); + icl_pdu_free(response); + iscsi_session_reconnect(is); + ISCSI_SESSION_UNLOCK(is); + return; + } } +skip_expdatasn: /* * With iSER, after getting good response we can be sure