in6_proto.c revision 222272
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: head/sys/netinet6/in6_proto.c 222272 2011-05-25 00:34:25Z bz $"); 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> 8153541Sshin#include <sys/domain.h> 8253541Sshin#include <sys/mbuf.h> 8353541Sshin#include <sys/systm.h> 8453541Sshin#include <sys/sysctl.h> 8553541Sshin 8653541Sshin#include <net/if.h> 8753541Sshin#include <net/radix.h> 8853541Sshin#include <net/route.h> 89178167Sqingli#ifdef RADIX_MPATH 90178167Sqingli#include <net/radix_mpath.h> 91178167Sqingli#endif 9253541Sshin 9353541Sshin#include <netinet/in.h> 9453541Sshin#include <netinet/in_systm.h> 9553541Sshin#include <netinet/in_var.h> 9662587Sitojun#include <netinet/ip_encap.h> 9753541Sshin#include <netinet/ip.h> 9853541Sshin#include <netinet/ip_var.h> 9962587Sitojun#include <netinet/ip6.h> 10053541Sshin#include <netinet6/ip6_var.h> 10162587Sitojun#include <netinet/icmp6.h> 10253541Sshin 10353541Sshin#include <netinet/tcp.h> 10453541Sshin#include <netinet/tcp_timer.h> 10553541Sshin#include <netinet/tcp_var.h> 10653541Sshin#include <netinet/udp.h> 10753541Sshin#include <netinet/udp_var.h> 10853541Sshin#include <netinet6/tcp6_var.h> 10978064Sume#include <netinet6/raw_ip6.h> 11053541Sshin#include <netinet6/udp6_var.h> 11153541Sshin#include <netinet6/pim6_var.h> 11253541Sshin#include <netinet6/nd6.h> 11353541Sshin 114163953Srrs#ifdef SCTP 115163953Srrs#include <netinet/in_pcb.h> 116163953Srrs#include <netinet/sctp_pcb.h> 117163953Srrs#include <netinet/sctp.h> 118163953Srrs#include <netinet/sctp_var.h> 119163953Srrs#include <netinet6/sctp6_var.h> 120163953Srrs#endif /* SCTP */ 121163953Srrs 122171167Sgnn#ifdef IPSEC 123171133Sgnn#include <netipsec/ipsec.h> 124105199Ssam#include <netipsec/ipsec6.h> 125171167Sgnn#endif /* IPSEC */ 126105199Ssam 12753541Sshin#include <netinet6/ip6protosw.h> 12853541Sshin 129207828Skmacy#ifdef FLOWTABLE 130207828Skmacy#include <net/flowtable.h> 131207828Skmacy#endif 132207828Skmacy 13353541Sshin/* 13453541Sshin * TCP/IP protocol family: IP6, ICMP6, UDP, TCP. 13553541Sshin */ 136222272SbzFEATURE(inet6, "Internet Protocol version 6"); 13753541Sshin 13862587Sitojunextern struct domain inet6domain; 139148917Sobrienstatic struct pr_usrreqs nousrreqs; 14053541Sshin 14178064Sume#define PR_LISTEN 0 14278064Sume#define PR_ABRTACPTDIS 0 14378064Sume 144211115Sbz/* Spacer for loadable protocols. */ 145211115Sbz#define IP6PROTOSPACER \ 146211115Sbz{ \ 147211115Sbz .pr_domain = &inet6domain, \ 148211115Sbz .pr_protocol = PROTO_SPACER, \ 149211115Sbz .pr_usrreqs = &nousrreqs \ 150211115Sbz} 151211115Sbz 15253541Sshinstruct ip6protosw inet6sw[] = { 153152242Sru{ 154152242Sru .pr_type = 0, 155152242Sru .pr_domain = &inet6domain, 156152242Sru .pr_protocol = IPPROTO_IPV6, 157152242Sru .pr_init = ip6_init, 158193731Szec#ifdef VIMAGE 159193731Szec .pr_destroy = ip6_destroy, 160193731Szec#endif 161152242Sru .pr_slowtimo = frag6_slowtimo, 162152242Sru .pr_drain = frag6_drain, 163152242Sru .pr_usrreqs = &nousrreqs, 16453541Sshin}, 165152242Sru{ 166152242Sru .pr_type = SOCK_DGRAM, 167152242Sru .pr_domain = &inet6domain, 168152242Sru .pr_protocol = IPPROTO_UDP, 169152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 170152242Sru .pr_input = udp6_input, 171152242Sru .pr_ctlinput = udp6_ctlinput, 172152242Sru .pr_ctloutput = ip6_ctloutput, 173220881Sbz#ifndef INET /* Do not call initialization twice. */ 174220881Sbz .pr_init = udp_init, 175220881Sbz#endif 176152242Sru .pr_usrreqs = &udp6_usrreqs, 17754263Sshin}, 178152242Sru{ 179152242Sru .pr_type = SOCK_STREAM, 180152242Sru .pr_domain = &inet6domain, 181152242Sru .pr_protocol = IPPROTO_TCP, 182152242Sru .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LISTEN, 183152242Sru .pr_input = tcp6_input, 184152242Sru .pr_ctlinput = tcp6_ctlinput, 185152242Sru .pr_ctloutput = tcp_ctloutput, 186152242Sru#ifndef INET /* don't call initialization and timeout routines twice */ 187152242Sru .pr_init = tcp_init, 188152242Sru .pr_slowtimo = tcp_slowtimo, 18955679Sshin#endif 190152242Sru .pr_drain = tcp_drain, 191152242Sru .pr_usrreqs = &tcp6_usrreqs, 19255679Sshin}, 193163953Srrs#ifdef SCTP 194171260Sdelphij{ 195171260Sdelphij .pr_type = SOCK_DGRAM, 196171260Sdelphij .pr_domain = &inet6domain, 197171260Sdelphij .pr_protocol = IPPROTO_SCTP, 198171260Sdelphij .pr_flags = PR_WANTRCVD, 199171260Sdelphij .pr_input = sctp6_input, 200171260Sdelphij .pr_ctlinput = sctp6_ctlinput, 201163953Srrs .pr_ctloutput = sctp_ctloutput, 202171260Sdelphij .pr_drain = sctp_drain, 203220881Sbz#ifndef INET /* Do not call initialization twice. */ 204220881Sbz .pr_init = sctp_init, 205220881Sbz#endif 206171260Sdelphij .pr_usrreqs = &sctp6_usrreqs 207163953Srrs}, 208152242Sru{ 209171260Sdelphij .pr_type = SOCK_SEQPACKET, 210171260Sdelphij .pr_domain = &inet6domain, 211171260Sdelphij .pr_protocol = IPPROTO_SCTP, 212171260Sdelphij .pr_flags = PR_WANTRCVD, 213171260Sdelphij .pr_input = sctp6_input, 214171260Sdelphij .pr_ctlinput = sctp6_ctlinput, 215163953Srrs .pr_ctloutput = sctp_ctloutput, 216171260Sdelphij .pr_drain = sctp_drain, 217171260Sdelphij .pr_usrreqs = &sctp6_usrreqs 218163953Srrs}, 219163953Srrs 220171260Sdelphij{ 221171260Sdelphij .pr_type = SOCK_STREAM, 222171260Sdelphij .pr_domain = &inet6domain, 223171260Sdelphij .pr_protocol = IPPROTO_SCTP, 224171260Sdelphij .pr_flags = PR_WANTRCVD, 225171260Sdelphij .pr_input = sctp6_input, 226171260Sdelphij .pr_ctlinput = sctp6_ctlinput, 227163953Srrs .pr_ctloutput = sctp_ctloutput, 228171260Sdelphij .pr_drain = sctp_drain, 229171260Sdelphij .pr_usrreqs = &sctp6_usrreqs 230163953Srrs}, 231163953Srrs#endif /* SCTP */ 232163953Srrs{ 233152242Sru .pr_type = SOCK_RAW, 234152242Sru .pr_domain = &inet6domain, 235152242Sru .pr_protocol = IPPROTO_RAW, 236152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 237152242Sru .pr_input = rip6_input, 238152242Sru .pr_output = rip6_output, 239152242Sru .pr_ctlinput = rip6_ctlinput, 240152242Sru .pr_ctloutput = rip6_ctloutput, 241220881Sbz#ifndef INET /* Do not call initialization twice. */ 242220881Sbz .pr_init = rip_init, 243220881Sbz#endif 244152242Sru .pr_usrreqs = &rip6_usrreqs 24553541Sshin}, 246152242Sru{ 247152242Sru .pr_type = SOCK_RAW, 248152242Sru .pr_domain = &inet6domain, 249152242Sru .pr_protocol = IPPROTO_ICMPV6, 250152242Sru .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, 251152242Sru .pr_input = icmp6_input, 252152242Sru .pr_output = rip6_output, 253152242Sru .pr_ctlinput = rip6_ctlinput, 254152242Sru .pr_ctloutput = rip6_ctloutput, 255152242Sru .pr_fasttimo = icmp6_fasttimo, 256191672Sbms .pr_slowtimo = icmp6_slowtimo, 257152242Sru .pr_usrreqs = &rip6_usrreqs 25853541Sshin}, 259152242Sru{ 260152242Sru .pr_type = SOCK_RAW, 261152242Sru .pr_domain = &inet6domain, 262152242Sru .pr_protocol = IPPROTO_DSTOPTS, 263152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 264152242Sru .pr_input = dest6_input, 265152242Sru .pr_usrreqs = &nousrreqs 26653541Sshin}, 267152242Sru{ 268152242Sru .pr_type = SOCK_RAW, 269152242Sru .pr_domain = &inet6domain, 270152242Sru .pr_protocol = IPPROTO_ROUTING, 271152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 272152242Sru .pr_input = route6_input, 273152242Sru .pr_usrreqs = &nousrreqs 27453541Sshin}, 275152242Sru{ 276152242Sru .pr_type = SOCK_RAW, 277152242Sru .pr_domain = &inet6domain, 278152242Sru .pr_protocol = IPPROTO_FRAGMENT, 279152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 280152242Sru .pr_input = frag6_input, 281152242Sru .pr_usrreqs = &nousrreqs 28253541Sshin}, 283171167Sgnn#ifdef IPSEC 284152242Sru{ 285152242Sru .pr_type = SOCK_RAW, 286152242Sru .pr_domain = &inet6domain, 287152242Sru .pr_protocol = IPPROTO_AH, 288152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 289171133Sgnn .pr_input = ipsec6_common_input, 290152242Sru .pr_usrreqs = &nousrreqs, 29153541Sshin}, 292152242Sru{ 293152242Sru .pr_type = SOCK_RAW, 294152242Sru .pr_domain = &inet6domain, 295152242Sru .pr_protocol = IPPROTO_ESP, 296152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 297171133Sgnn .pr_input = ipsec6_common_input, 298152242Sru .pr_ctlinput = esp6_ctlinput, 299152242Sru .pr_usrreqs = &nousrreqs, 30053541Sshin}, 301152242Sru{ 302152242Sru .pr_type = SOCK_RAW, 303152242Sru .pr_domain = &inet6domain, 304152242Sru .pr_protocol = IPPROTO_IPCOMP, 305152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 306171133Sgnn .pr_input = ipsec6_common_input, 307152242Sru .pr_usrreqs = &nousrreqs, 30862587Sitojun}, 309171167Sgnn#endif /* IPSEC */ 31062587Sitojun#ifdef INET 311152242Sru{ 312152242Sru .pr_type = SOCK_RAW, 313152242Sru .pr_domain = &inet6domain, 314152242Sru .pr_protocol = IPPROTO_IPV4, 315152242Sru .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, 316152242Sru .pr_input = encap6_input, 317152242Sru .pr_output = rip6_output, 318152242Sru .pr_ctloutput = rip6_ctloutput, 319152242Sru .pr_init = encap_init, 320152242Sru .pr_usrreqs = &rip6_usrreqs 32153541Sshin}, 32295023Ssuz#endif /* INET */ 323152242Sru{ 324152242Sru .pr_type = SOCK_RAW, 325152242Sru .pr_domain = &inet6domain, 326152242Sru .pr_protocol = IPPROTO_IPV6, 327152242Sru .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, 328152242Sru .pr_input = encap6_input, 329152242Sru .pr_output = rip6_output, 330152242Sru .pr_ctloutput = rip6_ctloutput, 331152242Sru .pr_init = encap_init, 332152242Sru .pr_usrreqs = &rip6_usrreqs 33353541Sshin}, 334152242Sru{ 335152242Sru .pr_type = SOCK_RAW, 336152242Sru .pr_domain = &inet6domain, 337152242Sru .pr_protocol = IPPROTO_PIM, 338152242Sru .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, 339166938Sbms .pr_input = encap6_input, 340152242Sru .pr_output = rip6_output, 341152242Sru .pr_ctloutput = rip6_ctloutput, 342152242Sru .pr_usrreqs = &rip6_usrreqs 34356722Sshin}, 344211115Sbz/* Spacer n-times for loadable protocols. */ 345211115SbzIP6PROTOSPACER, 346211115SbzIP6PROTOSPACER, 347211115SbzIP6PROTOSPACER, 348211115SbzIP6PROTOSPACER, 349211115SbzIP6PROTOSPACER, 350211115SbzIP6PROTOSPACER, 351211115SbzIP6PROTOSPACER, 352211115SbzIP6PROTOSPACER, 35353541Sshin/* raw wildcard */ 354152242Sru{ 355152242Sru .pr_type = SOCK_RAW, 356152242Sru .pr_domain = &inet6domain, 357152242Sru .pr_flags = PR_ATOMIC|PR_ADDR, 358152242Sru .pr_input = rip6_input, 359152242Sru .pr_output = rip6_output, 360152242Sru .pr_ctloutput = rip6_ctloutput, 361152242Sru .pr_usrreqs = &rip6_usrreqs 36253541Sshin}, 36353541Sshin}; 36453541Sshin 365175162Sobrienextern int in6_inithead(void **, int); 366193731Szec#ifdef VIMAGE 367193731Szecextern int in6_detachhead(void **, int); 368193731Szec#endif 36962587Sitojun 370152242Srustruct domain inet6domain = { 371152242Sru .dom_family = AF_INET6, 372152242Sru .dom_name = "internet6", 373152242Sru .dom_protosw = (struct protosw *)inet6sw, 374152242Sru .dom_protoswNPROTOSW = (struct protosw *) 375152242Sru &inet6sw[sizeof(inet6sw)/sizeof(inet6sw[0])], 376178167Sqingli#ifdef RADIX_MPATH 377178167Sqingli .dom_rtattach = rn6_mpath_inithead, 378178167Sqingli#else 379152242Sru .dom_rtattach = in6_inithead, 380178167Sqingli#endif 381193731Szec#ifdef VIMAGE 382193731Szec .dom_rtdetach = in6_detachhead, 383193731Szec#endif 384152242Sru .dom_rtoffset = offsetof(struct sockaddr_in6, sin6_addr) << 3, 385152242Sru .dom_maxrtkey = sizeof(struct sockaddr_in6), 386152242Sru .dom_ifattach = in6_domifattach, 387152242Sru .dom_ifdetach = in6_domifdetach 388152242Sru}; 38953541Sshin 390195837SrwatsonVNET_DOMAIN_SET(inet6); 39153541Sshin 39253541Sshin/* 39353541Sshin * Internet configuration info 39453541Sshin */ 395207369Sbz#ifndef IPV6FORWARDING 396207369Sbz#ifdef GATEWAY6 397207369Sbz#define IPV6FORWARDING 1 /* forward IP6 packets not for us */ 398207369Sbz#else 399207369Sbz#define IPV6FORWARDING 0 /* don't forward IP6 packets not for us */ 400207369Sbz#endif /* GATEWAY6 */ 401207369Sbz#endif /* !IPV6FORWARDING */ 40253541Sshin 403207369Sbz#ifndef IPV6_SENDREDIRECTS 404207369Sbz#define IPV6_SENDREDIRECTS 1 405207369Sbz#endif 406207369Sbz 407207369SbzVNET_DEFINE(int, ip6_forwarding) = IPV6FORWARDING; /* act as router? */ 408207369SbzVNET_DEFINE(int, ip6_sendredirects) = IPV6_SENDREDIRECTS; 409207369SbzVNET_DEFINE(int, ip6_defhlim) = IPV6_DEFHLIM; 410207369SbzVNET_DEFINE(int, ip6_defmcasthlim) = IPV6_DEFAULT_MULTICAST_HOPS; 411207369SbzVNET_DEFINE(int, ip6_accept_rtadv) = 0; 412207369SbzVNET_DEFINE(int, ip6_maxfragpackets); /* initialized in frag6.c:frag6_init() */ 413207369SbzVNET_DEFINE(int, ip6_maxfrags); /* initialized in frag6.c:frag6_init() */ 414207369SbzVNET_DEFINE(int, ip6_log_interval) = 5; 415207369SbzVNET_DEFINE(int, ip6_hdrnestlimit) = 15;/* How many header options will we 416207369Sbz * process? */ 417207369SbzVNET_DEFINE(int, ip6_dad_count) = 1; /* DupAddrDetectionTransmits */ 418207369SbzVNET_DEFINE(int, ip6_auto_flowlabel) = 1; 419207369SbzVNET_DEFINE(int, ip6_use_deprecated) = 1;/* allow deprecated addr 420207369Sbz * (RFC2462 5.5.4) */ 421207369SbzVNET_DEFINE(int, ip6_rr_prune) = 5; /* router renumbering prefix 422207369Sbz * walk list every 5 sec. */ 423207369SbzVNET_DEFINE(int, ip6_mcast_pmtu) = 0; /* enable pMTU discovery for multicast? */ 424207369SbzVNET_DEFINE(int, ip6_v6only) = 1; 425207369Sbz 426207369SbzVNET_DEFINE(int, ip6_keepfaith) = 0; 427207369SbzVNET_DEFINE(time_t, ip6_log_time) = (time_t)0L; 428207369Sbz#ifdef IPSTEALTH 429207369SbzVNET_DEFINE(int, ip6stealth) = 0; 430207369Sbz#endif 431207369SbzVNET_DEFINE(int, nd6_onlink_ns_rfc4861) = 0;/* allow 'on-link' nd6 NS 432207369Sbz * (RFC 4861) */ 433207369Sbz 43453541Sshin/* icmp6 */ 43553541Sshin/* 43653541Sshin * BSDI4 defines these variables in in_proto.c... 43753541Sshin * XXX: what if we don't define INET? Should we define pmtu6_expire 43853541Sshin * or so? (jinmei@kame.net 19990310) 43953541Sshin */ 440207369SbzVNET_DEFINE(int, pmtu_expire) = 60*10; 441207369SbzVNET_DEFINE(int, pmtu_probe) = 60*2; 44253541Sshin 44353541Sshin/* raw IP6 parameters */ 44453541Sshin/* 44553541Sshin * Nominal space allocated to a raw ip socket. 44653541Sshin */ 447207369Sbz#define RIPV6SNDQ 8192 448207369Sbz#define RIPV6RCVQ 8192 44953541Sshin 450207369SbzVNET_DEFINE(u_long, rip6_sendspace) = RIPV6SNDQ; 451207369SbzVNET_DEFINE(u_long, rip6_recvspace) = RIPV6RCVQ; 452207369Sbz 45353541Sshin/* ICMPV6 parameters */ 454207369SbzVNET_DEFINE(int, icmp6_rediraccept) = 1;/* accept and process redirects */ 455207369SbzVNET_DEFINE(int, icmp6_redirtimeout) = 10 * 60; /* 10 minutes */ 456207369SbzVNET_DEFINE(int, icmp6errppslim) = 100; /* 100pps */ 457169664Sjinmei/* control how to respond to NI queries */ 458207369SbzVNET_DEFINE(int, icmp6_nodeinfo) = 459207369Sbz (ICMP6_NODEINFO_FQDNOK|ICMP6_NODEINFO_NODEADDROK); 46053541Sshin 46153541Sshin/* UDP on IP6 parameters */ 462207369SbzVNET_DEFINE(int, udp6_sendspace) = 9216;/* really max datagram size */ 463207369SbzVNET_DEFINE(int, udp6_recvspace) = 40 * (1024 + sizeof(struct sockaddr_in6)); 464207369Sbz /* 40 1K datagrams */ 46553541Sshin 46653541Sshin/* 46753541Sshin * sysctl related items. 46853541Sshin */ 46953541SshinSYSCTL_NODE(_net, PF_INET6, inet6, CTLFLAG_RW, 0, 47053541Sshin "Internet6 Family"); 47153541Sshin 47253541Sshin/* net.inet6 */ 47353541SshinSYSCTL_NODE(_net_inet6, IPPROTO_IPV6, ip6, CTLFLAG_RW, 0, "IP6"); 47453541SshinSYSCTL_NODE(_net_inet6, IPPROTO_ICMPV6, icmp6, CTLFLAG_RW, 0, "ICMP6"); 47553541SshinSYSCTL_NODE(_net_inet6, IPPROTO_UDP, udp6, CTLFLAG_RW, 0, "UDP6"); 47653541SshinSYSCTL_NODE(_net_inet6, IPPROTO_TCP, tcp6, CTLFLAG_RW, 0, "TCP6"); 477163953Srrs#ifdef SCTP 478163953SrrsSYSCTL_NODE(_net_inet6, IPPROTO_SCTP, sctp6, CTLFLAG_RW, 0, "SCTP6"); 479163953Srrs#endif 480171167Sgnn#ifdef IPSEC 48153541SshinSYSCTL_NODE(_net_inet6, IPPROTO_ESP, ipsec6, CTLFLAG_RW, 0, "IPSEC6"); 482171167Sgnn#endif /* IPSEC */ 48353541Sshin 48453541Sshin/* net.inet6.ip6 */ 48553541Sshinstatic int 48678064Sumesysctl_ip6_temppltime(SYSCTL_HANDLER_ARGS) 48753541Sshin{ 48853541Sshin int error = 0; 48978064Sume int old; 49053541Sshin 491195814Sbz VNET_SYSCTL_ARG(req, arg1); 492191688Szec 49353541Sshin error = SYSCTL_OUT(req, arg1, sizeof(int)); 49453541Sshin if (error || !req->newptr) 49553541Sshin return (error); 496181803Sbz old = V_ip6_temp_preferred_lifetime; 49753541Sshin error = SYSCTL_IN(req, arg1, sizeof(int)); 498181803Sbz if (V_ip6_temp_preferred_lifetime < 499181803Sbz V_ip6_desync_factor + V_ip6_temp_regen_advance) { 500181803Sbz V_ip6_temp_preferred_lifetime = old; 501120856Sume return (EINVAL); 50253541Sshin } 503120856Sume return (error); 50453541Sshin} 50553541Sshin 50662587Sitojunstatic int 50778064Sumesysctl_ip6_tempvltime(SYSCTL_HANDLER_ARGS) 50862587Sitojun{ 50978064Sume int error = 0; 51078064Sume int old; 51162587Sitojun 512195814Sbz VNET_SYSCTL_ARG(req, arg1); 513191688Szec 51478064Sume error = SYSCTL_OUT(req, arg1, sizeof(int)); 51578064Sume if (error || !req->newptr) 51662587Sitojun return (error); 517181803Sbz old = V_ip6_temp_valid_lifetime; 51878064Sume error = SYSCTL_IN(req, arg1, sizeof(int)); 519181803Sbz if (V_ip6_temp_valid_lifetime < V_ip6_temp_preferred_lifetime) { 520181803Sbz V_ip6_temp_preferred_lifetime = old; 521120856Sume return (EINVAL); 52278064Sume } 523120856Sume return (error); 52462587Sitojun} 52562587Sitojun 526195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_FORWARDING, forwarding, CTLFLAG_RW, 527195699Srwatson &VNET_NAME(ip6_forwarding), 0, ""); 528195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_SENDREDIRECTS, redirect, CTLFLAG_RW, 529195699Srwatson &VNET_NAME(ip6_sendredirects), 0, ""); 530195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_DEFHLIM, hlim, CTLFLAG_RW, 531195699Srwatson &VNET_NAME(ip6_defhlim), 0, ""); 532195699SrwatsonSYSCTL_VNET_STRUCT(_net_inet6_ip6, IPV6CTL_STATS, stats, CTLFLAG_RD, 533195699Srwatson &VNET_NAME(ip6stat), ip6stat, ""); 534195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGPACKETS, maxfragpackets, 535195699Srwatson CTLFLAG_RW, &VNET_NAME(ip6_maxfragpackets), 0, ""); 536195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_ACCEPT_RTADV, accept_rtadv, 537197138Shrs CTLFLAG_RW, &VNET_NAME(ip6_accept_rtadv), 0, 538197138Shrs "Default value of per-interface flag for accepting ICMPv6 Router" 539197138Shrs "Advertisement messages"); 540195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_KEEPFAITH, keepfaith, CTLFLAG_RW, 541195699Srwatson &VNET_NAME(ip6_keepfaith), 0, ""); 542195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_LOG_INTERVAL, log_interval, 543195699Srwatson CTLFLAG_RW, &VNET_NAME(ip6_log_interval), 0, ""); 544195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_HDRNESTLIMIT, hdrnestlimit, 545195699Srwatson CTLFLAG_RW, &VNET_NAME(ip6_hdrnestlimit), 0, ""); 546195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_DAD_COUNT, dad_count, CTLFLAG_RW, 547195699Srwatson &VNET_NAME(ip6_dad_count), 0, ""); 548195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_AUTO_FLOWLABEL, auto_flowlabel, 549195699Srwatson CTLFLAG_RW, &VNET_NAME(ip6_auto_flowlabel), 0, ""); 550195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_DEFMCASTHLIM, defmcasthlim, 551195699Srwatson CTLFLAG_RW, &VNET_NAME(ip6_defmcasthlim), 0, ""); 552195699SrwatsonSYSCTL_STRING(_net_inet6_ip6, IPV6CTL_KAME_VERSION, kame_version, 553195699Srwatson CTLFLAG_RD, __KAME_VERSION, 0, ""); 554195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_USE_DEPRECATED, use_deprecated, 555195699Srwatson CTLFLAG_RW, &VNET_NAME(ip6_use_deprecated), 0, ""); 556195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_RR_PRUNE, rr_prune, CTLFLAG_RW, 557195699Srwatson &VNET_NAME(ip6_rr_prune), 0, ""); 558195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_USETEMPADDR, use_tempaddr, 559195699Srwatson CTLFLAG_RW, &VNET_NAME(ip6_use_tempaddr), 0, ""); 560195699SrwatsonSYSCTL_VNET_PROC(_net_inet6_ip6, IPV6CTL_TEMPPLTIME, temppltime, 561195699Srwatson CTLTYPE_INT|CTLFLAG_RW, &VNET_NAME(ip6_temp_preferred_lifetime), 0, 562183550Szec sysctl_ip6_temppltime, "I", ""); 563195699SrwatsonSYSCTL_VNET_PROC(_net_inet6_ip6, IPV6CTL_TEMPVLTIME, tempvltime, 564195699Srwatson CTLTYPE_INT|CTLFLAG_RW, &VNET_NAME(ip6_temp_valid_lifetime), 0, 565183550Szec sysctl_ip6_tempvltime, "I", ""); 566195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_V6ONLY, v6only, CTLFLAG_RW, 567195699Srwatson &VNET_NAME(ip6_v6only), 0, ""); 568195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_AUTO_LINKLOCAL, auto_linklocal, 569197138Shrs CTLFLAG_RW, &VNET_NAME(ip6_auto_linklocal), 0, 570197138Shrs "Default value of per-interface flag for automatically adding an IPv6" 571197138Shrs " link-local address to interfaces when attached"); 572195699SrwatsonSYSCTL_VNET_STRUCT(_net_inet6_ip6, IPV6CTL_RIP6STATS, rip6stats, CTLFLAG_RD, 573195699Srwatson &VNET_NAME(rip6stat), rip6stat, ""); 574195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_PREFER_TEMPADDR, prefer_tempaddr, 575195699Srwatson CTLFLAG_RW, &VNET_NAME(ip6_prefer_tempaddr), 0, ""); 576195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_USE_DEFAULTZONE, use_defaultzone, 577195699Srwatson CTLFLAG_RW, &VNET_NAME(ip6_use_defzone), 0,""); 578195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGS, maxfrags, CTLFLAG_RW, 579195699Srwatson &VNET_NAME(ip6_maxfrags), 0, ""); 580195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_MCAST_PMTU, mcast_pmtu, CTLFLAG_RW, 581195699Srwatson &VNET_NAME(ip6_mcast_pmtu), 0, ""); 582148921Ssuz#ifdef IPSTEALTH 583195699SrwatsonSYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_STEALTH, stealth, CTLFLAG_RW, 584195699Srwatson &VNET_NAME(ip6stealth), 0, ""); 585148921Ssuz#endif 58653541Sshin 587207828Skmacy#ifdef FLOWTABLE 588207828SkmacyVNET_DEFINE(int, ip6_output_flowtable_size) = 2048; 589207828SkmacyVNET_DEFINE(struct flowtable *, ip6_ft); 590207828Skmacy#define V_ip6_output_flowtable_size VNET(ip6_output_flowtable_size) 591207828Skmacy 592207828SkmacySYSCTL_VNET_INT(_net_inet6_ip6, OID_AUTO, output_flowtable_size, CTLFLAG_RDTUN, 593207828Skmacy &VNET_NAME(ip6_output_flowtable_size), 2048, 594207828Skmacy "number of entries in the per-cpu output flow caches"); 595207828Skmacy#endif 596207828Skmacy 59753541Sshin/* net.inet6.icmp6 */ 598195699SrwatsonSYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT, rediraccept, 599195699Srwatson CTLFLAG_RW, &VNET_NAME(icmp6_rediraccept), 0, ""); 600195699SrwatsonSYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT, redirtimeout, 601195699Srwatson CTLFLAG_RW, &VNET_NAME(icmp6_redirtimeout), 0, ""); 602195699SrwatsonSYSCTL_VNET_STRUCT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats, CTLFLAG_RD, 603195699Srwatson &VNET_NAME(icmp6stat), icmp6stat, ""); 604195699SrwatsonSYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE, nd6_prune, CTLFLAG_RW, 605195699Srwatson &VNET_NAME(nd6_prune), 0, ""); 606195699SrwatsonSYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DELAY, nd6_delay, CTLFLAG_RW, 607195699Srwatson &VNET_NAME(nd6_delay), 0, ""); 608195699SrwatsonSYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_UMAXTRIES, nd6_umaxtries, 609195699Srwatson CTLFLAG_RW, &VNET_NAME(nd6_umaxtries), 0, ""); 610195699SrwatsonSYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MMAXTRIES, nd6_mmaxtries, 611195699Srwatson CTLFLAG_RW, &VNET_NAME(nd6_mmaxtries), 0, ""); 612195699SrwatsonSYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_USELOOPBACK, nd6_useloopback, 613195699Srwatson CTLFLAG_RW, &VNET_NAME(nd6_useloopback), 0, ""); 614195699SrwatsonSYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO, nodeinfo, CTLFLAG_RW, 615195699Srwatson &VNET_NAME(icmp6_nodeinfo), 0, ""); 616195699SrwatsonSYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_ERRPPSLIMIT, errppslimit, 617195699Srwatson CTLFLAG_RW, &VNET_NAME(icmp6errppslim), 0, ""); 618195699SrwatsonSYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MAXNUDHINT, nd6_maxnudhint, 619195699Srwatson CTLFLAG_RW, &VNET_NAME(nd6_maxnudhint), 0, ""); 620195699SrwatsonSYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DEBUG, nd6_debug, CTLFLAG_RW, 621195699Srwatson &VNET_NAME(nd6_debug), 0, ""); 622195699SrwatsonSYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_ONLINKNSRFC4861, 623195699Srwatson nd6_onlink_ns_rfc4861, CTLFLAG_RW, &VNET_NAME(nd6_onlink_ns_rfc4861), 624195699Srwatson 0, "Accept 'on-link' nd6 NS in compliance with RFC 4861."); 625