Module Name: src
Committed By: christos
Date: Tue Mar 9 13:48:16 UTC 2021
Modified Files:
src/sys/netinet: tcp_subr.c
Log Message:
Move the offset addition in one place and mask the random generated value
to make sure that the isn is monotonic.
To generate a diff of this commit:
cvs rdiff -u -r1.287 -r1.288 src/sys/netinet/tcp_subr.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/netinet/tcp_subr.c
diff -u src/sys/netinet/tcp_subr.c:1.287 src/sys/netinet/tcp_subr.c:1.288
--- src/sys/netinet/tcp_subr.c:1.287 Mon Mar 8 13:17:27 2021
+++ src/sys/netinet/tcp_subr.c Tue Mar 9 08:48:16 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_subr.c,v 1.287 2021/03/08 18:17:27 christos Exp $ */
+/* $NetBSD: tcp_subr.c,v 1.288 2021/03/09 13:48:16 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.287 2021/03/08 18:17:27 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.288 2021/03/09 13:48:16 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -2210,23 +2210,23 @@ tcp_new_iss1(void *laddr, void *faddr, u
#ifdef TCPISS_DEBUG
printf("ISS hash 0x%08x, ", tcp_iss);
#endif
- /*
- * Add the offset in to the computed value.
- */
- tcp_iss += tcp_iss_seq;
-#ifdef TCPISS_DEBUG
- printf("ISS %08x\n", tcp_iss);
-#endif
} else {
/*
* Randomize.
*/
- tcp_iss = cprng_fast32();
+ tcp_iss = cprng_fast32() & TCP_ISS_RANDOM_MASK;
#ifdef TCPISS_DEBUG
printf("ISS random 0x%08x, ", tcp_iss);
#endif
}
+ /*
+ * Add the offset in to the computed value.
+ */
+ tcp_iss += tcp_iss_seq;
+#ifdef TCPISS_DEBUG
+ printf("ISS %08x\n", tcp_iss);
+#endif
return tcp_iss;
}