summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_timewait.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2006-09-08 13:09:15 +0000
committerglebius <glebius@FreeBSD.org>2006-09-08 13:09:15 +0000
commit9dc28ac0b4752bea8cbeafd6c6c063ed4a4a0039 (patch)
treee2d87d4fb591ed78dacff417b91c5e106c54519b /sys/netinet/tcp_timewait.c
parent454c903c073d0b9a35bedbdbb7800d2023496691 (diff)
downloadFreeBSD-src-9dc28ac0b4752bea8cbeafd6c6c063ed4a4a0039.zip
FreeBSD-src-9dc28ac0b4752bea8cbeafd6c6c063ed4a4a0039.tar.gz
Add a sysctl net.inet.tcp.nolocaltimewait that allows to suppress
creating a compress TIME WAIT states, if both connection endpoints are local. Default is off.
Diffstat (limited to 'sys/netinet/tcp_timewait.c')
-rw-r--r--sys/netinet/tcp_timewait.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c
index 85d5a9e..fb0fba5 100644
--- a/sys/netinet/tcp_timewait.c
+++ b/sys/netinet/tcp_timewait.c
@@ -202,6 +202,11 @@ SYSCTL_PROC(_net_inet_tcp, OID_AUTO, maxtcptw, CTLTYPE_INT|CTLFLAG_RW,
&maxtcptw, 0, sysctl_maxtcptw, "IU",
"Maximum number of compressed TCP TIME_WAIT entries");
+static int nolocaltimewait = 0;
+SYSCTL_INT(_net_inet_tcp, OID_AUTO, nolocaltimewait, CTLFLAG_RW,
+ &nolocaltimewait, 0, "Do not create compressed TCP TIME_WAIT entries"
+ "for local connections");
+
/*
* TCP bandwidth limiting sysctls. Note that the default lower bound of
* 1024 exists only for debugging. A good production default would be
@@ -1735,12 +1740,19 @@ void
tcp_twstart(struct tcpcb *tp)
{
struct tcptw *tw;
- struct inpcb *inp;
+ struct inpcb *inp = tp->t_inpcb;
int acknow;
struct socket *so;
INP_INFO_WLOCK_ASSERT(&tcbinfo); /* tcp_timer_2msl_reset(). */
- INP_LOCK_ASSERT(tp->t_inpcb);
+ INP_LOCK_ASSERT(inp);
+
+ if (nolocaltimewait && in_localip(inp->inp_faddr)) {
+ tp = tcp_close(tp);
+ if (tp != NULL)
+ INP_UNLOCK(inp);
+ return;
+ }
tw = uma_zalloc(tcptw_zone, M_NOWAIT);
if (tw == NULL) {
@@ -1748,11 +1760,10 @@ tcp_twstart(struct tcpcb *tp)
if (tw == NULL) {
tp = tcp_close(tp);
if (tp != NULL)
- INP_UNLOCK(tp->t_inpcb);
+ INP_UNLOCK(inp);
return;
}
}
- inp = tp->t_inpcb;
tw->tw_inpcb = inp;
/*
OpenPOWER on IntegriCloud