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:
parent
24e1c6ae7d
commit
644ca0846d
@ -130,7 +130,7 @@ static struct domain hv_socket_domain = {
|
||||
.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 MIN_PORT ((uint32_t)0x0)
|
||||
|
@ -183,29 +183,21 @@ domain_init(void *arg)
|
||||
struct protosw *pr;
|
||||
int flags;
|
||||
|
||||
MPASS(IS_DEFAULT_VNET(curvnet));
|
||||
|
||||
flags = atomic_load_acq_int(&dp->dom_flags);
|
||||
if ((flags & DOMF_SUPPORTED) == 0)
|
||||
return;
|
||||
KASSERT((flags & DOMF_INITED) == 0 || !IS_DEFAULT_VNET(curvnet),
|
||||
("Premature initialization of domain in non-default vnet"));
|
||||
MPASS((flags & DOMF_INITED) == 0);
|
||||
|
||||
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);
|
||||
rm_wlock(&pftimo_lock);
|
||||
if (pr->pr_fasttimo != NULL)
|
||||
LIST_INSERT_HEAD(&pffast_list, pr,
|
||||
pr_fasttimos);
|
||||
if (pr->pr_slowtimo != NULL)
|
||||
LIST_INSERT_HEAD(&pfslow_list, pr,
|
||||
pr_slowtimos);
|
||||
rm_wunlock(&pftimo_lock);
|
||||
}
|
||||
pr_usrreqs_init(pr);
|
||||
rm_wlock(&pftimo_lock);
|
||||
if (pr->pr_fasttimo != NULL)
|
||||
LIST_INSERT_HEAD(&pffast_list, pr, pr_fasttimos);
|
||||
if (pr->pr_slowtimo != NULL)
|
||||
LIST_INSERT_HEAD(&pfslow_list, pr, pr_slowtimos);
|
||||
rm_wunlock(&pftimo_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -215,29 +207,9 @@ domain_init(void *arg)
|
||||
max_datalen = MHLEN - max_hdr;
|
||||
if (max_datalen < 1)
|
||||
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
|
||||
* Note: you cant unload it again because a socket may be using it.
|
||||
|
@ -2702,4 +2702,4 @@ static struct domain routedomain = {
|
||||
.dom_protoswNPROTOSW = &routesw[nitems(routesw)]
|
||||
};
|
||||
|
||||
VNET_DOMAIN_SET(route);
|
||||
DOMAIN_SET(route);
|
||||
|
@ -287,4 +287,4 @@ ng_btsocket_modevent(module_t mod, int event, void *data)
|
||||
return (error);
|
||||
} /* ng_btsocket_modevent */
|
||||
|
||||
VNET_DOMAIN_SET(ng_btsocket_);
|
||||
DOMAIN_SET(ng_btsocket_);
|
||||
|
@ -1223,7 +1223,7 @@ ngs_mod_event(module_t mod, int event, void *data)
|
||||
return (error);
|
||||
}
|
||||
|
||||
VNET_DOMAIN_SET(ng);
|
||||
DOMAIN_SET(ng);
|
||||
|
||||
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,
|
||||
|
@ -302,7 +302,7 @@ struct domain inetdomain = {
|
||||
.dom_ifdetach = in_domifdetach
|
||||
};
|
||||
|
||||
VNET_DOMAIN_SET(inet);
|
||||
DOMAIN_SET(inet);
|
||||
#endif /* INET */
|
||||
|
||||
SYSCTL_NODE(_net, PF_INET, inet, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
|
||||
|
@ -345,7 +345,7 @@ struct domain inet6domain = {
|
||||
.dom_ifmtu = in6_domifmtu
|
||||
};
|
||||
|
||||
VNET_DOMAIN_SET(inet6);
|
||||
DOMAIN_SET(inet6);
|
||||
|
||||
/*
|
||||
* Internet configuration info
|
||||
|
@ -87,19 +87,6 @@ void vnet_domain_uninit(void *);
|
||||
SI_ORDER_FIRST, domain_add, & name ## domain); \
|
||||
SYSINIT(domain_init_ ## name, SI_SUB_PROTO_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 /* !_SYS_DOMAIN_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user