Skip to content

Commit

Permalink
IFR_IO_ERROR returns a iscsi_pdu_scsi_response with read-error sense …
Browse files Browse the repository at this point in the history
…code
  • Loading branch information
folkertvanheusden committed Oct 14, 2024
1 parent 6d6693f commit da094d4
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,12 +566,23 @@ void server::handler()
if (ifr != IFR_OK && ifr != IFR_CONNECTION) { // something wrong with the received PDU?
DOLOG(logging::ll_debug, "server::handler", endpoint, "invalid PDU");

std::optional<blob_t> reject;
std::optional<uint8_t> reason;

if (ifr == IFR_INVALID_FIELD || ifr == IFR_IO_ERROR || ifr == IFR_MISC) {
if (ifr == IFR_INVALID_FIELD || ifr == IFR_MISC) {
is->iscsiInstSsnFormatErrors++;
reason = 0x09;
}
else if (ifr == IFR_IO_ERROR) {
auto *temp = new iscsi_pdu_scsi_response(ses) /* 0x21 */;

if (temp->set(*reinterpret_cast<iscsi_pdu_scsi_cmd *>(pdu), s->error_read_error(), { }, 0x09) == false) {
reason = IFR_CONNECTION;
DOLOG(logging::ll_info, "server::handler", ses->get_endpoint_name(), "iscsi_pdu_scsi_response::set returned error");
}

reject = temp->get()[0];
}
else if (ifr == IFR_DIGEST) {
is->iscsiInstSsnDigestErrors++;
reason = 0x02;
Expand All @@ -582,10 +593,12 @@ void server::handler()
DOLOG(logging::ll_error, "server::handler", endpoint, "internal error, IFR %d not known", ifr);
}

std::optional<blob_t> reject = generate_reject_pdu(*pdu, reason);
if (reject.has_value() == false) {
DOLOG(logging::ll_error, "server::handler", endpoint, "cannot generate reject PDU");
continue;
reject = generate_reject_pdu(*pdu, reason);
if (reject.has_value() == false) {
DOLOG(logging::ll_error, "server::handler", endpoint, "cannot generate reject PDU");
continue;
}
}

bool rc = cc->send(reject.value().data, reject.value().n);
Expand Down

0 comments on commit da094d4

Please sign in to comment.