From 395ca12746585bac00ed8037696dfc8b82fea314 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Mon, 30 Mar 2015 11:50:04 +0200 Subject: [PATCH] login: implicitly set statsn RFC3720 10.13.4. states that the statsn should explicitly set with the first Login Repsonse. In theory the target could choose a StatSN that is not greater than iscsi->statsn (zero at start) in Serial32 arithmetic. Signed-off-by: Peter Lieven --- lib/login.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/login.c b/lib/login.c index 10ea64f..0d56518 100644 --- a/lib/login.c +++ b/lib/login.c @@ -1045,7 +1045,13 @@ iscsi_process_login_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu, status = scsi_get_uint16(&in->hdr[36]); - iscsi_adjust_statsn(iscsi, in); + // Status-Class is 0 + if (!(status >> 8)) { + if (!iscsi->current_phase && !iscsi->secneg_phase) { + iscsi->statsn = scsi_get_uint32(&in->hdr[24]); + } + iscsi_adjust_statsn(iscsi, in); + } iscsi_adjust_maxexpcmdsn(iscsi, in); /* Using bidirectional CHAP? Then we must see a chap_n and chap_r