in6_rmx.c revision 139826
162587Sitojun/*	$FreeBSD: head/sys/netinet6/in6_rmx.c 139826 2005-01-07 02:30:35Z imp $	*/
295023Ssuz/*	$KAME: in6_rmx.c,v 1.11 2001/07/26 06:53:16 jinmei Exp $	*/
362587Sitojun
4139826Simp/*-
553541Sshin * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
653541Sshin * All rights reserved.
753541Sshin *
853541Sshin * Redistribution and use in source and binary forms, with or without
953541Sshin * modification, are permitted provided that the following conditions
1053541Sshin * are met:
1153541Sshin * 1. Redistributions of source code must retain the above copyright
1253541Sshin *    notice, this list of conditions and the following disclaimer.
1353541Sshin * 2. Redistributions in binary form must reproduce the above copyright
1453541Sshin *    notice, this list of conditions and the following disclaimer in the
1553541Sshin *    documentation and/or other materials provided with the distribution.
1653541Sshin * 3. Neither the name of the project nor the names of its contributors
1753541Sshin *    may be used to endorse or promote products derived from this software
1853541Sshin *    without specific prior written permission.
1953541Sshin *
2053541Sshin * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
2153541Sshin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2253541Sshin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2353541Sshin * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
2453541Sshin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2553541Sshin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2653541Sshin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2753541Sshin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2853541Sshin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2953541Sshin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3053541Sshin * SUCH DAMAGE.
3153541Sshin */
3253541Sshin
33139826Simp/*-
3453541Sshin * Copyright 1994, 1995 Massachusetts Institute of Technology
3553541Sshin *
3653541Sshin * Permission to use, copy, modify, and distribute this software and
3753541Sshin * its documentation for any purpose and without fee is hereby
3853541Sshin * granted, provided that both the above copyright notice and this
3953541Sshin * permission notice appear in all copies, that both the above
4053541Sshin * copyright notice and this permission notice appear in all
4153541Sshin * supporting documentation, and that the name of M.I.T. not be used
4253541Sshin * in advertising or publicity pertaining to distribution of the
4353541Sshin * software without specific, written prior permission.  M.I.T. makes
4453541Sshin * no representations about the suitability of this software for any
4553541Sshin * purpose.  It is provided "as is" without express or implied
4653541Sshin * warranty.
4753541Sshin *
4853541Sshin * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
4953541Sshin * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
5053541Sshin * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
5153541Sshin * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
5253541Sshin * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
5353541Sshin * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
5453541Sshin * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
5553541Sshin * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
5653541Sshin * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5753541Sshin * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
5853541Sshin * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5953541Sshin * SUCH DAMAGE.
6053541Sshin *
6153541Sshin */
6253541Sshin
6353541Sshin/*
6453541Sshin * This code does two things necessary for the enhanced TCP metrics to
6553541Sshin * function in a useful manner:
6653541Sshin *  1) It marks all non-host routes as `cloning', thus ensuring that
6753541Sshin *     every actual reference to such a route actually gets turned
6853541Sshin *     into a reference to a host route to the specific destination
6953541Sshin *     requested.
7053541Sshin *  2) When such routes lose all their references, it arranges for them
7153541Sshin *     to be deleted in some random collection of circumstances, so that
7253541Sshin *     a large quantity of stale routing data is not kept in kernel memory
7353541Sshin *     indefinitely.  See in6_rtqtimo() below for the exact mechanism.
7453541Sshin */
7553541Sshin
7653541Sshin#include <sys/param.h>
7753541Sshin#include <sys/systm.h>
7853541Sshin#include <sys/kernel.h>
7953541Sshin#include <sys/sysctl.h>
8053541Sshin#include <sys/queue.h>
8153541Sshin#include <sys/socket.h>
8253541Sshin#include <sys/socketvar.h>
8353541Sshin#include <sys/mbuf.h>
8453541Sshin#include <sys/syslog.h>
85120727Ssam#include <sys/callout.h>
8653541Sshin
8753541Sshin#include <net/if.h>
8853541Sshin#include <net/route.h>
8953541Sshin#include <netinet/in.h>
9053541Sshin#include <netinet/ip_var.h>
9153541Sshin#include <netinet/in_var.h>
9253541Sshin
9362587Sitojun#include <netinet/ip6.h>
9453541Sshin#include <netinet6/ip6_var.h>
9553541Sshin
9662587Sitojun#include <netinet/icmp6.h>
97121283Sume#include <netinet6/nd6.h>
9853541Sshin
9953541Sshin#include <netinet/tcp.h>
10053541Sshin#include <netinet/tcp_seq.h>
10153541Sshin#include <netinet/tcp_timer.h>
10253541Sshin#include <netinet/tcp_var.h>
10353541Sshin
10453541Sshinextern int	in6_inithead __P((void **head, int off));
10553541Sshin
10662587Sitojun#define RTPRF_OURS		RTF_PROTO3	/* set on routes we manage */
10753541Sshin
10853541Sshin/*
10953541Sshin * Do what we need to do when inserting a route.
11053541Sshin */
11153541Sshinstatic struct radix_node *
11253541Sshinin6_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
11362587Sitojun	    struct radix_node *treenodes)
11453541Sshin{
11553541Sshin	struct rtentry *rt = (struct rtentry *)treenodes;
11653541Sshin	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)rt_key(rt);
11753541Sshin	struct radix_node *ret;
11853541Sshin
11953541Sshin	if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
12053541Sshin		rt->rt_flags |= RTF_MULTICAST;
12153541Sshin
12253541Sshin	/*
12353541Sshin	 * A little bit of help for both IPv6 output and input:
12453541Sshin	 *   For local addresses, we make sure that RTF_LOCAL is set,
12553541Sshin	 *   with the thought that this might one day be used to speed up
12653541Sshin	 *   ip_input().
12753541Sshin	 *
12853541Sshin	 * We also mark routes to multicast addresses as such, because
12953541Sshin	 * it's easy to do and might be useful (but this is much more
13053541Sshin	 * dubious since it's so easy to inspect the address).  (This
13153541Sshin	 * is done above.)
13253541Sshin	 *
13353541Sshin	 * XXX
13453541Sshin	 * should elaborate the code.
13553541Sshin	 */
13653541Sshin	if (rt->rt_flags & RTF_HOST) {
13753541Sshin		if (IN6_ARE_ADDR_EQUAL(&satosin6(rt->rt_ifa->ifa_addr)
13853541Sshin					->sin6_addr,
13953541Sshin				       &sin6->sin6_addr)) {
14053541Sshin			rt->rt_flags |= RTF_LOCAL;
14153541Sshin		}
14253541Sshin	}
14353541Sshin
144122922Sandre	if (!rt->rt_rmx.rmx_mtu && rt->rt_ifp)
145121283Sume		rt->rt_rmx.rmx_mtu = IN6_LINKMTU(rt->rt_ifp);
14653541Sshin
14753541Sshin	ret = rn_addroute(v_arg, n_arg, head, treenodes);
14853541Sshin	if (ret == NULL && rt->rt_flags & RTF_HOST) {
14953541Sshin		struct rtentry *rt2;
15053541Sshin		/*
15153541Sshin		 * We are trying to add a host route, but can't.
15253541Sshin		 * Find out if it is because of an
15353541Sshin		 * ARP entry and delete it if so.
15453541Sshin		 */
155122921Sandre		rt2 = rtalloc1((struct sockaddr *)sin6, 0, RTF_CLONING);
15653541Sshin		if (rt2) {
15753541Sshin			if (rt2->rt_flags & RTF_LLINFO &&
15853541Sshin				rt2->rt_flags & RTF_HOST &&
15953541Sshin				rt2->rt_gateway &&
16053541Sshin				rt2->rt_gateway->sa_family == AF_LINK) {
161121770Ssam				rtexpunge(rt2);
162121770Ssam				RTFREE_LOCKED(rt2);
16353541Sshin				ret = rn_addroute(v_arg, n_arg, head,
16453541Sshin					treenodes);
165121770Ssam			} else
166121770Ssam				RTFREE_LOCKED(rt2);
16753541Sshin		}
16853541Sshin	} else if (ret == NULL && rt->rt_flags & RTF_CLONING) {
16953541Sshin		struct rtentry *rt2;
17053541Sshin		/*
17153541Sshin		 * We are trying to add a net route, but can't.
17253541Sshin		 * The following case should be allowed, so we'll make a
17353541Sshin		 * special check for this:
17453541Sshin		 *	Two IPv6 addresses with the same prefix is assigned
17553541Sshin		 *	to a single interrface.
17653541Sshin		 *	# ifconfig if0 inet6 3ffe:0501::1 prefix 64 alias (*1)
17753541Sshin		 *	# ifconfig if0 inet6 3ffe:0501::2 prefix 64 alias (*2)
17853541Sshin		 *	In this case, (*1) and (*2) want to add the same
17953541Sshin		 *	net route entry, 3ffe:0501:: -> if0.
18053541Sshin		 *	This case should not raise an error.
18153541Sshin		 */
182122921Sandre		rt2 = rtalloc1((struct sockaddr *)sin6, 0, RTF_CLONING);
18353541Sshin		if (rt2) {
18453541Sshin			if ((rt2->rt_flags & (RTF_CLONING|RTF_HOST|RTF_GATEWAY))
18553541Sshin					== RTF_CLONING
18653541Sshin			 && rt2->rt_gateway
18753541Sshin			 && rt2->rt_gateway->sa_family == AF_LINK
18853541Sshin			 && rt2->rt_ifp == rt->rt_ifp) {
18953541Sshin				ret = rt2->rt_nodes;
19053541Sshin			}
191120727Ssam			RTFREE_LOCKED(rt2);
19253541Sshin		}
19353541Sshin	}
19453541Sshin	return ret;
19553541Sshin}
19653541Sshin
19753541Sshin/*
19853541Sshin * This code is the inverse of in6_clsroute: on first reference, if we
19953541Sshin * were managing the route, stop doing so and set the expiration timer
20053541Sshin * back off again.
20153541Sshin */
20253541Sshinstatic struct radix_node *
20353541Sshinin6_matroute(void *v_arg, struct radix_node_head *head)
20453541Sshin{
20553541Sshin	struct radix_node *rn = rn_match(v_arg, head);
20653541Sshin	struct rtentry *rt = (struct rtentry *)rn;
20753541Sshin
20853541Sshin	if (rt && rt->rt_refcnt == 0) { /* this is first reference */
20953541Sshin		if (rt->rt_flags & RTPRF_OURS) {
21053541Sshin			rt->rt_flags &= ~RTPRF_OURS;
21153541Sshin			rt->rt_rmx.rmx_expire = 0;
21253541Sshin		}
21353541Sshin	}
21453541Sshin	return rn;
21553541Sshin}
21653541Sshin
21762604SitojunSYSCTL_DECL(_net_inet6_ip6);
21862604Sitojun
21953541Sshinstatic int rtq_reallyold = 60*60;
22053541Sshin	/* one hour is ``really old'' */
22162604SitojunSYSCTL_INT(_net_inet6_ip6, IPV6CTL_RTEXPIRE, rtexpire,
22253541Sshin	CTLFLAG_RW, &rtq_reallyold , 0, "");
223120913Sume
22453541Sshinstatic int rtq_minreallyold = 10;
22553541Sshin	/* never automatically crank down to less */
22662604SitojunSYSCTL_INT(_net_inet6_ip6, IPV6CTL_RTMINEXPIRE, rtminexpire,
22753541Sshin	CTLFLAG_RW, &rtq_minreallyold , 0, "");
228120913Sume
22953541Sshinstatic int rtq_toomany = 128;
23053541Sshin	/* 128 cached routes is ``too many'' */
23162604SitojunSYSCTL_INT(_net_inet6_ip6, IPV6CTL_RTMAXCACHE, rtmaxcache,
23253541Sshin	CTLFLAG_RW, &rtq_toomany , 0, "");
23353541Sshin
234120913Sume
23553541Sshin/*
23653541Sshin * On last reference drop, mark the route as belong to us so that it can be
23753541Sshin * timed out.
23853541Sshin */
23953541Sshinstatic void
24053541Sshinin6_clsroute(struct radix_node *rn, struct radix_node_head *head)
24153541Sshin{
24253541Sshin	struct rtentry *rt = (struct rtentry *)rn;
24353541Sshin
244120727Ssam	RT_LOCK_ASSERT(rt);
245120727Ssam
24653541Sshin	if (!(rt->rt_flags & RTF_UP))
24753541Sshin		return;		/* prophylactic measures */
24853541Sshin
24953541Sshin	if ((rt->rt_flags & (RTF_LLINFO | RTF_HOST)) != RTF_HOST)
25053541Sshin		return;
25153541Sshin
252108250Shsu	if ((rt->rt_flags & (RTF_WASCLONED | RTPRF_OURS)) != RTF_WASCLONED)
25353541Sshin		return;
25453541Sshin
25553541Sshin	/*
25653541Sshin	 * As requested by David Greenman:
25753541Sshin	 * If rtq_reallyold is 0, just delete the route without
25853541Sshin	 * waiting for a timeout cycle to kill it.
25953541Sshin	 */
26053541Sshin	if (rtq_reallyold != 0) {
26153541Sshin		rt->rt_flags |= RTPRF_OURS;
26253541Sshin		rt->rt_rmx.rmx_expire = time_second + rtq_reallyold;
26353541Sshin	} else {
264121770Ssam		rtexpunge(rt);
26553541Sshin	}
26653541Sshin}
26753541Sshin
26853541Sshinstruct rtqk_arg {
26953541Sshin	struct radix_node_head *rnh;
27053541Sshin	int mode;
27153541Sshin	int updating;
27253541Sshin	int draining;
27353541Sshin	int killed;
27453541Sshin	int found;
27553541Sshin	time_t nextstop;
27653541Sshin};
27753541Sshin
27853541Sshin/*
27953541Sshin * Get rid of old routes.  When draining, this deletes everything, even when
28053541Sshin * the timeout is not expired yet.  When updating, this makes sure that
28153541Sshin * nothing has a timeout longer than the current value of rtq_reallyold.
28253541Sshin */
28353541Sshinstatic int
28453541Sshinin6_rtqkill(struct radix_node *rn, void *rock)
28553541Sshin{
28653541Sshin	struct rtqk_arg *ap = rock;
28753541Sshin	struct rtentry *rt = (struct rtentry *)rn;
28853541Sshin	int err;
28953541Sshin
29053541Sshin	if (rt->rt_flags & RTPRF_OURS) {
29153541Sshin		ap->found++;
29253541Sshin
29353541Sshin		if (ap->draining || rt->rt_rmx.rmx_expire <= time_second) {
29453541Sshin			if (rt->rt_refcnt > 0)
29553541Sshin				panic("rtqkill route really not free");
29653541Sshin
29753541Sshin			err = rtrequest(RTM_DELETE,
29853541Sshin					(struct sockaddr *)rt_key(rt),
29953541Sshin					rt->rt_gateway, rt_mask(rt),
30053541Sshin					rt->rt_flags, 0);
30153541Sshin			if (err) {
30253541Sshin				log(LOG_WARNING, "in6_rtqkill: error %d", err);
30353541Sshin			} else {
30453541Sshin				ap->killed++;
30553541Sshin			}
30653541Sshin		} else {
30753541Sshin			if (ap->updating
30853541Sshin			   && (rt->rt_rmx.rmx_expire - time_second
30953541Sshin			       > rtq_reallyold)) {
31053541Sshin				rt->rt_rmx.rmx_expire = time_second
31153541Sshin					+ rtq_reallyold;
31253541Sshin			}
31353541Sshin			ap->nextstop = lmin(ap->nextstop,
31453541Sshin					    rt->rt_rmx.rmx_expire);
31553541Sshin		}
31653541Sshin	}
31753541Sshin
31853541Sshin	return 0;
31953541Sshin}
32053541Sshin
32153541Sshin#define RTQ_TIMEOUT	60*10	/* run no less than once every ten minutes */
32253541Sshinstatic int rtq_timeout = RTQ_TIMEOUT;
323120727Ssamstatic struct callout rtq_timer;
32453541Sshin
32553541Sshinstatic void
32653541Sshinin6_rtqtimo(void *rock)
32753541Sshin{
32853541Sshin	struct radix_node_head *rnh = rock;
32953541Sshin	struct rtqk_arg arg;
33053541Sshin	struct timeval atv;
33153541Sshin	static time_t last_adjusted_timeout = 0;
33253541Sshin
33353541Sshin	arg.found = arg.killed = 0;
33453541Sshin	arg.rnh = rnh;
33553541Sshin	arg.nextstop = time_second + rtq_timeout;
33653541Sshin	arg.draining = arg.updating = 0;
337108250Shsu	RADIX_NODE_HEAD_LOCK(rnh);
33853541Sshin	rnh->rnh_walktree(rnh, in6_rtqkill, &arg);
339108250Shsu	RADIX_NODE_HEAD_UNLOCK(rnh);
34053541Sshin
34153541Sshin	/*
34253541Sshin	 * Attempt to be somewhat dynamic about this:
34353541Sshin	 * If there are ``too many'' routes sitting around taking up space,
34453541Sshin	 * then crank down the timeout, and see if we can't make some more
34553541Sshin	 * go away.  However, we make sure that we will never adjust more
34653541Sshin	 * than once in rtq_timeout seconds, to keep from cranking down too
34753541Sshin	 * hard.
34853541Sshin	 */
34953541Sshin	if ((arg.found - arg.killed > rtq_toomany)
35053541Sshin	   && (time_second - last_adjusted_timeout >= rtq_timeout)
35153541Sshin	   && rtq_reallyold > rtq_minreallyold) {
35253541Sshin		rtq_reallyold = 2*rtq_reallyold / 3;
35353541Sshin		if (rtq_reallyold < rtq_minreallyold) {
35453541Sshin			rtq_reallyold = rtq_minreallyold;
35553541Sshin		}
35653541Sshin
35753541Sshin		last_adjusted_timeout = time_second;
35853541Sshin#ifdef DIAGNOSTIC
35953541Sshin		log(LOG_DEBUG, "in6_rtqtimo: adjusted rtq_reallyold to %d",
36053541Sshin		    rtq_reallyold);
36153541Sshin#endif
36253541Sshin		arg.found = arg.killed = 0;
36353541Sshin		arg.updating = 1;
364108250Shsu		RADIX_NODE_HEAD_LOCK(rnh);
36553541Sshin		rnh->rnh_walktree(rnh, in6_rtqkill, &arg);
366108250Shsu		RADIX_NODE_HEAD_UNLOCK(rnh);
36753541Sshin	}
36853541Sshin
36953541Sshin	atv.tv_usec = 0;
370136184Ssuz	atv.tv_sec = arg.nextstop - time_second;
371120727Ssam	callout_reset(&rtq_timer, tvtohz(&atv), in6_rtqtimo, rock);
37253541Sshin}
37353541Sshin
37453541Sshin/*
37553541Sshin * Age old PMTUs.
37653541Sshin */
37753541Sshinstruct mtuex_arg {
37853541Sshin	struct radix_node_head *rnh;
37953541Sshin	time_t nextstop;
38053541Sshin};
381120727Ssamstatic struct callout rtq_mtutimer;
38253541Sshin
38353541Sshinstatic int
38453541Sshinin6_mtuexpire(struct radix_node *rn, void *rock)
38553541Sshin{
38653541Sshin	struct rtentry *rt = (struct rtentry *)rn;
38753541Sshin	struct mtuex_arg *ap = rock;
38853541Sshin
38953541Sshin	/* sanity */
39053541Sshin	if (!rt)
39153541Sshin		panic("rt == NULL in in6_mtuexpire");
39253541Sshin
39353541Sshin	if (rt->rt_rmx.rmx_expire && !(rt->rt_flags & RTF_PROBEMTU)) {
39453541Sshin		if (rt->rt_rmx.rmx_expire <= time_second) {
39553541Sshin			rt->rt_flags |= RTF_PROBEMTU;
39653541Sshin		} else {
39753541Sshin			ap->nextstop = lmin(ap->nextstop,
39853541Sshin					rt->rt_rmx.rmx_expire);
39953541Sshin		}
40053541Sshin	}
40153541Sshin
40253541Sshin	return 0;
40353541Sshin}
40453541Sshin
40553541Sshin#define	MTUTIMO_DEFAULT	(60*1)
40653541Sshin
40753541Sshinstatic void
40853541Sshinin6_mtutimo(void *rock)
40953541Sshin{
41053541Sshin	struct radix_node_head *rnh = rock;
41153541Sshin	struct mtuex_arg arg;
41253541Sshin	struct timeval atv;
41353541Sshin
41453541Sshin	arg.rnh = rnh;
41553541Sshin	arg.nextstop = time_second + MTUTIMO_DEFAULT;
416108250Shsu	RADIX_NODE_HEAD_LOCK(rnh);
41753541Sshin	rnh->rnh_walktree(rnh, in6_mtuexpire, &arg);
418108250Shsu	RADIX_NODE_HEAD_UNLOCK(rnh);
41953541Sshin
42053541Sshin	atv.tv_usec = 0;
421136184Ssuz	atv.tv_sec = arg.nextstop - time_second;
422136184Ssuz	if (atv.tv_sec < 0) {
42353541Sshin		printf("invalid mtu expiration time on routing table\n");
424136184Ssuz		arg.nextstop = 30;	/* last resort */
42553541Sshin	}
426120727Ssam	callout_reset(&rtq_mtutimer, tvtohz(&atv), in6_mtutimo, rock);
42753541Sshin}
42853541Sshin
42962587Sitojun#if 0
43062587Sitojunvoid
43162587Sitojunin6_rtqdrain()
43262587Sitojun{
43362587Sitojun	struct radix_node_head *rnh = rt_tables[AF_INET6];
43462587Sitojun	struct rtqk_arg arg;
435120727Ssam
43662587Sitojun	arg.found = arg.killed = 0;
43762587Sitojun	arg.rnh = rnh;
43862587Sitojun	arg.nextstop = 0;
43962587Sitojun	arg.draining = 1;
44062587Sitojun	arg.updating = 0;
441108250Shsu	RADIX_NODE_HEAD_LOCK(rnh);
44262587Sitojun	rnh->rnh_walktree(rnh, in6_rtqkill, &arg);
443108250Shsu	RADIX_NODE_HEAD_UNLOCK(rnh);
44462587Sitojun}
44562587Sitojun#endif
44662587Sitojun
44753541Sshin/*
44853541Sshin * Initialize our routing tree.
44953541Sshin */
45053541Sshinint
45153541Sshinin6_inithead(void **head, int off)
45253541Sshin{
45353541Sshin	struct radix_node_head *rnh;
45453541Sshin
45553541Sshin	if (!rn_inithead(head, off))
45653541Sshin		return 0;
45753541Sshin
45853541Sshin	if (head != (void **)&rt_tables[AF_INET6]) /* BOGUS! */
45953541Sshin		return 1;	/* only do this for the real routing table */
46053541Sshin
46153541Sshin	rnh = *head;
46253541Sshin	rnh->rnh_addaddr = in6_addroute;
46353541Sshin	rnh->rnh_matchaddr = in6_matroute;
46453541Sshin	rnh->rnh_close = in6_clsroute;
465120727Ssam	callout_init(&rtq_timer, CALLOUT_MPSAFE);
46653541Sshin	in6_rtqtimo(rnh);	/* kick off timeout first time */
467120727Ssam	callout_init(&rtq_mtutimer, CALLOUT_MPSAFE);
46853541Sshin	in6_mtutimo(rnh);	/* kick off timeout first time */
46953541Sshin	return 1;
47053541Sshin}
471