summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-11-23 15:59:43 +0000
committerrwatson <rwatson@FreeBSD.org>2004-11-23 15:59:43 +0000
commit37654f9d78eafb0fa438f156e67683a3faa82a29 (patch)
treee15d97403376779534052d7a4fa3bcd2963538c5 /sys/netinet
parent6fc68675579e237b310082f22cd47d66ee83c826 (diff)
downloadFreeBSD-src-37654f9d78eafb0fa438f156e67683a3faa82a29.zip
FreeBSD-src-37654f9d78eafb0fa438f156e67683a3faa82a29.tar.gz
Assert the tcbinfo write lock in tcp_new_isn(), as the tcbinfo lock
protects access to the ISN state variables. Acquire the tcbinfo write lock in tcp_isn_tick() to synchronize timer-driven isn bumping. Staticize internal ISN variables since they're not used outside of tcp_subr.c. MFC after: 2 weeks
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/tcp_subr.c15
-rw-r--r--sys/netinet/tcp_timewait.c15
2 files changed, 22 insertions, 8 deletions
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index f63cb5a..d54b6fa 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1282,16 +1282,19 @@ tcp6_ctlinput(cmd, sa, d)
* between seeding of isn_secret. This is normally set to zero,
* as reseeding should not be necessary.
*
+ * Locking of the global variables isn_secret, isn_last_reseed, isn_offset,
+ * isn_offset_old, and isn_ctx is performed using the TCP pcbinfo lock. In
+ * general, this means holding an exclusive (write) lock.
*/
#define ISN_BYTES_PER_SECOND 1048576
#define ISN_STATIC_INCREMENT 4096
#define ISN_RANDOM_INCREMENT (4096 - 1)
-u_char isn_secret[32];
-int isn_last_reseed;
-u_int32_t isn_offset, isn_offset_old;
-MD5_CTX isn_ctx;
+static u_char isn_secret[32];
+static int isn_last_reseed;
+static u_int32_t isn_offset, isn_offset_old;
+static MD5_CTX isn_ctx;
tcp_seq
tcp_new_isn(tp)
@@ -1300,6 +1303,8 @@ tcp_new_isn(tp)
u_int32_t md5_buffer[4];
tcp_seq new_isn;
+ INP_INFO_WLOCK_ASSERT(&tcbinfo);
+
/* Seed if this is the first use, reseed if requested. */
if ((isn_last_reseed == 0) || ((tcp_isn_reseed_interval > 0) &&
(((u_int)isn_last_reseed + (u_int)tcp_isn_reseed_interval*hz)
@@ -1346,6 +1351,7 @@ tcp_isn_tick(xtp)
{
u_int32_t projected_offset;
+ INP_INFO_WLOCK(&tcbinfo);
projected_offset = isn_offset_old + ISN_BYTES_PER_SECOND / hz;
if (projected_offset > isn_offset)
@@ -1353,6 +1359,7 @@ tcp_isn_tick(xtp)
isn_offset_old = isn_offset;
callout_reset(&isn_callout, 1, tcp_isn_tick, NULL);
+ INP_INFO_WUNLOCK(&tcbinfo);
}
/*
diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c
index f63cb5a..d54b6fa 100644
--- a/sys/netinet/tcp_timewait.c
+++ b/sys/netinet/tcp_timewait.c
@@ -1282,16 +1282,19 @@ tcp6_ctlinput(cmd, sa, d)
* between seeding of isn_secret. This is normally set to zero,
* as reseeding should not be necessary.
*
+ * Locking of the global variables isn_secret, isn_last_reseed, isn_offset,
+ * isn_offset_old, and isn_ctx is performed using the TCP pcbinfo lock. In
+ * general, this means holding an exclusive (write) lock.
*/
#define ISN_BYTES_PER_SECOND 1048576
#define ISN_STATIC_INCREMENT 4096
#define ISN_RANDOM_INCREMENT (4096 - 1)
-u_char isn_secret[32];
-int isn_last_reseed;
-u_int32_t isn_offset, isn_offset_old;
-MD5_CTX isn_ctx;
+static u_char isn_secret[32];
+static int isn_last_reseed;
+static u_int32_t isn_offset, isn_offset_old;
+static MD5_CTX isn_ctx;
tcp_seq
tcp_new_isn(tp)
@@ -1300,6 +1303,8 @@ tcp_new_isn(tp)
u_int32_t md5_buffer[4];
tcp_seq new_isn;
+ INP_INFO_WLOCK_ASSERT(&tcbinfo);
+
/* Seed if this is the first use, reseed if requested. */
if ((isn_last_reseed == 0) || ((tcp_isn_reseed_interval > 0) &&
(((u_int)isn_last_reseed + (u_int)tcp_isn_reseed_interval*hz)
@@ -1346,6 +1351,7 @@ tcp_isn_tick(xtp)
{
u_int32_t projected_offset;
+ INP_INFO_WLOCK(&tcbinfo);
projected_offset = isn_offset_old + ISN_BYTES_PER_SECOND / hz;
if (projected_offset > isn_offset)
@@ -1353,6 +1359,7 @@ tcp_isn_tick(xtp)
isn_offset_old = isn_offset;
callout_reset(&isn_callout, 1, tcp_isn_tick, NULL);
+ INP_INFO_WUNLOCK(&tcbinfo);
}
/*
OpenPOWER on IntegriCloud