diff options
author | bz <bz@FreeBSD.org> | 2011-04-20 08:00:29 +0000 |
---|---|---|
committer | bz <bz@FreeBSD.org> | 2011-04-20 08:00:29 +0000 |
commit | 25cccaf492f9174346c2e76cb28eefd79c356c61 (patch) | |
tree | d91c3220e574e361498bf3a8393460f3bcb463f0 /sys/netinet/in_pcb.c | |
parent | d10762bec798133f31617d3978e0e684a7beaa8d (diff) | |
download | FreeBSD-src-25cccaf492f9174346c2e76cb28eefd79c356c61.zip FreeBSD-src-25cccaf492f9174346c2e76cb28eefd79c356c61.tar.gz |
MFp4 CH=191470:
Move the ipport_tick_callout and related functions from ip_input.c
to in_pcb.c. The random source port allocation code has been merged
and is now local to in_pcb.c only.
Use a SYSINIT to get the callout started and no longer depend on
initialization from the inet code, which would not work in an IPv6
only setup.
Reviewed by: gnn
Sponsored by: The FreeBSD Foundation
Sponsored by: iXsystems
MFC after: 4 days
Diffstat (limited to 'sys/netinet/in_pcb.c')
-rw-r--r-- | sys/netinet/in_pcb.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 03c98ff..ff4a530 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/malloc.h> #include <sys/mbuf.h> +#include <sys/callout.h> #include <sys/domain.h> #include <sys/protosw.h> #include <sys/socket.h> @@ -85,6 +86,8 @@ __FBSDID("$FreeBSD$"); #include <security/mac/mac_framework.h> +static struct callout ipport_tick_callout; + /* * These configure the range of local port addresses assigned to * "unspecified" outgoing connections/packets/whatever. @@ -1668,7 +1671,7 @@ in_pcbsosetlabel(struct socket *so) * allocation. We return to random allocation only once we drop below * ipport_randomcps for at least ipport_randomtime seconds. */ -void +static void ipport_tick(void *xtp) { VNET_ITERATOR_DECL(vnet_iter); @@ -1689,6 +1692,30 @@ ipport_tick(void *xtp) callout_reset(&ipport_tick_callout, hz, ipport_tick, NULL); } +static void +ip_fini(void *xtp) +{ + + callout_stop(&ipport_tick_callout); +} + +/* + * The ipport_callout should start running at about the time we attach the + * inet or inet6 domains. + */ +static void +ipport_tick_init(const void *unused __unused) +{ + + /* Start ipport_tick. */ + callout_init(&ipport_tick_callout, CALLOUT_MPSAFE); + callout_reset(&ipport_tick_callout, 1, ipport_tick, NULL); + EVENTHANDLER_REGISTER(shutdown_pre_sync, ip_fini, NULL, + SHUTDOWN_PRI_DEFAULT); +} +SYSINIT(ipport_tick_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_MIDDLE, + ipport_tick_init, NULL); + void inp_wlock(struct inpcb *inp) { |