in6_proto.c revision 337798
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_proto.c,v 1.91 2001/05/27 13:28:35 itojun Exp $ 3053541Sshin */ 3153541Sshin 32139826Simp/*- 3353541Sshin * Copyright (c) 1982, 1986, 1993 3453541Sshin * The Regents of the University of California. All rights reserved. 3553541Sshin * 3653541Sshin * Redistribution and use in source and binary forms, with or without 3753541Sshin * modification, are permitted provided that the following conditions 3853541Sshin * are met: 3953541Sshin * 1. Redistributions of source code must retain the above copyright 4053541Sshin * notice, this list of conditions and the following disclaimer. 4153541Sshin * 2. Redistributions in binary form must reproduce the above copyright 4253541Sshin * notice, this list of conditions and the following disclaimer in the 4353541Sshin * documentation and/or other materials provided with the distribution. 4453541Sshin * 4. Neither the name of the University nor the names of its contributors 4553541Sshin * may be used to endorse or promote products derived from this software 4653541Sshin * without specific prior written permission. 4753541Sshin * 4853541Sshin * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 4953541Sshin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 5053541Sshin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 5153541Sshin * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 5253541Sshin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 5353541Sshin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 5453541Sshin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 5553541Sshin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 5653541Sshin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 5753541Sshin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5853541Sshin * SUCH DAMAGE. 5953541Sshin * 6053541Sshin * @(#)in_proto.c 8.1 (Berkeley) 6/10/93 6153541Sshin */ 6253541Sshin 63174510Sobrien#include <sys/cdefs.h> 64174510Sobrien__FBSDID("$FreeBSD: stable/11/sys/netinet6/in6_proto.c 337798 2018-08-14 18:06:59Z jtl $"); 65174510Sobrien 6655679Sshin#include "opt_inet.h" 6762587Sitojun#include "opt_inet6.h" 6855009Sshin#include "opt_ipsec.h" 69148921Ssuz#include "opt_ipstealth.h" 70163953Srrs#include "opt_sctp.h" 71178167Sqingli#include "opt_mpath.h" 72207828Skmacy#include "opt_route.h" 7355009Sshin 7453541Sshin#include <sys/param.h> 7553541Sshin#include <sys/socket.h> 7653541Sshin#include <sys/socketvar.h> 77185895Szec#include <sys/proc.h> 7853541Sshin#include <sys/protosw.h> 79194368Sbz#include <sys/jail.h> 8053541Sshin#include <sys/kernel.h> 81295126Sglebius#include <sys/malloc.h> 8253541Sshin#include <sys/domain.h> 8353541Sshin#include <sys/mbuf.h> 8453541Sshin#include <sys/systm.h> 8553541Sshin#include <sys/sysctl.h> 8653541Sshin 8753541Sshin#include <net/if.h> 88257176Sglebius#include <net/if_var.h> 8953541Sshin#include <net/radix.h> 9053541Sshin#include <net/route.h> 91178167Sqingli#ifdef RADIX_MPATH 92178167Sqingli#include <net/radix_mpath.h> 93178167Sqingli#endif 9453541Sshin 9553541Sshin#include <netinet/in.h> 9653541Sshin#include <netinet/in_systm.h> 9753541Sshin#include <netinet/in_var.h> 9862587Sitojun#include <netinet/ip_encap.h> 9953541Sshin#include <netinet/ip.h> 10053541Sshin#include <netinet/ip_var.h> 10162587Sitojun#include <netinet/ip6.h> 10253541Sshin#include <netinet6/ip6_var.h> 10362587Sitojun#include <netinet/icmp6.h> 10453541Sshin 10553541Sshin#include <netinet/tcp.h> 10653541Sshin#include <netinet/tcp_timer.h> 10753541Sshin#include <netinet/tcp_var.h> 10853541Sshin#include <netinet/udp.h> 10953541Sshin#include <netinet/udp_var.h> 11053541Sshin#include <netinet6/tcp6_var.h> 11178064Sume#include <netinet6/raw_ip6.h> 11253541Sshin#include <netinet6/udp6_var.h> 11353541Sshin#include <netinet6/pim6_var.h> 11453541Sshin#include <netinet6/nd6.h> 11553541Sshin 116163953Srrs#ifdef SCTP 117163953Srrs#include <netinet/in_pcb.h> 118163953Srrs#include <netinet/sctp_pcb.h> 119163953Srrs#include <netinet/sctp.h> 120163953Srrs#include <netinet/sctp_var.h> 121163953Srrs#include <netinet6/sctp6_var.h> 122163953Srrs#endif /* SCTP */ 123163953Srrs 12453541Sshin#include <netinet6/ip6protosw.h> 12553541Sshin 12653541Sshin/* 12753541Sshin * TCP/IP protocol family: IP6, ICMP6, UDP, TCP. 12853541Sshin */ 129222272SbzFEATURE(inet6, "Internet Protocol version 6"); 13053541Sshin 13162587Sitojunextern struct domain inet6domain; 132148917Sobrienstatic struct pr_usrreqs nousrreqs; 13353541Sshin 13478064Sume#define PR_LISTEN 0 13578064Sume#define PR_ABRTACPTDIS 0 13678064Sume 137211115Sbz/* Spacer for loadable protocols. */ 138211115Sbz#define IP6PROTOSPACER \ 139211115Sbz{ \ 140211115Sbz .pr_domain = &inet6domain, \ 141211115Sbz .pr_protocol = PROTO_SPACER, \ 142211115Sbz .pr_usrreqs = &nousrreqs \ 143211115Sbz} 144211115Sbz 145269699Skevlostruct protosw inet6sw[] = { 146152242Sru{ 147152242Sru .pr_type = 0, 148152242Sru .pr_domain = &inet6domain, 149152242Sru .pr_protocol = IPPROTO_IPV6, 150152242Sru .pr_init = ip6_init, 151152242Sru .pr_slowtimo = frag6_slowtimo, 152152242Sru .pr_drain = frag6_drain, 153152242Sru .pr_usrreqs = &nousrreqs, 15453541Sshin}, 155152242Sru{ 156152242Sru .pr_type = SOCK_DGRAM, 157152242Sru .pr_domain = &inet6domain, 158152242Sru .pr_protocol = IPPROTO_UDP, 159152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 160152242Sru .pr_input = udp6_input, 161152242Sru .pr_ctlinput = udp6_ctlinput, 162152242Sru .pr_ctloutput = ip6_ctloutput, 163220881Sbz#ifndef INET /* Do not call initialization twice. */ 164220881Sbz .pr_init = udp_init, 165220881Sbz#endif 166152242Sru .pr_usrreqs = &udp6_usrreqs, 16754263Sshin}, 168152242Sru{ 169152242Sru .pr_type = SOCK_STREAM, 170152242Sru .pr_domain = &inet6domain, 171152242Sru .pr_protocol = IPPROTO_TCP, 172152242Sru .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LISTEN, 173152242Sru .pr_input = tcp6_input, 174152242Sru .pr_ctlinput = tcp6_ctlinput, 175152242Sru .pr_ctloutput = tcp_ctloutput, 176152242Sru#ifndef INET /* don't call initialization and timeout routines twice */ 177152242Sru .pr_init = tcp_init, 178152242Sru .pr_slowtimo = tcp_slowtimo, 17955679Sshin#endif 180152242Sru .pr_drain = tcp_drain, 181152242Sru .pr_usrreqs = &tcp6_usrreqs, 18255679Sshin}, 183163953Srrs#ifdef SCTP 184171260Sdelphij{ 185223963Stuexen .pr_type = SOCK_SEQPACKET, 186223963Stuexen .pr_domain = &inet6domain, 187223963Stuexen .pr_protocol = IPPROTO_SCTP, 188315514Sae .pr_flags = PR_WANTRCVD|PR_LASTHDR, 189223963Stuexen .pr_input = sctp6_input, 190223963Stuexen .pr_ctlinput = sctp6_ctlinput, 191223963Stuexen .pr_ctloutput = sctp_ctloutput, 192223963Stuexen .pr_drain = sctp_drain, 193220881Sbz#ifndef INET /* Do not call initialization twice. */ 194223963Stuexen .pr_init = sctp_init, 195220881Sbz#endif 196223963Stuexen .pr_usrreqs = &sctp6_usrreqs 197163953Srrs}, 198152242Sru{ 199223963Stuexen .pr_type = SOCK_STREAM, 200223963Stuexen .pr_domain = &inet6domain, 201223963Stuexen .pr_protocol = IPPROTO_SCTP, 202315514Sae .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LASTHDR, 203223963Stuexen .pr_input = sctp6_input, 204264213Skevlo .pr_ctlinput = sctp6_ctlinput, 205223963Stuexen .pr_ctloutput = sctp_ctloutput, 206223963Stuexen .pr_drain = sctp_drain, 207223963Stuexen .pr_usrreqs = &sctp6_usrreqs 208163953Srrs}, 209163953Srrs#endif /* SCTP */ 210163953Srrs{ 211264212Skevlo .pr_type = SOCK_DGRAM, 212264212Skevlo .pr_domain = &inet6domain, 213264212Skevlo .pr_protocol = IPPROTO_UDPLITE, 214264212Skevlo .pr_flags = PR_ATOMIC|PR_ADDR, 215264212Skevlo .pr_input = udp6_input, 216264212Skevlo .pr_ctlinput = udplite6_ctlinput, 217264212Skevlo .pr_ctloutput = udp_ctloutput, 218264212Skevlo#ifndef INET /* Do not call initialization twice. */ 219264212Skevlo .pr_init = udplite_init, 220264212Skevlo#endif 221264212Skevlo .pr_usrreqs = &udp6_usrreqs, 222264212Skevlo}, 223264212Skevlo{ 224152242Sru .pr_type = SOCK_RAW, 225152242Sru .pr_domain = &inet6domain, 226152242Sru .pr_protocol = IPPROTO_RAW, 227152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 228152242Sru .pr_input = rip6_input, 229270008Skevlo .pr_output = rip6_output, 230152242Sru .pr_ctlinput = rip6_ctlinput, 231152242Sru .pr_ctloutput = rip6_ctloutput, 232220881Sbz#ifndef INET /* Do not call initialization twice. */ 233220881Sbz .pr_init = rip_init, 234220881Sbz#endif 235152242Sru .pr_usrreqs = &rip6_usrreqs 23653541Sshin}, 237152242Sru{ 238152242Sru .pr_type = SOCK_RAW, 239152242Sru .pr_domain = &inet6domain, 240152242Sru .pr_protocol = IPPROTO_ICMPV6, 241152242Sru .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, 242152242Sru .pr_input = icmp6_input, 243270008Skevlo .pr_output = rip6_output, 244152242Sru .pr_ctlinput = rip6_ctlinput, 245152242Sru .pr_ctloutput = rip6_ctloutput, 246152242Sru .pr_fasttimo = icmp6_fasttimo, 247191672Sbms .pr_slowtimo = icmp6_slowtimo, 248152242Sru .pr_usrreqs = &rip6_usrreqs 24953541Sshin}, 250152242Sru{ 251152242Sru .pr_type = SOCK_RAW, 252152242Sru .pr_domain = &inet6domain, 253152242Sru .pr_protocol = IPPROTO_DSTOPTS, 254152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 255152242Sru .pr_input = dest6_input, 256152242Sru .pr_usrreqs = &nousrreqs 25753541Sshin}, 258152242Sru{ 259152242Sru .pr_type = SOCK_RAW, 260152242Sru .pr_domain = &inet6domain, 261152242Sru .pr_protocol = IPPROTO_ROUTING, 262152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 263152242Sru .pr_input = route6_input, 264152242Sru .pr_usrreqs = &nousrreqs 26553541Sshin}, 266152242Sru{ 267152242Sru .pr_type = SOCK_RAW, 268152242Sru .pr_domain = &inet6domain, 269152242Sru .pr_protocol = IPPROTO_FRAGMENT, 270152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 271152242Sru .pr_input = frag6_input, 272152242Sru .pr_usrreqs = &nousrreqs 27353541Sshin}, 27462587Sitojun#ifdef INET 275152242Sru{ 276152242Sru .pr_type = SOCK_RAW, 277152242Sru .pr_domain = &inet6domain, 278152242Sru .pr_protocol = IPPROTO_IPV4, 279152242Sru .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, 280152242Sru .pr_input = encap6_input, 281270008Skevlo .pr_output = rip6_output, 282152242Sru .pr_ctloutput = rip6_ctloutput, 283152242Sru .pr_usrreqs = &rip6_usrreqs 28453541Sshin}, 28595023Ssuz#endif /* INET */ 286152242Sru{ 287152242Sru .pr_type = SOCK_RAW, 288152242Sru .pr_domain = &inet6domain, 289152242Sru .pr_protocol = IPPROTO_IPV6, 290152242Sru .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, 291152242Sru .pr_input = encap6_input, 292270008Skevlo .pr_output = rip6_output, 293152242Sru .pr_ctloutput = rip6_ctloutput, 294152242Sru .pr_usrreqs = &rip6_usrreqs 29553541Sshin}, 296152242Sru{ 297152242Sru .pr_type = SOCK_RAW, 298152242Sru .pr_domain = &inet6domain, 299274246Sae .pr_protocol = IPPROTO_GRE, 300274246Sae .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, 301274246Sae .pr_input = encap6_input, 302274246Sae .pr_output = rip6_output, 303274246Sae .pr_ctloutput = rip6_ctloutput, 304274246Sae .pr_usrreqs = &rip6_usrreqs 305274246Sae}, 306274246Sae{ 307274246Sae .pr_type = SOCK_RAW, 308274246Sae .pr_domain = &inet6domain, 309152242Sru .pr_protocol = IPPROTO_PIM, 310152242Sru .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, 311166938Sbms .pr_input = encap6_input, 312270008Skevlo .pr_output = rip6_output, 313152242Sru .pr_ctloutput = rip6_ctloutput, 314152242Sru .pr_usrreqs = &rip6_usrreqs 31556722Sshin}, 316211115Sbz/* Spacer n-times for loadable protocols. */ 317211115SbzIP6PROTOSPACER, 318211115SbzIP6PROTOSPACER, 319211115SbzIP6PROTOSPACER, 320211115SbzIP6PROTOSPACER, 321211115SbzIP6PROTOSPACER, 322211115SbzIP6PROTOSPACER, 323211115SbzIP6PROTOSPACER, 324211115SbzIP6PROTOSPACER, 32553541Sshin/* raw wildcard */ 326152242Sru{ 327152242Sru .pr_type = SOCK_RAW, 328152242Sru .pr_domain = &inet6domain, 329152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 330152242Sru .pr_input = rip6_input, 331270008Skevlo .pr_output = rip6_output, 332152242Sru .pr_ctloutput = rip6_ctloutput, 333152242Sru .pr_usrreqs = &rip6_usrreqs 33453541Sshin}, 33553541Sshin}; 33653541Sshin 337175162Sobrienextern int in6_inithead(void **, int); 338193731Szec#ifdef VIMAGE 339193731Szecextern int in6_detachhead(void **, int); 340193731Szec#endif 34162587Sitojun 342152242Srustruct domain inet6domain = { 343152242Sru .dom_family = AF_INET6, 344152242Sru .dom_name = "internet6", 345152242Sru .dom_protosw = (struct protosw *)inet6sw, 346298354Spfg .dom_protoswNPROTOSW = (struct protosw *)&inet6sw[nitems(inet6sw)], 347178167Sqingli#ifdef RADIX_MPATH 348178167Sqingli .dom_rtattach = rn6_mpath_inithead, 349178167Sqingli#else 350152242Sru .dom_rtattach = in6_inithead, 351178167Sqingli#endif 352193731Szec#ifdef VIMAGE 353193731Szec .dom_rtdetach = in6_detachhead, 354193731Szec#endif 355152242Sru .dom_ifattach = in6_domifattach, 356274175Smelifaro .dom_ifdetach = in6_domifdetach, 357274175Smelifaro .dom_ifmtu = in6_domifmtu 358152242Sru}; 35953541Sshin 360195837SrwatsonVNET_DOMAIN_SET(inet6); 36153541Sshin 36253541Sshin/* 36353541Sshin * Internet configuration info 36453541Sshin */ 365207369Sbz#ifndef IPV6FORWARDING 366207369Sbz#ifdef GATEWAY6 367207369Sbz#define IPV6FORWARDING 1 /* forward IP6 packets not for us */ 368207369Sbz#else 369207369Sbz#define IPV6FORWARDING 0 /* don't forward IP6 packets not for us */ 370207369Sbz#endif /* GATEWAY6 */ 371207369Sbz#endif /* !IPV6FORWARDING */ 37253541Sshin 373207369Sbz#ifndef IPV6_SENDREDIRECTS 374207369Sbz#define IPV6_SENDREDIRECTS 1 375207369Sbz#endif 376207369Sbz 377207369SbzVNET_DEFINE(int, ip6_forwarding) = IPV6FORWARDING; /* act as router? */ 378207369SbzVNET_DEFINE(int, ip6_sendredirects) = IPV6_SENDREDIRECTS; 379207369SbzVNET_DEFINE(int, ip6_defhlim) = IPV6_DEFHLIM; 380207369SbzVNET_DEFINE(int, ip6_defmcasthlim) = IPV6_DEFAULT_MULTICAST_HOPS; 381207369SbzVNET_DEFINE(int, ip6_accept_rtadv) = 0; 382222728ShrsVNET_DEFINE(int, ip6_no_radr) = 0; 383222728ShrsVNET_DEFINE(int, ip6_norbit_raif) = 0; 384225521ShrsVNET_DEFINE(int, ip6_rfc6204w3) = 0; 385207369SbzVNET_DEFINE(int, ip6_maxfragpackets); /* initialized in frag6.c:frag6_init() */ 386337797Sjtlint ip6_maxfrags; /* initialized in frag6.c:frag6_init() */ 387337798SjtlVNET_DEFINE(int, ip6_maxfragsperpacket); /* initialized in frag6.c:frag6_init() */ 388207369SbzVNET_DEFINE(int, ip6_log_interval) = 5; 389207369SbzVNET_DEFINE(int, ip6_hdrnestlimit) = 15;/* How many header options will we 390207369Sbz * process? */ 391207369SbzVNET_DEFINE(int, ip6_dad_count) = 1; /* DupAddrDetectionTransmits */ 392207369SbzVNET_DEFINE(int, ip6_auto_flowlabel) = 1; 393207369SbzVNET_DEFINE(int, ip6_use_deprecated) = 1;/* allow deprecated addr 394207369Sbz * (RFC2462 5.5.4) */ 395207369SbzVNET_DEFINE(int, ip6_rr_prune) = 5; /* router renumbering prefix 396207369Sbz * walk list every 5 sec. */ 397207369SbzVNET_DEFINE(int, ip6_mcast_pmtu) = 0; /* enable pMTU discovery for multicast? */ 398207369SbzVNET_DEFINE(int, ip6_v6only) = 1; 399207369Sbz 400207369SbzVNET_DEFINE(time_t, ip6_log_time) = (time_t)0L; 401207369Sbz#ifdef IPSTEALTH 402207369SbzVNET_DEFINE(int, ip6stealth) = 0; 403207369Sbz#endif 404207369SbzVNET_DEFINE(int, nd6_onlink_ns_rfc4861) = 0;/* allow 'on-link' nd6 NS 405207369Sbz * (RFC 4861) */ 406207369Sbz 40753541Sshin/* icmp6 */ 40853541Sshin/* 40953541Sshin * BSDI4 defines these variables in in_proto.c... 41053541Sshin * XXX: what if we don't define INET? Should we define pmtu6_expire 41153541Sshin * or so? (jinmei@kame.net 19990310) 41253541Sshin */ 413207369SbzVNET_DEFINE(int, pmtu_expire) = 60*10; 414207369SbzVNET_DEFINE(int, pmtu_probe) = 60*2; 41553541Sshin 41653541Sshin/* ICMPV6 parameters */ 417207369SbzVNET_DEFINE(int, icmp6_rediraccept) = 1;/* accept and process redirects */ 418207369SbzVNET_DEFINE(int, icmp6_redirtimeout) = 10 * 60; /* 10 minutes */ 419207369SbzVNET_DEFINE(int, icmp6errppslim) = 100; /* 100pps */ 420169664Sjinmei/* control how to respond to NI queries */ 421207369SbzVNET_DEFINE(int, icmp6_nodeinfo) = 422207369Sbz (ICMP6_NODEINFO_FQDNOK|ICMP6_NODEINFO_NODEADDROK); 423250251ShrsVNET_DEFINE(int, icmp6_nodeinfo_oldmcprefix) = 1; 42453541Sshin 42553541Sshin/* 42653541Sshin * sysctl related items. 42753541Sshin */ 42853541SshinSYSCTL_NODE(_net, PF_INET6, inet6, CTLFLAG_RW, 0, 42953541Sshin "Internet6 Family"); 43053541Sshin 43153541Sshin/* net.inet6 */ 43253541SshinSYSCTL_NODE(_net_inet6, IPPROTO_IPV6, ip6, CTLFLAG_RW, 0, "IP6"); 43353541SshinSYSCTL_NODE(_net_inet6, IPPROTO_ICMPV6, icmp6, CTLFLAG_RW, 0, "ICMP6"); 43453541SshinSYSCTL_NODE(_net_inet6, IPPROTO_UDP, udp6, CTLFLAG_RW, 0, "UDP6"); 43553541SshinSYSCTL_NODE(_net_inet6, IPPROTO_TCP, tcp6, CTLFLAG_RW, 0, "TCP6"); 436163953Srrs#ifdef SCTP 437163953SrrsSYSCTL_NODE(_net_inet6, IPPROTO_SCTP, sctp6, CTLFLAG_RW, 0, "SCTP6"); 438163953Srrs#endif 439315514Sae#if defined(IPSEC) || defined(IPSEC_SUPPORT) 44053541SshinSYSCTL_NODE(_net_inet6, IPPROTO_ESP, ipsec6, CTLFLAG_RW, 0, "IPSEC6"); 441171167Sgnn#endif /* IPSEC */ 44253541Sshin 44353541Sshin/* net.inet6.ip6 */ 44453541Sshinstatic int 44578064Sumesysctl_ip6_temppltime(SYSCTL_HANDLER_ARGS) 44653541Sshin{ 447299827Smarkj int error, val; 44853541Sshin 449299827Smarkj val = V_ip6_temp_preferred_lifetime; 450299827Smarkj error = sysctl_handle_int(oidp, &val, 0, req); 451299827Smarkj if (error != 0 || !req->newptr) 45253541Sshin return (error); 453299827Smarkj if (val < V_ip6_desync_factor + V_ip6_temp_regen_advance) 454120856Sume return (EINVAL); 455299827Smarkj V_ip6_temp_preferred_lifetime = val; 456299827Smarkj return (0); 45753541Sshin} 45853541Sshin 45962587Sitojunstatic int 46078064Sumesysctl_ip6_tempvltime(SYSCTL_HANDLER_ARGS) 46162587Sitojun{ 462299827Smarkj int error, val; 46362587Sitojun 464299827Smarkj val = V_ip6_temp_valid_lifetime; 465299827Smarkj error = sysctl_handle_int(oidp, &val, 0, req); 466299827Smarkj if (error != 0 || !req->newptr) 46762587Sitojun return (error); 468299827Smarkj if (val < V_ip6_temp_preferred_lifetime) 469120856Sume return (EINVAL); 470299827Smarkj V_ip6_temp_valid_lifetime = val; 471299827Smarkj return (0); 47262587Sitojun} 47362587Sitojun 474274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_FORWARDING, forwarding, 475299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_forwarding), 0, 476313118Smarkj "Enable forwarding of IPv6 packets between interfaces"); 477274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_SENDREDIRECTS, redirect, 478299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_sendredirects), 0, 479313118Smarkj "Send ICMPv6 redirects for unforwardable IPv6 packets"); 480299827SmarkjSYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFHLIM, hlim, 481299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_defhlim), 0, 482313118Smarkj "Default hop limit to use for outgoing IPv6 packets"); 483253085SaeSYSCTL_VNET_PCPUSTAT(_net_inet6_ip6, IPV6CTL_STATS, stats, struct ip6stat, 484299827Smarkj ip6stat, 485299827Smarkj "IP6 statistics (struct ip6stat, netinet6/ip6_var.h)"); 486274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGPACKETS, maxfragpackets, 487299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_maxfragpackets), 0, 488313118Smarkj "Default maximum number of outstanding fragmented IPv6 packets. " 489313118Smarkj "A value of 0 means no fragmented packets will be accepted, while a " 490313118Smarkj "a value of -1 means no limit"); 491274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_ACCEPT_RTADV, accept_rtadv, 492274225Sglebius CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_accept_rtadv), 0, 493299827Smarkj "Default value of per-interface flag for accepting ICMPv6 RA messages"); 494274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_NO_RADR, no_radr, 495274225Sglebius CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_no_radr), 0, 496222728Shrs "Default value of per-interface flag to control whether routers " 497222728Shrs "sending ICMPv6 RA messages on that interface are added into the " 498299827Smarkj "default router list"); 499274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_NORBIT_RAIF, norbit_raif, 500274225Sglebius CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_norbit_raif), 0, 501299827Smarkj "Always set clear the R flag in ICMPv6 NA messages when accepting RA " 502299827Smarkj "on the interface"); 503274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_RFC6204W3, rfc6204w3, 504274225Sglebius CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_rfc6204w3), 0, 505225521Shrs "Accept the default router list from ICMPv6 RA messages even " 506299827Smarkj "when packet forwarding is enabled"); 507274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_LOG_INTERVAL, log_interval, 508299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_log_interval), 0, 509299827Smarkj "Frequency in seconds at which to log IPv6 forwarding errors"); 510274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_HDRNESTLIMIT, hdrnestlimit, 511299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_hdrnestlimit), 0, 512313118Smarkj "Default maximum number of IPv6 extension headers permitted on " 513313118Smarkj "incoming IPv6 packets, 0 for no artificial limit"); 514274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_DAD_COUNT, dad_count, 515299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_dad_count), 0, 516299827Smarkj "Number of ICMPv6 NS messages sent during duplicate address detection"); 517274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_AUTO_FLOWLABEL, auto_flowlabel, 518299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_auto_flowlabel), 0, 519299827Smarkj "Provide an IPv6 flowlabel in outbound packets"); 520274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFMCASTHLIM, defmcasthlim, 521299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_defmcasthlim), 0, 522313118Smarkj "Default hop limit for IPv6 multicast packets originating from this " 523313118Smarkj "node"); 524195699SrwatsonSYSCTL_STRING(_net_inet6_ip6, IPV6CTL_KAME_VERSION, kame_version, 525299827Smarkj CTLFLAG_RD, __KAME_VERSION, 0, 526299827Smarkj "KAME version string"); 527274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_USE_DEPRECATED, use_deprecated, 528299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_use_deprecated), 0, 529299827Smarkj "Allow the use of addresses whose preferred lifetimes have expired"); 530274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_RR_PRUNE, rr_prune, 531299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_rr_prune), 0, 532299827Smarkj ""); /* XXX unused */ 533274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_USETEMPADDR, use_tempaddr, 534299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_use_tempaddr), 0, 535299827Smarkj "Create RFC3041 temporary addresses for autoconfigured addresses"); 536274225SglebiusSYSCTL_PROC(_net_inet6_ip6, IPV6CTL_TEMPPLTIME, temppltime, 537274225Sglebius CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW, 538299827Smarkj NULL, 0, sysctl_ip6_temppltime, "I", 539299827Smarkj "Maximum preferred lifetime for temporary addresses"); 540274225SglebiusSYSCTL_PROC(_net_inet6_ip6, IPV6CTL_TEMPVLTIME, tempvltime, 541274225Sglebius CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW, 542299827Smarkj NULL, 0, sysctl_ip6_tempvltime, "I", 543299827Smarkj "Maximum valid lifetime for temporary addresses"); 544274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_V6ONLY, v6only, 545299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_v6only), 0, 546299827Smarkj "Restrict AF_INET6 sockets to IPv6 addresses only"); 547274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_AUTO_LINKLOCAL, auto_linklocal, 548274225Sglebius CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_auto_linklocal), 0, 549299827Smarkj "Default value of per-interface flag for automatically adding an IPv6 " 550299827Smarkj "link-local address to interfaces when attached"); 551253085SaeSYSCTL_VNET_PCPUSTAT(_net_inet6_ip6, IPV6CTL_RIP6STATS, rip6stats, 552274225Sglebius struct rip6stat, rip6stat, 553274225Sglebius "Raw IP6 statistics (struct rip6stat, netinet6/raw_ip6.h)"); 554274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_PREFER_TEMPADDR, prefer_tempaddr, 555299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_prefer_tempaddr), 0, 556299827Smarkj "Prefer RFC3041 temporary addresses in source address selection"); 557274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_USE_DEFAULTZONE, use_defaultzone, 558299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_use_defzone), 0, 559299827Smarkj "Use the default scope zone when none is specified"); 560274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGS, maxfrags, 561337797Sjtl CTLFLAG_RW, &ip6_maxfrags, 0, 562337797Sjtl "Maximum allowed number of outstanding IPv6 packet fragments. " 563337797Sjtl "A value of 0 means no fragmented packets will be accepted, while a " 564337797Sjtl "a value of -1 means no limit"); 565337798SjtlSYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGSPERPACKET, maxfragsperpacket, 566337798Sjtl CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_maxfragsperpacket), 0, 567337798Sjtl "Maximum allowed number of fragments per packet"); 568274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_MCAST_PMTU, mcast_pmtu, 569299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_mcast_pmtu), 0, 570299827Smarkj "Enable path MTU discovery for multicast packets"); 571148921Ssuz#ifdef IPSTEALTH 572274225SglebiusSYSCTL_INT(_net_inet6_ip6, IPV6CTL_STEALTH, stealth, CTLFLAG_VNET | CTLFLAG_RW, 573299827Smarkj &VNET_NAME(ip6stealth), 0, 574299827Smarkj "Forward IPv6 packets without decrementing their TTL"); 575148921Ssuz#endif 57653541Sshin 57753541Sshin/* net.inet6.icmp6 */ 578274225SglebiusSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT, rediraccept, 579299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6_rediraccept), 0, 580299827Smarkj "Accept ICMPv6 redirect messages"); 581274225SglebiusSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT, redirtimeout, 582299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6_redirtimeout), 0, 583299827Smarkj ""); /* XXX unused */ 584253085SaeSYSCTL_VNET_PCPUSTAT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats, 585274225Sglebius struct icmp6stat, icmp6stat, 586274225Sglebius "ICMPv6 statistics (struct icmp6stat, netinet/icmp6.h)"); 587274225SglebiusSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE, nd6_prune, 588299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_prune), 0, 589299827Smarkj "Frequency in seconds of checks for expired prefixes and routers"); 590274225SglebiusSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DELAY, nd6_delay, 591299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_delay), 0, 592299827Smarkj "Delay in seconds before probing for reachability"); 593274225SglebiusSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_UMAXTRIES, nd6_umaxtries, 594299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_umaxtries), 0, 595299827Smarkj "Number of ICMPv6 NS messages sent during reachability detection"); 596274225SglebiusSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MMAXTRIES, nd6_mmaxtries, 597299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_mmaxtries), 0, 598299827Smarkj "Number of ICMPv6 NS messages sent during address resolution"); 599274225SglebiusSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_USELOOPBACK, nd6_useloopback, 600299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_useloopback), 0, 601299827Smarkj "Create a loopback route when configuring an IPv6 address"); 602274225SglebiusSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO, nodeinfo, 603299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6_nodeinfo), 0, 604299827Smarkj "Mask of enabled RF4620 node information query types"); 605274225SglebiusSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO_OLDMCPREFIX, 606274225Sglebius nodeinfo_oldmcprefix, CTLFLAG_VNET | CTLFLAG_RW, 607299827Smarkj &VNET_NAME(icmp6_nodeinfo_oldmcprefix), 0, 608299827Smarkj "Join old IPv6 NI group address in draft-ietf-ipngwg-icmp-name-lookup " 609299827Smarkj "for compatibility with KAME implementation"); 610274225SglebiusSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ERRPPSLIMIT, errppslimit, 611299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6errppslim), 0, 612299827Smarkj "Maximum number of ICMPv6 error messages per second"); 613274225SglebiusSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MAXNUDHINT, nd6_maxnudhint, 614299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_maxnudhint), 0, 615299827Smarkj ""); /* XXX unused */ 616274225SglebiusSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DEBUG, nd6_debug, 617299827Smarkj CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_debug), 0, 618299827Smarkj "Log NDP debug messages"); 619274225SglebiusSYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_ONLINKNSRFC4861, 620274225Sglebius nd6_onlink_ns_rfc4861, CTLFLAG_VNET | CTLFLAG_RW, 621274225Sglebius &VNET_NAME(nd6_onlink_ns_rfc4861), 0, 622299827Smarkj "Accept 'on-link' ICMPv6 NS messages in compliance with RFC 4861"); 623