fix critical bugs and improve iSCSI protocol compliance
- Fix nil pointer dereference in BindISCSISession when existSess is nil - Fix reversed logic in SPCLuOffline/SPCLuOnline (Online flag was swapped) - Use negotiated MaxXmitDataSegmentLength for response PDU segmentation (issue #41) - Fix debug log incorrectly using Warn level in SBCGetLbaStatus Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -546,6 +546,12 @@ func (s *ISCSITargetDriver) iscsiExecLogin(conn *iscsiConnection) error {
|
||||
if conn.loginParam.tgtNSG == FullFeaturePhase &&
|
||||
conn.loginParam.tgtTrans {
|
||||
conn.state = CONN_STATE_LOGIN_FULL
|
||||
// Update maxRecvDataSegmentLength from the negotiated MaxXmitDataSegmentLength
|
||||
// (which comes from the initiator's MaxRecvDataSegmentLength)
|
||||
if negotiatedMaxXmit := conn.loginParam.sessionParam[ISCSI_PARAM_MAX_XMIT_DLENGTH].Value; negotiatedMaxXmit > 0 {
|
||||
conn.maxRecvDataSegmentLength = uint32(negotiatedMaxXmit)
|
||||
conn.maxSeqCount = conn.maxBurstLength / conn.maxRecvDataSegmentLength
|
||||
}
|
||||
} else {
|
||||
conn.state = CONN_STATE_LOGIN
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ func (s *ISCSITargetDriver) BindISCSISession(conn *iscsiConnection) error {
|
||||
return fmt.Errorf("initiator err, invalid request")
|
||||
}
|
||||
|
||||
if existSess == nil && conn.loginParam.tsih != 0 &&
|
||||
if existSess != nil && conn.loginParam.tsih != 0 &&
|
||||
existSess.TSIH != conn.loginParam.tsih {
|
||||
return fmt.Errorf("initiator err, no session")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user