From 6df323fe96499f82edb9fe95255a08b7f5fb59e8 Mon Sep 17 00:00:00 2001 From: Folkert van Heusden Date: Fri, 11 Oct 2024 23:45:22 +0200 Subject: [PATCH] windows initiator compatibility fixes --- iscsi-pdu.cpp | 29 ++++++++--------------------- session.h | 2 +- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/iscsi-pdu.cpp b/iscsi-pdu.cpp index 03b304b..f5bb40e 100644 --- a/iscsi-pdu.cpp +++ b/iscsi-pdu.cpp @@ -256,9 +256,7 @@ bool iscsi_pdu_login_request::set_data(const std::pairget_max_seg_len(); for(const auto & kv: kvs_in) { DOLOG(logging::ll_debug, "iscsi_pdu_login_request::set_data", ses->get_endpoint_name(), "kv %s", kv.c_str()); @@ -271,13 +269,9 @@ bool iscsi_pdu_login_request::set_data(const std::pairset_header_digest(has_CRC32C(parts[1])); else if (parts[0] == "DataDigest") @@ -291,11 +285,6 @@ bool iscsi_pdu_login_request::set_data(const std::pairset_ack_interval(max_burst); } - if (target_name != ses->get_target_name() && discovery == false) { - DOLOG(logging::ll_warning, "iscsi_pdu_login_request::set_data", ses->get_endpoint_name(), "invalid target name \"%s\", expecting \"%s\"", target_name.c_str(), ses->get_target_name().c_str()); - return false; - } - return true; } @@ -334,11 +323,12 @@ bool iscsi_pdu_login_reply::set(const iscsi_pdu_login_request & reply_to) bool discovery = reply_to.get_NSG() == 1; if (discovery) { - DOLOG(logging::ll_debug, "iscsi_pdu_login_reply::set", ses->get_endpoint_name(), "discovery mode"); + DOLOG(logging::ll_debug, "iscsi_pdu_login_reply::set", ses->get_endpoint_name(), "discovery mode, CSG %d, NSG %d", reply_to.get_CSG(), reply_to.get_NSG()); const std::vector kvs { "TargetPortalGroupTag=1", "AuthMethod=None", + "ErrorRecoveryLevel=0", }; for(const auto & kv : kvs) DOLOG(logging::ll_debug, "iscsi_pdu_login_reply::set", ses->get_endpoint_name(), "send KV \"%s\"", kv.c_str()); @@ -347,16 +337,14 @@ bool iscsi_pdu_login_reply::set(const iscsi_pdu_login_request & reply_to) login_reply_reply_data.second = temp.second; } else { - DOLOG(logging::ll_debug, "iscsi_pdu_login_reply::set", ses->get_endpoint_name(), "login mode"); + DOLOG(logging::ll_debug, "iscsi_pdu_login_reply::set", ses->get_endpoint_name(), "login mode, CSG %d, NSG %d", reply_to.get_CSG(), reply_to.get_NSG()); const std::vector kvs { ses->get_header_digest() ? "HeaderDigest=CRC32C,None" : "HeaderDigest=None", ses->get_data_digest () ? "DataDigest=CRC32C,None" : "DataDigest=None", "DefaultTime2Wait=2", "DefaultTime2Retain=20", - "ErrorRecoveryLevel=0", "InitialR2T=Yes", - myformat("MaxRecvDataSegmentLength=%u", MAX_DATA_SEGMENT_SIZE), }; for(const auto & kv : kvs) DOLOG(logging::ll_debug, "iscsi_pdu_login_reply::set", ses->get_endpoint_name(), "send KV \"%s\"", kv.c_str()); @@ -381,17 +369,16 @@ bool iscsi_pdu_login_reply::set(const iscsi_pdu_login_request & reply_to) login_reply->datalenM = login_reply_reply_data.second >> 8; login_reply->datalenL = login_reply_reply_data.second ; memcpy(login_reply->ISID, reply_to.get_ISID(), 6); - if (!discovery) { - do { + if (reply_to.get_NSG() == 3) { + while(login_reply->TSIH == 0) { if (my_getrandom(&login_reply->TSIH, sizeof login_reply->TSIH) == false) { DOLOG(logging::ll_error, "iscsi_pdu_login_reply::set", ses->get_endpoint_name(), "random generator returned an error"); return false; } } - while(login_reply->TSIH == 0); } login_reply->Itasktag = reply_to.get_Itasktag(); - login_reply->StatSN = my_HTONL(discovery ? 0 : reply_to.get_ExpStatSN()); + login_reply->StatSN = my_HTONL(reply_to.get_CSG() == 0 ? 0 : 1); login_reply->ExpCmdSN = my_HTONL(reply_to.get_CmdSN()); login_reply->MaxCmdSN = my_HTONL(reply_to.get_CmdSN() + 1); diff --git a/session.h b/session.h index 40bb2a4..d0fab73 100644 --- a/session.h +++ b/session.h @@ -21,7 +21,7 @@ class session uint64_t bytes_rx { 0 }; uint64_t bytes_tx { 0 }; - uint32_t max_seg_len { 8192 }; + uint32_t max_seg_len { MAX_DATA_SEGMENT_SIZE }; const bool allow_digest { false }; bool header_digest { false };