xref: /netbsd-src/sys/netinet6/in6_proto.c (revision c38e7cc395b1472a774ff828e46123de44c628e9)
1 /*	$NetBSD: in6_proto.c,v 1.124 2018/05/03 07:13:48 maxv Exp $	*/
2 /*	$KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $	*/
3 
4 /*
5  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the project nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32 
33 /*
34  * Copyright (c) 1982, 1986, 1993
35  *	The Regents of the University of California.  All rights reserved.
36  *
37  * Redistribution and use in source and binary forms, with or without
38  * modification, are permitted provided that the following conditions
39  * are met:
40  * 1. Redistributions of source code must retain the above copyright
41  *    notice, this list of conditions and the following disclaimer.
42  * 2. Redistributions in binary form must reproduce the above copyright
43  *    notice, this list of conditions and the following disclaimer in the
44  *    documentation and/or other materials provided with the distribution.
45  * 3. Neither the name of the University nor the names of its contributors
46  *    may be used to endorse or promote products derived from this software
47  *    without specific prior written permission.
48  *
49  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
50  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
51  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59  * SUCH DAMAGE.
60  *
61  *	@(#)in_proto.c	8.1 (Berkeley) 6/10/93
62  */
63 
64 #include <sys/cdefs.h>
65 __KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.124 2018/05/03 07:13:48 maxv Exp $");
66 
67 #ifdef _KERNEL_OPT
68 #include "opt_gateway.h"
69 #include "opt_inet.h"
70 #include "opt_ipsec.h"
71 #include "opt_dccp.h"
72 #include "opt_sctp.h"
73 #include "opt_net_mpsafe.h"
74 #endif
75 
76 #include <sys/param.h>
77 #include <sys/socket.h>
78 #include <sys/protosw.h>
79 #include <sys/kernel.h>
80 #include <sys/domain.h>
81 #include <sys/mbuf.h>
82 
83 #include <net/if.h>
84 
85 #include <netinet/in.h>
86 #include <netinet/in_systm.h>
87 #include <netinet/in_var.h>
88 #include <netinet/ip_encap.h>
89 #include <netinet/ip.h>
90 #include <netinet/ip_var.h>
91 #include <netinet/in_pcb.h>
92 #include <netinet/ip6.h>
93 #include <netinet6/ip6_var.h>
94 #include <netinet/icmp6.h>
95 #include <netinet6/in6_pcb.h>
96 
97 #include <netinet/tcp.h>
98 #include <netinet/tcp_fsm.h>
99 #include <netinet/tcp_seq.h>
100 #include <netinet/tcp_timer.h>
101 #include <netinet/tcp_var.h>
102 #include <netinet/tcp_debug.h>
103 
104 #include <netinet6/udp6.h>
105 #include <netinet6/udp6_var.h>
106 
107 #ifdef DCCP
108 #include <netinet/dccp.h>
109 #include <netinet/dccp_var.h>
110 #include <netinet6/dccp6_var.h>
111 #endif
112 
113 #ifdef SCTP
114 #include <netinet/sctp_pcb.h>
115 #include <netinet/sctp.h>
116 #include <netinet/sctp_var.h>
117 #include <netinet6/sctp6_var.h>
118 #endif
119 
120 #include <netinet6/pim6_var.h>
121 
122 #ifdef IPSEC
123 #include <netipsec/ipsec.h>
124 #include <netipsec/ipsec6.h>
125 #include <netipsec/key.h>
126 #endif
127 
128 #include "carp.h"
129 #if NCARP > 0
130 #include <netinet/ip_carp.h>
131 #endif
132 
133 #include "etherip.h"
134 #if NETHERIP > 0
135 #include <netinet6/ip6_etherip.h>
136 #endif
137 
138 #include <netinet6/ip6protosw.h>
139 
140 /*
141  * TCP/IP protocol family: IP6, ICMP6, UDP, TCP.
142  */
143 
144 DOMAIN_DEFINE(inet6domain);	/* forward declare and add to link set */
145 
146 /* Wrappers to acquire kernel_lock. */
147 
148 PR_WRAP_CTLINPUT(rip6_ctlinput)
149 PR_WRAP_CTLINPUT(encap6_ctlinput)
150 PR_WRAP_CTLINPUT(udp6_ctlinput)
151 PR_WRAP_CTLINPUT(tcp6_ctlinput)
152 
153 #define	rip6_ctlinput	rip6_ctlinput_wrapper
154 #define	encap6_ctlinput	encap6_ctlinput_wrapper
155 #define	udp6_ctlinput	udp6_ctlinput_wrapper
156 #define	tcp6_ctlinput	tcp6_ctlinput_wrapper
157 
158 PR_WRAP_CTLOUTPUT(rip6_ctloutput)
159 PR_WRAP_CTLOUTPUT(tcp_ctloutput)
160 PR_WRAP_CTLOUTPUT(udp6_ctloutput)
161 PR_WRAP_CTLOUTPUT(icmp6_ctloutput)
162 
163 #define	rip6_ctloutput	rip6_ctloutput_wrapper
164 #define	tcp_ctloutput	tcp_ctloutput_wrapper
165 #define	udp6_ctloutput	udp6_ctloutput_wrapper
166 #define	icmp6_ctloutput	icmp6_ctloutput_wrapper
167 
168 #if defined(DCCP)
169 PR_WRAP_CTLINPUT(dccp6_ctlinput)
170 PR_WRAP_CTLOUTPUT(dccp_ctloutput)
171 
172 #define dccp6_ctlinput	dccp6_ctlinput_wrapper
173 #define dccp_ctloutput	dccp_ctloutput_wrapper
174 #endif
175 
176 #if defined(SCTP)
177 PR_WRAP_CTLINPUT(sctp6_ctlinput)
178 PR_WRAP_CTLOUTPUT(sctp_ctloutput)
179 
180 #define sctp6_ctlinput	sctp6_ctlinput_wrapper
181 #define sctp_ctloutput	sctp_ctloutput_wrapper
182 #endif
183 
184 #ifdef NET_MPSAFE
185 PR_WRAP_INPUT6(udp6_input)
186 PR_WRAP_INPUT6(tcp6_input)
187 #ifdef DCCP
188 PR_WRAP_INPUT6(dccp6_input)
189 #endif
190 #ifdef SCTP
191 PR_WRAP_INPUT6(sctp6_input)
192 #endif
193 PR_WRAP_INPUT6(rip6_input)
194 PR_WRAP_INPUT6(dest6_input)
195 PR_WRAP_INPUT6(route6_input)
196 PR_WRAP_INPUT6(frag6_input)
197 #if NETHERIP > 0
198 PR_WRAP_INPUT6(ip6_etherip_input)
199 #endif
200 #if NPFSYNC > 0
201 PR_WRAP_INPUT6(pfsync_input)
202 #endif
203 PR_WRAP_INPUT6(pim6_input)
204 
205 #define	udp6_input		udp6_input_wrapper
206 #define	tcp6_input		tcp6_input_wrapper
207 #define	dccp6_input		dccp6_input_wrapper
208 #define	sctp6_input		sctp6_input_wrapper
209 #define	rip6_input		rip6_input_wrapper
210 #define	dest6_input		dest6_input_wrapper
211 #define	route6_input		route6_input_wrapper
212 #define	frag6_input		frag6_input_wrapper
213 #define	ip6_etherip_input	ip6_etherip_input_wrapper
214 #define	pim6_input		pim6_input_wrapper
215 #endif
216 
217 #if defined(IPSEC)
218 
219 #ifdef IPSEC_RUMPKERNEL
220 /*
221  * .pr_input = ipsec6_common_input won't be resolved on loading
222  * the ipsec shared library. We need a wrapper anyway.
223  */
224 static int
225 ipsec6_common_input_wrapper(struct mbuf **mp, int *offp, int proto)
226 {
227 
228 	if (ipsec_enabled) {
229 		return ipsec6_common_input(mp, offp, proto);
230 	} else {
231 		m_freem(*mp);
232 		return IPPROTO_DONE;
233 	}
234 }
235 #define	ipsec6_common_input	ipsec6_common_input_wrapper
236 
237 /* The ctlinput functions may not be loaded */
238 #define	IPSEC_WRAP_CTLINPUT(name)			\
239 static void *						\
240 name##_wrapper(int a, const struct sockaddr *b, void *c)\
241 {							\
242 	void *rv;					\
243 	KERNEL_LOCK(1, NULL);				\
244 	if (ipsec_enabled)				\
245 		rv = name(a, b, c);			\
246 	else						\
247 		rv = NULL;				\
248 	KERNEL_UNLOCK_ONE(NULL);			\
249 	return rv;					\
250 }
251 IPSEC_WRAP_CTLINPUT(ah6_ctlinput)
252 IPSEC_WRAP_CTLINPUT(esp6_ctlinput)
253 
254 #else /* !IPSEC_RUMPKERNEL */
255 
256 PR_WRAP_CTLINPUT(ah6_ctlinput)
257 PR_WRAP_CTLINPUT(esp6_ctlinput)
258 
259 #endif /* !IPSEC_RUMPKERNEL */
260 
261 #define	ah6_ctlinput	ah6_ctlinput_wrapper
262 #define	esp6_ctlinput	esp6_ctlinput_wrapper
263 
264 #endif /* IPSEC */
265 
266 static void
267 tcp6_init(void)
268 {
269 
270 	icmp6_mtudisc_callback_register(tcp6_mtudisc_callback);
271 
272 	tcp_init_common(sizeof(struct ip6_hdr));
273 }
274 
275 const struct ip6protosw inet6sw[] = {
276 {	.pr_domain = &inet6domain,
277 	.pr_protocol = IPPROTO_IPV6,
278 	.pr_init = ip6_init,
279 	.pr_fasttimo = frag6_fasttimo,
280 	.pr_slowtimo = frag6_slowtimo,
281 	.pr_drain = frag6_drainstub,
282 },
283 {	.pr_type = SOCK_RAW,
284 	.pr_domain = &inet6domain,
285 	.pr_protocol = IPPROTO_ICMPV6,
286 	.pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
287 	.pr_input = icmp6_input,
288 	.pr_ctlinput = rip6_ctlinput,
289 	.pr_ctloutput = icmp6_ctloutput,
290 	.pr_usrreqs = &rip6_usrreqs,
291 	.pr_init = icmp6_init,
292 },
293 {	.pr_type = SOCK_DGRAM,
294 	.pr_domain = &inet6domain,
295 	.pr_protocol = IPPROTO_UDP,
296 	.pr_flags = PR_ATOMIC|PR_ADDR|PR_PURGEIF,
297 	.pr_input = udp6_input,
298 	.pr_ctlinput = udp6_ctlinput,
299 	.pr_ctloutput = udp6_ctloutput,
300 	.pr_usrreqs = &udp6_usrreqs,
301 	.pr_init = udp6_init,
302 },
303 {	.pr_type = SOCK_STREAM,
304 	.pr_domain = &inet6domain,
305 	.pr_protocol = IPPROTO_TCP,
306 	.pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LISTEN|PR_ABRTACPTDIS|PR_PURGEIF,
307 	.pr_input = tcp6_input,
308 	.pr_ctlinput = tcp6_ctlinput,
309 	.pr_ctloutput = tcp_ctloutput,
310 	.pr_usrreqs = &tcp_usrreqs,
311 	.pr_init = tcp6_init,
312 	.pr_fasttimo = tcp_fasttimo,
313 	.pr_drain = tcp_drainstub,
314 },
315 #ifdef DCCP
316 {	.pr_type = SOCK_CONN_DGRAM,
317 	.pr_domain = &inet6domain,
318 	.pr_protocol = IPPROTO_DCCP,
319 	.pr_flags = PR_CONNREQUIRED|PR_ATOMIC|PR_LISTEN,
320 	.pr_input = dccp6_input,
321 	.pr_ctlinput = dccp6_ctlinput,
322 	.pr_ctloutput = dccp_ctloutput,
323 	.pr_usrreqs = &dccp6_usrreqs,
324 #ifndef INET
325 	.pr_init = dccp_init,
326 #endif
327 },
328 #endif /* DCCP */
329 #ifdef SCTP
330 {	.pr_type = SOCK_DGRAM,
331 	.pr_domain = &inet6domain,
332 	.pr_protocol = IPPROTO_SCTP,
333 	.pr_flags = PR_ADDR_OPT|PR_WANTRCVD,
334 	.pr_input = sctp6_input,
335 	.pr_ctlinput = sctp6_ctlinput,
336 	.pr_ctloutput = sctp_ctloutput,
337 	.pr_usrreqs = &sctp6_usrreqs,
338 	.pr_drain = sctp_drain,
339 },
340 {	.pr_type = SOCK_SEQPACKET,
341 	.pr_domain = &inet6domain,
342 	.pr_protocol = IPPROTO_SCTP,
343 	.pr_flags = PR_ADDR_OPT|PR_WANTRCVD,
344 	.pr_input = sctp6_input,
345 	.pr_ctlinput = sctp6_ctlinput,
346 	.pr_ctloutput = sctp_ctloutput,
347 	.pr_drain = sctp_drain,
348 },
349 {	.pr_type = SOCK_STREAM,
350 	.pr_domain = &inet6domain,
351 	.pr_protocol = IPPROTO_SCTP,
352 	.pr_flags = PR_CONNREQUIRED|PR_ADDR_OPT|PR_WANTRCVD|PR_LISTEN,
353 	.pr_input = sctp6_input,
354 	.pr_ctlinput = sctp6_ctlinput,
355 	.pr_ctloutput = sctp_ctloutput,
356 	.pr_drain = sctp_drain,
357 },
358 #endif /* SCTP */
359 {	.pr_type = SOCK_RAW,
360 	.pr_domain = &inet6domain,
361 	.pr_protocol = IPPROTO_RAW,
362 	.pr_flags = PR_ATOMIC|PR_ADDR|PR_PURGEIF,
363 	.pr_input = rip6_input,
364 	.pr_ctlinput = rip6_ctlinput,
365 	.pr_ctloutput = rip6_ctloutput,
366 	.pr_usrreqs = &rip6_usrreqs,
367 },
368 #ifdef GATEWAY
369 {	.pr_domain = &inet6domain,
370 	.pr_protocol = IPPROTO_IPV6,
371 	.pr_slowtimo = ip6flow_slowtimo,
372 	.pr_init = ip6flow_poolinit,
373 },
374 #endif /* GATEWAY */
375 {	.pr_type = SOCK_RAW,
376 	.pr_domain = &inet6domain,
377 	.pr_protocol = IPPROTO_DSTOPTS,
378 	.pr_flags = PR_ATOMIC|PR_ADDR,
379 	.pr_input = dest6_input,
380 },
381 {	.pr_type = SOCK_RAW,
382 	.pr_domain = &inet6domain,
383 	.pr_protocol = IPPROTO_ROUTING,
384 	.pr_flags = PR_ATOMIC|PR_ADDR,
385 	.pr_input = route6_input,
386 },
387 {	.pr_type = SOCK_RAW,
388 	.pr_domain = &inet6domain,
389 	.pr_protocol = IPPROTO_FRAGMENT,
390 	.pr_flags = PR_ATOMIC|PR_ADDR,
391 	.pr_input = frag6_input,
392 },
393 #ifdef IPSEC
394 {	.pr_type = SOCK_RAW,
395 	.pr_domain = &inet6domain,
396 	.pr_protocol = IPPROTO_AH,
397 	.pr_flags = PR_ATOMIC|PR_ADDR,
398 	.pr_input = ipsec6_common_input,
399 	.pr_ctlinput = ah6_ctlinput,
400 },
401 {	.pr_type = SOCK_RAW,
402 	.pr_domain = &inet6domain,
403 	.pr_protocol = IPPROTO_ESP,
404 	.pr_flags = PR_ATOMIC|PR_ADDR,
405 	.pr_input = ipsec6_common_input,
406 	.pr_ctlinput = esp6_ctlinput,
407 },
408 {	.pr_type = SOCK_RAW,
409 	.pr_domain = &inet6domain,
410 	.pr_protocol = IPPROTO_IPCOMP,
411 	.pr_flags = PR_ATOMIC|PR_ADDR,
412 	.pr_input = ipsec6_common_input,
413 },
414 #endif /* IPSEC */
415 #ifdef INET
416 {	.pr_type = SOCK_RAW,
417 	.pr_domain = &inet6domain,
418 	.pr_protocol = IPPROTO_IPV4,
419 	.pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
420 	.pr_input = encap6_input,
421 	.pr_ctlinput = encap6_ctlinput,
422 	.pr_ctloutput = rip6_ctloutput,
423 	.pr_usrreqs = &rip6_usrreqs,
424 	.pr_init = encap_init,
425 },
426 #endif
427 {	.pr_type = SOCK_RAW,
428 	.pr_domain = &inet6domain,
429 	.pr_protocol = IPPROTO_IPV6,
430 	.pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
431 	.pr_input = encap6_input,
432 	.pr_ctlinput = encap6_ctlinput,
433 	.pr_ctloutput = rip6_ctloutput,
434 	.pr_usrreqs = &rip6_usrreqs,
435 	.pr_init = encap_init,
436 },
437 #if NETHERIP > 0
438 {	.pr_type = SOCK_RAW,
439 	.pr_domain = &inet6domain,
440 	.pr_protocol = IPPROTO_ETHERIP,
441 	.pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
442 	.pr_input = ip6_etherip_input,
443 	.pr_ctlinput = rip6_ctlinput,
444 	.pr_ctloutput = rip6_ctloutput,
445 	.pr_usrreqs = &rip6_usrreqs,
446 },
447 #endif
448 #if NCARP > 0
449 {	.pr_type = SOCK_RAW,
450 	.pr_domain = &inet6domain,
451 	.pr_protocol = IPPROTO_CARP,
452 	.pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
453 	.pr_input = carp6_proto_input,
454 	.pr_ctloutput = rip6_ctloutput,
455 	.pr_usrreqs = &rip6_usrreqs,
456 },
457 #endif /* NCARP */
458 {	.pr_type = SOCK_RAW,
459 	.pr_domain = &inet6domain,
460 	.pr_protocol = IPPROTO_L2TP,
461 	.pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
462 	.pr_input = encap6_input,
463 	.pr_ctlinput = rip6_ctlinput,
464 	.pr_ctloutput = rip6_ctloutput,
465 	.pr_usrreqs = &rip6_usrreqs,
466 	.pr_init = encap_init,
467 },
468 {	.pr_type = SOCK_RAW,
469 	.pr_domain = &inet6domain,
470 	.pr_protocol = IPPROTO_PIM,
471 	.pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
472 	.pr_input = pim6_input,
473 	.pr_ctloutput = rip6_ctloutput,
474 	.pr_usrreqs = &rip6_usrreqs,
475 	.pr_init = pim6_init,
476 },
477 /* raw wildcard */
478 {	.pr_type = SOCK_RAW,
479 	.pr_domain = &inet6domain,
480 	.pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
481 	.pr_input = rip6_input,
482 	.pr_ctloutput = rip6_ctloutput,
483 	.pr_usrreqs = &rip6_usrreqs,
484 	.pr_init = rip6_init,
485 },
486 };
487 
488 static const struct sockaddr_in6 in6_any = {
489 	  .sin6_len = sizeof(in6_any)
490 	, .sin6_family = AF_INET6
491 	, .sin6_port = 0
492 	, .sin6_flowinfo = 0
493 	, .sin6_addr = IN6ADDR_ANY_INIT
494 	, .sin6_scope_id = 0
495 };
496 
497 bool in6_present = false;
498 static void
499 in6_dom_init(void)
500 {
501 
502 	in6_present = true;
503 }
504 
505 struct domain inet6domain = {
506 	.dom_family = AF_INET6, .dom_name = "internet6",
507 	.dom_init = in6_dom_init, .dom_externalize = NULL, .dom_dispose = NULL,
508 	.dom_protosw = (const struct protosw *)inet6sw,
509 	.dom_protoswNPROTOSW = (const struct protosw *)&inet6sw[sizeof(inet6sw)/sizeof(inet6sw[0])],
510 	.dom_rtattach = rt_inithead,
511 	.dom_rtoffset = offsetof(struct sockaddr_in6, sin6_addr) << 3,
512 	.dom_maxrtkey = sizeof(struct ip_pack6),
513 	.dom_if_up = in6_if_up, .dom_if_down = in6_if_down,
514 	.dom_ifattach = in6_domifattach, .dom_ifdetach = in6_domifdetach,
515 	.dom_if_link_state_change = in6_if_link_state_change,
516 	.dom_ifqueues = { NULL, NULL },
517 	.dom_link = { NULL },
518 	.dom_mowner = MOWNER_INIT("",""),
519 	.dom_sa_cmpofs = offsetof(struct sockaddr_in6, sin6_addr),
520 	.dom_sa_cmplen = sizeof(struct in6_addr),
521 	.dom_sa_any = (const struct sockaddr *)&in6_any,
522 	.dom_sockaddr_externalize = sockaddr_in6_externalize,
523 };
524 
525 #if 0
526 int
527 sockaddr_in6_cmp(const struct sockaddr *lsa, const struct sockaddr *rsa)
528 {
529 	uint_fast8_t len;
530 	const uint_fast8_t addrofs = offsetof(struct sockaddr_in6, sin6_addr),
531 			   addrend = addrofs + sizeof(struct in6_addr);
532 	int rc;
533 	const struct sockaddr_in6 *lsin6, *rsin6;
534 
535 	lsin6 = satocsin6(lsa);
536 	rsin6 = satocsin6(rsa);
537 
538 	len = MIN(addrend, MIN(lsin6->sin6_len, rsin6->sin6_len));
539 
540 	if (len > addrofs &&
541 	    (rc = memcmp(&lsin6->sin6_addr, &rsin6->sin6_addr,
542 	                  len - addrofs)) != 0)
543 		return rc;
544 
545 	return lsin6->sin6_len - rsin6->sin6_len;
546 }
547 #endif
548 
549 /*
550  * Internet configuration info
551  */
552 #ifdef GATEWAY6
553 #define IPV6FORWARDING	1	/* forward IP6 packets not for us */
554 #else
555 #define IPV6FORWARDING	0	/* don't forward IP6 packets not for us */
556 #endif
557 
558 int ip6_forwarding = IPV6FORWARDING;	/* act as router? */
559 int ip6_sendredirects = 1;
560 int ip6_defhlim = IPV6_DEFHLIM;
561 int ip6_defmcasthlim = IPV6_DEFAULT_MULTICAST_HOPS;
562 int ip6_accept_rtadv = 0;
563 int ip6_maxfragpackets = 200;
564 int ip6_maxfrags = 200;
565 int ip6_log_interval = 5;
566 int ip6_hdrnestlimit = 15;
567 int ip6_dad_count = 1;	/* DupAddrDetectionTransmits */
568 int ip6_auto_flowlabel = 1;
569 int ip6_use_deprecated = 1;	/* allow deprecated addr (RFC2462 5.5.4) */
570 int ip6_rr_prune = 5;	/* router renumbering prefix
571                          * walk list every 5 sec. */
572 int ip6_mcast_pmtu = 0;	/* enable pMTU discovery for multicast? */
573 int ip6_v6only = 1;
574 int ip6_neighborgcthresh = 2048; /* Threshold # of NDP entries for GC */
575 int ip6_maxifprefixes = 16; /* Max acceptable prefixes via RA per IF */
576 int ip6_maxifdefrouters = 16; /* Max acceptable def routers via RA */
577 int ip6_maxdynroutes = 4096; /* Max # of routes created via redirect */
578 
579 int ip6_keepfaith = 0;
580 time_t ip6_log_time = 0;
581 int ip6_rtadv_maxroutes = 100; /* (arbitrary) initial maximum number of
582                                 * routes via rtadv expected to be
583                                 * significantly larger than common use.
584                                 * if you need to count: 3 extra initial
585                                 * routes, plus 1 per interface after the
586                                 * first one, then one per non-linklocal
587                                 * prefix */
588 
589 /* icmp6 */
590 int pmtu_expire = 60*10;
591 
592 /* raw IP6 parameters */
593 /*
594  * Nominal space allocated to a raw ip socket.
595  */
596 #define	RIPV6SNDQ	8192
597 #define	RIPV6RCVQ	8192
598 
599 u_long	rip6_sendspace = RIPV6SNDQ;
600 u_long	rip6_recvspace = RIPV6RCVQ;
601 
602 /* ICMPV6 parameters */
603 int	icmp6_rediraccept = 1;		/* accept and process redirects */
604 int	icmp6_redirtimeout = 10 * 60;	/* 10 minutes */
605 int	icmp6errppslim = 100;		/* 100pps */
606 int	icmp6_nodeinfo = 1;		/* enable/disable NI response */
607