in6_proto.c revision 1.123 1 /* $NetBSD: in6_proto.c,v 1.123 2018/05/03 06:41:30 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.123 2018/05/03 06:41:30 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/tcpip.h>
103 #include <netinet/tcp_debug.h>
104
105 #include <netinet6/udp6.h>
106 #include <netinet6/udp6_var.h>
107
108 #ifdef DCCP
109 #include <netinet/dccp.h>
110 #include <netinet/dccp_var.h>
111 #include <netinet6/dccp6_var.h>
112 #endif
113
114 #ifdef SCTP
115 #include <netinet/sctp_pcb.h>
116 #include <netinet/sctp.h>
117 #include <netinet/sctp_var.h>
118 #include <netinet6/sctp6_var.h>
119 #endif
120
121 #include <netinet6/pim6_var.h>
122
123 #ifdef IPSEC
124 #include <netipsec/ipsec.h>
125 #include <netipsec/ipsec6.h>
126 #include <netipsec/key.h>
127 #endif
128
129 #include "carp.h"
130 #if NCARP > 0
131 #include <netinet/ip_carp.h>
132 #endif
133
134 #include "etherip.h"
135 #if NETHERIP > 0
136 #include <netinet6/ip6_etherip.h>
137 #endif
138
139 #include <netinet6/ip6protosw.h>
140
141 /*
142 * TCP/IP protocol family: IP6, ICMP6, UDP, TCP.
143 */
144
145 DOMAIN_DEFINE(inet6domain); /* forward declare and add to link set */
146
147 /* Wrappers to acquire kernel_lock. */
148
149 PR_WRAP_CTLINPUT(rip6_ctlinput)
150 PR_WRAP_CTLINPUT(encap6_ctlinput)
151 PR_WRAP_CTLINPUT(udp6_ctlinput)
152 PR_WRAP_CTLINPUT(tcp6_ctlinput)
153
154 #define rip6_ctlinput rip6_ctlinput_wrapper
155 #define encap6_ctlinput encap6_ctlinput_wrapper
156 #define udp6_ctlinput udp6_ctlinput_wrapper
157 #define tcp6_ctlinput tcp6_ctlinput_wrapper
158
159 PR_WRAP_CTLOUTPUT(rip6_ctloutput)
160 PR_WRAP_CTLOUTPUT(tcp_ctloutput)
161 PR_WRAP_CTLOUTPUT(udp6_ctloutput)
162 PR_WRAP_CTLOUTPUT(icmp6_ctloutput)
163
164 #define rip6_ctloutput rip6_ctloutput_wrapper
165 #define tcp_ctloutput tcp_ctloutput_wrapper
166 #define udp6_ctloutput udp6_ctloutput_wrapper
167 #define icmp6_ctloutput icmp6_ctloutput_wrapper
168
169 #if defined(DCCP)
170 PR_WRAP_CTLINPUT(dccp6_ctlinput)
171 PR_WRAP_CTLOUTPUT(dccp_ctloutput)
172
173 #define dccp6_ctlinput dccp6_ctlinput_wrapper
174 #define dccp_ctloutput dccp_ctloutput_wrapper
175 #endif
176
177 #if defined(SCTP)
178 PR_WRAP_CTLINPUT(sctp6_ctlinput)
179 PR_WRAP_CTLOUTPUT(sctp_ctloutput)
180
181 #define sctp6_ctlinput sctp6_ctlinput_wrapper
182 #define sctp_ctloutput sctp_ctloutput_wrapper
183 #endif
184
185 #ifdef NET_MPSAFE
186 PR_WRAP_INPUT6(udp6_input)
187 PR_WRAP_INPUT6(tcp6_input)
188 #ifdef DCCP
189 PR_WRAP_INPUT6(dccp6_input)
190 #endif
191 #ifdef SCTP
192 PR_WRAP_INPUT6(sctp6_input)
193 #endif
194 PR_WRAP_INPUT6(rip6_input)
195 PR_WRAP_INPUT6(dest6_input)
196 PR_WRAP_INPUT6(route6_input)
197 PR_WRAP_INPUT6(frag6_input)
198 #if NETHERIP > 0
199 PR_WRAP_INPUT6(ip6_etherip_input)
200 #endif
201 #if NPFSYNC > 0
202 PR_WRAP_INPUT6(pfsync_input)
203 #endif
204 PR_WRAP_INPUT6(pim6_input)
205
206 #define udp6_input udp6_input_wrapper
207 #define tcp6_input tcp6_input_wrapper
208 #define dccp6_input dccp6_input_wrapper
209 #define sctp6_input sctp6_input_wrapper
210 #define rip6_input rip6_input_wrapper
211 #define dest6_input dest6_input_wrapper
212 #define route6_input route6_input_wrapper
213 #define frag6_input frag6_input_wrapper
214 #define ip6_etherip_input ip6_etherip_input_wrapper
215 #define pim6_input pim6_input_wrapper
216 #endif
217
218 #if defined(IPSEC)
219
220 #ifdef IPSEC_RUMPKERNEL
221 /*
222 * .pr_input = ipsec6_common_input won't be resolved on loading
223 * the ipsec shared library. We need a wrapper anyway.
224 */
225 static int
226 ipsec6_common_input_wrapper(struct mbuf **mp, int *offp, int proto)
227 {
228
229 if (ipsec_enabled) {
230 return ipsec6_common_input(mp, offp, proto);
231 } else {
232 m_freem(*mp);
233 return IPPROTO_DONE;
234 }
235 }
236 #define ipsec6_common_input ipsec6_common_input_wrapper
237
238 /* The ctlinput functions may not be loaded */
239 #define IPSEC_WRAP_CTLINPUT(name) \
240 static void * \
241 name##_wrapper(int a, const struct sockaddr *b, void *c)\
242 { \
243 void *rv; \
244 KERNEL_LOCK(1, NULL); \
245 if (ipsec_enabled) \
246 rv = name(a, b, c); \
247 else \
248 rv = NULL; \
249 KERNEL_UNLOCK_ONE(NULL); \
250 return rv; \
251 }
252 IPSEC_WRAP_CTLINPUT(ah6_ctlinput)
253 IPSEC_WRAP_CTLINPUT(esp6_ctlinput)
254
255 #else /* !IPSEC_RUMPKERNEL */
256
257 PR_WRAP_CTLINPUT(ah6_ctlinput)
258 PR_WRAP_CTLINPUT(esp6_ctlinput)
259
260 #endif /* !IPSEC_RUMPKERNEL */
261
262 #define ah6_ctlinput ah6_ctlinput_wrapper
263 #define esp6_ctlinput esp6_ctlinput_wrapper
264
265 #endif /* IPSEC */
266
267 static void
268 tcp6_init(void)
269 {
270
271 icmp6_mtudisc_callback_register(tcp6_mtudisc_callback);
272
273 tcp_init_common(sizeof(struct ip6_hdr));
274 }
275
276 const struct ip6protosw inet6sw[] = {
277 { .pr_domain = &inet6domain,
278 .pr_protocol = IPPROTO_IPV6,
279 .pr_init = ip6_init,
280 .pr_fasttimo = frag6_fasttimo,
281 .pr_slowtimo = frag6_slowtimo,
282 .pr_drain = frag6_drainstub,
283 },
284 { .pr_type = SOCK_RAW,
285 .pr_domain = &inet6domain,
286 .pr_protocol = IPPROTO_ICMPV6,
287 .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
288 .pr_input = icmp6_input,
289 .pr_ctlinput = rip6_ctlinput,
290 .pr_ctloutput = icmp6_ctloutput,
291 .pr_usrreqs = &rip6_usrreqs,
292 .pr_init = icmp6_init,
293 },
294 { .pr_type = SOCK_DGRAM,
295 .pr_domain = &inet6domain,
296 .pr_protocol = IPPROTO_UDP,
297 .pr_flags = PR_ATOMIC|PR_ADDR|PR_PURGEIF,
298 .pr_input = udp6_input,
299 .pr_ctlinput = udp6_ctlinput,
300 .pr_ctloutput = udp6_ctloutput,
301 .pr_usrreqs = &udp6_usrreqs,
302 .pr_init = udp6_init,
303 },
304 { .pr_type = SOCK_STREAM,
305 .pr_domain = &inet6domain,
306 .pr_protocol = IPPROTO_TCP,
307 .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LISTEN|PR_ABRTACPTDIS|PR_PURGEIF,
308 .pr_input = tcp6_input,
309 .pr_ctlinput = tcp6_ctlinput,
310 .pr_ctloutput = tcp_ctloutput,
311 .pr_usrreqs = &tcp_usrreqs,
312 .pr_init = tcp6_init,
313 .pr_fasttimo = tcp_fasttimo,
314 .pr_drain = tcp_drainstub,
315 },
316 #ifdef DCCP
317 { .pr_type = SOCK_CONN_DGRAM,
318 .pr_domain = &inet6domain,
319 .pr_protocol = IPPROTO_DCCP,
320 .pr_flags = PR_CONNREQUIRED|PR_ATOMIC|PR_LISTEN,
321 .pr_input = dccp6_input,
322 .pr_ctlinput = dccp6_ctlinput,
323 .pr_ctloutput = dccp_ctloutput,
324 .pr_usrreqs = &dccp6_usrreqs,
325 #ifndef INET
326 .pr_init = dccp_init,
327 #endif
328 },
329 #endif /* DCCP */
330 #ifdef SCTP
331 { .pr_type = SOCK_DGRAM,
332 .pr_domain = &inet6domain,
333 .pr_protocol = IPPROTO_SCTP,
334 .pr_flags = PR_ADDR_OPT|PR_WANTRCVD,
335 .pr_input = sctp6_input,
336 .pr_ctlinput = sctp6_ctlinput,
337 .pr_ctloutput = sctp_ctloutput,
338 .pr_usrreqs = &sctp6_usrreqs,
339 .pr_drain = sctp_drain,
340 },
341 { .pr_type = SOCK_SEQPACKET,
342 .pr_domain = &inet6domain,
343 .pr_protocol = IPPROTO_SCTP,
344 .pr_flags = PR_ADDR_OPT|PR_WANTRCVD,
345 .pr_input = sctp6_input,
346 .pr_ctlinput = sctp6_ctlinput,
347 .pr_ctloutput = sctp_ctloutput,
348 .pr_drain = sctp_drain,
349 },
350 { .pr_type = SOCK_STREAM,
351 .pr_domain = &inet6domain,
352 .pr_protocol = IPPROTO_SCTP,
353 .pr_flags = PR_CONNREQUIRED|PR_ADDR_OPT|PR_WANTRCVD|PR_LISTEN,
354 .pr_input = sctp6_input,
355 .pr_ctlinput = sctp6_ctlinput,
356 .pr_ctloutput = sctp_ctloutput,
357 .pr_drain = sctp_drain,
358 },
359 #endif /* SCTP */
360 { .pr_type = SOCK_RAW,
361 .pr_domain = &inet6domain,
362 .pr_protocol = IPPROTO_RAW,
363 .pr_flags = PR_ATOMIC|PR_ADDR|PR_PURGEIF,
364 .pr_input = rip6_input,
365 .pr_ctlinput = rip6_ctlinput,
366 .pr_ctloutput = rip6_ctloutput,
367 .pr_usrreqs = &rip6_usrreqs,
368 },
369 #ifdef GATEWAY
370 { .pr_domain = &inet6domain,
371 .pr_protocol = IPPROTO_IPV6,
372 .pr_slowtimo = ip6flow_slowtimo,
373 .pr_init = ip6flow_poolinit,
374 },
375 #endif /* GATEWAY */
376 { .pr_type = SOCK_RAW,
377 .pr_domain = &inet6domain,
378 .pr_protocol = IPPROTO_DSTOPTS,
379 .pr_flags = PR_ATOMIC|PR_ADDR,
380 .pr_input = dest6_input,
381 },
382 { .pr_type = SOCK_RAW,
383 .pr_domain = &inet6domain,
384 .pr_protocol = IPPROTO_ROUTING,
385 .pr_flags = PR_ATOMIC|PR_ADDR,
386 .pr_input = route6_input,
387 },
388 { .pr_type = SOCK_RAW,
389 .pr_domain = &inet6domain,
390 .pr_protocol = IPPROTO_FRAGMENT,
391 .pr_flags = PR_ATOMIC|PR_ADDR,
392 .pr_input = frag6_input,
393 },
394 #ifdef IPSEC
395 { .pr_type = SOCK_RAW,
396 .pr_domain = &inet6domain,
397 .pr_protocol = IPPROTO_AH,
398 .pr_flags = PR_ATOMIC|PR_ADDR,
399 .pr_input = ipsec6_common_input,
400 .pr_ctlinput = ah6_ctlinput,
401 },
402 { .pr_type = SOCK_RAW,
403 .pr_domain = &inet6domain,
404 .pr_protocol = IPPROTO_ESP,
405 .pr_flags = PR_ATOMIC|PR_ADDR,
406 .pr_input = ipsec6_common_input,
407 .pr_ctlinput = esp6_ctlinput,
408 },
409 { .pr_type = SOCK_RAW,
410 .pr_domain = &inet6domain,
411 .pr_protocol = IPPROTO_IPCOMP,
412 .pr_flags = PR_ATOMIC|PR_ADDR,
413 .pr_input = ipsec6_common_input,
414 },
415 #endif /* IPSEC */
416 #ifdef INET
417 { .pr_type = SOCK_RAW,
418 .pr_domain = &inet6domain,
419 .pr_protocol = IPPROTO_IPV4,
420 .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
421 .pr_input = encap6_input,
422 .pr_ctlinput = encap6_ctlinput,
423 .pr_ctloutput = rip6_ctloutput,
424 .pr_usrreqs = &rip6_usrreqs,
425 .pr_init = encap_init,
426 },
427 #endif
428 { .pr_type = SOCK_RAW,
429 .pr_domain = &inet6domain,
430 .pr_protocol = IPPROTO_IPV6,
431 .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
432 .pr_input = encap6_input,
433 .pr_ctlinput = encap6_ctlinput,
434 .pr_ctloutput = rip6_ctloutput,
435 .pr_usrreqs = &rip6_usrreqs,
436 .pr_init = encap_init,
437 },
438 #if NETHERIP > 0
439 { .pr_type = SOCK_RAW,
440 .pr_domain = &inet6domain,
441 .pr_protocol = IPPROTO_ETHERIP,
442 .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
443 .pr_input = ip6_etherip_input,
444 .pr_ctlinput = rip6_ctlinput,
445 .pr_ctloutput = rip6_ctloutput,
446 .pr_usrreqs = &rip6_usrreqs,
447 },
448 #endif
449 #if NCARP > 0
450 { .pr_type = SOCK_RAW,
451 .pr_domain = &inet6domain,
452 .pr_protocol = IPPROTO_CARP,
453 .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
454 .pr_input = carp6_proto_input,
455 .pr_ctloutput = rip6_ctloutput,
456 .pr_usrreqs = &rip6_usrreqs,
457 },
458 #endif /* NCARP */
459 { .pr_type = SOCK_RAW,
460 .pr_domain = &inet6domain,
461 .pr_protocol = IPPROTO_L2TP,
462 .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
463 .pr_input = encap6_input,
464 .pr_ctlinput = rip6_ctlinput,
465 .pr_ctloutput = rip6_ctloutput,
466 .pr_usrreqs = &rip6_usrreqs,
467 .pr_init = encap_init,
468 },
469 { .pr_type = SOCK_RAW,
470 .pr_domain = &inet6domain,
471 .pr_protocol = IPPROTO_PIM,
472 .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
473 .pr_input = pim6_input,
474 .pr_ctloutput = rip6_ctloutput,
475 .pr_usrreqs = &rip6_usrreqs,
476 .pr_init = pim6_init,
477 },
478 /* raw wildcard */
479 { .pr_type = SOCK_RAW,
480 .pr_domain = &inet6domain,
481 .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
482 .pr_input = rip6_input,
483 .pr_ctloutput = rip6_ctloutput,
484 .pr_usrreqs = &rip6_usrreqs,
485 .pr_init = rip6_init,
486 },
487 };
488
489 static const struct sockaddr_in6 in6_any = {
490 .sin6_len = sizeof(in6_any)
491 , .sin6_family = AF_INET6
492 , .sin6_port = 0
493 , .sin6_flowinfo = 0
494 , .sin6_addr = IN6ADDR_ANY_INIT
495 , .sin6_scope_id = 0
496 };
497
498 bool in6_present = false;
499 static void
500 in6_dom_init(void)
501 {
502
503 in6_present = true;
504 }
505
506 struct domain inet6domain = {
507 .dom_family = AF_INET6, .dom_name = "internet6",
508 .dom_init = in6_dom_init, .dom_externalize = NULL, .dom_dispose = NULL,
509 .dom_protosw = (const struct protosw *)inet6sw,
510 .dom_protoswNPROTOSW = (const struct protosw *)&inet6sw[sizeof(inet6sw)/sizeof(inet6sw[0])],
511 .dom_rtattach = rt_inithead,
512 .dom_rtoffset = offsetof(struct sockaddr_in6, sin6_addr) << 3,
513 .dom_maxrtkey = sizeof(struct ip_pack6),
514 .dom_if_up = in6_if_up, .dom_if_down = in6_if_down,
515 .dom_ifattach = in6_domifattach, .dom_ifdetach = in6_domifdetach,
516 .dom_if_link_state_change = in6_if_link_state_change,
517 .dom_ifqueues = { NULL, NULL },
518 .dom_link = { NULL },
519 .dom_mowner = MOWNER_INIT("",""),
520 .dom_sa_cmpofs = offsetof(struct sockaddr_in6, sin6_addr),
521 .dom_sa_cmplen = sizeof(struct in6_addr),
522 .dom_sa_any = (const struct sockaddr *)&in6_any,
523 .dom_sockaddr_externalize = sockaddr_in6_externalize,
524 };
525
526 #if 0
527 int
528 sockaddr_in6_cmp(const struct sockaddr *lsa, const struct sockaddr *rsa)
529 {
530 uint_fast8_t len;
531 const uint_fast8_t addrofs = offsetof(struct sockaddr_in6, sin6_addr),
532 addrend = addrofs + sizeof(struct in6_addr);
533 int rc;
534 const struct sockaddr_in6 *lsin6, *rsin6;
535
536 lsin6 = satocsin6(lsa);
537 rsin6 = satocsin6(rsa);
538
539 len = MIN(addrend, MIN(lsin6->sin6_len, rsin6->sin6_len));
540
541 if (len > addrofs &&
542 (rc = memcmp(&lsin6->sin6_addr, &rsin6->sin6_addr,
543 len - addrofs)) != 0)
544 return rc;
545
546 return lsin6->sin6_len - rsin6->sin6_len;
547 }
548 #endif
549
550 /*
551 * Internet configuration info
552 */
553 #ifdef GATEWAY6
554 #define IPV6FORWARDING 1 /* forward IP6 packets not for us */
555 #else
556 #define IPV6FORWARDING 0 /* don't forward IP6 packets not for us */
557 #endif
558
559 int ip6_forwarding = IPV6FORWARDING; /* act as router? */
560 int ip6_sendredirects = 1;
561 int ip6_defhlim = IPV6_DEFHLIM;
562 int ip6_defmcasthlim = IPV6_DEFAULT_MULTICAST_HOPS;
563 int ip6_accept_rtadv = 0;
564 int ip6_maxfragpackets = 200;
565 int ip6_maxfrags = 200;
566 int ip6_log_interval = 5;
567 int ip6_hdrnestlimit = 15;
568 int ip6_dad_count = 1; /* DupAddrDetectionTransmits */
569 int ip6_auto_flowlabel = 1;
570 int ip6_use_deprecated = 1; /* allow deprecated addr (RFC2462 5.5.4) */
571 int ip6_rr_prune = 5; /* router renumbering prefix
572 * walk list every 5 sec. */
573 int ip6_mcast_pmtu = 0; /* enable pMTU discovery for multicast? */
574 int ip6_v6only = 1;
575 int ip6_neighborgcthresh = 2048; /* Threshold # of NDP entries for GC */
576 int ip6_maxifprefixes = 16; /* Max acceptable prefixes via RA per IF */
577 int ip6_maxifdefrouters = 16; /* Max acceptable def routers via RA */
578 int ip6_maxdynroutes = 4096; /* Max # of routes created via redirect */
579
580 int ip6_keepfaith = 0;
581 time_t ip6_log_time = 0;
582 int ip6_rtadv_maxroutes = 100; /* (arbitrary) initial maximum number of
583 * routes via rtadv expected to be
584 * significantly larger than common use.
585 * if you need to count: 3 extra initial
586 * routes, plus 1 per interface after the
587 * first one, then one per non-linklocal
588 * prefix */
589
590 /* icmp6 */
591 int pmtu_expire = 60*10;
592
593 /* raw IP6 parameters */
594 /*
595 * Nominal space allocated to a raw ip socket.
596 */
597 #define RIPV6SNDQ 8192
598 #define RIPV6RCVQ 8192
599
600 u_long rip6_sendspace = RIPV6SNDQ;
601 u_long rip6_recvspace = RIPV6RCVQ;
602
603 /* ICMPV6 parameters */
604 int icmp6_rediraccept = 1; /* accept and process redirects */
605 int icmp6_redirtimeout = 10 * 60; /* 10 minutes */
606 int icmp6errppslim = 100; /* 100pps */
607 int icmp6_nodeinfo = 1; /* enable/disable NI response */
608