in6_rmx.c revision 195699
1139826Simp/*-
253541Sshin * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
353541Sshin * All rights reserved.
453541Sshin *
553541Sshin * Redistribution and use in source and binary forms, with or without
653541Sshin * modification, are permitted provided that the following conditions
753541Sshin * are met:
853541Sshin * 1. Redistributions of source code must retain the above copyright
953541Sshin *    notice, this list of conditions and the following disclaimer.
1053541Sshin * 2. Redistributions in binary form must reproduce the above copyright
1153541Sshin *    notice, this list of conditions and the following disclaimer in the
1253541Sshin *    documentation and/or other materials provided with the distribution.
1353541Sshin * 3. Neither the name of the project nor the names of its contributors
1453541Sshin *    may be used to endorse or promote products derived from this software
1553541Sshin *    without specific prior written permission.
1653541Sshin *
1753541Sshin * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
1853541Sshin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1953541Sshin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2053541Sshin * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
2153541Sshin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2253541Sshin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2353541Sshin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2453541Sshin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2553541Sshin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2653541Sshin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2753541Sshin * SUCH DAMAGE.
28174510Sobrien *
29174510Sobrien *	$KAME: in6_rmx.c,v 1.11 2001/07/26 06:53:16 jinmei Exp $
3053541Sshin */
3153541Sshin
32139826Simp/*-
3353541Sshin * Copyright 1994, 1995 Massachusetts Institute of Technology
3453541Sshin *
3553541Sshin * Permission to use, copy, modify, and distribute this software and
3653541Sshin * its documentation for any purpose and without fee is hereby
3753541Sshin * granted, provided that both the above copyright notice and this
3853541Sshin * permission notice appear in all copies, that both the above
3953541Sshin * copyright notice and this permission notice appear in all
4053541Sshin * supporting documentation, and that the name of M.I.T. not be used
4153541Sshin * in advertising or publicity pertaining to distribution of the
4253541Sshin * software without specific, written prior permission.  M.I.T. makes
4353541Sshin * no representations about the suitability of this software for any
4453541Sshin * purpose.  It is provided "as is" without express or implied
4553541Sshin * warranty.
4653541Sshin *
4753541Sshin * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
4853541Sshin * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
4953541Sshin * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
5053541Sshin * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
5153541Sshin * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
5253541Sshin * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
5353541Sshin * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
5453541Sshin * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
5553541Sshin * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5653541Sshin * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
5753541Sshin * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5853541Sshin * SUCH DAMAGE.
5953541Sshin *
6053541Sshin */
6153541Sshin
6253541Sshin/*
6353541Sshin * This code does two things necessary for the enhanced TCP metrics to
6453541Sshin * function in a useful manner:
6553541Sshin *  1) It marks all non-host routes as `cloning', thus ensuring that
6653541Sshin *     every actual reference to such a route actually gets turned
6753541Sshin *     into a reference to a host route to the specific destination
6853541Sshin *     requested.
6953541Sshin *  2) When such routes lose all their references, it arranges for them
7053541Sshin *     to be deleted in some random collection of circumstances, so that
7153541Sshin *     a large quantity of stale routing data is not kept in kernel memory
7253541Sshin *     indefinitely.  See in6_rtqtimo() below for the exact mechanism.
7353541Sshin */
7453541Sshin
75174510Sobrien#include <sys/cdefs.h>
76174510Sobrien__FBSDID("$FreeBSD: head/sys/netinet6/in6_rmx.c 195699 2009-07-14 22:48:30Z rwatson $");
77174510Sobrien
7853541Sshin#include <sys/param.h>
7953541Sshin#include <sys/systm.h>
8053541Sshin#include <sys/kernel.h>
81185751Simp#include <sys/lock.h>
8253541Sshin#include <sys/sysctl.h>
8353541Sshin#include <sys/queue.h>
8453541Sshin#include <sys/socket.h>
8553541Sshin#include <sys/socketvar.h>
8653541Sshin#include <sys/mbuf.h>
87185747Skmacy#include <sys/rwlock.h>
8853541Sshin#include <sys/syslog.h>
89120727Ssam#include <sys/callout.h>
90181803Sbz#include <sys/vimage.h>
9153541Sshin
9253541Sshin#include <net/if.h>
93194714Sbz#include <net/route.h>
94185571Sbz
9553541Sshin#include <netinet/in.h>
9653541Sshin#include <netinet/ip_var.h>
9753541Sshin#include <netinet/in_var.h>
9853541Sshin
9962587Sitojun#include <netinet/ip6.h>
10053541Sshin#include <netinet6/ip6_var.h>
10153541Sshin
10262587Sitojun#include <netinet/icmp6.h>
103121283Sume#include <netinet6/nd6.h>
10453541Sshin
10553541Sshin#include <netinet/tcp.h>
10653541Sshin#include <netinet/tcp_seq.h>
10753541Sshin#include <netinet/tcp_timer.h>
10853541Sshin#include <netinet/tcp_var.h>
10953541Sshin
110175162Sobrienextern int	in6_inithead(void **head, int off);
111193731Szec#ifdef VIMAGE
112193731Szecextern int	in6_detachhead(void **head, int off);
113193731Szec#endif
11453541Sshin
11562587Sitojun#define RTPRF_OURS		RTF_PROTO3	/* set on routes we manage */
11653541Sshin
11753541Sshin/*
11853541Sshin * Do what we need to do when inserting a route.
11953541Sshin */
12053541Sshinstatic struct radix_node *
12153541Sshinin6_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
122171260Sdelphij    struct radix_node *treenodes)
12353541Sshin{
12453541Sshin	struct rtentry *rt = (struct rtentry *)treenodes;
12553541Sshin	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)rt_key(rt);
12653541Sshin	struct radix_node *ret;
12753541Sshin
128186119Sqingli	RADIX_NODE_HEAD_WLOCK_ASSERT(head);
12953541Sshin	if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
13053541Sshin		rt->rt_flags |= RTF_MULTICAST;
13153541Sshin
13253541Sshin	/*
13353541Sshin	 * A little bit of help for both IPv6 output and input:
13453541Sshin	 *   For local addresses, we make sure that RTF_LOCAL is set,
13553541Sshin	 *   with the thought that this might one day be used to speed up
13653541Sshin	 *   ip_input().
13753541Sshin	 *
13853541Sshin	 * We also mark routes to multicast addresses as such, because
13953541Sshin	 * it's easy to do and might be useful (but this is much more
14053541Sshin	 * dubious since it's so easy to inspect the address).  (This
14153541Sshin	 * is done above.)
14253541Sshin	 *
14353541Sshin	 * XXX
14453541Sshin	 * should elaborate the code.
14553541Sshin	 */
14653541Sshin	if (rt->rt_flags & RTF_HOST) {
14753541Sshin		if (IN6_ARE_ADDR_EQUAL(&satosin6(rt->rt_ifa->ifa_addr)
14853541Sshin					->sin6_addr,
14953541Sshin				       &sin6->sin6_addr)) {
15053541Sshin			rt->rt_flags |= RTF_LOCAL;
15153541Sshin		}
15253541Sshin	}
15353541Sshin
154122922Sandre	if (!rt->rt_rmx.rmx_mtu && rt->rt_ifp)
155121283Sume		rt->rt_rmx.rmx_mtu = IN6_LINKMTU(rt->rt_ifp);
15653541Sshin
15753541Sshin	ret = rn_addroute(v_arg, n_arg, head, treenodes);
158186119Sqingli	if (ret == NULL) {
15953541Sshin		struct rtentry *rt2;
16053541Sshin		/*
16153541Sshin		 * We are trying to add a net route, but can't.
16253541Sshin		 * The following case should be allowed, so we'll make a
16353541Sshin		 * special check for this:
16453541Sshin		 *	Two IPv6 addresses with the same prefix is assigned
16553541Sshin		 *	to a single interrface.
16653541Sshin		 *	# ifconfig if0 inet6 3ffe:0501::1 prefix 64 alias (*1)
16753541Sshin		 *	# ifconfig if0 inet6 3ffe:0501::2 prefix 64 alias (*2)
16853541Sshin		 *	In this case, (*1) and (*2) want to add the same
16953541Sshin		 *	net route entry, 3ffe:0501:: -> if0.
17053541Sshin		 *	This case should not raise an error.
17153541Sshin		 */
172186119Sqingli		rt2 = rtalloc1((struct sockaddr *)sin6, 0, RTF_RNH_LOCKED);
17353541Sshin		if (rt2) {
174186119Sqingli			if (((rt2->rt_flags & (RTF_HOST|RTF_GATEWAY)) == 0)
17553541Sshin			 && rt2->rt_gateway
17653541Sshin			 && rt2->rt_gateway->sa_family == AF_LINK
17753541Sshin			 && rt2->rt_ifp == rt->rt_ifp) {
17853541Sshin				ret = rt2->rt_nodes;
17953541Sshin			}
180120727Ssam			RTFREE_LOCKED(rt2);
18153541Sshin		}
18253541Sshin	}
183186119Sqingli	return (ret);
18453541Sshin}
18553541Sshin
18653541Sshin/*
18753541Sshin * This code is the inverse of in6_clsroute: on first reference, if we
18853541Sshin * were managing the route, stop doing so and set the expiration timer
18953541Sshin * back off again.
19053541Sshin */
19153541Sshinstatic struct radix_node *
19253541Sshinin6_matroute(void *v_arg, struct radix_node_head *head)
19353541Sshin{
19453541Sshin	struct radix_node *rn = rn_match(v_arg, head);
19553541Sshin	struct rtentry *rt = (struct rtentry *)rn;
19653541Sshin
19753541Sshin	if (rt && rt->rt_refcnt == 0) { /* this is first reference */
19853541Sshin		if (rt->rt_flags & RTPRF_OURS) {
19953541Sshin			rt->rt_flags &= ~RTPRF_OURS;
20053541Sshin			rt->rt_rmx.rmx_expire = 0;
20153541Sshin		}
20253541Sshin	}
20353541Sshin	return rn;
20453541Sshin}
20553541Sshin
20662604SitojunSYSCTL_DECL(_net_inet6_ip6);
20762604Sitojun
208195699Srwatsonstatic VNET_DEFINE(int, rtq_reallyold6);
209195699Srwatsonstatic VNET_DEFINE(int, rtq_minreallyold6);
210195699Srwatsonstatic VNET_DEFINE(int, rtq_toomany6);
211185088Szec
212195699Srwatson#define	V_rtq_reallyold6		VNET_GET(rtq_reallyold6)
213195699Srwatson#define	V_rtq_minreallyold6		VNET_GET(rtq_minreallyold6)
214195699Srwatson#define	V_rtq_toomany6			VNET_GET(rtq_toomany6)
215120913Sume
216195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_RTEXPIRE, rtexpire, CTLFLAG_RW,
217195699Srwatson    &VNET_NAME(rtq_reallyold6) , 0, "");
218120913Sume
219195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_RTMINEXPIRE, rtminexpire, CTLFLAG_RW,
220195699Srwatson    &VNET_NAME(rtq_minreallyold6) , 0, "");
22153541Sshin
222195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_RTMAXCACHE, rtmaxcache, CTLFLAG_RW,
223195699Srwatson    &VNET_NAME(rtq_toomany6) , 0, "");
224120913Sume
22553541Sshinstruct rtqk_arg {
22653541Sshin	struct radix_node_head *rnh;
22753541Sshin	int mode;
22853541Sshin	int updating;
22953541Sshin	int draining;
23053541Sshin	int killed;
23153541Sshin	int found;
23253541Sshin	time_t nextstop;
23353541Sshin};
23453541Sshin
23553541Sshin/*
23653541Sshin * Get rid of old routes.  When draining, this deletes everything, even when
23753541Sshin * the timeout is not expired yet.  When updating, this makes sure that
238181832Sbz * nothing has a timeout longer than the current value of rtq_reallyold6.
23953541Sshin */
24053541Sshinstatic int
24153541Sshinin6_rtqkill(struct radix_node *rn, void *rock)
24253541Sshin{
24353541Sshin	struct rtqk_arg *ap = rock;
24453541Sshin	struct rtentry *rt = (struct rtentry *)rn;
24553541Sshin	int err;
24653541Sshin
247188963Srwatson	RADIX_NODE_HEAD_WLOCK_ASSERT(ap->rnh);
248188963Srwatson
24953541Sshin	if (rt->rt_flags & RTPRF_OURS) {
25053541Sshin		ap->found++;
25153541Sshin
252150351Sandre		if (ap->draining || rt->rt_rmx.rmx_expire <= time_uptime) {
25353541Sshin			if (rt->rt_refcnt > 0)
25453541Sshin				panic("rtqkill route really not free");
25553541Sshin
25653541Sshin			err = rtrequest(RTM_DELETE,
25753541Sshin					(struct sockaddr *)rt_key(rt),
25853541Sshin					rt->rt_gateway, rt_mask(rt),
259186119Sqingli					rt->rt_flags|RTF_RNH_LOCKED, 0);
26053541Sshin			if (err) {
26153541Sshin				log(LOG_WARNING, "in6_rtqkill: error %d", err);
26253541Sshin			} else {
26353541Sshin				ap->killed++;
26453541Sshin			}
26553541Sshin		} else {
26653541Sshin			if (ap->updating
267150351Sandre			   && (rt->rt_rmx.rmx_expire - time_uptime
268181832Sbz			       > V_rtq_reallyold6)) {
269150351Sandre				rt->rt_rmx.rmx_expire = time_uptime
270181832Sbz					+ V_rtq_reallyold6;
27153541Sshin			}
27253541Sshin			ap->nextstop = lmin(ap->nextstop,
27353541Sshin					    rt->rt_rmx.rmx_expire);
27453541Sshin		}
27553541Sshin	}
27653541Sshin
27753541Sshin	return 0;
27853541Sshin}
27953541Sshin
28053541Sshin#define RTQ_TIMEOUT	60*10	/* run no less than once every ten minutes */
281195699Srwatsonstatic VNET_DEFINE(int, rtq_timeout6);
282195699Srwatsonstatic VNET_DEFINE(struct callout, rtq_timer6);
28353541Sshin
284195699Srwatson#define	V_rtq_timeout6			VNET_GET(rtq_timeout6)
285195699Srwatson#define	V_rtq_timer6			VNET_GET(rtq_timer6)
286195699Srwatson
28753541Sshinstatic void
28853541Sshinin6_rtqtimo(void *rock)
28953541Sshin{
290183550Szec	CURVNET_SET_QUIET((struct vnet *) rock);
291193232Sbz	struct radix_node_head *rnh;
29253541Sshin	struct rtqk_arg arg;
29353541Sshin	struct timeval atv;
29453541Sshin	static time_t last_adjusted_timeout = 0;
29553541Sshin
296193232Sbz	rnh = rt_tables_get_rnh(0, AF_INET6);
297193232Sbz	if (rnh == NULL) {
298193232Sbz		CURVNET_RESTORE();
299193232Sbz		return;
300193232Sbz	}
30153541Sshin	arg.found = arg.killed = 0;
30253541Sshin	arg.rnh = rnh;
303181803Sbz	arg.nextstop = time_uptime + V_rtq_timeout6;
30453541Sshin	arg.draining = arg.updating = 0;
305108250Shsu	RADIX_NODE_HEAD_LOCK(rnh);
30653541Sshin	rnh->rnh_walktree(rnh, in6_rtqkill, &arg);
307108250Shsu	RADIX_NODE_HEAD_UNLOCK(rnh);
30853541Sshin
30953541Sshin	/*
31053541Sshin	 * Attempt to be somewhat dynamic about this:
31153541Sshin	 * If there are ``too many'' routes sitting around taking up space,
31253541Sshin	 * then crank down the timeout, and see if we can't make some more
31353541Sshin	 * go away.  However, we make sure that we will never adjust more
314180084Sjulian	 * than once in rtq_timeout6 seconds, to keep from cranking down too
31553541Sshin	 * hard.
31653541Sshin	 */
317181832Sbz	if ((arg.found - arg.killed > V_rtq_toomany6)
318181803Sbz	   && (time_uptime - last_adjusted_timeout >= V_rtq_timeout6)
319181832Sbz	   && V_rtq_reallyold6 > V_rtq_minreallyold6) {
320181832Sbz		V_rtq_reallyold6 = 2*V_rtq_reallyold6 / 3;
321181832Sbz		if (V_rtq_reallyold6 < V_rtq_minreallyold6) {
322181832Sbz			V_rtq_reallyold6 = V_rtq_minreallyold6;
32353541Sshin		}
32453541Sshin
325160123Soleg		last_adjusted_timeout = time_uptime;
32653541Sshin#ifdef DIAGNOSTIC
327181832Sbz		log(LOG_DEBUG, "in6_rtqtimo: adjusted rtq_reallyold6 to %d",
328181832Sbz		    V_rtq_reallyold6);
32953541Sshin#endif
33053541Sshin		arg.found = arg.killed = 0;
33153541Sshin		arg.updating = 1;
332108250Shsu		RADIX_NODE_HEAD_LOCK(rnh);
33353541Sshin		rnh->rnh_walktree(rnh, in6_rtqkill, &arg);
334108250Shsu		RADIX_NODE_HEAD_UNLOCK(rnh);
33553541Sshin	}
33653541Sshin
33753541Sshin	atv.tv_usec = 0;
338160123Soleg	atv.tv_sec = arg.nextstop - time_uptime;
339181803Sbz	callout_reset(&V_rtq_timer6, tvtohz(&atv), in6_rtqtimo, rock);
340183550Szec	CURVNET_RESTORE();
34153541Sshin}
34253541Sshin
34353541Sshin/*
34453541Sshin * Age old PMTUs.
34553541Sshin */
34653541Sshinstruct mtuex_arg {
34753541Sshin	struct radix_node_head *rnh;
34853541Sshin	time_t nextstop;
34953541Sshin};
35053541Sshin
351195699Srwatsonstatic VNET_DEFINE(struct callout, rtq_mtutimer);
352195699Srwatson#define	V_rtq_mtutimer			VNET_GET(rtq_mtutimer)
353195699Srwatson
35453541Sshinstatic int
35553541Sshinin6_mtuexpire(struct radix_node *rn, void *rock)
35653541Sshin{
35753541Sshin	struct rtentry *rt = (struct rtentry *)rn;
35853541Sshin	struct mtuex_arg *ap = rock;
35953541Sshin
36053541Sshin	/* sanity */
36153541Sshin	if (!rt)
36253541Sshin		panic("rt == NULL in in6_mtuexpire");
36353541Sshin
36453541Sshin	if (rt->rt_rmx.rmx_expire && !(rt->rt_flags & RTF_PROBEMTU)) {
365150351Sandre		if (rt->rt_rmx.rmx_expire <= time_uptime) {
36653541Sshin			rt->rt_flags |= RTF_PROBEMTU;
36753541Sshin		} else {
36853541Sshin			ap->nextstop = lmin(ap->nextstop,
36953541Sshin					rt->rt_rmx.rmx_expire);
37053541Sshin		}
37153541Sshin	}
37253541Sshin
37353541Sshin	return 0;
37453541Sshin}
37553541Sshin
37653541Sshin#define	MTUTIMO_DEFAULT	(60*1)
37753541Sshin
37853541Sshinstatic void
37953541Sshinin6_mtutimo(void *rock)
38053541Sshin{
381183550Szec	CURVNET_SET_QUIET((struct vnet *) rock);
382193232Sbz	struct radix_node_head *rnh;
38353541Sshin	struct mtuex_arg arg;
38453541Sshin	struct timeval atv;
38553541Sshin
386193232Sbz	rnh = rt_tables_get_rnh(0, AF_INET6);
387193232Sbz	if (rnh == NULL) {
388193232Sbz		CURVNET_RESTORE();
389193232Sbz		return;
390193232Sbz	}
39153541Sshin	arg.rnh = rnh;
392160123Soleg	arg.nextstop = time_uptime + MTUTIMO_DEFAULT;
393108250Shsu	RADIX_NODE_HEAD_LOCK(rnh);
39453541Sshin	rnh->rnh_walktree(rnh, in6_mtuexpire, &arg);
395108250Shsu	RADIX_NODE_HEAD_UNLOCK(rnh);
39653541Sshin
39753541Sshin	atv.tv_usec = 0;
398160123Soleg	atv.tv_sec = arg.nextstop - time_uptime;
399136184Ssuz	if (atv.tv_sec < 0) {
40053541Sshin		printf("invalid mtu expiration time on routing table\n");
401160123Soleg		arg.nextstop = time_uptime + 30;	/* last resort */
402160123Soleg		atv.tv_sec = 30;
40353541Sshin	}
404181803Sbz	callout_reset(&V_rtq_mtutimer, tvtohz(&atv), in6_mtutimo, rock);
405183550Szec	CURVNET_RESTORE();
40653541Sshin}
40753541Sshin
40853541Sshin/*
40953541Sshin * Initialize our routing tree.
410178888Sjulian * XXX MRT When off == 0, we are being called from vfs_export.c
411178888Sjulian * so just set up their table and leave. (we know what the correct
412178888Sjulian * value should be so just use that).. FIX AFTER RELENG_7 is MFC'd
413178888Sjulian * see also comments in in_inithead() vfs_export.c and domain.h
41453541Sshin */
41553541Sshinint
41653541Sshinin6_inithead(void **head, int off)
41753541Sshin{
41853541Sshin	struct radix_node_head *rnh;
41953541Sshin
420178888Sjulian	if (!rn_inithead(head, offsetof(struct sockaddr_in6, sin6_addr) << 3))
421178888Sjulian		return 0;		/* See above */
42253541Sshin
423178888Sjulian	if (off == 0)		/* See above */
424178888Sjulian		return 1;	/* only do the rest for the real thing */
42553541Sshin
426185088Szec	V_rtq_reallyold6 = 60*60; /* one hour is ``really old'' */
427185088Szec	V_rtq_minreallyold6 = 10; /* never automatically crank down to less */
428185088Szec	V_rtq_toomany6 = 128;	  /* 128 cached routes is ``too many'' */
429185088Szec	V_rtq_timeout6 = RTQ_TIMEOUT;
430185088Szec
43153541Sshin	rnh = *head;
432193232Sbz	KASSERT(rnh == rt_tables_get_rnh(0, AF_INET6), ("rnh?"));
43353541Sshin	rnh->rnh_addaddr = in6_addroute;
43453541Sshin	rnh->rnh_matchaddr = in6_matroute;
435181803Sbz	callout_init(&V_rtq_timer6, CALLOUT_MPSAFE);
436181803Sbz	callout_init(&V_rtq_mtutimer, CALLOUT_MPSAFE);
437191816Szec	in6_rtqtimo(curvnet);	/* kick off timeout first time */
438191816Szec	in6_mtutimo(curvnet);	/* kick off timeout first time */
43953541Sshin	return 1;
44053541Sshin}
441193731Szec
442193731Szec#ifdef VIMAGE
443193731Szecint
444193731Szecin6_detachhead(void **head, int off)
445193731Szec{
446193731Szec
447193731Szec	callout_drain(&V_rtq_timer6);
448193731Szec	callout_drain(&V_rtq_mtutimer);
449193731Szec	return (1);
450193731Szec}
451193731Szec#endif
452