Module Name:    src
Committed By:   mlelstv
Date:           Sun Jun  5 05:11:57 UTC 2016

Modified Files:
        src/sys/dev/iscsi: iscsi_rcv.c

Log Message:
Handle ExpCmdSN and MaxCmdSN updates as specified. Don't compare
serial numbers as integers.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/iscsi/iscsi_rcv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/iscsi/iscsi_rcv.c
diff -u src/sys/dev/iscsi/iscsi_rcv.c:1.15 src/sys/dev/iscsi/iscsi_rcv.c:1.16
--- src/sys/dev/iscsi/iscsi_rcv.c:1.15	Sun Jun  5 05:07:23 2016
+++ src/sys/dev/iscsi/iscsi_rcv.c	Sun Jun  5 05:11:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_rcv.c,v 1.15 2016/06/05 05:07:23 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_rcv.c,v 1.16 2016/06/05 05:11:57 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -1014,7 +1014,7 @@ receive_pdu(connection_t *conn, pdu_t *p
 	ccb_t *req_ccb;
 	ccb_list_t waiting;
 	int rc;
-	uint32_t MaxCmdSN, digest;
+	uint32_t MaxCmdSN, ExpCmdSN, digest;
 	session_t *sess = conn->session;
 
 	if (conn->HeaderDigest) {
@@ -1112,7 +1112,7 @@ receive_pdu(connection_t *conn, pdu_t *p
 		return rc;
 
 	/* MaxCmdSN and ExpCmdSN are in the same place in all received PDUs */
-	sess->ExpCmdSN = max(sess->ExpCmdSN, ntohl(pdu->pdu.p.nop_in.ExpCmdSN));
+	ExpCmdSN = ntohl(pdu->pdu.p.nop_in.ExpCmdSN);
 	MaxCmdSN = ntohl(pdu->pdu.p.nop_in.MaxCmdSN);
 
 	/* received a valid frame, reset timeout */
@@ -1128,7 +1128,17 @@ receive_pdu(connection_t *conn, pdu_t *p
 	 * We have to handle wait/nowait CCBs a bit differently.
 	 */
 	mutex_enter(&sess->lock);
-	if (MaxCmdSN != sess->MaxCmdSN) {
+
+	if (sn_a_lt_b(MaxCmdSN, ExpCmdSN-1)) {
+		/* both are ignored */
+		mutex_exit(&sess->lock);
+		return 0;
+	}
+
+	if (sn_a_lt_b(sess->ExpCmdSN, ExpCmdSN))
+		sess->ExpCmdSN = ExpCmdSN;
+
+	if (sn_a_lt_b(sess->MaxCmdSN, MaxCmdSN)) {
 		sess->MaxCmdSN = MaxCmdSN;
 		if (TAILQ_FIRST(&sess->ccbs_throttled) == NULL) {
 			mutex_exit(&sess->lock);

Reply via email to