diff options
author | zec <zec@FreeBSD.org> | 2009-06-08 17:15:40 +0000 |
---|---|---|
committer | zec <zec@FreeBSD.org> | 2009-06-08 17:15:40 +0000 |
commit | 8b1f38241aaf07621c062901b7946145be2862b6 (patch) | |
tree | 7c00057a3f90cc6cfd121e2a6594d254fc72cba3 /sys/net/route.c | |
parent | 76b38c556af92b00895865a09a6f444150b8a8d8 (diff) | |
download | FreeBSD-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/net/route.c')
-rw-r--r-- | sys/net/route.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index 8705a54..aaa38d7 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -99,12 +99,18 @@ static int rttrash; /* routes not in table but not freed */ static void rt_maskedcopy(struct sockaddr *, struct sockaddr *, struct sockaddr *); static int vnet_route_iattach(const void *); +#ifdef VIMAGE +static int vnet_route_idetach(const void *); +#endif #ifndef VIMAGE_GLOBALS static const vnet_modinfo_t vnet_rtable_modinfo = { .vmi_id = VNET_MOD_RTABLE, .vmi_name = "rtable", - .vmi_iattach = vnet_route_iattach + .vmi_iattach = vnet_route_iattach, +#ifdef VIMAGE + .vmi_idetach = vnet_route_idetach +#endif }; #endif /* !VIMAGE_GLOBALS */ @@ -194,7 +200,8 @@ route_init(void) #endif } -static int vnet_route_iattach(const void *unused __unused) +static int +vnet_route_iattach(const void *unused __unused) { INIT_VNET_NET(curvnet); struct domain *dom; @@ -235,6 +242,36 @@ static int vnet_route_iattach(const void *unused __unused) return (0); } +#ifdef VIMAGE +static int +vnet_route_idetach(const void *unused __unused) +{ + int table; + int fam; + struct domain *dom; + struct radix_node_head **rnh; + + for (dom = domains; dom; dom = dom->dom_next) { + if (dom->dom_rtdetach) { + for (table = 0; table < rt_numfibs; table++) { + if ( (fam = dom->dom_family) == AF_INET || + table == 0) { + /* For now only AF_INET has > 1 tbl. */ + rnh = rt_tables_get_rnh_ptr(table, fam); + if (rnh == NULL) + panic("%s: rnh NULL", __func__); + dom->dom_rtdetach((void **)rnh, + dom->dom_rtoffset); + } else { + break; + } + } + } + } + return (0); +} +#endif + #ifndef _SYS_SYSPROTO_H_ struct setfib_args { int fibnum; |