domains: make domain_init() initialize only global state

Now that each module handles its global and VNET initialization
itself, there is no VNET related stuff left to do in domain_init().

Differential revision:	https://reviews.freebsd.org/D33541
This commit is contained in:
Gleb Smirnoff
2022-01-03 10:15:22 -08:00
parent 24e1c6ae7d
commit 644ca0846d
8 changed files with 18 additions and 59 deletions
+1 -1
View File
@@ -130,7 +130,7 @@ static struct domain hv_socket_domain = {
.dom_protoswNPROTOSW = &hv_socket_protosw[nitems(hv_socket_protosw)] .dom_protoswNPROTOSW = &hv_socket_protosw[nitems(hv_socket_protosw)]
}; };
VNET_DOMAIN_SET(hv_socket_); DOMAIN_SET(hv_socket_);
#define MAX_PORT ((uint32_t)0xFFFFFFFF) #define MAX_PORT ((uint32_t)0xFFFFFFFF)
#define MIN_PORT ((uint32_t)0x0) #define MIN_PORT ((uint32_t)0x0)
+6 -34
View File
@@ -183,30 +183,22 @@ domain_init(void *arg)
struct protosw *pr; struct protosw *pr;
int flags; int flags;
MPASS(IS_DEFAULT_VNET(curvnet));
flags = atomic_load_acq_int(&dp->dom_flags); flags = atomic_load_acq_int(&dp->dom_flags);
if ((flags & DOMF_SUPPORTED) == 0) if ((flags & DOMF_SUPPORTED) == 0)
return; return;
KASSERT((flags & DOMF_INITED) == 0 || !IS_DEFAULT_VNET(curvnet), MPASS((flags & DOMF_INITED) == 0);
("Premature initialization of domain in non-default vnet"));
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) { for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
/*
* Note that with VIMAGE enabled, domain_init() will be
* re-invoked for each new vnet that's created. The below lists
* are intended to be system-wide, so avoid altering global
* state for non-default vnets.
*/
if (IS_DEFAULT_VNET(curvnet)) {
pr_usrreqs_init(pr); pr_usrreqs_init(pr);
rm_wlock(&pftimo_lock); rm_wlock(&pftimo_lock);
if (pr->pr_fasttimo != NULL) if (pr->pr_fasttimo != NULL)
LIST_INSERT_HEAD(&pffast_list, pr, LIST_INSERT_HEAD(&pffast_list, pr, pr_fasttimos);
pr_fasttimos);
if (pr->pr_slowtimo != NULL) if (pr->pr_slowtimo != NULL)
LIST_INSERT_HEAD(&pfslow_list, pr, LIST_INSERT_HEAD(&pfslow_list, pr, pr_slowtimos);
pr_slowtimos);
rm_wunlock(&pftimo_lock); rm_wunlock(&pftimo_lock);
} }
}
/* /*
* update global information about maximums * update global information about maximums
@@ -215,29 +207,9 @@ domain_init(void *arg)
max_datalen = MHLEN - max_hdr; max_datalen = MHLEN - max_hdr;
if (max_datalen < 1) if (max_datalen < 1)
panic("%s: max_datalen < 1", __func__); panic("%s: max_datalen < 1", __func__);
if (IS_DEFAULT_VNET(curvnet))
atomic_set_rel_int(&dp->dom_flags, DOMF_INITED); atomic_set_rel_int(&dp->dom_flags, DOMF_INITED);
} }
#ifdef VIMAGE
void
vnet_domain_init(void *arg)
{
/* Virtualized case is no different -- call init functions. */
domain_init(arg);
}
void
vnet_domain_uninit(void *arg)
{
struct domain *dp = arg;
if ((atomic_load_acq_int(&dp->dom_flags) & DOMF_SUPPORTED) == 0)
return;
}
#endif
/* /*
* Add a new protocol domain to the list of supported domains * Add a new protocol domain to the list of supported domains
* Note: you cant unload it again because a socket may be using it. * Note: you cant unload it again because a socket may be using it.
+1 -1
View File
@@ -2702,4 +2702,4 @@ static struct domain routedomain = {
.dom_protoswNPROTOSW = &routesw[nitems(routesw)] .dom_protoswNPROTOSW = &routesw[nitems(routesw)]
}; };
VNET_DOMAIN_SET(route); DOMAIN_SET(route);
+1 -1
View File
@@ -287,4 +287,4 @@ ng_btsocket_modevent(module_t mod, int event, void *data)
return (error); return (error);
} /* ng_btsocket_modevent */ } /* ng_btsocket_modevent */
VNET_DOMAIN_SET(ng_btsocket_); DOMAIN_SET(ng_btsocket_);
+1 -1
View File
@@ -1223,7 +1223,7 @@ ngs_mod_event(module_t mod, int event, void *data)
return (error); return (error);
} }
VNET_DOMAIN_SET(ng); DOMAIN_SET(ng);
SYSCTL_INT(_net_graph, OID_AUTO, family, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, AF_NETGRAPH, ""); SYSCTL_INT(_net_graph, OID_AUTO, family, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, AF_NETGRAPH, "");
static SYSCTL_NODE(_net_graph, OID_AUTO, data, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, static SYSCTL_NODE(_net_graph, OID_AUTO, data, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
+1 -1
View File
@@ -302,7 +302,7 @@ struct domain inetdomain = {
.dom_ifdetach = in_domifdetach .dom_ifdetach = in_domifdetach
}; };
VNET_DOMAIN_SET(inet); DOMAIN_SET(inet);
#endif /* INET */ #endif /* INET */
SYSCTL_NODE(_net, PF_INET, inet, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, SYSCTL_NODE(_net, PF_INET, inet, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
+1 -1
View File
@@ -345,7 +345,7 @@ struct domain inet6domain = {
.dom_ifmtu = in6_domifmtu .dom_ifmtu = in6_domifmtu
}; };
VNET_DOMAIN_SET(inet6); DOMAIN_SET(inet6);
/* /*
* Internet configuration info * Internet configuration info
-13
View File
@@ -87,19 +87,6 @@ void vnet_domain_uninit(void *);
SI_ORDER_FIRST, domain_add, & name ## domain); \ SI_ORDER_FIRST, domain_add, & name ## domain); \
SYSINIT(domain_init_ ## name, SI_SUB_PROTO_DOMAIN, \ SYSINIT(domain_init_ ## name, SI_SUB_PROTO_DOMAIN, \
SI_ORDER_SECOND, domain_init, & name ## domain); SI_ORDER_SECOND, domain_init, & name ## domain);
#ifdef VIMAGE
#define VNET_DOMAIN_SET(name) \
SYSINIT(domain_add_ ## name, SI_SUB_PROTO_DOMAIN, \
SI_ORDER_FIRST, domain_add, & name ## domain); \
VNET_SYSINIT(vnet_domain_init_ ## name, SI_SUB_PROTO_DOMAIN, \
SI_ORDER_SECOND, vnet_domain_init, & name ## domain); \
VNET_SYSUNINIT(vnet_domain_uninit_ ## name, \
SI_SUB_PROTO_DOMAIN, SI_ORDER_SECOND, vnet_domain_uninit, \
& name ## domain)
#else /* !VIMAGE */
#define VNET_DOMAIN_SET(name) DOMAIN_SET(name)
#endif /* VIMAGE */
#endif /* _KERNEL */ #endif /* _KERNEL */
#endif /* !_SYS_DOMAIN_H_ */ #endif /* !_SYS_DOMAIN_H_ */