summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_domain.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/kern/uipc_domain.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/kern/uipc_domain.c')
-rw-r--r--sys/kern/uipc_domain.c55
1 files changed, 19 insertions, 36 deletions
diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
index 88322d5..dd0602e 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -59,17 +59,12 @@ __FBSDID("$FreeBSD$");
*/
static void domaininit(void *);
-SYSINIT(domain, SI_SUB_PROTO_DOMAIN, SI_ORDER_FIRST, domaininit, NULL);
+SYSINIT(domain, SI_SUB_PROTO_DOMAININIT, SI_ORDER_ANY, domaininit, NULL);
static void domainfinalize(void *);
SYSINIT(domainfin, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST, domainfinalize,
NULL);
-static vnet_attach_fn net_init_domain;
-#ifdef VIMAGE
-static vnet_detach_fn net_detach_domain;
-#endif
-
static struct callout pffast_callout;
static struct callout pfslow_callout;
@@ -106,15 +101,6 @@ struct pr_usrreqs nousrreqs = {
.pru_sopoll = pru_sopoll_notsupp,
};
-#ifdef VIMAGE
-vnet_modinfo_t vnet_domain_modinfo = {
- .vmi_id = VNET_MOD_DOMAIN,
- .vmi_name = "domain",
- .vmi_iattach = net_init_domain,
- .vmi_idetach = net_detach_domain,
-};
-#endif
-
static void
protosw_init(struct protosw *pr)
{
@@ -174,10 +160,10 @@ protosw_init(struct protosw *pr)
* Note: you cant unload it again because a socket may be using it.
* XXX can't fail at this time.
*/
-static int
-net_init_domain(const void *arg)
+void
+domain_init(void *arg)
{
- const struct domain *dp = arg;
+ struct domain *dp = arg;
struct protosw *pr;
if (dp->dom_init)
@@ -191,17 +177,21 @@ net_init_domain(const void *arg)
max_datalen = MHLEN - max_hdr;
if (max_datalen < 1)
panic("%s: max_datalen < 1", __func__);
- return (0);
}
#ifdef VIMAGE
-/*
- * Detach / free a domain instance.
- */
-static int
-net_detach_domain(const void *arg)
+void
+vnet_domain_init(void *arg)
+{
+
+ /* Virtualized case is no different -- call init functions. */
+ domain_init(arg);
+}
+
+void
+vnet_domain_uninit(void *arg)
{
- const struct domain *dp = arg;
+ struct domain *dp = arg;
struct protosw *pr;
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
@@ -209,8 +199,6 @@ net_detach_domain(const void *arg)
(*pr->pr_destroy)();
if (dp->dom_destroy)
(*dp->dom_destroy)();
-
- return (0);
}
#endif
@@ -220,7 +208,7 @@ net_detach_domain(const void *arg)
* XXX can't fail at this time.
*/
void
-net_add_domain(void *data)
+domain_add(void *data)
{
struct domain *dp;
@@ -234,24 +222,19 @@ net_add_domain(void *data)
dp->dom_name));
#ifndef INVARIANTS
if (domain_init_status < 1)
- printf("WARNING: attempt to net_add_domain(%s) before "
+ printf("WARNING: attempt to domain_add(%s) before "
"domaininit()\n", dp->dom_name);
#endif
#ifdef notyet
KASSERT(domain_init_status < 2,
- ("attempt to net_add_domain(%s) after domainfinalize()",
+ ("attempt to domain_add(%s) after domainfinalize()",
dp->dom_name));
#else
if (domain_init_status >= 2)
- printf("WARNING: attempt to net_add_domain(%s) after "
+ printf("WARNING: attempt to domain_add(%s) after "
"domainfinalize()\n", dp->dom_name);
#endif
mtx_unlock(&dom_mtx);
-#ifdef VIMAGE
- vnet_mod_register_multi(&vnet_domain_modinfo, dp, dp->dom_name);
-#else
- net_init_domain(dp);
-#endif
}
static void
OpenPOWER on IntegriCloud