Index: sys/netinet/igmp.c =================================================================== --- sys/netinet/igmp.c +++ sys/netinet/igmp.c @@ -60,7 +60,6 @@ #include #include #include -#include #include #include #include @@ -93,6 +92,10 @@ #define KTR_IGMPV3 KTR_INET #endif +#define IGMP_SLOWTIMER_DELAY (SBT_1MS * 200) /* 200 ms */ +#define IGMP_FASTTIMER_DELAY (SBT_1MS * 500) /* 500 ms */ +#define IGMP_RESPONSE_BURST_INTERVAL (IGMP_FASTTIMER_DELAY / 2) + static struct igmp_ifsoftc * igi_alloc_locked(struct ifnet *); static void igi_delete_locked(const struct ifnet *); @@ -201,8 +204,8 @@ /* * VIMAGE-wide globals. * - * The IGMPv3 timers themselves need to run per-image, however, - * protosw timers run globally (see tcp). + * The IGMPv3 timers themselves need to run per-image, however, for + * historical reasons, timers run globally. This needs to be improved. * An ifnet can only be in one vimage at a time, and the loopback * ifnet, loif, is itself virtualized. * It would otherwise be possible to seriously hose IGMP state, @@ -816,7 +819,7 @@ case IGMP_AWAKENING_MEMBER: inm->inm_state = IGMP_REPORTING_MEMBER; inm->inm_timer = IGMP_RANDOM_DELAY( - IGMP_V1V2_MAX_RI * PR_FASTHZ); + IGMP_V1V2_MAX_RI * IGMP_FASTTIMER_DELAY); V_current_state_timers_running = 1; break; case IGMP_LEAVING_MEMBER: @@ -886,7 +889,7 @@ igmp_set_version(igi, IGMP_VERSION_2); - timer = igmp->igmp_code * PR_FASTHZ / IGMP_TIMER_SCALE; + timer = igmp->igmp_code * IGMP_FASTTIMER_DELAY / IGMP_TIMER_SCALE; if (timer == 0) timer = 1; @@ -1026,7 +1029,7 @@ (IGMP_EXP(igmpv3->igmp_qqi) + 3); } - timer = maxresp * PR_FASTHZ / IGMP_TIMER_SCALE; + timer = maxresp * IGMP_FASTTIMER_DELAY / IGMP_TIMER_SCALE; if (timer == 0) timer = 1; @@ -1655,11 +1658,14 @@ * Fast timeout handler (global). * VIMAGE: Timeout handlers are expected to service all vimages. */ -void -igmp_fasttimo(void) +static struct callout igmpfast_callout; +static void +igmp_fasttimo(void *arg __unused) { + struct epoch_tracker et; VNET_ITERATOR_DECL(vnet_iter); + NET_EPOCH_ENTER(et); VNET_LIST_RLOCK_NOSLEEP(); VNET_FOREACH(vnet_iter) { CURVNET_SET(vnet_iter); @@ -1667,6 +1673,10 @@ CURVNET_RESTORE(); } VNET_LIST_RUNLOCK_NOSLEEP(); + NET_EPOCH_EXIT(et); + + callout_reset(&igmpfast_callout, IGMP_FASTTIMER_DELAY, igmp_fasttimo, + NULL); } /* @@ -1741,7 +1751,7 @@ if (igi->igi_version == IGMP_VERSION_3) { loop = (igi->igi_flags & IGIF_LOOPBACK) ? 1 : 0; uri_fasthz = IGMP_RANDOM_DELAY(igi->igi_uri * - PR_FASTHZ); + IGMP_FASTTIMER_DELAY); mbufq_init(&qrq, IGMP_MAX_G_GS_PACKETS); mbufq_init(&scq, IGMP_MAX_STATE_CHANGE_PACKETS); } @@ -2000,7 +2010,7 @@ * Section 8.12. */ old_version_timer = igi->igi_rv * igi->igi_qi + igi->igi_qri; - old_version_timer *= PR_SLOWHZ; + old_version_timer *= IGMP_SLOWTIMER_DELAY; if (version == IGMP_VERSION_1) { igi->igi_v1_timer = old_version_timer; @@ -2193,11 +2203,14 @@ * Global slowtimo handler. * VIMAGE: Timeout handlers are expected to service all vimages. */ -void -igmp_slowtimo(void) +static struct callout igmpslow_callout; +static void +igmp_slowtimo(void *arg __unused) { + struct epoch_tracker et; VNET_ITERATOR_DECL(vnet_iter); + NET_EPOCH_ENTER(et); VNET_LIST_RLOCK_NOSLEEP(); VNET_FOREACH(vnet_iter) { CURVNET_SET(vnet_iter); @@ -2205,6 +2218,10 @@ CURVNET_RESTORE(); } VNET_LIST_RUNLOCK_NOSLEEP(); + NET_EPOCH_EXIT(et); + + callout_reset(&igmpslow_callout, IGMP_SLOWTIMER_DELAY, igmp_slowtimo, + NULL); } /* @@ -2433,7 +2450,7 @@ IGMP_v1_HOST_MEMBERSHIP_REPORT); if (error == 0) { inm->inm_timer = IGMP_RANDOM_DELAY( - IGMP_V1V2_MAX_RI * PR_FASTHZ); + IGMP_V1V2_MAX_RI * IGMP_FASTTIMER_DELAY); V_current_state_timers_running = 1; } break; @@ -3688,6 +3705,12 @@ IGMP_LOCK_INIT(); m_raopt = igmp_ra_alloc(); netisr_register(&igmp_nh); + callout_init(&igmpslow_callout, 1); + callout_reset(&igmpslow_callout, IGMP_SLOWTIMER_DELAY, + igmp_slowtimo, NULL); + callout_init(&igmpfast_callout, 1); + callout_reset(&igmpfast_callout, IGMP_FASTTIMER_DELAY, + igmp_fasttimo, NULL); break; case MOD_UNLOAD: CTR1(KTR_IGMPV3, "%s: tearing down", __func__); Index: sys/netinet/igmp_var.h =================================================================== --- sys/netinet/igmp_var.h +++ sys/netinet/igmp_var.h @@ -148,7 +148,6 @@ #define IGMP_MAX_STATE_CHANGE_PACKETS 8 /* # of packets per state change */ #define IGMP_MAX_RESPONSE_PACKETS 16 /* # of packets for general query */ #define IGMP_MAX_RESPONSE_BURST 4 /* # of responses to send at once */ -#define IGMP_RESPONSE_BURST_INTERVAL (PR_FASTHZ / 2) /* 500ms */ /* * IGMP-specific mbuf flags. @@ -223,13 +222,11 @@ }; int igmp_change_state(struct in_multi *); -void igmp_fasttimo(void); struct igmp_ifsoftc * igmp_domifattach(struct ifnet *); void igmp_domifdetach(struct ifnet *); void igmp_ifdetach(struct ifnet *); int igmp_input(struct mbuf **, int *, int); -void igmp_slowtimo(void); SYSCTL_DECL(_net_inet_igmp); Index: sys/netinet/in_proto.c =================================================================== --- sys/netinet/in_proto.c +++ sys/netinet/in_proto.c @@ -184,8 +184,6 @@ .pr_protocol = IPPROTO_IGMP, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_ctloutput = rip_ctloutput, - .pr_fasttimo = igmp_fasttimo, - .pr_slowtimo = igmp_slowtimo, .pr_usrreqs = &rip_usrreqs }, {