domains: allow domains to be unloaded
Add domain_remove() SYSUNINT callback that removes the domain from the domain list if it has DOMF_UNLOADABLE flag set. This change is required to support netlink ( D36002 ). Reviewed by: glebius Differential Revision: https://reviews.freebsd.org/D36173
This commit is contained in:
parent
278d080bad
commit
9b967bd65d
@ -239,6 +239,29 @@ domain_add(void *data)
|
||||
mtx_unlock(&dom_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
domain_remove(void *data)
|
||||
{
|
||||
struct domain *dp = (struct domain *)data;
|
||||
|
||||
if ((dp->dom_flags & DOMF_UNLOADABLE) == 0)
|
||||
return;
|
||||
|
||||
mtx_lock(&dom_mtx);
|
||||
if (domains == dp) {
|
||||
domains = dp->dom_next;
|
||||
} else {
|
||||
struct domain *curr;
|
||||
for (curr = domains; curr != NULL; curr = curr->dom_next) {
|
||||
if (curr->dom_next == dp) {
|
||||
curr->dom_next = dp->dom_next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
mtx_unlock(&dom_mtx);
|
||||
}
|
||||
|
||||
/* ARGSUSED*/
|
||||
static void
|
||||
domaininit(void *dummy)
|
||||
|
@ -71,11 +71,13 @@ struct domain {
|
||||
/* dom_flags */
|
||||
#define DOMF_SUPPORTED 0x0001 /* System supports this domain. */
|
||||
#define DOMF_INITED 0x0002 /* Initialized in the default vnet. */
|
||||
#define DOMF_UNLOADABLE 0x0004 /* Can be unloaded */
|
||||
|
||||
#ifdef _KERNEL
|
||||
extern int domain_init_status;
|
||||
extern struct domain *domains;
|
||||
void domain_add(void *);
|
||||
void domain_remove(void *);
|
||||
void domain_init(void *);
|
||||
#ifdef VIMAGE
|
||||
void vnet_domain_init(void *);
|
||||
@ -85,6 +87,8 @@ void vnet_domain_uninit(void *);
|
||||
#define DOMAIN_SET(name) \
|
||||
SYSINIT(domain_add_ ## name, SI_SUB_PROTO_DOMAIN, \
|
||||
SI_ORDER_FIRST, domain_add, & name ## domain); \
|
||||
SYSUNINIT(domain_remove_ ## name, SI_SUB_PROTO_DOMAIN, \
|
||||
SI_ORDER_FIRST, domain_remove, & name ## domain); \
|
||||
SYSINIT(domain_init_ ## name, SI_SUB_PROTO_DOMAIN, \
|
||||
SI_ORDER_SECOND, domain_init, & name ## domain);
|
||||
#endif /* _KERNEL */
|
||||
|
Loading…
Reference in New Issue
Block a user