From 735e3063adc5e4b161218535d2095b3281d492eb Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Fri, 14 Dec 2012 17:29:08 +0100 Subject: [PATCH 1/3] PDU log header of rejected PDUs Signed-off-by: Peter Lieven --- lib/pdu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/pdu.c b/lib/pdu.c index 4ae3139..b5e57fe 100644 --- a/lib/pdu.c +++ b/lib/pdu.c @@ -59,6 +59,14 @@ iscsi_itt_post_increment(struct iscsi_context *iscsi) { return old_itt; } +void iscsi_dump_pdu_header(struct iscsi_context *iscsi, unsigned char *data) { + char dump[ISCSI_RAW_HEADER_SIZE*3+1]={0}; + int i; + for (i=0;idata[16]); + if (iscsi->log_level > 1) { + iscsi_dump_pdu_header(iscsi, in->data); + } + for (pdu = iscsi->waitpdu; pdu; pdu = pdu->next) { if (pdu->itt == itt) { break; From 2f9fda19d2baf19ce2b30e5f6449659ff2898fc1 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Sat, 15 Dec 2012 13:24:01 +0100 Subject: [PATCH 2/3] SOCKET do not queue PDUs with itt==0xffffffff head of queue Queing packets with itt = 0xffffffff (e.g. NOP-Out replies) ahead of queue because they might have a higher CmdSN than following packets. This again could lead to a deadlock AND its a protocol violotion: RFC3720 Section 3.2.2.1 second last paragraph on Page 21: "On any connection, the iSCSI initiator MUST send the commands in increasing order of CmdSN, except for commands that are retransmitted due to digest error recovery and connection recovery." Signed-off-by: Peter Lieven --- lib/socket.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/socket.c b/lib/socket.c index b448ff5..7e4f703 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -63,11 +63,9 @@ iscsi_add_to_outqueue(struct iscsi_context *iscsi, struct iscsi_pdu *pdu) /* queue pdus in ascending order of itt. * ensure that pakets with the same itt are kept in order. - * queue pdus with itt = 0xffffffff (SNACK / DataACK) in order but at head of queue. */ do { - if (iscsi_serial32_compare(pdu->itt, current->itt) < 0 - || (pdu->itt == 0xffffffff && current->itt != 0xffffffff)) { + if (iscsi_serial32_compare(pdu->itt, current->itt) < 0) { /* insert PDU before the current */ if (last != NULL) { last->next=pdu; From 4cbbc0e1e9f9c86df227060ec3ffcb1a021627ae Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Sun, 16 Dec 2012 12:36:34 +0100 Subject: [PATCH 3/3] SOCKET order packets in outqueue by CmdSN Ordering by itt adds the special case of handling itt == 0xffffffff. Order by CmdSN instead as described by RFC3720. Signed-off-by: Peter Lieven --- lib/socket.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/socket.c b/lib/socket.c index 7e4f703..c30f862 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -61,11 +61,11 @@ iscsi_add_to_outqueue(struct iscsi_context *iscsi, struct iscsi_pdu *pdu) return; } - /* queue pdus in ascending order of itt. - * ensure that pakets with the same itt are kept in order. + /* queue pdus in ascending order of CmdSN. + * ensure that pakets with the same CmdSN are kept in FIFO order. */ do { - if (iscsi_serial32_compare(pdu->itt, current->itt) < 0) { + if (iscsi_serial32_compare(pdu->cmdsn, current->cmdsn) < 0) { /* insert PDU before the current */ if (last != NULL) { last->next=pdu;