summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_subr.c
diff options
context:
space:
mode:
authorsilby <silby@FreeBSD.org>2003-11-01 07:30:08 +0000
committersilby <silby@FreeBSD.org>2003-11-01 07:30:08 +0000
commit34fc0661fd7ffdd72ebd690082b4490b2a198754 (patch)
tree243678db3e842414f07bf976a824feb772294945 /sys/netinet/tcp_subr.c
parent2cedc070de4852174973d34b8317ff273d31ca54 (diff)
downloadFreeBSD-src-34fc0661fd7ffdd72ebd690082b4490b2a198754.zip
FreeBSD-src-34fc0661fd7ffdd72ebd690082b4490b2a198754.tar.gz
- Add a new function tcp_twrecycleable, which tells us if the ISN which
we will generate for a given ip/port tuple has advanced far enough for the time_wait socket in question to be safely recycled. - Have in_pcblookup_local use tcp_twrecycleable to determine if time_Wait sockets which are hogging local ports can be safely freed. This change preserves proper TIME_WAIT behavior under normal circumstances while allowing for safe and fast recycling whenever ephemeral port space is scarce.
Diffstat (limited to 'sys/netinet/tcp_subr.c')
-rw-r--r--sys/netinet/tcp_subr.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index d2a28c8..d77ab59 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1637,6 +1637,7 @@ tcp_twstart(tp)
tw->snd_nxt = tp->snd_nxt;
tw->rcv_nxt = tp->rcv_nxt;
+ tw->iss = tp->iss;
tw->cc_recv = tp->cc_recv;
tw->cc_send = tp->cc_send;
tw->t_starttime = tp->t_starttime;
@@ -1671,6 +1672,24 @@ tcp_twstart(tp)
INP_UNLOCK(inp);
}
+/*
+ * Determine if the ISN we will generate has advanced beyond the last
+ * sequence number used by the previous connection. If so, indicate
+ * that it is safe to recycle this tw socket by returning 1.
+ */
+int
+tcp_twrecycleable(struct tcptw *tw)
+{
+ tcp_seq new_isn = tw->iss;
+
+ new_isn += (ticks - tw->t_starttime) * (ISN_BYTES_PER_SECOND / hz);
+
+ if (SEQ_GT(new_isn, tw->snd_nxt))
+ return 1;
+ else
+ return 0;
+}
+
struct tcptw *
tcp_twclose(struct tcptw *tw, int reuse)
{
OpenPOWER on IntegriCloud