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); 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) {