From 79246def9d01eb9e0b2e172df8085dd051816e79 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Mon, 30 Mar 2015 11:43:07 +0200 Subject: [PATCH] login: randomize cmdsn and itt Signed-off-by: Peter Lieven --- lib/login.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/login.c b/lib/login.c index 381f929..10ea64f 100644 --- a/lib/login.c +++ b/lib/login.c @@ -790,6 +790,13 @@ iscsi_login_async(struct iscsi_context *iscsi, iscsi_command_cb cb, return -1; } + /* randomize cmdsn and itt */ + if (!iscsi->current_phase && !iscsi->secneg_phase) { + iscsi->itt = (u_int32_t) rand(); + iscsi->cmdsn = (u_int32_t) rand(); + iscsi->expcmdsn = iscsi->maxcmdsn = iscsi->cmdsn; + } + pdu = iscsi_allocate_pdu(iscsi, ISCSI_PDU_LOGIN_REQUEST, ISCSI_PDU_LOGIN_RESPONSE, @@ -804,6 +811,10 @@ iscsi_login_async(struct iscsi_context *iscsi, iscsi_command_cb cb, /* login request */ iscsi_pdu_set_immediate(pdu); + /* cmdsn is not increased if Immediate delivery*/ + iscsi_pdu_set_cmdsn(pdu, iscsi->cmdsn); + pdu->cmdsn = iscsi->cmdsn; + if (!iscsi->user[0]) { iscsi->current_phase = ISCSI_PDU_LOGIN_CSG_OPNEG; }