diff options
| author | mlelstv <mlelstv@NetBSD.org> | 2016-06-05 05:11:57 +0000 |
|---|---|---|
| committer | mlelstv <mlelstv@NetBSD.org> | 2016-06-05 05:11:57 +0000 |
| commit | 9bfc90c705f0aa31e9e05a0d9afa5e18e7ebedf7 (patch) | |
| tree | 6ebc209daa65216e79a2ecb4a4b7f6e1acb1ea66 /sys/dev | |
| parent | 90e17dfc0fb71371597e1bbd21dda72d6debc7a1 (diff) | |
Handle ExpCmdSN and MaxCmdSN updates as specified. Don't compare
serial numbers as integers.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/iscsi/iscsi_rcv.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/dev/iscsi/iscsi_rcv.c b/sys/dev/iscsi/iscsi_rcv.c index 4e98b0c632f..7e53a3d42ec 100644 --- a/sys/dev/iscsi/iscsi_rcv.c +++ b/sys/dev/iscsi/iscsi_rcv.c @@ -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 *pdu) 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 *pdu) 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 *pdu) * 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); |
