summaryrefslogtreecommitdiffstats
path: root/sys/netinet6
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/netinet6
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/netinet6')
-rw-r--r--sys/netinet6/in6_proto.c9
-rw-r--r--sys/netinet6/in6_rmx.c15
-rw-r--r--sys/netinet6/ip6_input.c11
-rw-r--r--sys/netinet6/ip6_var.h3
-rw-r--r--sys/netinet6/ip6protosw.h2
-rw-r--r--sys/netinet6/nd6.c19
-rw-r--r--sys/netinet6/nd6.h3
7 files changed, 55 insertions, 7 deletions
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
index c0b0b25..e4d280d 100644
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -148,6 +148,9 @@ struct ip6protosw inet6sw[] = {
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_IPV6,
.pr_init = ip6_init,
+#ifdef VIMAGE
+ .pr_destroy = ip6_destroy,
+#endif
.pr_slowtimo = frag6_slowtimo,
.pr_drain = frag6_drain,
.pr_usrreqs = &nousrreqs,
@@ -349,6 +352,9 @@ struct ip6protosw inet6sw[] = {
};
extern int in6_inithead(void **, int);
+#ifdef VIMAGE
+extern int in6_detachhead(void **, int);
+#endif
struct domain inet6domain = {
.dom_family = AF_INET6,
@@ -361,6 +367,9 @@ struct domain inet6domain = {
#else
.dom_rtattach = in6_inithead,
#endif
+#ifdef VIMAGE
+ .dom_rtdetach = in6_detachhead,
+#endif
.dom_rtoffset = offsetof(struct sockaddr_in6, sin6_addr) << 3,
.dom_maxrtkey = sizeof(struct sockaddr_in6),
.dom_ifattach = in6_domifattach,
diff --git a/sys/netinet6/in6_rmx.c b/sys/netinet6/in6_rmx.c
index 3a423ed..4dbdad6 100644
--- a/sys/netinet6/in6_rmx.c
+++ b/sys/netinet6/in6_rmx.c
@@ -112,6 +112,9 @@ __FBSDID("$FreeBSD$");
#include <netinet/tcp_var.h>
extern int in6_inithead(void **head, int off);
+#ifdef VIMAGE
+extern int in6_detachhead(void **head, int off);
+#endif
#define RTPRF_OURS RTF_PROTO3 /* set on routes we manage */
@@ -464,3 +467,15 @@ in6_inithead(void **head, int off)
in6_mtutimo(curvnet); /* kick off timeout first time */
return 1;
}
+
+#ifdef VIMAGE
+int
+in6_detachhead(void **head, int off)
+{
+ INIT_VNET_INET6(curvnet);
+
+ callout_drain(&V_rtq_timer6);
+ callout_drain(&V_rtq_mtutimer);
+ return (1);
+}
+#endif
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index b9617bb..5166eb4 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -303,6 +303,17 @@ ip6_init(void)
netisr_register(&ip6_nh);
}
+#ifdef VIMAGE
+void
+ip6_destroy()
+{
+ INIT_VNET_INET6(curvnet);
+
+ nd6_destroy();
+ callout_drain(&V_in6_tmpaddrtimer_ch);
+}
+#endif
+
static int
ip6_init2_vnet(const void *unused __unused)
{
diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h
index 313b6ca..74749f6 100644
--- a/sys/netinet6/ip6_var.h
+++ b/sys/netinet6/ip6_var.h
@@ -339,6 +339,9 @@ int icmp6_ctloutput __P((struct socket *, struct sockopt *sopt));
struct in6_ifaddr;
void ip6_init __P((void));
+#ifdef VIMAGE
+void ip6_destroy __P((void));
+#endif
void ip6_input __P((struct mbuf *));
struct in6_ifaddr *ip6_getdstifaddr __P((struct mbuf *));
void ip6_freepcbopts __P((struct ip6_pktopts *));
diff --git a/sys/netinet6/ip6protosw.h b/sys/netinet6/ip6protosw.h
index 2a7cea4..1fae44c 100644
--- a/sys/netinet6/ip6protosw.h
+++ b/sys/netinet6/ip6protosw.h
@@ -129,6 +129,8 @@ struct ip6protosw {
/* utility hooks */
void (*pr_init) /* initialization hook */
__P((void));
+ void (*pr_destroy) /* cleanup hook */
+ __P((void));
void (*pr_fasttimo) /* fast timeout (200ms) */
__P((void));
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index ccfdb8f..96c6d01 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -134,14 +134,8 @@ void
nd6_init(void)
{
INIT_VNET_INET6(curvnet);
- static int nd6_init_done = 0;
int i;
- if (nd6_init_done) {
- log(LOG_NOTICE, "nd6_init called more than once(ignored)\n");
- return;
- }
-
V_nd6_prune = 1; /* walk list every 1 seconds */
V_nd6_delay = 5; /* delay first probe time 5 second */
V_nd6_umaxtries = 3; /* maximum unicast query */
@@ -180,6 +174,8 @@ nd6_init(void)
V_ip6_temp_valid_lifetime = DEF_TEMP_VALID_LIFETIME;
V_ip6_temp_regen_advance = TEMPADDR_REGEN_ADVANCE;
+ V_ip6_desync_factor = 0;
+
all1_sa.sin6_family = AF_INET6;
all1_sa.sin6_len = sizeof(struct sockaddr_in6);
for (i = 0; i < sizeof(all1_sa.sin6_addr); i++)
@@ -191,10 +187,19 @@ nd6_init(void)
callout_init(&V_nd6_slowtimo_ch, 0);
callout_reset(&V_nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL * hz,
nd6_slowtimo, curvnet);
+}
- nd6_init_done = 1;
+#ifdef VIMAGE
+void
+nd6_destroy()
+{
+ INIT_VNET_INET6(curvnet);
+
+ callout_drain(&V_nd6_slowtimo_ch);
+ callout_drain(&V_nd6_timer_ch);
}
+#endif
struct nd_ifinfo *
nd6_ifattach(struct ifnet *ifp)
diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h
index d4d2fd5..0730d84 100644
--- a/sys/netinet6/nd6.h
+++ b/sys/netinet6/nd6.h
@@ -371,6 +371,9 @@ union nd_opts {
/* XXX: need nd6_var.h?? */
/* nd6.c */
void nd6_init __P((void));
+#ifdef VIMAGE
+void nd6_destroy __P((void));
+#endif
struct nd_ifinfo *nd6_ifattach __P((struct ifnet *));
void nd6_ifdetach __P((struct nd_ifinfo *));
int nd6_is_addr_neighbor __P((struct sockaddr_in6 *, struct ifnet *));
OpenPOWER on IntegriCloud