summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_subr.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2006-09-05 12:08:47 +0000
committerglebius <glebius@FreeBSD.org>2006-09-05 12:08:47 +0000
commit70efc78561ad63a56b82bb72f195e3bd7717fcef (patch)
tree2960d1971ae56fbeff665411fff460e77f665497 /sys/netinet/tcp_subr.c
parent3001f9c21fed62232d6bf99b116ff067d9ce4fcb (diff)
downloadFreeBSD-src-70efc78561ad63a56b82bb72f195e3bd7717fcef.zip
FreeBSD-src-70efc78561ad63a56b82bb72f195e3bd7717fcef.tar.gz
- Make net.inet.tcp.maxtcptw modifiable at run time.
- If net.inet.tcp.maxtcptw was ever set explicitly, do not change it if kern.ipc.maxsockets is changed.
Diffstat (limited to 'sys/netinet/tcp_subr.c')
-rw-r--r--sys/netinet/tcp_subr.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index aedd8b0..cb20deb 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -178,8 +178,27 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, isn_reseed_interval, CTLFLAG_RW,
&tcp_isn_reseed_interval, 0, "Seconds between reseeding of ISN secret");
static int maxtcptw;
-SYSCTL_INT(_net_inet_tcp, OID_AUTO, maxtcptw, CTLFLAG_RDTUN,
- &maxtcptw, 0, "Maximum number of compressed TCP TIME_WAIT entries");
+static int
+sysctl_maxtcptw(SYSCTL_HANDLER_ARGS)
+{
+ int error, new;
+
+ if (maxtcptw == 0)
+ new = maxsockets / 5;
+ else
+ new = maxtcptw;
+ error = sysctl_handle_int(oidp, &new, sizeof(int), req);
+ if (error == 0 && req->newptr) {
+ if (new > maxtcptw) {
+ maxtcptw = new;
+ } else
+ error = EINVAL;
+ }
+ return (error);
+}
+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");
/*
* TCP bandwidth limiting sysctls. Note that the default lower bound of
@@ -259,7 +278,8 @@ tcp_zone_change(void *tag)
uma_zone_set_max(tcbinfo.ipi_zone, maxsockets);
uma_zone_set_max(tcpcb_zone, maxsockets);
- uma_zone_set_max(tcptw_zone, maxsockets / 5);
+ if (maxtcptw == 0)
+ uma_zone_set_max(tcptw_zone, maxsockets / 5);
}
static int
@@ -316,12 +336,13 @@ tcp_init(void)
tcpcb_zone = uma_zcreate("tcpcb", sizeof(struct tcpcb_mem),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
uma_zone_set_max(tcpcb_zone, maxsockets);
- TUNABLE_INT_FETCH("net.inet.tcp.maxtcptw", &maxtcptw);
- if (maxtcptw == 0)
- maxtcptw = maxsockets / 5;
tcptw_zone = uma_zcreate("tcptw", sizeof(struct tcptw),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
- uma_zone_set_max(tcptw_zone, maxtcptw);
+ TUNABLE_INT_FETCH("net.inet.tcp.maxtcptw", &maxtcptw);
+ if (maxtcptw == 0)
+ uma_zone_set_max(tcptw_zone, maxsockets / 5);
+ else
+ uma_zone_set_max(tcptw_zone, maxtcptw);
tcp_timer_init();
syncache_init();
tcp_hc_init();
OpenPOWER on IntegriCloud