From 5da6ea7275cc6bfa2a6155ac7be193001a6be1e5 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Wed, 28 Nov 2012 18:44:22 +0100 Subject: [PATCH 1/2] NOP make the message optional Signed-off-by: Peter Lieven --- lib/nop.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/nop.c b/lib/nop.c index 325013a..3f930c0 100644 --- a/lib/nop.c +++ b/lib/nop.c @@ -64,10 +64,12 @@ iscsi_nop_out_async(struct iscsi_context *iscsi, iscsi_command_cb cb, pdu->callback = cb; pdu->private_data = private_data; - if (iscsi_pdu_add_data(iscsi, pdu, data, len) != 0) { - iscsi_set_error(iscsi, "Failed to add outdata to nop-out"); - iscsi_free_pdu(iscsi, pdu); - return -1; + if (data != NULL && len > 0) { + if (iscsi_pdu_add_data(iscsi, pdu, data, len) != 0) { + iscsi_set_error(iscsi, "Failed to add outdata to nop-out"); + iscsi_free_pdu(iscsi, pdu); + return -1; + } } if (iscsi_queue_pdu(iscsi, pdu) != 0) { From 14bee1007f025dc033e277b763e537f67616f4cc Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Thu, 29 Nov 2012 15:17:30 +0100 Subject: [PATCH 2/2] RECONNECT do not increase CmdSN for immediate PDUs Immediate PDUs such as queued NOP-Outs will cause a protocol error on reconnect. Signed-off-by: Peter Lieven --- lib/connect.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/connect.c b/lib/connect.c index d52baad..fd4c97b 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -282,7 +282,9 @@ try_again: pdu->itt = iscsi_itt_post_increment(iscsi); iscsi_pdu_set_itt(pdu, pdu->itt); - pdu->cmdsn = iscsi->cmdsn++; + /* do not increase cmdsn for PDUs marked for immediate delivery + * this will result in a protocol error */ + pdu->cmdsn = (pdu->outdata.data[0] & ISCSI_PDU_IMMEDIATE)?iscsi->cmdsn:iscsi->cmdsn++; iscsi_pdu_set_cmdsn(pdu, pdu->cmdsn); iscsi_pdu_set_expstatsn(pdu, iscsi->statsn); @@ -312,7 +314,9 @@ try_again: pdu->itt = iscsi_itt_post_increment(iscsi); iscsi_pdu_set_itt(pdu, pdu->itt); - pdu->cmdsn = iscsi->cmdsn++; + /* do not increase cmdsn for PDUs marked for immediate delivery + * this will result in a protocol error */ + pdu->cmdsn = (pdu->outdata.data[0] & ISCSI_PDU_IMMEDIATE)?iscsi->cmdsn:iscsi->cmdsn++; iscsi_pdu_set_cmdsn(pdu, pdu->cmdsn); iscsi_pdu_set_expstatsn(pdu, iscsi->statsn);