in6_rmx.c revision 53541
153541Sshin/* 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. 2853541Sshin * 2953541Sshin * $FreeBSD: head/sys/netinet6/in6_rmx.c 53541 1999-11-22 02:45:11Z shin $ 3053541Sshin */ 3153541Sshin 3253541Sshin/* 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 * $Id: in6_rmx.c,v 1.3 1999/08/16 13:42:53 itojun Exp $ 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> 8553541Sshin 8653541Sshin#include <net/if.h> 8753541Sshin#include <net/route.h> 8853541Sshin#include <netinet/in.h> 8953541Sshin#include <netinet/ip_var.h> 9053541Sshin#include <netinet/in_var.h> 9153541Sshin 9253541Sshin#include <netinet6/ip6.h> 9353541Sshin#include <netinet6/ip6_var.h> 9453541Sshin 9553541Sshin#include <netinet6/icmp6.h> 9653541Sshin 9753541Sshin#include <netinet/tcp.h> 9853541Sshin#include <netinet/tcp_seq.h> 9953541Sshin#include <netinet/tcp_timer.h> 10053541Sshin#include <netinet/tcp_var.h> 10153541Sshin 10253541Sshinextern int in6_inithead __P((void **head, int off)); 10353541Sshin 10453541Sshin#define RTPRF_OURS RTF_PROTO3 /* set on routes we manage */ 10553541Sshin 10653541Sshin/* 10753541Sshin * Do what we need to do when inserting a route. 10853541Sshin */ 10953541Sshinstatic struct radix_node * 11053541Sshinin6_addroute(void *v_arg, void *n_arg, struct radix_node_head *head, 11153541Sshin struct radix_node *treenodes) 11253541Sshin{ 11353541Sshin struct rtentry *rt = (struct rtentry *)treenodes; 11453541Sshin struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)rt_key(rt); 11553541Sshin struct radix_node *ret; 11653541Sshin 11753541Sshin /* 11853541Sshin * For IPv6, all unicast non-host routes are automatically cloning. 11953541Sshin */ 12053541Sshin if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) 12153541Sshin rt->rt_flags |= RTF_MULTICAST; 12253541Sshin 12353541Sshin if (!(rt->rt_flags & (RTF_HOST | RTF_CLONING | RTF_MULTICAST))) { 12453541Sshin rt->rt_flags |= RTF_PRCLONING; 12553541Sshin } 12653541Sshin 12753541Sshin /* 12853541Sshin * A little bit of help for both IPv6 output and input: 12953541Sshin * For local addresses, we make sure that RTF_LOCAL is set, 13053541Sshin * with the thought that this might one day be used to speed up 13153541Sshin * ip_input(). 13253541Sshin * 13353541Sshin * We also mark routes to multicast addresses as such, because 13453541Sshin * it's easy to do and might be useful (but this is much more 13553541Sshin * dubious since it's so easy to inspect the address). (This 13653541Sshin * is done above.) 13753541Sshin * 13853541Sshin * XXX 13953541Sshin * should elaborate the code. 14053541Sshin */ 14153541Sshin if (rt->rt_flags & RTF_HOST) { 14253541Sshin if (IN6_ARE_ADDR_EQUAL(&satosin6(rt->rt_ifa->ifa_addr) 14353541Sshin ->sin6_addr, 14453541Sshin &sin6->sin6_addr)) { 14553541Sshin rt->rt_flags |= RTF_LOCAL; 14653541Sshin } 14753541Sshin } 14853541Sshin 14953541Sshin /* 15053541Sshin * We also specify a send and receive pipe size for every 15153541Sshin * route added, to help TCP a bit. TCP doesn't actually 15253541Sshin * want a true pipe size, which would be prohibitive in memory 15353541Sshin * costs and is hard to compute anyway; it simply uses these 15453541Sshin * values to size its buffers. So, we fill them in with the 15553541Sshin * same values that TCP would have used anyway, and allow the 15653541Sshin * installing program or the link layer to override these values 15753541Sshin * as it sees fit. This will hopefully allow TCP more 15853541Sshin * opportunities to save its ssthresh value. 15953541Sshin */ 16053541Sshin if (!rt->rt_rmx.rmx_sendpipe && !(rt->rt_rmx.rmx_locks & RTV_SPIPE)) 16153541Sshin rt->rt_rmx.rmx_sendpipe = tcp_sendspace; 16253541Sshin 16353541Sshin if (!rt->rt_rmx.rmx_recvpipe && !(rt->rt_rmx.rmx_locks & RTV_RPIPE)) 16453541Sshin rt->rt_rmx.rmx_recvpipe = tcp_recvspace; 16553541Sshin 16653541Sshin if (!rt->rt_rmx.rmx_mtu && !(rt->rt_rmx.rmx_locks & RTV_MTU) 16753541Sshin && rt->rt_ifp) 16853541Sshin rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu; 16953541Sshin 17053541Sshin ret = rn_addroute(v_arg, n_arg, head, treenodes); 17153541Sshin if (ret == NULL && rt->rt_flags & RTF_HOST) { 17253541Sshin struct rtentry *rt2; 17353541Sshin /* 17453541Sshin * We are trying to add a host route, but can't. 17553541Sshin * Find out if it is because of an 17653541Sshin * ARP entry and delete it if so. 17753541Sshin */ 17853541Sshin rt2 = rtalloc1((struct sockaddr *)sin6, 0, 17953541Sshin RTF_CLONING | RTF_PRCLONING); 18053541Sshin if (rt2) { 18153541Sshin if (rt2->rt_flags & RTF_LLINFO && 18253541Sshin rt2->rt_flags & RTF_HOST && 18353541Sshin rt2->rt_gateway && 18453541Sshin rt2->rt_gateway->sa_family == AF_LINK) { 18553541Sshin rtrequest(RTM_DELETE, 18653541Sshin (struct sockaddr *)rt_key(rt2), 18753541Sshin rt2->rt_gateway, 18853541Sshin rt_mask(rt2), rt2->rt_flags, 0); 18953541Sshin ret = rn_addroute(v_arg, n_arg, head, 19053541Sshin treenodes); 19153541Sshin } 19253541Sshin RTFREE(rt2); 19353541Sshin } 19453541Sshin } else if (ret == NULL && rt->rt_flags & RTF_CLONING) { 19553541Sshin struct rtentry *rt2; 19653541Sshin /* 19753541Sshin * We are trying to add a net route, but can't. 19853541Sshin * The following case should be allowed, so we'll make a 19953541Sshin * special check for this: 20053541Sshin * Two IPv6 addresses with the same prefix is assigned 20153541Sshin * to a single interrface. 20253541Sshin * # ifconfig if0 inet6 3ffe:0501::1 prefix 64 alias (*1) 20353541Sshin * # ifconfig if0 inet6 3ffe:0501::2 prefix 64 alias (*2) 20453541Sshin * In this case, (*1) and (*2) want to add the same 20553541Sshin * net route entry, 3ffe:0501:: -> if0. 20653541Sshin * This case should not raise an error. 20753541Sshin */ 20853541Sshin rt2 = rtalloc1((struct sockaddr *)sin6, 0, 20953541Sshin RTF_CLONING | RTF_PRCLONING); 21053541Sshin if (rt2) { 21153541Sshin if ((rt2->rt_flags & (RTF_CLONING|RTF_HOST|RTF_GATEWAY)) 21253541Sshin == RTF_CLONING 21353541Sshin && rt2->rt_gateway 21453541Sshin && rt2->rt_gateway->sa_family == AF_LINK 21553541Sshin && rt2->rt_ifp == rt->rt_ifp) { 21653541Sshin ret = rt2->rt_nodes; 21753541Sshin } 21853541Sshin RTFREE(rt2); 21953541Sshin } 22053541Sshin } 22153541Sshin return ret; 22253541Sshin} 22353541Sshin 22453541Sshin/* 22553541Sshin * This code is the inverse of in6_clsroute: on first reference, if we 22653541Sshin * were managing the route, stop doing so and set the expiration timer 22753541Sshin * back off again. 22853541Sshin */ 22953541Sshinstatic struct radix_node * 23053541Sshinin6_matroute(void *v_arg, struct radix_node_head *head) 23153541Sshin{ 23253541Sshin struct radix_node *rn = rn_match(v_arg, head); 23353541Sshin struct rtentry *rt = (struct rtentry *)rn; 23453541Sshin 23553541Sshin if (rt && rt->rt_refcnt == 0) { /* this is first reference */ 23653541Sshin if (rt->rt_flags & RTPRF_OURS) { 23753541Sshin rt->rt_flags &= ~RTPRF_OURS; 23853541Sshin rt->rt_rmx.rmx_expire = 0; 23953541Sshin } 24053541Sshin } 24153541Sshin return rn; 24253541Sshin} 24353541Sshin 24453541Sshinstatic int rtq_reallyold = 60*60; 24553541Sshin /* one hour is ``really old'' */ 24653541SshinSYSCTL_INT(_net_inet_ip, IPCTL_RTEXPIRE, rtexpire, 24753541Sshin CTLFLAG_RW, &rtq_reallyold , 0, ""); 24853541Sshin 24953541Sshinstatic int rtq_minreallyold = 10; 25053541Sshin /* never automatically crank down to less */ 25153541SshinSYSCTL_INT(_net_inet_ip, IPCTL_RTMINEXPIRE, rtminexpire, 25253541Sshin CTLFLAG_RW, &rtq_minreallyold , 0, ""); 25353541Sshin 25453541Sshinstatic int rtq_toomany = 128; 25553541Sshin /* 128 cached routes is ``too many'' */ 25653541SshinSYSCTL_INT(_net_inet_ip, IPCTL_RTMAXCACHE, rtmaxcache, 25753541Sshin CTLFLAG_RW, &rtq_toomany , 0, ""); 25853541Sshin 25953541Sshin 26053541Sshin/* 26153541Sshin * On last reference drop, mark the route as belong to us so that it can be 26253541Sshin * timed out. 26353541Sshin */ 26453541Sshinstatic void 26553541Sshinin6_clsroute(struct radix_node *rn, struct radix_node_head *head) 26653541Sshin{ 26753541Sshin struct rtentry *rt = (struct rtentry *)rn; 26853541Sshin 26953541Sshin if (!(rt->rt_flags & RTF_UP)) 27053541Sshin return; /* prophylactic measures */ 27153541Sshin 27253541Sshin if ((rt->rt_flags & (RTF_LLINFO | RTF_HOST)) != RTF_HOST) 27353541Sshin return; 27453541Sshin 27553541Sshin if ((rt->rt_flags & (RTF_WASCLONED | RTPRF_OURS)) 27653541Sshin != RTF_WASCLONED) 27753541Sshin return; 27853541Sshin 27953541Sshin /* 28053541Sshin * As requested by David Greenman: 28153541Sshin * If rtq_reallyold is 0, just delete the route without 28253541Sshin * waiting for a timeout cycle to kill it. 28353541Sshin */ 28453541Sshin if (rtq_reallyold != 0) { 28553541Sshin rt->rt_flags |= RTPRF_OURS; 28653541Sshin rt->rt_rmx.rmx_expire = time_second + rtq_reallyold; 28753541Sshin } else { 28853541Sshin rtrequest(RTM_DELETE, 28953541Sshin (struct sockaddr *)rt_key(rt), 29053541Sshin rt->rt_gateway, rt_mask(rt), 29153541Sshin rt->rt_flags, 0); 29253541Sshin } 29353541Sshin} 29453541Sshin 29553541Sshinstruct rtqk_arg { 29653541Sshin struct radix_node_head *rnh; 29753541Sshin int mode; 29853541Sshin int updating; 29953541Sshin int draining; 30053541Sshin int killed; 30153541Sshin int found; 30253541Sshin time_t nextstop; 30353541Sshin}; 30453541Sshin 30553541Sshin/* 30653541Sshin * Get rid of old routes. When draining, this deletes everything, even when 30753541Sshin * the timeout is not expired yet. When updating, this makes sure that 30853541Sshin * nothing has a timeout longer than the current value of rtq_reallyold. 30953541Sshin */ 31053541Sshinstatic int 31153541Sshinin6_rtqkill(struct radix_node *rn, void *rock) 31253541Sshin{ 31353541Sshin struct rtqk_arg *ap = rock; 31453541Sshin struct rtentry *rt = (struct rtentry *)rn; 31553541Sshin int err; 31653541Sshin 31753541Sshin if (rt->rt_flags & RTPRF_OURS) { 31853541Sshin ap->found++; 31953541Sshin 32053541Sshin if (ap->draining || rt->rt_rmx.rmx_expire <= time_second) { 32153541Sshin if (rt->rt_refcnt > 0) 32253541Sshin panic("rtqkill route really not free"); 32353541Sshin 32453541Sshin err = rtrequest(RTM_DELETE, 32553541Sshin (struct sockaddr *)rt_key(rt), 32653541Sshin rt->rt_gateway, rt_mask(rt), 32753541Sshin rt->rt_flags, 0); 32853541Sshin if (err) { 32953541Sshin log(LOG_WARNING, "in6_rtqkill: error %d", err); 33053541Sshin } else { 33153541Sshin ap->killed++; 33253541Sshin } 33353541Sshin } else { 33453541Sshin if (ap->updating 33553541Sshin && (rt->rt_rmx.rmx_expire - time_second 33653541Sshin > rtq_reallyold)) { 33753541Sshin rt->rt_rmx.rmx_expire = time_second 33853541Sshin + rtq_reallyold; 33953541Sshin } 34053541Sshin ap->nextstop = lmin(ap->nextstop, 34153541Sshin rt->rt_rmx.rmx_expire); 34253541Sshin } 34353541Sshin } 34453541Sshin 34553541Sshin return 0; 34653541Sshin} 34753541Sshin 34853541Sshin#define RTQ_TIMEOUT 60*10 /* run no less than once every ten minutes */ 34953541Sshinstatic int rtq_timeout = RTQ_TIMEOUT; 35053541Sshin 35153541Sshinstatic void 35253541Sshinin6_rtqtimo(void *rock) 35353541Sshin{ 35453541Sshin struct radix_node_head *rnh = rock; 35553541Sshin struct rtqk_arg arg; 35653541Sshin struct timeval atv; 35753541Sshin static time_t last_adjusted_timeout = 0; 35853541Sshin int s; 35953541Sshin 36053541Sshin arg.found = arg.killed = 0; 36153541Sshin arg.rnh = rnh; 36253541Sshin arg.nextstop = time_second + rtq_timeout; 36353541Sshin arg.draining = arg.updating = 0; 36453541Sshin s = splnet(); 36553541Sshin rnh->rnh_walktree(rnh, in6_rtqkill, &arg); 36653541Sshin splx(s); 36753541Sshin 36853541Sshin /* 36953541Sshin * Attempt to be somewhat dynamic about this: 37053541Sshin * If there are ``too many'' routes sitting around taking up space, 37153541Sshin * then crank down the timeout, and see if we can't make some more 37253541Sshin * go away. However, we make sure that we will never adjust more 37353541Sshin * than once in rtq_timeout seconds, to keep from cranking down too 37453541Sshin * hard. 37553541Sshin */ 37653541Sshin if ((arg.found - arg.killed > rtq_toomany) 37753541Sshin && (time_second - last_adjusted_timeout >= rtq_timeout) 37853541Sshin && rtq_reallyold > rtq_minreallyold) { 37953541Sshin rtq_reallyold = 2*rtq_reallyold / 3; 38053541Sshin if (rtq_reallyold < rtq_minreallyold) { 38153541Sshin rtq_reallyold = rtq_minreallyold; 38253541Sshin } 38353541Sshin 38453541Sshin last_adjusted_timeout = time_second; 38553541Sshin#ifdef DIAGNOSTIC 38653541Sshin log(LOG_DEBUG, "in6_rtqtimo: adjusted rtq_reallyold to %d", 38753541Sshin rtq_reallyold); 38853541Sshin#endif 38953541Sshin arg.found = arg.killed = 0; 39053541Sshin arg.updating = 1; 39153541Sshin s = splnet(); 39253541Sshin rnh->rnh_walktree(rnh, in6_rtqkill, &arg); 39353541Sshin splx(s); 39453541Sshin } 39553541Sshin 39653541Sshin atv.tv_usec = 0; 39753541Sshin atv.tv_sec = arg.nextstop; 39853541Sshin timeout(in6_rtqtimo, rock, tvtohz(&atv)); 39953541Sshin} 40053541Sshin 40153541Sshin/* 40253541Sshin * Age old PMTUs. 40353541Sshin */ 40453541Sshinstruct mtuex_arg { 40553541Sshin struct radix_node_head *rnh; 40653541Sshin time_t nextstop; 40753541Sshin}; 40853541Sshin 40953541Sshinstatic int 41053541Sshinin6_mtuexpire(struct radix_node *rn, void *rock) 41153541Sshin{ 41253541Sshin struct rtentry *rt = (struct rtentry *)rn; 41353541Sshin struct mtuex_arg *ap = rock; 41453541Sshin 41553541Sshin /* sanity */ 41653541Sshin if (!rt) 41753541Sshin panic("rt == NULL in in6_mtuexpire"); 41853541Sshin 41953541Sshin if (rt->rt_rmx.rmx_expire && !(rt->rt_flags & RTF_PROBEMTU)) { 42053541Sshin if (rt->rt_rmx.rmx_expire <= time_second) { 42153541Sshin rt->rt_flags |= RTF_PROBEMTU; 42253541Sshin } else { 42353541Sshin ap->nextstop = lmin(ap->nextstop, 42453541Sshin rt->rt_rmx.rmx_expire); 42553541Sshin } 42653541Sshin } 42753541Sshin 42853541Sshin return 0; 42953541Sshin} 43053541Sshin 43153541Sshin#define MTUTIMO_DEFAULT (60*1) 43253541Sshin 43353541Sshinstatic void 43453541Sshinin6_mtutimo(void *rock) 43553541Sshin{ 43653541Sshin struct radix_node_head *rnh = rock; 43753541Sshin struct mtuex_arg arg; 43853541Sshin struct timeval atv; 43953541Sshin int s; 44053541Sshin 44153541Sshin arg.rnh = rnh; 44253541Sshin arg.nextstop = time_second + MTUTIMO_DEFAULT; 44353541Sshin s = splnet(); 44453541Sshin rnh->rnh_walktree(rnh, in6_mtuexpire, &arg); 44553541Sshin splx(s); 44653541Sshin 44753541Sshin atv.tv_usec = 0; 44853541Sshin atv.tv_sec = arg.nextstop; 44953541Sshin if (atv.tv_sec < time_second) { 45053541Sshin printf("invalid mtu expiration time on routing table\n"); 45153541Sshin arg.nextstop = time_second + 30; /*last resort*/ 45253541Sshin } 45353541Sshin timeout(in6_mtutimo, rock, tvtohz(&atv)); 45453541Sshin} 45553541Sshin 45653541Sshin/* 45753541Sshin * Initialize our routing tree. 45853541Sshin */ 45953541Sshinint 46053541Sshinin6_inithead(void **head, int off) 46153541Sshin{ 46253541Sshin struct radix_node_head *rnh; 46353541Sshin 46453541Sshin if (!rn_inithead(head, off)) 46553541Sshin return 0; 46653541Sshin 46753541Sshin if (head != (void **)&rt_tables[AF_INET6]) /* BOGUS! */ 46853541Sshin return 1; /* only do this for the real routing table */ 46953541Sshin 47053541Sshin rnh = *head; 47153541Sshin rnh->rnh_addaddr = in6_addroute; 47253541Sshin rnh->rnh_matchaddr = in6_matroute; 47353541Sshin rnh->rnh_close = in6_clsroute; 47453541Sshin in6_rtqtimo(rnh); /* kick off timeout first time */ 47553541Sshin in6_mtutimo(rnh); /* kick off timeout first time */ 47653541Sshin return 1; 47753541Sshin} 478