Merge pull request #122 from gostor/fix/critical-bugs-and-protocol-compliance

fix critical bugs and improve iSCSI protocol compliance
This commit is contained in:
Lei Xue
2026-03-14 12:18:43 +08:00
committed by GitHub
4 changed files with 10 additions and 4 deletions

View File

@@ -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
}

View File

@@ -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")
}

View File

@@ -789,7 +789,7 @@ func SBCGetLbaStatus(host int, cmd *api.SCSICommand) api.SAMStat {
tl = getSCSIReadWriteCount(scb)
// Verify that we are not doing i/o beyond the end-of-lun
totalBlocks = dev.Size >> dev.BlockShift
log.Warnf("DEBUG: dev.Size=%d, BlockShift=%d, totalBlocks=%d", dev.Size, dev.BlockShift, totalBlocks)
log.Debugf("dev.Size=%d, BlockShift=%d, totalBlocks=%d", dev.Size, dev.BlockShift, totalBlocks)
if lba >= totalBlocks || lba+uint64(tl) < lba || lba+uint64(tl) > totalBlocks {
key = ILLEGAL_REQUEST
asc = ASC_LBA_OUT_OF_RANGE

View File

@@ -38,7 +38,7 @@ func SPCIllegalOp(host int, cmd *api.SCSICommand) api.SAMStat {
}
func SPCLuOffline(lu *api.SCSILu) error {
lu.Attrs.Online = true
lu.Attrs.Online = false
return nil
}
@@ -47,7 +47,7 @@ func SPCLuOnline(lu *api.SCSILu) error {
return fmt.Errorf("lu prevent removal")
}
lu.Attrs.Online = false
lu.Attrs.Online = true
return nil
}