The serial number arithmetic calculation in libiscsi.c
_looks_ wrong, and the SNA32_CHECK value should actually
be 2**31 as indicated in RFC3720.

I'm not sure if this actually is a bug, but it'll cause
at least some raised eyebrows by anyone else reviewing
the code.
So it's safer to defer to the RFC here.

Signed-off-by: Hannes Reinecke <h...@suse.de>
---
 drivers/scsi/libiscsi.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 716cc34..52d876f 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -84,19 +84,19 @@ MODULE_PARM_DESC(debug_libiscsi_eh,
        } while (0);
 
 /* Serial Number Arithmetic, 32 bits, less than, RFC1982 */
-#define SNA32_CHECK 2147483648UL
+#define SNA32_CHECK 0x80000000UL
 
 static int iscsi_sna_lt(u32 n1, u32 n2)
 {
        return n1 != n2 && ((n1 < n2 && (n2 - n1 < SNA32_CHECK)) ||
-                           (n1 > n2 && (n2 - n1 < SNA32_CHECK)));
+                           (n1 > n2 && (n1 - n2 > SNA32_CHECK)));
 }
 
-/* Serial Number Arithmetic, 32 bits, less than, RFC1982 */
+/* Serial Number Arithmetic, 32 bits, less than equal, RFC1982 */
 static int iscsi_sna_lte(u32 n1, u32 n2)
 {
        return n1 == n2 || ((n1 < n2 && (n2 - n1 < SNA32_CHECK)) ||
-                           (n1 > n2 && (n2 - n1 < SNA32_CHECK)));
+                           (n1 > n2 && (n1 - n2 > SNA32_CHECK)));
 }
 
 inline void iscsi_conn_queue_work(struct iscsi_conn *conn)
-- 
1.5.3.2


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/open-iscsi
-~----------~----~----~----~------~----~------~--~---

Reply via email to