summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_domain.c
diff options
context:
space:
mode:
authorzec <zec@FreeBSD.org>2009-06-08 17:15:40 +0000
committerzec <zec@FreeBSD.org>2009-06-08 17:15:40 +0000
commit8b1f38241aaf07621c062901b7946145be2862b6 (patch)
tree7c00057a3f90cc6cfd121e2a6594d254fc72cba3 /sys/kern/uipc_domain.c
parent76b38c556af92b00895865a09a6f444150b8a8d8 (diff)
downloadFreeBSD-src-8b1f38241aaf07621c062901b7946145be2862b6.zip
FreeBSD-src-8b1f38241aaf07621c062901b7946145be2862b6.tar.gz
Introduce an infrastructure for dismantling vnet instances.
Vnet modules and protocol domains may now register destructor functions to clean up and release per-module state. The destructor mechanisms can be triggered by invoking "vimage -d", or a future equivalent command which will be provided via the new jail framework. While this patch introduces numerous placeholder destructor functions, many of those are currently incomplete, thus leaking memory or (even worse) failing to stop all running timers. Many of such issues are already known and will be incrementaly fixed over the next weeks in smaller incremental commits. Apart from introducing new fields in structs ifnet, domain, protosw and vnet_net, which requires the kernel and modules to be rebuilt, this change should have no impact on nooptions VIMAGE builds, since vnet destructors can only be called in VIMAGE kernels. Moreover, destructor functions should be in general compiled in only in options VIMAGE builds, except for kernel modules which can be safely kldunloaded at run time. Bump __FreeBSD_version to 800097. Reviewed by: bz, julian Approved by: rwatson, kib (re), julian (mentor)
Diffstat (limited to 'sys/kern/uipc_domain.c')
-rw-r--r--sys/kern/uipc_domain.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
index df35bcb..9ee6047 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -66,6 +66,9 @@ 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;
@@ -107,7 +110,10 @@ struct pr_usrreqs nousrreqs = {
vnet_modinfo_t vnet_domain_modinfo = {
.vmi_id = VNET_MOD_DOMAIN,
.vmi_name = "domain",
- .vmi_iattach = net_init_domain
+ .vmi_iattach = net_init_domain,
+#ifdef VIMAGE
+ .vmi_idetach = net_detach_domain,
+#endif
};
#endif
@@ -190,6 +196,26 @@ net_init_domain(const void *arg)
return (0);
}
+#ifdef VIMAGE
+/*
+ * Detach / free a domain instance.
+ */
+static int
+net_detach_domain(const void *arg)
+{
+ const struct domain *dp = arg;
+ struct protosw *pr;
+
+ for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
+ if (pr->pr_destroy)
+ (*pr->pr_destroy)();
+ if (dp->dom_destroy)
+ (*dp->dom_destroy)();
+
+ return (0);
+}
+#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.
OpenPOWER on IntegriCloud