in6_proto.c revision 193731
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 193731 2009-06-08 17:15:40Z zec $");
65174510Sobrien
6655679Sshin#include "opt_inet.h"
6762587Sitojun#include "opt_inet6.h"
6855009Sshin#include "opt_ipsec.h"
69148921Ssuz#include "opt_ipstealth.h"
70189106Sbz#include "opt_route.h"
71142215Sglebius#include "opt_carp.h"
72163953Srrs#include "opt_sctp.h"
73178167Sqingli#include "opt_mpath.h"
7455009Sshin
7553541Sshin#include <sys/param.h>
7653541Sshin#include <sys/socket.h>
7753541Sshin#include <sys/socketvar.h>
78185895Szec#include <sys/proc.h>
7953541Sshin#include <sys/protosw.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>
85181803Sbz#include <sys/vimage.h>
8653541Sshin
8753541Sshin#include <net/if.h>
8853541Sshin#include <net/radix.h>
8953541Sshin#include <net/route.h>
90178167Sqingli#ifdef RADIX_MPATH
91178167Sqingli#include <net/radix_mpath.h>
92178167Sqingli#endif
9353541Sshin
9453541Sshin#include <netinet/in.h>
9553541Sshin#include <netinet/in_systm.h>
9653541Sshin#include <netinet/in_var.h>
9762587Sitojun#include <netinet/ip_encap.h>
9853541Sshin#include <netinet/ip.h>
9953541Sshin#include <netinet/ip_var.h>
10062587Sitojun#include <netinet/ip6.h>
10153541Sshin#include <netinet6/ip6_var.h>
10262587Sitojun#include <netinet/icmp6.h>
10353541Sshin
10453541Sshin#include <netinet/tcp.h>
10553541Sshin#include <netinet/tcp_timer.h>
10653541Sshin#include <netinet/tcp_var.h>
10753541Sshin#include <netinet/udp.h>
10853541Sshin#include <netinet/udp_var.h>
10953541Sshin#include <netinet6/tcp6_var.h>
11078064Sume#include <netinet6/raw_ip6.h>
11153541Sshin#include <netinet6/udp6_var.h>
11253541Sshin#include <netinet6/pim6_var.h>
11353541Sshin#include <netinet6/nd6.h>
11453541Sshin
115142215Sglebius#ifdef DEV_CARP
116142215Sglebius#include <netinet/ip_carp.h>
117142215Sglebius#endif
118142215Sglebius
119163953Srrs#ifdef SCTP
120163953Srrs#include <netinet/in_pcb.h>
121163953Srrs#include <netinet/sctp_pcb.h>
122163953Srrs#include <netinet/sctp.h>
123163953Srrs#include <netinet/sctp_var.h>
124163953Srrs#include <netinet6/sctp6_var.h>
125163953Srrs#endif /* SCTP */
126163953Srrs
127171167Sgnn#ifdef IPSEC
128171133Sgnn#include <netipsec/ipsec.h>
129105199Ssam#include <netipsec/ipsec6.h>
130171167Sgnn#endif /* IPSEC */
131105199Ssam
13253541Sshin#include <netinet6/ip6protosw.h>
133185571Sbz#include <netinet6/vinet6.h>
13453541Sshin
13553541Sshin/*
13653541Sshin * TCP/IP protocol family: IP6, ICMP6, UDP, TCP.
13753541Sshin */
13853541Sshin
13962587Sitojunextern	struct domain inet6domain;
140148917Sobrienstatic	struct pr_usrreqs nousrreqs;
14153541Sshin
14278064Sume#define PR_LISTEN	0
14378064Sume#define PR_ABRTACPTDIS	0
14478064Sume
14553541Sshinstruct ip6protosw inet6sw[] = {
146152242Sru{
147152242Sru	.pr_type =		0,
148152242Sru	.pr_domain =		&inet6domain,
149152242Sru	.pr_protocol =		IPPROTO_IPV6,
150152242Sru	.pr_init =		ip6_init,
151193731Szec#ifdef VIMAGE
152193731Szec	.pr_destroy =		ip6_destroy,
153193731Szec#endif
154152242Sru	.pr_slowtimo =		frag6_slowtimo,
155152242Sru	.pr_drain =		frag6_drain,
156152242Sru	.pr_usrreqs =		&nousrreqs,
15753541Sshin},
158152242Sru{
159152242Sru	.pr_type =		SOCK_DGRAM,
160152242Sru	.pr_domain =		&inet6domain,
161152242Sru	.pr_protocol =		IPPROTO_UDP,
162152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR,
163152242Sru	.pr_input =		udp6_input,
164152242Sru	.pr_ctlinput =		udp6_ctlinput,
165152242Sru	.pr_ctloutput =		ip6_ctloutput,
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_fasttimo =		tcp_fasttimo,
179152242Sru	.pr_slowtimo =		tcp_slowtimo,
18055679Sshin#endif
181152242Sru	.pr_drain =		tcp_drain,
182152242Sru	.pr_usrreqs =		&tcp6_usrreqs,
18355679Sshin},
184163953Srrs#ifdef SCTP
185171260Sdelphij{
186171260Sdelphij	.pr_type =	SOCK_DGRAM,
187171260Sdelphij	.pr_domain =	&inet6domain,
188171260Sdelphij        .pr_protocol =	IPPROTO_SCTP,
189171260Sdelphij        .pr_flags =	PR_WANTRCVD,
190171260Sdelphij        .pr_input =	sctp6_input,
191171260Sdelphij        .pr_ctlinput =  sctp6_ctlinput,
192163953Srrs        .pr_ctloutput = sctp_ctloutput,
193171260Sdelphij        .pr_drain =	sctp_drain,
194171260Sdelphij        .pr_usrreqs =	&sctp6_usrreqs
195163953Srrs},
196152242Sru{
197171260Sdelphij	.pr_type =	SOCK_SEQPACKET,
198171260Sdelphij	.pr_domain =	&inet6domain,
199171260Sdelphij        .pr_protocol =	IPPROTO_SCTP,
200171260Sdelphij        .pr_flags =	PR_WANTRCVD,
201171260Sdelphij        .pr_input =	sctp6_input,
202171260Sdelphij        .pr_ctlinput =  sctp6_ctlinput,
203163953Srrs        .pr_ctloutput = sctp_ctloutput,
204171260Sdelphij        .pr_drain =	sctp_drain,
205171260Sdelphij        .pr_usrreqs =	&sctp6_usrreqs
206163953Srrs},
207163953Srrs
208171260Sdelphij{
209171260Sdelphij	.pr_type =	SOCK_STREAM,
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#endif /* SCTP */
220163953Srrs{
221152242Sru	.pr_type =		SOCK_RAW,
222152242Sru	.pr_domain =		&inet6domain,
223152242Sru	.pr_protocol =		IPPROTO_RAW,
224152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR,
225152242Sru	.pr_input =		rip6_input,
226152242Sru	.pr_output =		rip6_output,
227152242Sru	.pr_ctlinput =		rip6_ctlinput,
228152242Sru	.pr_ctloutput =		rip6_ctloutput,
229152242Sru	.pr_usrreqs =		&rip6_usrreqs
23053541Sshin},
231152242Sru{
232152242Sru	.pr_type =		SOCK_RAW,
233152242Sru	.pr_domain =		&inet6domain,
234152242Sru	.pr_protocol =		IPPROTO_ICMPV6,
235152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR|PR_LASTHDR,
236152242Sru	.pr_input =		icmp6_input,
237152242Sru	.pr_output =		rip6_output,
238152242Sru	.pr_ctlinput =		rip6_ctlinput,
239152242Sru	.pr_ctloutput =		rip6_ctloutput,
240152242Sru	.pr_init =		icmp6_init,
241152242Sru	.pr_fasttimo =		icmp6_fasttimo,
242191672Sbms	.pr_slowtimo =		icmp6_slowtimo,
243152242Sru	.pr_usrreqs =		&rip6_usrreqs
24453541Sshin},
245152242Sru{
246152242Sru	.pr_type =		SOCK_RAW,
247152242Sru	.pr_domain =		&inet6domain,
248152242Sru	.pr_protocol =		IPPROTO_DSTOPTS,
249152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR,
250152242Sru	.pr_input =		dest6_input,
251152242Sru	.pr_usrreqs =		&nousrreqs
25253541Sshin},
253152242Sru{
254152242Sru	.pr_type =		SOCK_RAW,
255152242Sru	.pr_domain =		&inet6domain,
256152242Sru	.pr_protocol =		IPPROTO_ROUTING,
257152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR,
258152242Sru	.pr_input =		route6_input,
259152242Sru	.pr_usrreqs =		&nousrreqs
26053541Sshin},
261152242Sru{
262152242Sru	.pr_type =		SOCK_RAW,
263152242Sru	.pr_domain =		&inet6domain,
264152242Sru	.pr_protocol =		IPPROTO_FRAGMENT,
265152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR,
266152242Sru	.pr_input =		frag6_input,
267152242Sru	.pr_usrreqs =		&nousrreqs
26853541Sshin},
269171167Sgnn#ifdef IPSEC
270152242Sru{
271152242Sru	.pr_type =		SOCK_RAW,
272152242Sru	.pr_domain =		&inet6domain,
273152242Sru	.pr_protocol =		IPPROTO_AH,
274152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR,
275171133Sgnn	.pr_input =		ipsec6_common_input,
276152242Sru	.pr_usrreqs =		&nousrreqs,
27753541Sshin},
278152242Sru{
279152242Sru	.pr_type =		SOCK_RAW,
280152242Sru	.pr_domain =		&inet6domain,
281152242Sru	.pr_protocol =		IPPROTO_ESP,
282152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR,
283171133Sgnn        .pr_input =		ipsec6_common_input,
284152242Sru	.pr_ctlinput =		esp6_ctlinput,
285152242Sru	.pr_usrreqs =		&nousrreqs,
28653541Sshin},
287152242Sru{
288152242Sru	.pr_type =		SOCK_RAW,
289152242Sru	.pr_domain =		&inet6domain,
290152242Sru	.pr_protocol =		IPPROTO_IPCOMP,
291152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR,
292171133Sgnn        .pr_input =		ipsec6_common_input,
293152242Sru	.pr_usrreqs =		&nousrreqs,
29462587Sitojun},
295171167Sgnn#endif /* IPSEC */
29662587Sitojun#ifdef INET
297152242Sru{
298152242Sru	.pr_type =		SOCK_RAW,
299152242Sru	.pr_domain =		&inet6domain,
300152242Sru	.pr_protocol =		IPPROTO_IPV4,
301152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR|PR_LASTHDR,
302152242Sru	.pr_input =		encap6_input,
303152242Sru	.pr_output =		rip6_output,
304152242Sru	.pr_ctloutput =		rip6_ctloutput,
305152242Sru	.pr_init =		encap_init,
306152242Sru	.pr_usrreqs =		&rip6_usrreqs
30753541Sshin},
30895023Ssuz#endif /* INET */
309152242Sru{
310152242Sru	.pr_type =		SOCK_RAW,
311152242Sru	.pr_domain =		&inet6domain,
312152242Sru	.pr_protocol =		IPPROTO_IPV6,
313152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR|PR_LASTHDR,
314152242Sru	.pr_input =		encap6_input,
315152242Sru	.pr_output =		rip6_output,
316152242Sru	.pr_ctloutput =		rip6_ctloutput,
317152242Sru	.pr_init =		encap_init,
318152242Sru	.pr_usrreqs =		&rip6_usrreqs
31953541Sshin},
320152242Sru{
321152242Sru	.pr_type =		SOCK_RAW,
322152242Sru	.pr_domain =		&inet6domain,
323152242Sru	.pr_protocol =		IPPROTO_PIM,
324152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR|PR_LASTHDR,
325166938Sbms	.pr_input =		encap6_input,
326152242Sru	.pr_output =		rip6_output,
327152242Sru	.pr_ctloutput =		rip6_ctloutput,
328152242Sru	.pr_usrreqs =		&rip6_usrreqs
32956722Sshin},
330142215Sglebius#ifdef DEV_CARP
331152242Sru{
332152242Sru	.pr_type =		SOCK_RAW,
333152242Sru	.pr_domain =		&inet6domain,
334152242Sru	.pr_protocol =		IPPROTO_CARP,
335152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR,
336152242Sru	.pr_input =		carp6_input,
337152242Sru	.pr_output =		rip6_output,
338152242Sru	.pr_ctloutput =		rip6_ctloutput,
339152242Sru	.pr_usrreqs =		&rip6_usrreqs
340142215Sglebius},
341142215Sglebius#endif /* DEV_CARP */
34253541Sshin/* raw wildcard */
343152242Sru{
344152242Sru	.pr_type =		SOCK_RAW,
345152242Sru	.pr_domain =		&inet6domain,
346152242Sru	.pr_flags =		PR_ATOMIC|PR_ADDR,
347152242Sru	.pr_input =		rip6_input,
348152242Sru	.pr_output =		rip6_output,
349152242Sru	.pr_ctloutput =		rip6_ctloutput,
350152242Sru	.pr_usrreqs =		&rip6_usrreqs
35153541Sshin},
35253541Sshin};
35353541Sshin
354175162Sobrienextern int in6_inithead(void **, int);
355193731Szec#ifdef VIMAGE
356193731Szecextern int in6_detachhead(void **, int);
357193731Szec#endif
35862587Sitojun
359152242Srustruct domain inet6domain = {
360152242Sru	.dom_family =		AF_INET6,
361152242Sru	.dom_name =		"internet6",
362152242Sru	.dom_protosw =		(struct protosw *)inet6sw,
363152242Sru	.dom_protoswNPROTOSW =	(struct protosw *)
364152242Sru				&inet6sw[sizeof(inet6sw)/sizeof(inet6sw[0])],
365178167Sqingli#ifdef RADIX_MPATH
366178167Sqingli	.dom_rtattach =		rn6_mpath_inithead,
367178167Sqingli#else
368152242Sru	.dom_rtattach =		in6_inithead,
369178167Sqingli#endif
370193731Szec#ifdef VIMAGE
371193731Szec	.dom_rtdetach =		in6_detachhead,
372193731Szec#endif
373152242Sru	.dom_rtoffset =		offsetof(struct sockaddr_in6, sin6_addr) << 3,
374152242Sru	.dom_maxrtkey =		sizeof(struct sockaddr_in6),
375152242Sru	.dom_ifattach =		in6_domifattach,
376152242Sru	.dom_ifdetach =		in6_domifdetach
377152242Sru};
37853541Sshin
37953541SshinDOMAIN_SET(inet6);
38053541Sshin
38153541Sshin/*
38253541Sshin * Internet configuration info
38353541Sshin */
384185088Szec#ifdef VIMAGE_GLOBALS
385185088Szecint	ip6_forwarding;
386185088Szecint	ip6_sendredirects;
387185088Szecint	ip6_defhlim;
388185088Szecint	ip6_defmcasthlim;
389185088Szecint	ip6_accept_rtadv;
390185088Szecint	ip6_maxfragpackets;
391185088Szecint	ip6_maxfrags;
392185088Szecint	ip6_log_interval;
393185088Szecint	ip6_hdrnestlimit;
394185088Szecint	ip6_dad_count;
395185088Szecint	ip6_auto_flowlabel;
396185088Szecint	ip6_use_deprecated;
397185088Szecint	ip6_rr_prune;
398185088Szecint	ip6_mcast_pmtu;
399185088Szecint	ip6_v6only;
400185088Szecint	ip6_keepfaith;
401185088Szectime_t	ip6_log_time;
402185088Szecint	ip6stealth;
403185088Szecint	nd6_onlink_ns_rfc4861;
40453541Sshin
40553541Sshin/* icmp6 */
40653541Sshin/*
40753541Sshin * BSDI4 defines these variables in in_proto.c...
40853541Sshin * XXX: what if we don't define INET? Should we define pmtu6_expire
40953541Sshin * or so? (jinmei@kame.net 19990310)
41053541Sshin */
411185088Szecint pmtu_expire;
412185088Szecint pmtu_probe;
41353541Sshin
41453541Sshin/* raw IP6 parameters */
41553541Sshin/*
41653541Sshin * Nominal space allocated to a raw ip socket.
41753541Sshin */
418185088Szecu_long	rip6_sendspace;
419185088Szecu_long	rip6_recvspace;
42053541Sshin
42153541Sshin/* ICMPV6 parameters */
422185088Szecint	icmp6_rediraccept;
423185088Szecint	icmp6_redirtimeout;
424185088Szecint	icmp6errppslim;
425169664Sjinmei/* control how to respond to NI queries */
426185088Szecint	icmp6_nodeinfo;
42753541Sshin
42853541Sshin/* UDP on IP6 parameters */
429185088Szecint	udp6_sendspace;
430185088Szecint	udp6_recvspace;
431185088Szec#endif /* VIMAGE_GLOBALS */
43253541Sshin
43353541Sshin/*
43453541Sshin * sysctl related items.
43553541Sshin */
43653541SshinSYSCTL_NODE(_net,	PF_INET6,	inet6,	CTLFLAG_RW,	0,
43753541Sshin	"Internet6 Family");
43853541Sshin
43953541Sshin/* net.inet6 */
44053541SshinSYSCTL_NODE(_net_inet6,	IPPROTO_IPV6,	ip6,	CTLFLAG_RW, 0,	"IP6");
44153541SshinSYSCTL_NODE(_net_inet6,	IPPROTO_ICMPV6,	icmp6,	CTLFLAG_RW, 0,	"ICMP6");
44253541SshinSYSCTL_NODE(_net_inet6,	IPPROTO_UDP,	udp6,	CTLFLAG_RW, 0,	"UDP6");
44353541SshinSYSCTL_NODE(_net_inet6,	IPPROTO_TCP,	tcp6,	CTLFLAG_RW, 0,	"TCP6");
444163953Srrs#ifdef SCTP
445163953SrrsSYSCTL_NODE(_net_inet6,	IPPROTO_SCTP,	sctp6,	CTLFLAG_RW, 0,	"SCTP6");
446163953Srrs#endif
447171167Sgnn#ifdef IPSEC
44853541SshinSYSCTL_NODE(_net_inet6,	IPPROTO_ESP,	ipsec6,	CTLFLAG_RW, 0,	"IPSEC6");
449171167Sgnn#endif /* IPSEC */
45053541Sshin
45153541Sshin/* net.inet6.ip6 */
45253541Sshinstatic int
45378064Sumesysctl_ip6_temppltime(SYSCTL_HANDLER_ARGS)
45453541Sshin{
455183550Szec	INIT_VNET_INET6(curvnet);
45653541Sshin	int error = 0;
45778064Sume	int old;
45853541Sshin
459191688Szec	SYSCTL_RESOLVE_V_ARG1();
460191688Szec
46153541Sshin	error = SYSCTL_OUT(req, arg1, sizeof(int));
46253541Sshin	if (error || !req->newptr)
46353541Sshin		return (error);
464181803Sbz	old = V_ip6_temp_preferred_lifetime;
46553541Sshin	error = SYSCTL_IN(req, arg1, sizeof(int));
466181803Sbz	if (V_ip6_temp_preferred_lifetime <
467181803Sbz	    V_ip6_desync_factor + V_ip6_temp_regen_advance) {
468181803Sbz		V_ip6_temp_preferred_lifetime = old;
469120856Sume		return (EINVAL);
47053541Sshin	}
471120856Sume	return (error);
47253541Sshin}
47353541Sshin
47462587Sitojunstatic int
47578064Sumesysctl_ip6_tempvltime(SYSCTL_HANDLER_ARGS)
47662587Sitojun{
477183550Szec	INIT_VNET_INET6(curvnet);
47878064Sume	int error = 0;
47978064Sume	int old;
48062587Sitojun
481191688Szec	SYSCTL_RESOLVE_V_ARG1();
482191688Szec
48378064Sume	error = SYSCTL_OUT(req, arg1, sizeof(int));
48478064Sume	if (error || !req->newptr)
48562587Sitojun		return (error);
486181803Sbz	old = V_ip6_temp_valid_lifetime;
48778064Sume	error = SYSCTL_IN(req, arg1, sizeof(int));
488181803Sbz	if (V_ip6_temp_valid_lifetime < V_ip6_temp_preferred_lifetime) {
489181803Sbz		V_ip6_temp_preferred_lifetime = old;
490120856Sume		return (EINVAL);
49178064Sume	}
492120856Sume	return (error);
49362587Sitojun}
49462587Sitojun
495183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_FORWARDING,
496183550Szec	forwarding, CTLFLAG_RW,		ip6_forwarding,	0, "");
497183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_SENDREDIRECTS,
498183550Szec	redirect, CTLFLAG_RW,		ip6_sendredirects,	0, "");
499183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_DEFHLIM,
500183550Szec	hlim, CTLFLAG_RW,		ip6_defhlim,	0, "");
501183550SzecSYSCTL_V_STRUCT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_STATS, stats,
502183550Szec	CTLFLAG_RD, ip6stat, ip6stat, "");
503183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_MAXFRAGPACKETS,
504183550Szec	maxfragpackets, CTLFLAG_RW,	ip6_maxfragpackets,	0, "");
505183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_ACCEPT_RTADV,
506183550Szec	accept_rtadv, CTLFLAG_RW,	ip6_accept_rtadv,	0, "");
507183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_KEEPFAITH,
508183550Szec	keepfaith, CTLFLAG_RW,		ip6_keepfaith,	0, "");
509183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_LOG_INTERVAL,
510183550Szec	log_interval, CTLFLAG_RW,	ip6_log_interval,	0, "");
511183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_HDRNESTLIMIT,
512183550Szec	hdrnestlimit, CTLFLAG_RW,	ip6_hdrnestlimit,	0, "");
513183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_DAD_COUNT,
514183550Szec	dad_count, CTLFLAG_RW,	ip6_dad_count,	0, "");
515183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_AUTO_FLOWLABEL,
516183550Szec	auto_flowlabel, CTLFLAG_RW,	ip6_auto_flowlabel,	0, "");
517183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_DEFMCASTHLIM,
518183550Szec	defmcasthlim, CTLFLAG_RW,	ip6_defmcasthlim,	0, "");
51954263SshinSYSCTL_STRING(_net_inet6_ip6, IPV6CTL_KAME_VERSION,
52054263Sshin	kame_version, CTLFLAG_RD,	__KAME_VERSION,		0, "");
521183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_USE_DEPRECATED,
522183550Szec	use_deprecated, CTLFLAG_RW,	ip6_use_deprecated,	0, "");
523183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_RR_PRUNE,
524183550Szec	rr_prune, CTLFLAG_RW,	ip6_rr_prune,			0, "");
525183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_USETEMPADDR,
526183550Szec	use_tempaddr, CTLFLAG_RW, ip6_use_tempaddr,		0, "");
527183550SzecSYSCTL_V_OID(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_TEMPPLTIME, temppltime,
528183550Szec	CTLTYPE_INT|CTLFLAG_RW, ip6_temp_preferred_lifetime, 0,
529183550Szec   	sysctl_ip6_temppltime, "I", "");
530183550SzecSYSCTL_V_OID(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_TEMPVLTIME, tempvltime,
531183550Szec	CTLTYPE_INT|CTLFLAG_RW, ip6_temp_valid_lifetime, 0,
532183550Szec   	sysctl_ip6_tempvltime, "I", "");
533183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_V6ONLY,
534183550Szec	v6only,	CTLFLAG_RW,	ip6_v6only,			0, "");
535183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_AUTO_LINKLOCAL,
536183550Szec	auto_linklocal, CTLFLAG_RW, ip6_auto_linklocal,	0, "");
537183550SzecSYSCTL_V_STRUCT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_RIP6STATS,
538183550Szec	rip6stats, CTLFLAG_RD, rip6stat, rip6stat, "");
539183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_PREFER_TEMPADDR,
540183550Szec	prefer_tempaddr, CTLFLAG_RW, ip6_prefer_tempaddr, 0, "");
541183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_USE_DEFAULTZONE,
542183550Szec	use_defaultzone, CTLFLAG_RW, ip6_use_defzone, 0,"");
543183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_MAXFRAGS,
544183550Szec	maxfrags, CTLFLAG_RW, ip6_maxfrags, 0, "");
545183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_MCAST_PMTU,
546183550Szec	mcast_pmtu, CTLFLAG_RW, ip6_mcast_pmtu, 0, "");
547148921Ssuz#ifdef IPSTEALTH
548183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_STEALTH,
549183550Szec	stealth, CTLFLAG_RW, ip6stealth, 0, "");
550148921Ssuz#endif
55153541Sshin
55253541Sshin/* net.inet6.icmp6 */
553183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT,
554183550Szec	rediraccept, CTLFLAG_RW,	icmp6_rediraccept,	0, "");
555183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT,
556183550Szec	redirtimeout, CTLFLAG_RW,	icmp6_redirtimeout,	0, "");
557183550SzecSYSCTL_V_STRUCT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_STATS,
558183550Szec	stats, CTLFLAG_RD, icmp6stat, icmp6stat, "");
559183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE,
560183550Szec	nd6_prune, CTLFLAG_RW,		nd6_prune,	0, "");
561183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_DELAY,
562183550Szec	nd6_delay, CTLFLAG_RW,		nd6_delay,	0, "");
563183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_UMAXTRIES,
564183550Szec	nd6_umaxtries, CTLFLAG_RW,	nd6_umaxtries,	0, "");
565183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_MMAXTRIES,
566183550Szec	nd6_mmaxtries, CTLFLAG_RW,	nd6_mmaxtries,	0, "");
567183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_USELOOPBACK,
568183550Szec	nd6_useloopback, CTLFLAG_RW,	nd6_useloopback, 0, "");
569183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_NODEINFO,
570183550Szec	nodeinfo, CTLFLAG_RW,	icmp6_nodeinfo,	0, "");
571183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ERRPPSLIMIT,
572183550Szec	errppslimit, CTLFLAG_RW,	icmp6errppslim,	0, "");
573183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_MAXNUDHINT,
574183550Szec	nd6_maxnudhint, CTLFLAG_RW,	nd6_maxnudhint, 0, "");
575183550SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_DEBUG,
576183550Szec	nd6_debug, CTLFLAG_RW,	nd6_debug,		0, "");
577183550Szec
578185348SzecSYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_ONLINKNSRFC4861,
579185348Szec	nd6_onlink_ns_rfc4861, CTLFLAG_RW, nd6_onlink_ns_rfc4861, 0,
580183529Scperciva	"Accept 'on-link' nd6 NS in compliance with RFC 4861.");
581