in6_proto.c revision 171167
162587Sitojun/* $FreeBSD: head/sys/netinet6/in6_proto.c 171167 2007-07-03 12:13:45Z gnn $ */ 278064Sume/* $KAME: in6_proto.c,v 1.91 2001/05/27 13:28:35 itojun 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 (c) 1982, 1986, 1993 3553541Sshin * The Regents of the University of California. All rights reserved. 3653541Sshin * 3753541Sshin * Redistribution and use in source and binary forms, with or without 3853541Sshin * modification, are permitted provided that the following conditions 3953541Sshin * are met: 4053541Sshin * 1. Redistributions of source code must retain the above copyright 4153541Sshin * notice, this list of conditions and the following disclaimer. 4253541Sshin * 2. Redistributions in binary form must reproduce the above copyright 4353541Sshin * notice, this list of conditions and the following disclaimer in the 4453541Sshin * documentation and/or other materials provided with the distribution. 4553541Sshin * 4. Neither the name of the University nor the names of its contributors 4653541Sshin * may be used to endorse or promote products derived from this software 4753541Sshin * without specific prior written permission. 4853541Sshin * 4953541Sshin * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 5053541Sshin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 5153541Sshin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 5253541Sshin * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 5353541Sshin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 5453541Sshin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 5553541Sshin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 5653541Sshin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 5753541Sshin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 5853541Sshin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5953541Sshin * SUCH DAMAGE. 6053541Sshin * 6153541Sshin * @(#)in_proto.c 8.1 (Berkeley) 6/10/93 6253541Sshin */ 6353541Sshin 6455679Sshin#include "opt_inet.h" 6562587Sitojun#include "opt_inet6.h" 6655009Sshin#include "opt_ipsec.h" 67148921Ssuz#include "opt_ipstealth.h" 68142215Sglebius#include "opt_carp.h" 69163953Srrs#include "opt_sctp.h" 7055009Sshin 7153541Sshin#include <sys/param.h> 7253541Sshin#include <sys/socket.h> 7353541Sshin#include <sys/socketvar.h> 7453541Sshin#include <sys/protosw.h> 7553541Sshin#include <sys/kernel.h> 7653541Sshin#include <sys/domain.h> 7753541Sshin#include <sys/mbuf.h> 7853541Sshin#include <sys/systm.h> 7953541Sshin#include <sys/sysctl.h> 8053541Sshin 8153541Sshin#include <net/if.h> 8253541Sshin#include <net/radix.h> 8353541Sshin#include <net/route.h> 8453541Sshin 8553541Sshin#include <netinet/in.h> 8653541Sshin#include <netinet/in_systm.h> 8753541Sshin#include <netinet/in_var.h> 8862587Sitojun#include <netinet/ip_encap.h> 8953541Sshin#include <netinet/ip.h> 9053541Sshin#include <netinet/ip_var.h> 9162587Sitojun#include <netinet/ip6.h> 9253541Sshin#include <netinet6/ip6_var.h> 9362587Sitojun#include <netinet/icmp6.h> 9453541Sshin 9553541Sshin#include <netinet/tcp.h> 9653541Sshin#include <netinet/tcp_timer.h> 9753541Sshin#include <netinet/tcp_var.h> 9853541Sshin#include <netinet/udp.h> 9953541Sshin#include <netinet/udp_var.h> 10053541Sshin#include <netinet6/tcp6_var.h> 10178064Sume#include <netinet6/raw_ip6.h> 10253541Sshin#include <netinet6/udp6_var.h> 10353541Sshin#include <netinet6/pim6_var.h> 10453541Sshin#include <netinet6/nd6.h> 10553541Sshin 106142215Sglebius#ifdef DEV_CARP 107142215Sglebius#include <netinet/ip_carp.h> 108142215Sglebius#endif 109142215Sglebius 110163953Srrs#ifdef SCTP 111163953Srrs#include <netinet/in_pcb.h> 112163953Srrs#include <netinet/sctp_pcb.h> 113163953Srrs#include <netinet/sctp.h> 114163953Srrs#include <netinet/sctp_var.h> 115163953Srrs#include <netinet6/sctp6_var.h> 116163953Srrs#endif /* SCTP */ 117163953Srrs 118171167Sgnn#ifdef IPSEC 119171133Sgnn#include <netipsec/ipsec.h> 120105199Ssam#include <netipsec/ipsec6.h> 121171167Sgnn#endif /* IPSEC */ 122105199Ssam 12353541Sshin#include <netinet6/ip6protosw.h> 12453541Sshin 12553541Sshin/* 12653541Sshin * TCP/IP protocol family: IP6, ICMP6, UDP, TCP. 12753541Sshin */ 12853541Sshin 12962587Sitojunextern struct domain inet6domain; 130148917Sobrienstatic struct pr_usrreqs nousrreqs; 13153541Sshin 13278064Sume#define PR_LISTEN 0 13378064Sume#define PR_ABRTACPTDIS 0 13478064Sume 13553541Sshinstruct ip6protosw inet6sw[] = { 136152242Sru{ 137152242Sru .pr_type = 0, 138152242Sru .pr_domain = &inet6domain, 139152242Sru .pr_protocol = IPPROTO_IPV6, 140152242Sru .pr_init = ip6_init, 141152242Sru .pr_slowtimo = frag6_slowtimo, 142152242Sru .pr_drain = frag6_drain, 143152242Sru .pr_usrreqs = &nousrreqs, 14453541Sshin}, 145152242Sru{ 146152242Sru .pr_type = SOCK_DGRAM, 147152242Sru .pr_domain = &inet6domain, 148152242Sru .pr_protocol = IPPROTO_UDP, 149152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 150152242Sru .pr_input = udp6_input, 151152242Sru .pr_ctlinput = udp6_ctlinput, 152152242Sru .pr_ctloutput = ip6_ctloutput, 153152242Sru .pr_usrreqs = &udp6_usrreqs, 15454263Sshin}, 155152242Sru{ 156152242Sru .pr_type = SOCK_STREAM, 157152242Sru .pr_domain = &inet6domain, 158152242Sru .pr_protocol = IPPROTO_TCP, 159152242Sru .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LISTEN, 160152242Sru .pr_input = tcp6_input, 161152242Sru .pr_ctlinput = tcp6_ctlinput, 162152242Sru .pr_ctloutput = tcp_ctloutput, 163152242Sru#ifndef INET /* don't call initialization and timeout routines twice */ 164152242Sru .pr_init = tcp_init, 165152242Sru .pr_fasttimo = tcp_fasttimo, 166152242Sru .pr_slowtimo = tcp_slowtimo, 16755679Sshin#endif 168152242Sru .pr_drain = tcp_drain, 169152242Sru .pr_usrreqs = &tcp6_usrreqs, 17055679Sshin}, 171163953Srrs#ifdef SCTP 172163953Srrs{ 173163953Srrs .pr_type = SOCK_DGRAM, 174163953Srrs .pr_domain = &inet6domain, 175163953Srrs .pr_protocol = IPPROTO_SCTP, 176163953Srrs .pr_flags = PR_WANTRCVD, 177163953Srrs .pr_input = sctp6_input, 178163953Srrs .pr_ctlinput = sctp6_ctlinput, 179163953Srrs .pr_ctloutput = sctp_ctloutput, 180163953Srrs .pr_drain = sctp_drain, 181163953Srrs .pr_usrreqs = &sctp6_usrreqs 182163953Srrs}, 183152242Sru{ 184163953Srrs .pr_type = SOCK_SEQPACKET, 185163953Srrs .pr_domain = &inet6domain, 186163953Srrs .pr_protocol = IPPROTO_SCTP, 187163953Srrs .pr_flags = PR_WANTRCVD, 188163953Srrs .pr_input = sctp6_input, 189163953Srrs .pr_ctlinput = sctp6_ctlinput, 190163953Srrs .pr_ctloutput = sctp_ctloutput, 191163953Srrs .pr_drain = sctp_drain, 192163953Srrs .pr_usrreqs = &sctp6_usrreqs 193163953Srrs}, 194163953Srrs 195163953Srrs{ 196163953Srrs .pr_type = SOCK_STREAM, 197163953Srrs .pr_domain = &inet6domain, 198163953Srrs .pr_protocol = IPPROTO_SCTP, 199163953Srrs .pr_flags = PR_WANTRCVD, 200163953Srrs .pr_input = sctp6_input, 201163953Srrs .pr_ctlinput = sctp6_ctlinput, 202163953Srrs .pr_ctloutput = sctp_ctloutput, 203163953Srrs .pr_drain = sctp_drain, 204163953Srrs .pr_usrreqs = &sctp6_usrreqs 205163953Srrs}, 206163953Srrs#endif /* SCTP */ 207163953Srrs{ 208152242Sru .pr_type = SOCK_RAW, 209152242Sru .pr_domain = &inet6domain, 210152242Sru .pr_protocol = IPPROTO_RAW, 211152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 212152242Sru .pr_input = rip6_input, 213152242Sru .pr_output = rip6_output, 214152242Sru .pr_ctlinput = rip6_ctlinput, 215152242Sru .pr_ctloutput = rip6_ctloutput, 216152242Sru .pr_usrreqs = &rip6_usrreqs 21753541Sshin}, 218152242Sru{ 219152242Sru .pr_type = SOCK_RAW, 220152242Sru .pr_domain = &inet6domain, 221152242Sru .pr_protocol = IPPROTO_ICMPV6, 222152242Sru .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, 223152242Sru .pr_input = icmp6_input, 224152242Sru .pr_output = rip6_output, 225152242Sru .pr_ctlinput = rip6_ctlinput, 226152242Sru .pr_ctloutput = rip6_ctloutput, 227152242Sru .pr_init = icmp6_init, 228152242Sru .pr_fasttimo = icmp6_fasttimo, 229152242Sru .pr_usrreqs = &rip6_usrreqs 23053541Sshin}, 231152242Sru{ 232152242Sru .pr_type = SOCK_RAW, 233152242Sru .pr_domain = &inet6domain, 234152242Sru .pr_protocol = IPPROTO_DSTOPTS, 235152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 236152242Sru .pr_input = dest6_input, 237152242Sru .pr_usrreqs = &nousrreqs 23853541Sshin}, 239152242Sru{ 240152242Sru .pr_type = SOCK_RAW, 241152242Sru .pr_domain = &inet6domain, 242152242Sru .pr_protocol = IPPROTO_ROUTING, 243152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 244152242Sru .pr_input = route6_input, 245152242Sru .pr_usrreqs = &nousrreqs 24653541Sshin}, 247152242Sru{ 248152242Sru .pr_type = SOCK_RAW, 249152242Sru .pr_domain = &inet6domain, 250152242Sru .pr_protocol = IPPROTO_FRAGMENT, 251152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 252152242Sru .pr_input = frag6_input, 253152242Sru .pr_usrreqs = &nousrreqs 25453541Sshin}, 255171167Sgnn#ifdef IPSEC 256152242Sru{ 257152242Sru .pr_type = SOCK_RAW, 258152242Sru .pr_domain = &inet6domain, 259152242Sru .pr_protocol = IPPROTO_AH, 260152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 261171133Sgnn .pr_input = ipsec6_common_input, 262152242Sru .pr_usrreqs = &nousrreqs, 26353541Sshin}, 264152242Sru{ 265152242Sru .pr_type = SOCK_RAW, 266152242Sru .pr_domain = &inet6domain, 267152242Sru .pr_protocol = IPPROTO_ESP, 268152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 269171133Sgnn .pr_input = ipsec6_common_input, 270152242Sru .pr_ctlinput = esp6_ctlinput, 271152242Sru .pr_usrreqs = &nousrreqs, 27253541Sshin}, 273152242Sru{ 274152242Sru .pr_type = SOCK_RAW, 275152242Sru .pr_domain = &inet6domain, 276152242Sru .pr_protocol = IPPROTO_IPCOMP, 277152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 278171133Sgnn .pr_input = ipsec6_common_input, 279152242Sru .pr_usrreqs = &nousrreqs, 28062587Sitojun}, 281171167Sgnn#endif /* IPSEC */ 28262587Sitojun#ifdef INET 283152242Sru{ 284152242Sru .pr_type = SOCK_RAW, 285152242Sru .pr_domain = &inet6domain, 286152242Sru .pr_protocol = IPPROTO_IPV4, 287152242Sru .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, 288152242Sru .pr_input = encap6_input, 289152242Sru .pr_output = rip6_output, 290152242Sru .pr_ctloutput = rip6_ctloutput, 291152242Sru .pr_init = encap_init, 292152242Sru .pr_usrreqs = &rip6_usrreqs 29353541Sshin}, 29495023Ssuz#endif /* INET */ 295152242Sru{ 296152242Sru .pr_type = SOCK_RAW, 297152242Sru .pr_domain = &inet6domain, 298152242Sru .pr_protocol = IPPROTO_IPV6, 299152242Sru .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, 300152242Sru .pr_input = encap6_input, 301152242Sru .pr_output = rip6_output, 302152242Sru .pr_ctloutput = rip6_ctloutput, 303152242Sru .pr_init = encap_init, 304152242Sru .pr_usrreqs = &rip6_usrreqs 30553541Sshin}, 306152242Sru{ 307152242Sru .pr_type = SOCK_RAW, 308152242Sru .pr_domain = &inet6domain, 309152242Sru .pr_protocol = IPPROTO_PIM, 310152242Sru .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, 311166938Sbms .pr_input = encap6_input, 312152242Sru .pr_output = rip6_output, 313152242Sru .pr_ctloutput = rip6_ctloutput, 314152242Sru .pr_usrreqs = &rip6_usrreqs 31556722Sshin}, 316142215Sglebius#ifdef DEV_CARP 317152242Sru{ 318152242Sru .pr_type = SOCK_RAW, 319152242Sru .pr_domain = &inet6domain, 320152242Sru .pr_protocol = IPPROTO_CARP, 321152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 322152242Sru .pr_input = carp6_input, 323152242Sru .pr_output = rip6_output, 324152242Sru .pr_ctloutput = rip6_ctloutput, 325152242Sru .pr_usrreqs = &rip6_usrreqs 326142215Sglebius}, 327142215Sglebius#endif /* DEV_CARP */ 32853541Sshin/* raw wildcard */ 329152242Sru{ 330152242Sru .pr_type = SOCK_RAW, 331152242Sru .pr_domain = &inet6domain, 332152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 333152242Sru .pr_input = rip6_input, 334152242Sru .pr_output = rip6_output, 335152242Sru .pr_ctloutput = rip6_ctloutput, 336152242Sru .pr_usrreqs = &rip6_usrreqs 33753541Sshin}, 33853541Sshin}; 33953541Sshin 34062587Sitojunextern int in6_inithead __P((void **, int)); 34162587Sitojun 342152242Srustruct domain inet6domain = { 343152242Sru .dom_family = AF_INET6, 344152242Sru .dom_name = "internet6", 345152242Sru .dom_protosw = (struct protosw *)inet6sw, 346152242Sru .dom_protoswNPROTOSW = (struct protosw *) 347152242Sru &inet6sw[sizeof(inet6sw)/sizeof(inet6sw[0])], 348152242Sru .dom_rtattach = in6_inithead, 349152242Sru .dom_rtoffset = offsetof(struct sockaddr_in6, sin6_addr) << 3, 350152242Sru .dom_maxrtkey = sizeof(struct sockaddr_in6), 351152242Sru .dom_ifattach = in6_domifattach, 352152242Sru .dom_ifdetach = in6_domifdetach 353152242Sru}; 35453541Sshin 35553541SshinDOMAIN_SET(inet6); 35653541Sshin 35753541Sshin/* 35853541Sshin * Internet configuration info 35953541Sshin */ 36053541Sshin#ifndef IPV6FORWARDING 36153541Sshin#ifdef GATEWAY6 36253541Sshin#define IPV6FORWARDING 1 /* forward IP6 packets not for us */ 36353541Sshin#else 36453541Sshin#define IPV6FORWARDING 0 /* don't forward IP6 packets not for us */ 36553541Sshin#endif /* GATEWAY6 */ 36653541Sshin#endif /* !IPV6FORWARDING */ 36753541Sshin 36853541Sshin#ifndef IPV6_SENDREDIRECTS 36953541Sshin#define IPV6_SENDREDIRECTS 1 37053541Sshin#endif 37153541Sshin 37253541Sshinint ip6_forwarding = IPV6FORWARDING; /* act as router? */ 37353541Sshinint ip6_sendredirects = IPV6_SENDREDIRECTS; 37453541Sshinint ip6_defhlim = IPV6_DEFHLIM; 37553541Sshinint ip6_defmcasthlim = IPV6_DEFAULT_MULTICAST_HOPS; 37653541Sshinint ip6_accept_rtadv = 0; /* "IPV6FORWARDING ? 0 : 1" is dangerous */ 37777969Sjesperint ip6_maxfragpackets; /* initialized in frag6.c:frag6_init() */ 378121345Sumeint ip6_maxfrags; /* initialized in frag6.c:frag6_init() */ 37953541Sshinint ip6_log_interval = 5; 380169388Sgnnint ip6_hdrnestlimit = 15; /* How many header options will we process? */ 38153541Sshinint ip6_dad_count = 1; /* DupAddrDetectionTransmits */ 38253541Sshinint ip6_auto_flowlabel = 1; 38353541Sshinint ip6_gif_hlim = 0; 38453541Sshinint ip6_use_deprecated = 1; /* allow deprecated addr (RFC2462 5.5.4) */ 38553541Sshinint ip6_rr_prune = 5; /* router renumbering prefix 386120913Sume * walk list every 5 sec. */ 387149033Sumeint ip6_mcast_pmtu = 0; /* enable pMTU discovery for multicast? */ 388100676Sumeint ip6_v6only = 1; 38953541Sshin 39053541Sshinint ip6_keepfaith = 0; 39153541Sshintime_t ip6_log_time = (time_t)0L; 392148921Ssuz#ifdef IPSTEALTH 393148921Ssuzint ip6stealth = 0; 394148921Ssuz#endif 39553541Sshin 39653541Sshin/* icmp6 */ 39753541Sshin/* 39853541Sshin * BSDI4 defines these variables in in_proto.c... 39953541Sshin * XXX: what if we don't define INET? Should we define pmtu6_expire 40053541Sshin * or so? (jinmei@kame.net 19990310) 40153541Sshin */ 40262587Sitojunint pmtu_expire = 60*10; 40362587Sitojunint pmtu_probe = 60*2; 40453541Sshin 40553541Sshin/* raw IP6 parameters */ 40653541Sshin/* 40753541Sshin * Nominal space allocated to a raw ip socket. 40853541Sshin */ 40953541Sshin#define RIPV6SNDQ 8192 41053541Sshin#define RIPV6RCVQ 8192 41153541Sshin 41253541Sshinu_long rip6_sendspace = RIPV6SNDQ; 41353541Sshinu_long rip6_recvspace = RIPV6RCVQ; 41453541Sshin 41553541Sshin/* ICMPV6 parameters */ 41653541Sshinint icmp6_rediraccept = 1; /* accept and process redirects */ 41753541Sshinint icmp6_redirtimeout = 10 * 60; /* 10 minutes */ 41862587Sitojunint icmp6errppslim = 100; /* 100pps */ 419169664Sjinmei/* control how to respond to NI queries */ 420169664Sjinmeiint icmp6_nodeinfo = (ICMP6_NODEINFO_FQDNOK|ICMP6_NODEINFO_NODEADDROK); 42153541Sshin 42253541Sshin/* UDP on IP6 parameters */ 42353541Sshinint udp6_sendspace = 9216; /* really max datagram size */ 42453541Sshinint udp6_recvspace = 40 * (1024 + sizeof(struct sockaddr_in6)); 42553541Sshin /* 40 1K datagrams */ 42653541Sshin 42753541Sshin/* 42853541Sshin * sysctl related items. 42953541Sshin */ 43053541SshinSYSCTL_NODE(_net, PF_INET6, inet6, CTLFLAG_RW, 0, 43153541Sshin "Internet6 Family"); 43253541Sshin 43353541Sshin/* net.inet6 */ 43453541SshinSYSCTL_NODE(_net_inet6, IPPROTO_IPV6, ip6, CTLFLAG_RW, 0, "IP6"); 43553541SshinSYSCTL_NODE(_net_inet6, IPPROTO_ICMPV6, icmp6, CTLFLAG_RW, 0, "ICMP6"); 43653541SshinSYSCTL_NODE(_net_inet6, IPPROTO_UDP, udp6, CTLFLAG_RW, 0, "UDP6"); 43753541SshinSYSCTL_NODE(_net_inet6, IPPROTO_TCP, tcp6, CTLFLAG_RW, 0, "TCP6"); 438163953Srrs#ifdef SCTP 439163953SrrsSYSCTL_NODE(_net_inet6, IPPROTO_SCTP, sctp6, CTLFLAG_RW, 0, "SCTP6"); 440163953Srrs#endif 441171167Sgnn#ifdef IPSEC 44253541SshinSYSCTL_NODE(_net_inet6, IPPROTO_ESP, ipsec6, CTLFLAG_RW, 0, "IPSEC6"); 443171167Sgnn#endif /* IPSEC */ 44453541Sshin 44553541Sshin/* net.inet6.ip6 */ 44653541Sshinstatic int 44778064Sumesysctl_ip6_temppltime(SYSCTL_HANDLER_ARGS) 44853541Sshin{ 44953541Sshin int error = 0; 45078064Sume int old; 45153541Sshin 45253541Sshin error = SYSCTL_OUT(req, arg1, sizeof(int)); 45353541Sshin if (error || !req->newptr) 45453541Sshin return (error); 45578064Sume old = ip6_temp_preferred_lifetime; 45653541Sshin error = SYSCTL_IN(req, arg1, sizeof(int)); 45778064Sume if (ip6_temp_preferred_lifetime < 45878064Sume ip6_desync_factor + ip6_temp_regen_advance) { 45978064Sume ip6_temp_preferred_lifetime = old; 460120856Sume return (EINVAL); 46153541Sshin } 462120856Sume return (error); 46353541Sshin} 46453541Sshin 46562587Sitojunstatic int 46678064Sumesysctl_ip6_tempvltime(SYSCTL_HANDLER_ARGS) 46762587Sitojun{ 46878064Sume int error = 0; 46978064Sume int old; 47062587Sitojun 47178064Sume error = SYSCTL_OUT(req, arg1, sizeof(int)); 47278064Sume if (error || !req->newptr) 47362587Sitojun return (error); 47478064Sume old = ip6_temp_valid_lifetime; 47578064Sume error = SYSCTL_IN(req, arg1, sizeof(int)); 47678064Sume if (ip6_temp_valid_lifetime < ip6_temp_preferred_lifetime) { 47778064Sume ip6_temp_preferred_lifetime = old; 478120856Sume return (EINVAL); 47978064Sume } 480120856Sume return (error); 48162587Sitojun} 48262587Sitojun 48378064SumeSYSCTL_INT(_net_inet6_ip6, IPV6CTL_FORWARDING, 48478064Sume forwarding, CTLFLAG_RW, &ip6_forwarding, 0, ""); 48553541SshinSYSCTL_INT(_net_inet6_ip6, IPV6CTL_SENDREDIRECTS, 48653541Sshin redirect, CTLFLAG_RW, &ip6_sendredirects, 0, ""); 48753541SshinSYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFHLIM, 48853541Sshin hlim, CTLFLAG_RW, &ip6_defhlim, 0, ""); 48978931SumeSYSCTL_STRUCT(_net_inet6_ip6, IPV6CTL_STATS, stats, CTLFLAG_RD, 49078931Sume &ip6stat, ip6stat, ""); 49153541SshinSYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGPACKETS, 49253541Sshin maxfragpackets, CTLFLAG_RW, &ip6_maxfragpackets, 0, ""); 49353541SshinSYSCTL_INT(_net_inet6_ip6, IPV6CTL_ACCEPT_RTADV, 49453541Sshin accept_rtadv, CTLFLAG_RW, &ip6_accept_rtadv, 0, ""); 49553541SshinSYSCTL_INT(_net_inet6_ip6, IPV6CTL_KEEPFAITH, 49653541Sshin keepfaith, CTLFLAG_RW, &ip6_keepfaith, 0, ""); 49753541SshinSYSCTL_INT(_net_inet6_ip6, IPV6CTL_LOG_INTERVAL, 49853541Sshin log_interval, CTLFLAG_RW, &ip6_log_interval, 0, ""); 49953541SshinSYSCTL_INT(_net_inet6_ip6, IPV6CTL_HDRNESTLIMIT, 50053541Sshin hdrnestlimit, CTLFLAG_RW, &ip6_hdrnestlimit, 0, ""); 50153541SshinSYSCTL_INT(_net_inet6_ip6, IPV6CTL_DAD_COUNT, 50253541Sshin dad_count, CTLFLAG_RW, &ip6_dad_count, 0, ""); 50353541SshinSYSCTL_INT(_net_inet6_ip6, IPV6CTL_AUTO_FLOWLABEL, 50453541Sshin auto_flowlabel, CTLFLAG_RW, &ip6_auto_flowlabel, 0, ""); 50553541SshinSYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFMCASTHLIM, 50653541Sshin defmcasthlim, CTLFLAG_RW, &ip6_defmcasthlim, 0, ""); 50753541SshinSYSCTL_INT(_net_inet6_ip6, IPV6CTL_GIF_HLIM, 50853541Sshin gifhlim, CTLFLAG_RW, &ip6_gif_hlim, 0, ""); 50954263SshinSYSCTL_STRING(_net_inet6_ip6, IPV6CTL_KAME_VERSION, 51054263Sshin kame_version, CTLFLAG_RD, __KAME_VERSION, 0, ""); 51153541SshinSYSCTL_INT(_net_inet6_ip6, IPV6CTL_USE_DEPRECATED, 51253541Sshin use_deprecated, CTLFLAG_RW, &ip6_use_deprecated, 0, ""); 51353541SshinSYSCTL_INT(_net_inet6_ip6, IPV6CTL_RR_PRUNE, 51453541Sshin rr_prune, CTLFLAG_RW, &ip6_rr_prune, 0, ""); 51578064SumeSYSCTL_INT(_net_inet6_ip6, IPV6CTL_USETEMPADDR, 51678064Sume use_tempaddr, CTLFLAG_RW, &ip6_use_tempaddr, 0, ""); 51778064SumeSYSCTL_OID(_net_inet6_ip6, IPV6CTL_TEMPPLTIME, temppltime, 51878064Sume CTLTYPE_INT|CTLFLAG_RW, &ip6_temp_preferred_lifetime, 0, 51978064Sume sysctl_ip6_temppltime, "I", ""); 52078064SumeSYSCTL_OID(_net_inet6_ip6, IPV6CTL_TEMPVLTIME, tempvltime, 52178064Sume CTLTYPE_INT|CTLFLAG_RW, &ip6_temp_valid_lifetime, 0, 52278064Sume sysctl_ip6_tempvltime, "I", ""); 52378064SumeSYSCTL_INT(_net_inet6_ip6, IPV6CTL_V6ONLY, 52478064Sume v6only, CTLFLAG_RW, &ip6_v6only, 0, ""); 525163308SumeTUNABLE_INT("net.inet6.ip6.auto_linklocal", &ip6_auto_linklocal); 52678064SumeSYSCTL_INT(_net_inet6_ip6, IPV6CTL_AUTO_LINKLOCAL, 52778064Sume auto_linklocal, CTLFLAG_RW, &ip6_auto_linklocal, 0, ""); 52878064SumeSYSCTL_STRUCT(_net_inet6_ip6, IPV6CTL_RIP6STATS, rip6stats, CTLFLAG_RD, 52978064Sume &rip6stat, rip6stat, ""); 530122077SumeSYSCTL_INT(_net_inet6_ip6, IPV6CTL_PREFER_TEMPADDR, 531122077Sume prefer_tempaddr, CTLFLAG_RW, &ip6_prefer_tempaddr, 0, ""); 532148385SumeSYSCTL_INT(_net_inet6_ip6, IPV6CTL_USE_DEFAULTZONE, 533148385Sume use_defaultzone, CTLFLAG_RW, &ip6_use_defzone, 0,""); 534121345SumeSYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGS, 535121345Sume maxfrags, CTLFLAG_RW, &ip6_maxfrags, 0, ""); 536149033SumeSYSCTL_INT(_net_inet6_ip6, IPV6CTL_MCAST_PMTU, 537149033Sume mcast_pmtu, CTLFLAG_RW, &ip6_mcast_pmtu, 0, ""); 538148921Ssuz#ifdef IPSTEALTH 539148921SsuzSYSCTL_INT(_net_inet6_ip6, IPV6CTL_STEALTH, stealth, CTLFLAG_RW, 540148921Ssuz &ip6stealth, 0, ""); 541148921Ssuz#endif 54253541Sshin 54353541Sshin/* net.inet6.icmp6 */ 54453541SshinSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT, 54553541Sshin rediraccept, CTLFLAG_RW, &icmp6_rediraccept, 0, ""); 54653541SshinSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT, 54753541Sshin redirtimeout, CTLFLAG_RW, &icmp6_redirtimeout, 0, ""); 54853541SshinSYSCTL_STRUCT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats, CTLFLAG_RD, 54953541Sshin &icmp6stat, icmp6stat, ""); 55053541SshinSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE, 55153541Sshin nd6_prune, CTLFLAG_RW, &nd6_prune, 0, ""); 55253541SshinSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DELAY, 55353541Sshin nd6_delay, CTLFLAG_RW, &nd6_delay, 0, ""); 55453541SshinSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_UMAXTRIES, 55553541Sshin nd6_umaxtries, CTLFLAG_RW, &nd6_umaxtries, 0, ""); 55653541SshinSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MMAXTRIES, 55753541Sshin nd6_mmaxtries, CTLFLAG_RW, &nd6_mmaxtries, 0, ""); 55853541SshinSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_USELOOPBACK, 55953541Sshin nd6_useloopback, CTLFLAG_RW, &nd6_useloopback, 0, ""); 56062587SitojunSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO, 56162587Sitojun nodeinfo, CTLFLAG_RW, &icmp6_nodeinfo, 0, ""); 56262587SitojunSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ERRPPSLIMIT, 56362587Sitojun errppslimit, CTLFLAG_RW, &icmp6errppslim, 0, ""); 56462587SitojunSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MAXNUDHINT, 56562587Sitojun nd6_maxnudhint, CTLFLAG_RW, &nd6_maxnudhint, 0, ""); 56678064SumeSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DEBUG, 56778064Sume nd6_debug, CTLFLAG_RW, &nd6_debug, 0, ""); 568