]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* $KAME: in6_proto.c,v 1.47 2000/03/29 07:37:22 sumikawa Exp $ */ |
2 | ||
3 | /* | |
4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | |
5 | * All rights reserved. | |
6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * 3. Neither the name of the project nor the names of its contributors | |
16 | * may be used to endorse or promote products derived from this software | |
17 | * without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | |
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
29 | * SUCH DAMAGE. | |
30 | */ | |
31 | ||
32 | /* | |
33 | * Copyright (c) 1982, 1986, 1993 | |
34 | * The Regents of the University of California. All rights reserved. | |
35 | * | |
36 | * Redistribution and use in source and binary forms, with or without | |
37 | * modification, are permitted provided that the following conditions | |
38 | * are met: | |
39 | * 1. Redistributions of source code must retain the above copyright | |
40 | * notice, this list of conditions and the following disclaimer. | |
41 | * 2. Redistributions in binary form must reproduce the above copyright | |
42 | * notice, this list of conditions and the following disclaimer in the | |
43 | * documentation and/or other materials provided with the distribution. | |
44 | * 3. All advertising materials mentioning features or use of this software | |
45 | * must display the following acknowledgement: | |
46 | * This product includes software developed by the University of | |
47 | * California, Berkeley and its contributors. | |
48 | * 4. Neither the name of the University nor the names of its contributors | |
49 | * may be used to endorse or promote products derived from this software | |
50 | * without specific prior written permission. | |
51 | * | |
52 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
53 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
54 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
55 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
58 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
60 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
61 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
62 | * SUCH DAMAGE. | |
63 | * | |
64 | * @(#)in_proto.c 8.1 (Berkeley) 6/10/93 | |
65 | */ | |
66 | ||
67 | #if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__NetBSD__) | |
68 | #include "opt_inet.h" | |
69 | #if __NetBSD__ /*XXX*/ | |
70 | #include "opt_ipsec.h" | |
71 | #endif | |
72 | #endif | |
73 | ||
74 | #include <sys/param.h> | |
75 | #include <sys/socket.h> | |
76 | #if defined(__FreeBSD__) || defined (__APPLE__) | |
77 | #include <sys/socketvar.h> | |
78 | #endif | |
79 | #include <sys/protosw.h> | |
80 | #include <sys/kernel.h> | |
81 | #include <sys/domain.h> | |
82 | #include <sys/mbuf.h> | |
83 | #if defined (__FreeBSD__) || defined (__APPLE__) | |
84 | #include <sys/systm.h> | |
85 | #include <sys/sysctl.h> | |
86 | #endif | |
87 | ||
88 | #include <net/if.h> | |
89 | #include <net/radix.h> | |
90 | #include <net/route.h> | |
91 | ||
92 | #include <netinet/in.h> | |
93 | #include <netinet/in_systm.h> | |
94 | #include <netinet/in_var.h> | |
95 | #include <netinet/ip_encap.h> | |
96 | #if defined (__APPLE__) || (defined(__FreeBSD__) && __FreeBSD__ >= 3) || (defined(__NetBSD__) && !defined(TCP6)) || defined(__OpenBSD__) || (defined(__bsdi__) && _BSDI_VERSION >= 199802) | |
97 | #include <netinet/ip.h> | |
98 | #include <netinet/ip_var.h> | |
99 | #endif | |
100 | #if (defined(__NetBSD__) && !defined(TCP6)) || defined(__OpenBSD__) || (defined(__bsdi__) && _BSDI_VERSION >= 199802) | |
101 | #include <netinet/in_pcb.h> | |
102 | #endif | |
103 | #include <netinet/ip6.h> | |
104 | #include <netinet6/ip6_var.h> | |
105 | #include <netinet/icmp6.h> | |
106 | ||
107 | #if defined (__APPLE__) | |
108 | #include <netinet/tcp.h> | |
109 | #include <netinet/tcp_timer.h> | |
110 | #include <netinet/tcp_var.h> | |
111 | #include <netinet/udp.h> | |
112 | #include <netinet/udp_var.h> | |
113 | # if (defined(__FreeBSD__) && __FreeBSD__ >= 4) | |
114 | #include <netinet6/tcp6_var.h> | |
115 | # endif | |
116 | #else | |
117 | #if defined(__NetBSD__) && !defined(TCP6) | |
118 | #include <netinet/tcp.h> | |
119 | #include <netinet/tcp_fsm.h> | |
120 | #include <netinet/tcp_seq.h> | |
121 | #include <netinet/tcp_timer.h> | |
122 | #include <netinet/tcp_var.h> | |
123 | #include <netinet/tcpip.h> | |
124 | #include <netinet/tcp_debug.h> | |
125 | #else | |
126 | #include <netinet6/tcp6.h> | |
127 | #include <netinet6/tcp6_fsm.h> | |
128 | #include <netinet6/tcp6_seq.h> | |
129 | #include <netinet6/tcp6_timer.h> | |
130 | #include <netinet6/tcp6_var.h> | |
131 | #endif | |
132 | #endif | |
133 | ||
134 | #include <netinet6/udp6.h> | |
135 | #include <netinet6/udp6_var.h> | |
136 | ||
137 | #include <netinet6/pim6_var.h> | |
138 | ||
139 | #include <netinet6/nd6.h> | |
140 | #if defined (__APPLE__) | |
141 | #include <netinet6/in6_prefix.h> | |
142 | #endif | |
143 | ||
144 | #if IPSEC | |
145 | #include <netinet6/ipsec.h> | |
146 | #include <netinet6/ah.h> | |
147 | #if IPSEC_ESP | |
148 | #include <netinet6/esp.h> | |
149 | #endif | |
150 | #include <netinet6/ipcomp.h> | |
151 | #endif /*IPSEC*/ | |
152 | ||
153 | #include <netinet6/ip6protosw.h> | |
154 | #include <netinet/tcpip.h> | |
155 | ||
156 | #include "gif.h" | |
157 | #if NGIF > 0 | |
158 | #include <netinet6/in6_gif.h> | |
159 | #endif | |
160 | ||
161 | #if MIP6 | |
162 | #include <netinet6/mip6.h> | |
163 | #endif | |
164 | ||
165 | #include <net/net_osdep.h> | |
166 | ||
167 | #define offsetof(type, member) ((size_t)(&((type *)0)->member)) | |
168 | ||
169 | /* | |
170 | * TCP/IP protocol family: IP6, ICMP6, UDP, TCP. | |
171 | */ | |
172 | ||
173 | extern struct domain inet6domain; | |
174 | #if defined(__FreeBSD__) && __FreeBSD__ >= 3 || defined (__APPLE__) | |
175 | static struct pr_usrreqs nousrreqs; | |
176 | #endif | |
177 | ||
178 | struct ip6protosw inet6sw[] = { | |
179 | { 0, &inet6domain, IPPROTO_IPV6, 0, | |
180 | 0, 0, 0, 0, | |
181 | 0, | |
182 | ip6_init, 0, frag6_slowtimo, frag6_drain, | |
183 | 0, &nousrreqs | |
184 | }, | |
185 | { SOCK_DGRAM, &inet6domain, IPPROTO_UDP, PR_ATOMIC | PR_ADDR, | |
186 | udp6_input, 0, udp6_ctlinput, ip6_ctloutput, | |
187 | 0, | |
188 | 0, 0, 0, 0, | |
189 | 0, &udp6_usrreqs | |
190 | }, | |
191 | { SOCK_STREAM, &inet6domain, IPPROTO_TCP, PR_CONNREQUIRED | PR_WANTRCVD, | |
192 | tcp6_input, 0, tcp6_ctlinput, tcp_ctloutput, | |
193 | 0, | |
194 | tcp_init, 0, 0, tcp_drain, | |
195 | 0, &tcp6_usrreqs | |
196 | }, | |
197 | { SOCK_RAW, &inet6domain, IPPROTO_RAW, PR_ATOMIC | PR_ADDR, | |
198 | rip6_input, rip6_output, rip6_ctlinput, rip6_ctloutput, | |
199 | 0, | |
200 | 0, 0, 0, 0, | |
201 | 0, &rip6_usrreqs | |
202 | }, | |
203 | { SOCK_RAW, &inet6domain, IPPROTO_ICMPV6, PR_ATOMIC | PR_ADDR, | |
204 | icmp6_input, rip6_output, 0, rip6_ctloutput, | |
205 | 0, | |
206 | icmp6_init, icmp6_fasttimo, 0, 0, | |
207 | 0, &rip6_usrreqs | |
208 | }, | |
209 | { SOCK_RAW, &inet6domain, IPPROTO_DSTOPTS,PR_ATOMIC|PR_ADDR, | |
210 | dest6_input, 0, 0, 0, | |
211 | 0, | |
212 | 0, 0, 0, 0, | |
213 | 0, &nousrreqs | |
214 | }, | |
215 | { SOCK_RAW, &inet6domain, IPPROTO_ROUTING,PR_ATOMIC|PR_ADDR, | |
216 | route6_input, 0, 0, 0, | |
217 | 0, | |
218 | 0, 0, 0, 0, | |
219 | 0, &nousrreqs | |
220 | }, | |
221 | { SOCK_RAW, &inet6domain, IPPROTO_FRAGMENT,PR_ATOMIC|PR_ADDR, | |
222 | frag6_input, 0, 0, 0, | |
223 | 0, | |
224 | 0, 0, 0, 0, | |
225 | 0, &nousrreqs | |
226 | }, | |
227 | #if IPSEC | |
228 | { SOCK_RAW, &inet6domain, IPPROTO_AH, PR_ATOMIC|PR_ADDR, | |
229 | ah6_input, 0, 0, 0, | |
230 | 0, | |
231 | 0, 0, 0, 0, | |
232 | 0, &nousrreqs | |
233 | }, | |
234 | #if IPSEC_ESP | |
235 | { SOCK_RAW, &inet6domain, IPPROTO_ESP, PR_ATOMIC|PR_ADDR, | |
236 | esp6_input, 0, 0, 0, | |
237 | 0, | |
238 | 0, 0, 0, 0, | |
239 | 0, &nousrreqs | |
240 | }, | |
241 | #endif | |
242 | { SOCK_RAW, &inet6domain, IPPROTO_IPCOMP, PR_ATOMIC|PR_ADDR, | |
243 | ipcomp6_input, 0, 0, 0, | |
244 | 0, | |
245 | 0, 0, 0, 0, | |
246 | 0, &nousrreqs | |
247 | }, | |
248 | #endif /* IPSEC */ | |
249 | { SOCK_RAW, &inet6domain, IPPROTO_IPV4, PR_ATOMIC|PR_ADDR, | |
250 | encap6_input, rip6_output, 0, rip6_ctloutput, | |
251 | 0, | |
252 | 0, 0, 0, 0, | |
253 | 0, &nousrreqs | |
254 | }, | |
255 | #if INET6 | |
256 | { SOCK_RAW, &inet6domain, IPPROTO_IPV6, PR_ATOMIC|PR_ADDR, | |
257 | encap6_input, rip6_output, 0, rip6_ctloutput, | |
258 | 0, | |
259 | 0, 0, 0, 0, | |
260 | 0, &rip6_usrreqs | |
261 | }, | |
262 | #endif /*INET6*/ | |
263 | { SOCK_RAW, &inet6domain, IPPROTO_PIM, PR_ATOMIC|PR_ADDR, | |
264 | pim6_input, rip6_output, 0, rip6_ctloutput, | |
265 | 0, | |
266 | 0, 0, 0, 0, | |
267 | 0, &rip6_usrreqs | |
268 | }, | |
269 | /* raw wildcard */ | |
270 | { SOCK_RAW, &inet6domain, 0, PR_ATOMIC | PR_ADDR, | |
271 | rip6_input, rip6_output, 0, rip6_ctloutput, | |
272 | 0, | |
273 | 0, 0, 0, 0, | |
274 | 0, &rip6_usrreqs | |
275 | }, | |
276 | }; | |
277 | ||
278 | #if NGIF > 0 | |
279 | struct ip6protosw in6_gif_protosw = | |
280 | { SOCK_RAW, &inet6domain, 0/*IPPROTO_IPV[46]*/, PR_ATOMIC|PR_ADDR, | |
281 | in6_gif_input, rip6_output, 0, rip6_ctloutput, | |
282 | 0, | |
283 | 0, 0, 0, 0, | |
284 | 0, &rip6_usrreqs | |
285 | }; | |
286 | #endif /*NGIF*/ | |
287 | ||
288 | #if MIP6 | |
289 | struct ip6protosw mip6_tunnel_protosw = | |
290 | { SOCK_RAW, &inet6domain, 0/*IPPROTO_IPV[46]*/, PR_ATOMIC|PR_ADDR, | |
291 | mip6_tunnel_input, rip6_output, 0, rip6_ctloutput, | |
292 | 0, | |
293 | 0, 0, 0, 0, | |
294 | 0, &rip6_usrreqs | |
295 | }; | |
296 | #endif /* MIP6 */ | |
297 | ||
298 | extern int in6_inithead __P((void **, int)); | |
299 | int in6_proto_count = (sizeof (inet6sw) / sizeof (struct ip6protosw)); | |
300 | extern void in6_dinit(void); | |
301 | ||
302 | struct domain inet6domain = | |
303 | { AF_INET6, "internet6", in6_dinit, 0, 0, | |
304 | inet6sw, 0, | |
305 | in6_inithead, offsetof(struct sockaddr_in6, sin6_addr) << 3, sizeof(struct sockaddr_in6) , | |
306 | sizeof(struct sockaddr_in6), 0 | |
307 | }; | |
308 | ||
309 | DOMAIN_SET(inet6); | |
310 | ||
311 | /* | |
312 | * Internet configuration info | |
313 | */ | |
314 | #ifndef IPV6FORWARDING | |
315 | #if GATEWAY6 | |
316 | #define IPV6FORWARDING 1 /* forward IP6 packets not for us */ | |
317 | #else | |
318 | #define IPV6FORWARDING 0 /* don't forward IP6 packets not for us */ | |
319 | #endif /* GATEWAY6 */ | |
320 | #endif /* !IPV6FORWARDING */ | |
321 | ||
322 | #ifndef IPV6_SENDREDIRECTS | |
323 | #define IPV6_SENDREDIRECTS 1 | |
324 | #endif | |
325 | ||
326 | int ip6_forwarding = IPV6FORWARDING; /* act as router? */ | |
327 | int ip6_sendredirects = IPV6_SENDREDIRECTS; | |
328 | int ip6_defhlim = IPV6_DEFHLIM; | |
329 | int ip6_defmcasthlim = IPV6_DEFAULT_MULTICAST_HOPS; | |
330 | int ip6_accept_rtadv = 0; /* "IPV6FORWARDING ? 0 : 1" is dangerous */ | |
331 | int ip6_maxfragpackets = 200; | |
332 | int ip6_log_interval = 5; | |
333 | int ip6_hdrnestlimit = 50; /* appropriate? */ | |
334 | int ip6_dad_count = 1; /* DupAddrDetectionTransmits */ | |
335 | u_int32_t ip6_flow_seq; | |
336 | int ip6_auto_flowlabel = 1; | |
337 | #if NGIF > 0 | |
338 | int ip6_gif_hlim = GIF_HLIM; | |
339 | #else | |
340 | int ip6_gif_hlim = 0; | |
341 | #endif | |
342 | int ip6_use_deprecated = 1; /* allow deprecated addr (RFC2462 5.5.4) */ | |
343 | int ip6_rr_prune = 5; /* router renumbering prefix | |
344 | * walk list every 5 sec. */ | |
345 | #if MAPPED_ADDR_ENABLED | |
346 | int ip6_mapped_addr_on = 1; | |
347 | #endif /* MAPPED_ADDR_ENABLED */ | |
348 | ||
349 | u_int32_t ip6_id = 0UL; | |
350 | int ip6_keepfaith = 0; | |
351 | time_t ip6_log_time = (time_t)0L; | |
352 | ||
353 | /* icmp6 */ | |
354 | #ifndef __bsdi__ | |
355 | /* | |
356 | * BSDI4 defines these variables in in_proto.c... | |
357 | * XXX: what if we don't define INET? Should we define pmtu6_expire | |
358 | * or so? (jinmei@kame.net 19990310) | |
359 | */ | |
360 | int pmtu_expire = 60*10; | |
361 | int pmtu_probe = 60*2; | |
362 | #endif | |
363 | ||
364 | /* raw IP6 parameters */ | |
365 | /* | |
366 | * Nominal space allocated to a raw ip socket. | |
367 | */ | |
368 | #define RIPV6SNDQ 8192 | |
369 | #define RIPV6RCVQ 8192 | |
370 | ||
371 | u_long rip6_sendspace = RIPV6SNDQ; | |
372 | u_long rip6_recvspace = RIPV6RCVQ; | |
373 | ||
374 | /* ICMPV6 parameters */ | |
375 | int icmp6_rediraccept = 1; /* accept and process redirects */ | |
376 | int icmp6_redirtimeout = 10 * 60; /* 10 minutes */ | |
377 | u_int icmp6errratelim = 1000; /* 1000usec = 1msec */ | |
378 | int icmp6_nodeinfo = 1; /* enable/disable NI response */ | |
379 | ||
380 | #if TCP6 | |
381 | /* TCP on IP6 parameters */ | |
382 | int tcp6_sendspace = 1024 * 8; | |
383 | int tcp6_recvspace = 1024 * 8; | |
384 | int tcp6_mssdflt = TCP6_MSS; | |
385 | int tcp6_rttdflt = TCP6TV_SRTTDFLT / PR_SLOWHZ; | |
386 | int tcp6_do_rfc1323 = 1; | |
387 | int tcp6_conntimeo = TCP6TV_KEEP_INIT; /* initial connection timeout */ | |
388 | int tcp6_43maxseg = 0; | |
389 | int tcp6_pmtu = 0; | |
390 | ||
391 | /* | |
392 | * Parameters for keepalive option. | |
393 | * Connections for which SO_KEEPALIVE is set will be probed | |
394 | * after being idle for a time of tcp6_keepidle (in units of PR_SLOWHZ). | |
395 | * Starting at that time, the connection is probed at intervals | |
396 | * of tcp6_keepintvl (same units) until a response is received | |
397 | * or until tcp6_keepcnt probes have been made, at which time | |
398 | * the connection is dropped. Note that a tcp6_keepidle value | |
399 | * under 2 hours is nonconformant with RFC-1122, Internet Host Requirements. | |
400 | */ | |
401 | int tcp6_keepidle = TCP6TV_KEEP_IDLE; /* time before probing idle */ | |
402 | int tcp6_keepintvl = TCP6TV_KEEPINTVL; /* interval betwn idle probes */ | |
403 | int tcp6_keepcnt = TCP6TV_KEEPCNT; /* max idle probes */ | |
404 | int tcp6_maxpersistidle = TCP6TV_KEEP_IDLE; /* max idle time in persist */ | |
405 | ||
406 | #ifndef INET_SERVER | |
407 | #define TCP6_LISTEN_HASH_SIZE 17 | |
408 | #define TCP6_CONN_HASH_SIZE 97 | |
409 | #define TCP6_SYN_HASH_SIZE 293 | |
410 | #define TCP6_SYN_BUCKET_SIZE 35 | |
411 | #else | |
412 | #define TCP6_LISTEN_HASH_SIZE 97 | |
413 | #define TCP6_CONN_HASH_SIZE 9973 | |
414 | #define TCP6_SYN_HASH_SIZE 997 | |
415 | #define TCP6_SYN_BUCKET_SIZE 35 | |
416 | #endif | |
417 | int tcp6_listen_hash_size = TCP6_LISTEN_HASH_SIZE; | |
418 | int tcp6_conn_hash_size = TCP6_CONN_HASH_SIZE; | |
419 | struct tcp6_hash_list tcp6_listen_hash[TCP6_LISTEN_HASH_SIZE], | |
420 | tcp6_conn_hash[TCP6_CONN_HASH_SIZE]; | |
421 | ||
422 | int tcp6_syn_cache_size = TCP6_SYN_HASH_SIZE; | |
423 | int tcp6_syn_cache_limit = TCP6_SYN_HASH_SIZE*TCP6_SYN_BUCKET_SIZE; | |
424 | int tcp6_syn_bucket_limit = 3*TCP6_SYN_BUCKET_SIZE; | |
425 | struct syn_cache_head6 tcp6_syn_cache[TCP6_SYN_HASH_SIZE]; | |
426 | struct syn_cache_head6 *tcp6_syn_cache_first; | |
427 | int tcp6_syn_cache_interval = 8; /* runs timer every 4 seconds */ | |
428 | int tcp6_syn_cache_timeo = TCP6TV_KEEP_INIT; | |
429 | ||
430 | /* | |
431 | * Parameters for computing a desirable data segment size | |
432 | * given an upper bound (either interface MTU, or peer's MSS option)_. | |
433 | * As applications tend to use a buffer size that is a multiple | |
434 | * of kilobytes, try for something that divides evenly. However, | |
435 | * do not round down too much. | |
436 | * | |
437 | * Round segment size down to a multiple of TCP6_ROUNDSIZE if this | |
438 | * does not result in lowering by more than (size/TCP6_ROUNDFRAC). | |
439 | * For example, round 536 to 512. Older versions of the system | |
440 | * effectively used MCLBYTES (1K or 2K) as TCP6_ROUNDSIZE, with | |
441 | * a value of 1 for TCP6_ROUNDFRAC (eliminating its effect). | |
442 | * We round to a multiple of 256 for SLIP. | |
443 | */ | |
444 | #ifndef TCP6_ROUNDSIZE | |
445 | #define TCP6_ROUNDSIZE 256 /* round to multiple of 256 */ | |
446 | #endif | |
447 | #ifndef TCP6_ROUNDFRAC | |
448 | #define TCP6_ROUNDFRAC 10 /* round down at most N/10, or 10% */ | |
449 | #endif | |
450 | ||
451 | int tcp6_roundsize = TCP6_ROUNDSIZE; | |
452 | int tcp6_roundfrac = TCP6_ROUNDFRAC; | |
453 | #endif /*TCP6*/ | |
454 | ||
455 | /* UDP on IP6 parameters */ | |
456 | int udp6_sendspace = 9216; /* really max datagram size */ | |
457 | int udp6_recvspace = 40 * (1024 + sizeof(struct sockaddr_in6)); | |
458 | /* 40 1K datagrams */ | |
459 | ||
460 | #if defined(__FreeBSD__) || defined(__APPLE__) | |
461 | /* | |
462 | * sysctl related items. | |
463 | */ | |
464 | SYSCTL_NODE(_net, PF_INET6, inet6, CTLFLAG_RW, 0, | |
465 | "Internet6 Family"); | |
466 | ||
467 | /* net.inet6 */ | |
468 | SYSCTL_NODE(_net_inet6, IPPROTO_IPV6, ip6, CTLFLAG_RW, 0, "IP6"); | |
469 | SYSCTL_NODE(_net_inet6, IPPROTO_ICMPV6, icmp6, CTLFLAG_RW, 0, "ICMP6"); | |
470 | SYSCTL_NODE(_net_inet6, IPPROTO_UDP, udp6, CTLFLAG_RW, 0, "UDP6"); | |
471 | SYSCTL_NODE(_net_inet6, IPPROTO_TCP, tcp6, CTLFLAG_RW, 0, "TCP6"); | |
472 | #if IPSEC | |
473 | SYSCTL_NODE(_net_inet6, IPPROTO_ESP, ipsec6, CTLFLAG_RW, 0, "IPSEC6"); | |
474 | #endif /* IPSEC */ | |
475 | ||
476 | /* net.inet6.ip6 */ | |
477 | static int | |
478 | sysctl_ip6_forwarding SYSCTL_HANDLER_ARGS | |
479 | { | |
480 | int error = 0; | |
481 | int old_ip6_forwarding; | |
482 | int changed; | |
483 | ||
484 | error = SYSCTL_OUT(req, arg1, sizeof(int)); | |
485 | if (error || !req->newptr) | |
486 | return (error); | |
487 | old_ip6_forwarding = ip6_forwarding; | |
488 | error = SYSCTL_IN(req, arg1, sizeof(int)); | |
489 | if (error != 0) | |
490 | return (error); | |
491 | changed = (ip6_forwarding ? 1 : 0) ^ (old_ip6_forwarding ? 1 : 0); | |
492 | if (changed == 0) | |
493 | return (error); | |
494 | /* | |
495 | * XXX while host->router removes prefix got from RA, | |
496 | * router->host case nukes all the prefixes managed by in6_prefix.c | |
497 | * (both RR and static). therefore, switching from host->router->host | |
498 | * will remove statically configured addresses/prefixes. | |
499 | * not sure if it is intended behavior or not. | |
500 | */ | |
501 | if (ip6_forwarding != 0) { /* host becomes router */ | |
502 | int s = splnet(); | |
503 | struct nd_prefix *pr, *next; | |
504 | ||
505 | for (pr = nd_prefix.lh_first; pr; pr = next) { | |
506 | next = pr->ndpr_next; | |
507 | if (!IN6_IS_ADDR_UNSPECIFIED(&pr->ndpr_addr)) | |
508 | in6_ifdel(pr->ndpr_ifp, &pr->ndpr_addr); | |
509 | prelist_remove(pr); | |
510 | } | |
511 | splx(s); | |
512 | } else { /* router becomes host */ | |
513 | while(!LIST_EMPTY(&rr_prefix)) | |
514 | delete_each_prefix(LIST_FIRST(&rr_prefix), | |
515 | PR_ORIG_KERNEL); | |
516 | } | |
517 | ||
518 | return (error); | |
519 | } | |
520 | ||
521 | SYSCTL_OID(_net_inet6_ip6, IPV6CTL_FORWARDING, forwarding, | |
522 | CTLTYPE_INT|CTLFLAG_RW, &ip6_forwarding, 0, sysctl_ip6_forwarding, | |
523 | "I", ""); | |
524 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_SENDREDIRECTS, | |
525 | redirect, CTLFLAG_RW, &ip6_sendredirects, 0, ""); | |
526 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFHLIM, | |
527 | hlim, CTLFLAG_RW, &ip6_defhlim, 0, ""); | |
528 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGPACKETS, | |
529 | maxfragpackets, CTLFLAG_RW, &ip6_maxfragpackets, 0, ""); | |
530 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_ACCEPT_RTADV, | |
531 | accept_rtadv, CTLFLAG_RW, &ip6_accept_rtadv, 0, ""); | |
532 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_KEEPFAITH, | |
533 | keepfaith, CTLFLAG_RW, &ip6_keepfaith, 0, ""); | |
534 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_LOG_INTERVAL, | |
535 | log_interval, CTLFLAG_RW, &ip6_log_interval, 0, ""); | |
536 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_HDRNESTLIMIT, | |
537 | hdrnestlimit, CTLFLAG_RW, &ip6_hdrnestlimit, 0, ""); | |
538 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DAD_COUNT, | |
539 | dad_count, CTLFLAG_RW, &ip6_dad_count, 0, ""); | |
540 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_AUTO_FLOWLABEL, | |
541 | auto_flowlabel, CTLFLAG_RW, &ip6_auto_flowlabel, 0, ""); | |
542 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFMCASTHLIM, | |
543 | defmcasthlim, CTLFLAG_RW, &ip6_defmcasthlim, 0, ""); | |
544 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_GIF_HLIM, | |
545 | gifhlim, CTLFLAG_RW, &ip6_gif_hlim, 0, ""); | |
546 | SYSCTL_STRING(_net_inet6_ip6, IPV6CTL_KAME_VERSION, | |
547 | kame_version, CTLFLAG_RD, __KAME_VERSION, 0, ""); | |
548 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_USE_DEPRECATED, | |
549 | use_deprecated, CTLFLAG_RW, &ip6_use_deprecated, 0, ""); | |
550 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_RR_PRUNE, | |
551 | rr_prune, CTLFLAG_RW, &ip6_rr_prune, 0, ""); | |
552 | #if MAPPED_ADDR_ENABLED | |
553 | SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAPPED_ADDR, | |
554 | mapped_addr, CTLFLAG_RW, &ip6_mapped_addr_on, 0, ""); | |
555 | #endif /* MAPPED_ADDR_ENABLED */ | |
556 | ||
557 | /* net.inet6.icmp6 */ | |
558 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT, | |
559 | rediraccept, CTLFLAG_RW, &icmp6_rediraccept, 0, ""); | |
560 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT, | |
561 | redirtimeout, CTLFLAG_RW, &icmp6_redirtimeout, 0, ""); | |
562 | SYSCTL_STRUCT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats, CTLFLAG_RD, | |
563 | &icmp6stat, icmp6stat, ""); | |
564 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ERRRATELIMIT, | |
565 | errratelimit, CTLFLAG_RW, &icmp6errratelim, 0, ""); | |
566 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE, | |
567 | nd6_prune, CTLFLAG_RW, &nd6_prune, 0, ""); | |
568 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DELAY, | |
569 | nd6_delay, CTLFLAG_RW, &nd6_delay, 0, ""); | |
570 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_UMAXTRIES, | |
571 | nd6_umaxtries, CTLFLAG_RW, &nd6_umaxtries, 0, ""); | |
572 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MMAXTRIES, | |
573 | nd6_mmaxtries, CTLFLAG_RW, &nd6_mmaxtries, 0, ""); | |
574 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_USELOOPBACK, | |
575 | nd6_useloopback, CTLFLAG_RW, &nd6_useloopback, 0, ""); | |
576 | //SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PROXYALL, | |
577 | // nd6_proxyall, CTLFLAG_RW, &nd6_proxyall, 0, ""); | |
578 | SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO, | |
579 | nodeinfo, CTLFLAG_RW, &icmp6_nodeinfo, 0, ""); | |
580 | ||
581 | ||
582 | #if defined(__FreeBSD__) && __FreeBSD__ < 3 | |
583 | /* net.inet6.udp6 */ | |
584 | SYSCTL_INT(_net_inet6_udp6, UDP6CTL_SENDMAX, | |
585 | sendmax, CTLFLAG_RW, &udp6_sendspace, 0, ""); | |
586 | SYSCTL_INT(_net_inet6_udp6, UDP6CTL_RECVSPACE, | |
587 | recvspace, CTLFLAG_RW, &udp6_recvspace, 0, ""); | |
588 | ||
589 | /* net.inet6.tcp6 */ | |
590 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_MSSDFLT, | |
591 | mssdflt, CTLFLAG_RW, &tcp6_mssdflt, 0, ""); | |
592 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_DO_RFC1323, | |
593 | do_rfc1323, CTLFLAG_RW, &tcp6_do_rfc1323, 0, ""); | |
594 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_KEEPIDLE, | |
595 | keepidle, CTLFLAG_RW, &tcp6_keepidle, 0, ""); | |
596 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_KEEPINTVL, | |
597 | keepintvl, CTLFLAG_RW, &tcp6_keepintvl, 0, ""); | |
598 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_KEEPCNT, | |
599 | keepcnt, CTLFLAG_RW, &tcp6_keepcnt, 0, ""); | |
600 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_MAXPERSISTIDLE, | |
601 | maxpersistidle, CTLFLAG_RW, &tcp6_maxpersistidle, 0, ""); | |
602 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_SENDSPACE, | |
603 | sendspace, CTLFLAG_RW, &tcp6_sendspace, 0, ""); | |
604 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_RECVSPACE, | |
605 | recvspace, CTLFLAG_RW, &tcp6_recvspace, 0, ""); | |
606 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_CONNTIMEO, | |
607 | conntimeo, CTLFLAG_RW, &tcp6_conntimeo, 0, ""); | |
608 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_PMTU, | |
609 | pmtu, CTLFLAG_RW, &tcp6_pmtu, 0, ""); | |
610 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_PMTU_EXPIRE, | |
611 | pmtu_expire, CTLFLAG_RW, &pmtu_expire, 0, ""); | |
612 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_PMTU_PROBE, | |
613 | pmtu_probe, CTLFLAG_RW, &pmtu_probe, 0, ""); | |
614 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_43MAXSEG, | |
615 | pmtu_43maxseg, CTLFLAG_RW, &tcp6_43maxseg, 0, ""); | |
616 | SYSCTL_STRUCT(_net_inet6_tcp6, TCP6CTL_STATS, stats, CTLFLAG_RD, | |
617 | &tcp6stat, tcp6stat, ""); | |
618 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_SYN_CACHE_LIMIT, | |
619 | syn_cache_limit, CTLFLAG_RW, &tcp6_syn_cache_limit, 0, ""); | |
620 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_SYN_BUCKET_LIMIT, | |
621 | syn_bucket_limit, CTLFLAG_RW, &tcp6_syn_bucket_limit, 0, ""); | |
622 | SYSCTL_INT(_net_inet6_tcp6, TCP6CTL_SYN_CACHE_INTER, | |
623 | syn_cache_interval, CTLFLAG_RW, &tcp6_syn_cache_interval, 0, ""); | |
624 | #endif /* !(defined(__FreeBSD__) && __FreeBSD__ >= 3) */ | |
625 | ||
626 | #endif /* __FreeBSD__ */ |