diff options
author | silby <silby@FreeBSD.org> | 2005-01-02 01:50:57 +0000 |
---|---|---|
committer | silby <silby@FreeBSD.org> | 2005-01-02 01:50:57 +0000 |
commit | c79cd91efc05ca91a24c2adea62738a1e660528a (patch) | |
tree | d32dcba0ed701ac7af89b0ca15a86f9f0c2cf9ad /sys/netinet/ip_input.c | |
parent | 6bfe519bf0d785388af7342b991f57aba1332cca (diff) | |
download | FreeBSD-src-c79cd91efc05ca91a24c2adea62738a1e660528a.zip FreeBSD-src-c79cd91efc05ca91a24c2adea62738a1e660528a.tar.gz |
Port randomization leads to extremely fast port reuse at high
connection rates, which is causing problems for some users.
To retain the security advantage of random ports and ensure
correct operation for high connection rate users, disable
port randomization during periods of high connection rates.
Whenever the connection rate exceeds randomcps (10 by default),
randomization will be disabled for randomtime (45 by default)
seconds. These thresholds may be tuned via sysctl.
Many thanks to Igor Sysoev, who proved the necessity of this
change and tested many preliminary versions of the patch.
MFC After: 20 seconds
Diffstat (limited to 'sys/netinet/ip_input.c')
-rw-r--r-- | sys/netinet/ip_input.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index b950504..07c7ba4 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -38,6 +38,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/callout.h> #include <sys/mac.h> #include <sys/mbuf.h> #include <sys/malloc.h> @@ -186,6 +187,7 @@ SYSCTL_STRUCT(_net_inet_ip, IPCTL_STATS, stats, CTLFLAG_RW, static TAILQ_HEAD(ipqhead, ipq) ipq[IPREASS_NHASH]; struct mtx ipqlock; +struct callout ipport_tick_callout; #define IPQ_LOCK() mtx_lock(&ipqlock) #define IPQ_UNLOCK() mtx_unlock(&ipqlock) @@ -279,6 +281,12 @@ ip_init() maxnipq = nmbclusters / 32; maxfragsperpacket = 16; + /* Start ipport_tick. */ + callout_init(&ipport_tick_callout, CALLOUT_MPSAFE); + ipport_tick(NULL); + EVENTHANDLER_REGISTER(shutdown_pre_sync, ip_fini, NULL, + SHUTDOWN_PRI_DEFAULT); + /* Initialize various other remaining things. */ ip_id = time_second & 0xffff; ipintrq.ifq_maxlen = ipqmaxlen; @@ -286,6 +294,12 @@ ip_init() netisr_register(NETISR_IP, ip_input, &ipintrq, NETISR_MPSAFE); } +void ip_fini(xtp) + void *xtp; +{ + callout_stop(&ipport_tick_callout); +} + /* * Ip input routine. Checksum and byte swap header. If fragmented * try to reassemble. Process options. Pass to next level. |