summaryrefslogtreecommitdiffstats
path: root/sys/netinet/igmp.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2009-07-23 20:46:49 +0000
committerrwatson <rwatson@FreeBSD.org>2009-07-23 20:46:49 +0000
commitb3be1c6e3bd7d3b5cf946ddb04c1c5811644229b (patch)
tree0191b21173debdadfbf9f7565dfc5a8b9eefe94a /sys/netinet/igmp.c
parentfc8defe5dd957eaee1f1c841d45804df5bbf20f5 (diff)
downloadFreeBSD-src-b3be1c6e3bd7d3b5cf946ddb04c1c5811644229b.zip
FreeBSD-src-b3be1c6e3bd7d3b5cf946ddb04c1c5811644229b.tar.gz
Introduce and use a sysinit-based initialization scheme for virtual
network stacks, VNET_SYSINIT: - Add VNET_SYSINIT and VNET_SYSUNINIT macros to declare events that will occur each time a network stack is instantiated and destroyed. In the !VIMAGE case, these are simply mapped into regular SYSINIT/SYSUNINIT. For the VIMAGE case, we instead use SYSINIT's to track their order and properties on registration, using them for each vnet when created/ destroyed, or immediately on module load for already-started vnets. - Remove vnet_modinfo mechanism that existed to serve this purpose previously, as well as its dependency scheme: we now just use the SYSINIT ordering scheme. - Implement VNET_DOMAIN_SET() to allow protocol domains to declare that they want init functions to be called for each virtual network stack rather than just once at boot, compiling down to DOMAIN_SET() in the non-VIMAGE case. - Walk all virtualized kernel subsystems and make use of these instead of modinfo or DOMAIN_SET() for init/uninit events. In some cases, convert modular components from using modevent to using sysinit (where appropriate). In some cases, do minor rejuggling of SYSINIT ordering to make room for or better manage events. Portions submitted by: jhb (VNET_SYSINIT), bz (cleanup) Discussed with: jhb, bz, julian, zec Reviewed by: bz Approved by: re (VIMAGE blanket)
Diffstat (limited to 'sys/netinet/igmp.c')
-rw-r--r--sys/netinet/igmp.c52
1 files changed, 12 insertions, 40 deletions
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index 2c7ed2e..44796de 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -114,7 +114,6 @@ static char * igmp_rec_type_to_str(const int);
#endif
static void igmp_set_version(struct igmp_ifinfo *, const int);
static void igmp_slowtimo_vnet(void);
-static void igmp_sysinit(void);
static int igmp_v1v2_queue_report(struct in_multi *, const int);
static void igmp_v1v2_process_group_timer(struct in_multi *, const int);
static void igmp_v1v2_process_querier_timers(struct igmp_ifinfo *);
@@ -137,9 +136,6 @@ static int sysctl_igmp_default_version(SYSCTL_HANDLER_ARGS);
static int sysctl_igmp_gsr(SYSCTL_HANDLER_ARGS);
static int sysctl_igmp_ifinfo(SYSCTL_HANDLER_ARGS);
-static vnet_attach_fn vnet_igmp_iattach;
-static vnet_detach_fn vnet_igmp_idetach;
-
static const struct netisr_handler igmp_nh = {
.nh_name = "igmp",
.nh_handler = igmp_intr,
@@ -3580,7 +3576,7 @@ igmp_rec_type_to_str(const int type)
#endif
static void
-igmp_sysinit(void)
+igmp_init(void *unused __unused)
{
CTR1(KTR_IGMPV3, "%s: initializing", __func__);
@@ -3591,9 +3587,10 @@ igmp_sysinit(void)
netisr_register(&igmp_nh);
}
+SYSINIT(igmp_init, SI_SUB_PSEUDO, SI_ORDER_MIDDLE, igmp_init, NULL);
static void
-igmp_sysuninit(void)
+igmp_uninit(void *unused __unused)
{
CTR1(KTR_IGMPV3, "%s: tearing down", __func__);
@@ -3605,42 +3602,30 @@ igmp_sysuninit(void)
IGMP_LOCK_DESTROY();
}
+SYSUNINIT(igmp_uninit, SI_SUB_PSEUDO, SI_ORDER_MIDDLE, igmp_uninit, NULL);
-/*
- * Initialize an IGMPv3 instance.
- * VIMAGE: Assumes curvnet set by caller and called per vimage.
- */
-static int
-vnet_igmp_iattach(const void *unused __unused)
+static void
+vnet_igmp_init(const void *unused __unused)
{
CTR1(KTR_IGMPV3, "%s: initializing", __func__);
LIST_INIT(&V_igi_head);
-
- return (0);
}
+VNET_SYSINIT(vnet_igmp_init, SI_SUB_PSEUDO, SI_ORDER_ANY, vnet_igmp_init,
+ NULL);
-static int
-vnet_igmp_idetach(const void *unused __unused)
+static void
+vnet_igmp_uninit(const void *unused __unused)
{
CTR1(KTR_IGMPV3, "%s: tearing down", __func__);
KASSERT(LIST_EMPTY(&V_igi_head),
("%s: igi list not empty; ifnets not detached?", __func__));
-
- return (0);
}
-
-#ifdef VIMAGE
-static vnet_modinfo_t vnet_igmp_modinfo = {
- .vmi_id = VNET_MOD_IGMP,
- .vmi_name = "igmp",
- .vmi_iattach = vnet_igmp_iattach,
- .vmi_idetach = vnet_igmp_idetach
-};
-#endif
+VNET_SYSUNINIT(vnet_igmp_uninit, SI_SUB_PSEUDO, SI_ORDER_ANY,
+ vnet_igmp_uninit, NULL);
static int
igmp_modevent(module_t mod, int type, void *unused __unused)
@@ -3648,20 +3633,7 @@ igmp_modevent(module_t mod, int type, void *unused __unused)
switch (type) {
case MOD_LOAD:
- igmp_sysinit();
-#ifdef VIMAGE
- vnet_mod_register(&vnet_igmp_modinfo);
-#else
- vnet_igmp_iattach(NULL);
-#endif
- break;
case MOD_UNLOAD:
-#ifdef VIMAGE
- vnet_mod_deregister(&vnet_igmp_modinfo);
-#else
- vnet_igmp_idetach(NULL);
-#endif
- igmp_sysuninit();
break;
default:
return (EOPNOTSUPP);
OpenPOWER on IntegriCloud