in6_proto.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. /*-
  2. * SPDX-License-Identifier: BSD-3-Clause
  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. * $KAME: in6_proto.c,v 1.91 2001/05/27 13:28:35 itojun Exp $
  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. #include <sys/cdefs.h>
  64. __FBSDID("$FreeBSD$");
  65. #include "opt_inet.h"
  66. #include "opt_inet6.h"
  67. #include "opt_ipsec.h"
  68. #include "opt_ipstealth.h"
  69. #include "opt_sctp.h"
  70. #include "opt_route.h"
  71. #include <sys/param.h>
  72. #include <sys/socket.h>
  73. #include <sys/socketvar.h>
  74. #include <sys/proc.h>
  75. #include <sys/protosw.h>
  76. #include <sys/jail.h>
  77. #include <sys/kernel.h>
  78. #include <sys/malloc.h>
  79. #include <sys/domain.h>
  80. #include <sys/mbuf.h>
  81. #include <sys/systm.h>
  82. #include <sys/sysctl.h>
  83. #include <net/if.h>
  84. #include <net/if_var.h>
  85. #include <net/radix.h>
  86. #include <net/route.h>
  87. #include <netinet/in.h>
  88. #include <netinet/in_systm.h>
  89. #include <netinet/in_var.h>
  90. #include <netinet/ip_encap.h>
  91. #include <netinet/ip.h>
  92. #include <netinet/ip_var.h>
  93. #include <netinet/ip6.h>
  94. #include <netinet6/ip6_var.h>
  95. #include <netinet/icmp6.h>
  96. #include <netinet/tcp.h>
  97. #include <netinet/tcp_timer.h>
  98. #include <netinet/tcp_var.h>
  99. #include <netinet/udp.h>
  100. #include <netinet/udp_var.h>
  101. #include <netinet6/tcp6_var.h>
  102. #include <netinet6/raw_ip6.h>
  103. #include <netinet6/udp6_var.h>
  104. #include <netinet6/pim6_var.h>
  105. #include <netinet6/nd6.h>
  106. #ifdef SCTP
  107. #include <netinet/in_pcb.h>
  108. #include <netinet/sctp_pcb.h>
  109. #include <netinet/sctp.h>
  110. #include <netinet/sctp_var.h>
  111. #include <netinet6/sctp6_var.h>
  112. #endif /* SCTP */
  113. #include <netinet6/ip6protosw.h>
  114. /*
  115. * TCP/IP protocol family: IP6, ICMP6, UDP, TCP.
  116. */
  117. FEATURE(inet6, "Internet Protocol version 6");
  118. extern struct domain inet6domain;
  119. static struct pr_usrreqs nousrreqs;
  120. #define PR_LISTEN 0
  121. #define PR_ABRTACPTDIS 0
  122. /* Spacer for loadable protocols. */
  123. #define IP6PROTOSPACER \
  124. { \
  125. .pr_domain = &inet6domain, \
  126. .pr_protocol = PROTO_SPACER, \
  127. .pr_usrreqs = &nousrreqs \
  128. }
  129. struct protosw inet6sw[] = {
  130. {
  131. .pr_type = 0,
  132. .pr_domain = &inet6domain,
  133. .pr_protocol = IPPROTO_IPV6,
  134. .pr_init = ip6_init,
  135. .pr_slowtimo = frag6_slowtimo,
  136. .pr_drain = frag6_drain,
  137. .pr_usrreqs = &nousrreqs,
  138. },
  139. {
  140. .pr_type = SOCK_DGRAM,
  141. .pr_domain = &inet6domain,
  142. .pr_protocol = IPPROTO_UDP,
  143. .pr_flags = PR_ATOMIC|PR_ADDR,
  144. .pr_input = udp6_input,
  145. .pr_ctlinput = udp6_ctlinput,
  146. .pr_ctloutput = ip6_ctloutput,
  147. #ifndef INET /* Do not call initialization twice. */
  148. .pr_init = udp_init,
  149. #endif
  150. .pr_usrreqs = &udp6_usrreqs,
  151. },
  152. {
  153. .pr_type = SOCK_STREAM,
  154. .pr_domain = &inet6domain,
  155. .pr_protocol = IPPROTO_TCP,
  156. .pr_flags = PR_CONNREQUIRED|PR_IMPLOPCL|PR_WANTRCVD|PR_LISTEN,
  157. .pr_input = tcp6_input,
  158. .pr_ctlinput = tcp6_ctlinput,
  159. .pr_ctloutput = tcp_ctloutput,
  160. #ifndef INET /* don't call initialization, timeout, and drain routines twice */
  161. .pr_init = tcp_init,
  162. .pr_slowtimo = tcp_slowtimo,
  163. .pr_drain = tcp_drain,
  164. #endif
  165. .pr_usrreqs = &tcp6_usrreqs,
  166. },
  167. #ifdef SCTP
  168. {
  169. .pr_type = SOCK_SEQPACKET,
  170. .pr_domain = &inet6domain,
  171. .pr_protocol = IPPROTO_SCTP,
  172. .pr_flags = PR_WANTRCVD|PR_LASTHDR,
  173. .pr_input = sctp6_input,
  174. .pr_ctlinput = sctp6_ctlinput,
  175. .pr_ctloutput = sctp_ctloutput,
  176. #ifndef INET /* Do not call initialization and drain routines twice. */
  177. .pr_drain = sctp_drain,
  178. .pr_init = sctp_init,
  179. #endif
  180. .pr_usrreqs = &sctp6_usrreqs
  181. },
  182. {
  183. .pr_type = SOCK_STREAM,
  184. .pr_domain = &inet6domain,
  185. .pr_protocol = IPPROTO_SCTP,
  186. .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LASTHDR,
  187. .pr_input = sctp6_input,
  188. .pr_ctlinput = sctp6_ctlinput,
  189. .pr_ctloutput = sctp_ctloutput,
  190. .pr_drain = NULL, /* Covered by the SOCK_SEQPACKET entry. */
  191. .pr_usrreqs = &sctp6_usrreqs
  192. },
  193. #endif /* SCTP */
  194. {
  195. .pr_type = SOCK_DGRAM,
  196. .pr_domain = &inet6domain,
  197. .pr_protocol = IPPROTO_UDPLITE,
  198. .pr_flags = PR_ATOMIC|PR_ADDR,
  199. .pr_input = udp6_input,
  200. .pr_ctlinput = udplite6_ctlinput,
  201. .pr_ctloutput = udp_ctloutput,
  202. #ifndef INET /* Do not call initialization twice. */
  203. .pr_init = udplite_init,
  204. #endif
  205. .pr_usrreqs = &udp6_usrreqs,
  206. },
  207. {
  208. .pr_type = SOCK_RAW,
  209. .pr_domain = &inet6domain,
  210. .pr_protocol = IPPROTO_RAW,
  211. .pr_flags = PR_ATOMIC|PR_ADDR,
  212. .pr_input = rip6_input,
  213. .pr_output = rip6_output,
  214. .pr_ctlinput = rip6_ctlinput,
  215. .pr_ctloutput = rip6_ctloutput,
  216. #ifndef INET /* Do not call initialization twice. */
  217. .pr_init = rip_init,
  218. #endif
  219. .pr_usrreqs = &rip6_usrreqs
  220. },
  221. {
  222. .pr_type = SOCK_RAW,
  223. .pr_domain = &inet6domain,
  224. .pr_protocol = IPPROTO_ICMPV6,
  225. .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  226. .pr_input = icmp6_input,
  227. .pr_output = rip6_output,
  228. .pr_ctlinput = rip6_ctlinput,
  229. .pr_ctloutput = rip6_ctloutput,
  230. .pr_fasttimo = icmp6_fasttimo,
  231. .pr_slowtimo = icmp6_slowtimo,
  232. .pr_usrreqs = &rip6_usrreqs
  233. },
  234. {
  235. .pr_type = SOCK_RAW,
  236. .pr_domain = &inet6domain,
  237. .pr_protocol = IPPROTO_DSTOPTS,
  238. .pr_flags = PR_ATOMIC|PR_ADDR,
  239. .pr_input = dest6_input,
  240. .pr_usrreqs = &nousrreqs
  241. },
  242. {
  243. .pr_type = SOCK_RAW,
  244. .pr_domain = &inet6domain,
  245. .pr_protocol = IPPROTO_ROUTING,
  246. .pr_flags = PR_ATOMIC|PR_ADDR,
  247. .pr_input = route6_input,
  248. .pr_usrreqs = &nousrreqs
  249. },
  250. {
  251. .pr_type = SOCK_RAW,
  252. .pr_domain = &inet6domain,
  253. .pr_protocol = IPPROTO_FRAGMENT,
  254. .pr_flags = PR_ATOMIC|PR_ADDR,
  255. .pr_input = frag6_input,
  256. .pr_usrreqs = &nousrreqs
  257. },
  258. #ifdef INET
  259. {
  260. .pr_type = SOCK_RAW,
  261. .pr_domain = &inet6domain,
  262. .pr_protocol = IPPROTO_IPV4,
  263. .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  264. .pr_input = encap6_input,
  265. .pr_output = rip6_output,
  266. .pr_ctloutput = rip6_ctloutput,
  267. .pr_usrreqs = &rip6_usrreqs
  268. },
  269. #endif /* INET */
  270. {
  271. .pr_type = SOCK_RAW,
  272. .pr_domain = &inet6domain,
  273. .pr_protocol = IPPROTO_IPV6,
  274. .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  275. .pr_input = encap6_input,
  276. .pr_output = rip6_output,
  277. .pr_ctloutput = rip6_ctloutput,
  278. .pr_usrreqs = &rip6_usrreqs
  279. },
  280. {
  281. .pr_type = SOCK_RAW,
  282. .pr_domain = &inet6domain,
  283. .pr_protocol = IPPROTO_GRE,
  284. .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  285. .pr_input = encap6_input,
  286. .pr_output = rip6_output,
  287. .pr_ctloutput = rip6_ctloutput,
  288. .pr_usrreqs = &rip6_usrreqs
  289. },
  290. {
  291. .pr_type = SOCK_RAW,
  292. .pr_domain = &inet6domain,
  293. .pr_protocol = IPPROTO_PIM,
  294. .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  295. .pr_input = encap6_input,
  296. .pr_output = rip6_output,
  297. .pr_ctloutput = rip6_ctloutput,
  298. .pr_usrreqs = &rip6_usrreqs
  299. },
  300. /* Spacer n-times for loadable protocols. */
  301. IP6PROTOSPACER,
  302. IP6PROTOSPACER,
  303. IP6PROTOSPACER,
  304. IP6PROTOSPACER,
  305. IP6PROTOSPACER,
  306. IP6PROTOSPACER,
  307. IP6PROTOSPACER,
  308. IP6PROTOSPACER,
  309. /* raw wildcard */
  310. {
  311. .pr_type = SOCK_RAW,
  312. .pr_domain = &inet6domain,
  313. .pr_flags = PR_ATOMIC|PR_ADDR,
  314. .pr_input = rip6_input,
  315. .pr_output = rip6_output,
  316. .pr_ctloutput = rip6_ctloutput,
  317. .pr_usrreqs = &rip6_usrreqs
  318. },
  319. };
  320. struct domain inet6domain = {
  321. .dom_family = AF_INET6,
  322. .dom_name = "internet6",
  323. .dom_protosw = (struct protosw *)inet6sw,
  324. .dom_protoswNPROTOSW = (struct protosw *)&inet6sw[nitems(inet6sw)],
  325. .dom_rtattach = in6_inithead,
  326. #ifdef VIMAGE
  327. .dom_rtdetach = in6_detachhead,
  328. #endif
  329. .dom_ifattach = in6_domifattach,
  330. .dom_ifdetach = in6_domifdetach,
  331. .dom_ifmtu = in6_domifmtu
  332. };
  333. VNET_DOMAIN_SET(inet6);
  334. /*
  335. * Internet configuration info
  336. */
  337. #ifndef IPV6FORWARDING
  338. #ifdef GATEWAY6
  339. #define IPV6FORWARDING 1 /* forward IP6 packets not for us */
  340. #else
  341. #define IPV6FORWARDING 0 /* don't forward IP6 packets not for us */
  342. #endif /* GATEWAY6 */
  343. #endif /* !IPV6FORWARDING */
  344. #ifndef IPV6_SENDREDIRECTS
  345. #define IPV6_SENDREDIRECTS 1
  346. #endif
  347. VNET_DEFINE(int, ip6_forwarding) = IPV6FORWARDING; /* act as router? */
  348. VNET_DEFINE(int, ip6_sendredirects) = IPV6_SENDREDIRECTS;
  349. VNET_DEFINE(int, ip6_defhlim) = IPV6_DEFHLIM;
  350. VNET_DEFINE(int, ip6_defmcasthlim) = IPV6_DEFAULT_MULTICAST_HOPS;
  351. VNET_DEFINE(int, ip6_accept_rtadv) = 0;
  352. VNET_DEFINE(int, ip6_no_radr) = 0;
  353. VNET_DEFINE(int, ip6_norbit_raif) = 0;
  354. VNET_DEFINE(int, ip6_rfc6204w3) = 0;
  355. VNET_DEFINE(int, ip6_log_interval) = 5;
  356. VNET_DEFINE(int, ip6_hdrnestlimit) = 15;/* How many header options will we
  357. * process? */
  358. VNET_DEFINE(int, ip6_dad_count) = 1; /* DupAddrDetectionTransmits */
  359. VNET_DEFINE(int, ip6_auto_flowlabel) = 1;
  360. VNET_DEFINE(int, ip6_use_deprecated) = 1;/* allow deprecated addr
  361. * (RFC2462 5.5.4) */
  362. VNET_DEFINE(int, ip6_rr_prune) = 5; /* router renumbering prefix
  363. * walk list every 5 sec. */
  364. VNET_DEFINE(int, ip6_mcast_pmtu) = 0; /* enable pMTU discovery for multicast? */
  365. VNET_DEFINE(int, ip6_v6only) = 1;
  366. VNET_DEFINE(time_t, ip6_log_time) = (time_t)0L;
  367. #ifdef IPSTEALTH
  368. VNET_DEFINE(int, ip6stealth) = 0;
  369. #endif
  370. VNET_DEFINE(int, nd6_onlink_ns_rfc4861) = 0;/* allow 'on-link' nd6 NS
  371. * (RFC 4861) */
  372. /* icmp6 */
  373. /*
  374. * BSDI4 defines these variables in in_proto.c...
  375. * XXX: what if we don't define INET? Should we define pmtu6_expire
  376. * or so? (jinmei@kame.net 19990310)
  377. */
  378. VNET_DEFINE(int, pmtu_expire) = 60*10;
  379. VNET_DEFINE(int, pmtu_probe) = 60*2;
  380. /* ICMPV6 parameters */
  381. VNET_DEFINE(int, icmp6_rediraccept) = 1;/* accept and process redirects */
  382. VNET_DEFINE(int, icmp6_redirtimeout) = 10 * 60; /* 10 minutes */
  383. VNET_DEFINE(int, icmp6errppslim) = 100; /* 100pps */
  384. /* control how to respond to NI queries */
  385. VNET_DEFINE(int, icmp6_nodeinfo) =
  386. (ICMP6_NODEINFO_FQDNOK|ICMP6_NODEINFO_NODEADDROK);
  387. VNET_DEFINE(int, icmp6_nodeinfo_oldmcprefix) = 1;
  388. /*
  389. * sysctl related items.
  390. */
  391. SYSCTL_NODE(_net, PF_INET6, inet6, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
  392. "Internet6 Family");
  393. /* net.inet6 */
  394. SYSCTL_NODE(_net_inet6, IPPROTO_IPV6, ip6, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
  395. "IP6");
  396. SYSCTL_NODE(_net_inet6, IPPROTO_ICMPV6, icmp6, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
  397. "ICMP6");
  398. SYSCTL_NODE(_net_inet6, IPPROTO_UDP, udp6, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
  399. "UDP6");
  400. SYSCTL_NODE(_net_inet6, IPPROTO_TCP, tcp6, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
  401. "TCP6");
  402. #if defined(SCTP) || defined(SCTP_SUPPORT)
  403. SYSCTL_NODE(_net_inet6, IPPROTO_SCTP, sctp6, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
  404. "SCTP6");
  405. #endif
  406. #if defined(IPSEC) || defined(IPSEC_SUPPORT)
  407. SYSCTL_NODE(_net_inet6, IPPROTO_ESP, ipsec6, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
  408. "IPSEC6");
  409. #endif /* IPSEC */
  410. /* net.inet6.ip6 */
  411. static int
  412. sysctl_ip6_temppltime(SYSCTL_HANDLER_ARGS)
  413. {
  414. int error, val;
  415. val = V_ip6_temp_preferred_lifetime;
  416. error = sysctl_handle_int(oidp, &val, 0, req);
  417. if (error != 0 || !req->newptr)
  418. return (error);
  419. if (val < V_ip6_desync_factor + V_ip6_temp_regen_advance)
  420. return (EINVAL);
  421. V_ip6_temp_preferred_lifetime = val;
  422. return (0);
  423. }
  424. static int
  425. sysctl_ip6_tempvltime(SYSCTL_HANDLER_ARGS)
  426. {
  427. int error, val;
  428. val = V_ip6_temp_valid_lifetime;
  429. error = sysctl_handle_int(oidp, &val, 0, req);
  430. if (error != 0 || !req->newptr)
  431. return (error);
  432. if (val < V_ip6_temp_preferred_lifetime)
  433. return (EINVAL);
  434. V_ip6_temp_valid_lifetime = val;
  435. return (0);
  436. }
  437. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_FORWARDING, forwarding,
  438. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_forwarding), 0,
  439. "Enable forwarding of IPv6 packets between interfaces");
  440. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_SENDREDIRECTS, redirect,
  441. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_sendredirects), 0,
  442. "Send ICMPv6 redirects for unforwardable IPv6 packets");
  443. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFHLIM, hlim,
  444. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_defhlim), 0,
  445. "Default hop limit to use for outgoing IPv6 packets");
  446. SYSCTL_VNET_PCPUSTAT(_net_inet6_ip6, IPV6CTL_STATS, stats, struct ip6stat,
  447. ip6stat,
  448. "IP6 statistics (struct ip6stat, netinet6/ip6_var.h)");
  449. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_ACCEPT_RTADV, accept_rtadv,
  450. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_accept_rtadv), 0,
  451. "Default value of per-interface flag for accepting ICMPv6 RA messages");
  452. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_NO_RADR, no_radr,
  453. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_no_radr), 0,
  454. "Default value of per-interface flag to control whether routers "
  455. "sending ICMPv6 RA messages on that interface are added into the "
  456. "default router list");
  457. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_NORBIT_RAIF, norbit_raif,
  458. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_norbit_raif), 0,
  459. "Always set clear the R flag in ICMPv6 NA messages when accepting RA "
  460. "on the interface");
  461. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_RFC6204W3, rfc6204w3,
  462. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_rfc6204w3), 0,
  463. "Accept the default router list from ICMPv6 RA messages even "
  464. "when packet forwarding is enabled");
  465. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_LOG_INTERVAL, log_interval,
  466. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_log_interval), 0,
  467. "Frequency in seconds at which to log IPv6 forwarding errors");
  468. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_HDRNESTLIMIT, hdrnestlimit,
  469. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_hdrnestlimit), 0,
  470. "Default maximum number of IPv6 extension headers permitted on "
  471. "incoming IPv6 packets, 0 for no artificial limit");
  472. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DAD_COUNT, dad_count,
  473. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_dad_count), 0,
  474. "Number of ICMPv6 NS messages sent during duplicate address detection");
  475. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_AUTO_FLOWLABEL, auto_flowlabel,
  476. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_auto_flowlabel), 0,
  477. "Provide an IPv6 flowlabel in outbound packets");
  478. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFMCASTHLIM, defmcasthlim,
  479. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_defmcasthlim), 0,
  480. "Default hop limit for IPv6 multicast packets originating from this "
  481. "node");
  482. SYSCTL_STRING(_net_inet6_ip6, IPV6CTL_KAME_VERSION, kame_version,
  483. CTLFLAG_RD, __KAME_VERSION, 0,
  484. "KAME version string");
  485. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_USE_DEPRECATED, use_deprecated,
  486. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_use_deprecated), 0,
  487. "Allow the use of addresses whose preferred lifetimes have expired");
  488. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_RR_PRUNE, rr_prune,
  489. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_rr_prune), 0,
  490. ""); /* XXX unused */
  491. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_USETEMPADDR, use_tempaddr,
  492. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_use_tempaddr), 0,
  493. "Create RFC3041 temporary addresses for autoconfigured addresses");
  494. SYSCTL_PROC(_net_inet6_ip6, IPV6CTL_TEMPPLTIME, temppltime,
  495. CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
  496. NULL, 0, sysctl_ip6_temppltime, "I",
  497. "Maximum preferred lifetime for temporary addresses");
  498. SYSCTL_PROC(_net_inet6_ip6, IPV6CTL_TEMPVLTIME, tempvltime,
  499. CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
  500. NULL, 0, sysctl_ip6_tempvltime, "I",
  501. "Maximum valid lifetime for temporary addresses");
  502. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_V6ONLY, v6only,
  503. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_v6only), 0,
  504. "Restrict AF_INET6 sockets to IPv6 addresses only");
  505. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_AUTO_LINKLOCAL, auto_linklocal,
  506. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_auto_linklocal), 0,
  507. "Default value of per-interface flag for automatically adding an IPv6 "
  508. "link-local address to interfaces when attached");
  509. SYSCTL_VNET_PCPUSTAT(_net_inet6_ip6, IPV6CTL_RIP6STATS, rip6stats,
  510. struct rip6stat, rip6stat,
  511. "Raw IP6 statistics (struct rip6stat, netinet6/raw_ip6.h)");
  512. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_PREFER_TEMPADDR, prefer_tempaddr,
  513. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_prefer_tempaddr), 0,
  514. "Prefer RFC3041 temporary addresses in source address selection");
  515. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_USE_DEFAULTZONE, use_defaultzone,
  516. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_use_defzone), 0,
  517. "Use the default scope zone when none is specified");
  518. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MCAST_PMTU, mcast_pmtu,
  519. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_mcast_pmtu), 0,
  520. "Enable path MTU discovery for multicast packets");
  521. #ifdef IPSTEALTH
  522. SYSCTL_INT(_net_inet6_ip6, IPV6CTL_STEALTH, stealth, CTLFLAG_VNET | CTLFLAG_RW,
  523. &VNET_NAME(ip6stealth), 0,
  524. "Forward IPv6 packets without decrementing their TTL");
  525. #endif
  526. /* net.inet6.icmp6 */
  527. SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT, rediraccept,
  528. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6_rediraccept), 0,
  529. "Accept ICMPv6 redirect messages");
  530. SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT, redirtimeout,
  531. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6_redirtimeout), 0,
  532. "Delay in seconds before expiring redirect route");
  533. SYSCTL_VNET_PCPUSTAT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats,
  534. struct icmp6stat, icmp6stat,
  535. "ICMPv6 statistics (struct icmp6stat, netinet/icmp6.h)");
  536. SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE, nd6_prune,
  537. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_prune), 0,
  538. "Frequency in seconds of checks for expired prefixes and routers");
  539. SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DELAY, nd6_delay,
  540. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_delay), 0,
  541. "Delay in seconds before probing for reachability");
  542. SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_UMAXTRIES, nd6_umaxtries,
  543. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_umaxtries), 0,
  544. "Number of ICMPv6 NS messages sent during reachability detection");
  545. SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MMAXTRIES, nd6_mmaxtries,
  546. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_mmaxtries), 0,
  547. "Number of ICMPv6 NS messages sent during address resolution");
  548. SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_USELOOPBACK, nd6_useloopback,
  549. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_useloopback), 0,
  550. "Create a loopback route when configuring an IPv6 address");
  551. SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO, nodeinfo,
  552. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6_nodeinfo), 0,
  553. "Mask of enabled RFC4620 node information query types");
  554. SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO_OLDMCPREFIX,
  555. nodeinfo_oldmcprefix, CTLFLAG_VNET | CTLFLAG_RW,
  556. &VNET_NAME(icmp6_nodeinfo_oldmcprefix), 0,
  557. "Join old IPv6 NI group address in draft-ietf-ipngwg-icmp-name-lookup "
  558. "for compatibility with KAME implementation");
  559. SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ERRPPSLIMIT, errppslimit,
  560. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6errppslim), 0,
  561. "Maximum number of ICMPv6 error messages per second");
  562. SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MAXNUDHINT, nd6_maxnudhint,
  563. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_maxnudhint), 0,
  564. ""); /* XXX unused */
  565. SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DEBUG, nd6_debug,
  566. CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_debug), 0,
  567. "Log NDP debug messages");
  568. SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_ONLINKNSRFC4861,
  569. nd6_onlink_ns_rfc4861, CTLFLAG_VNET | CTLFLAG_RW,
  570. &VNET_NAME(nd6_onlink_ns_rfc4861), 0,
  571. "Accept 'on-link' ICMPv6 NS messages in compliance with RFC 4861");
  572. #ifdef EXPERIMENTAL
  573. SYSCTL_INT(_net_inet6_icmp6, OID_AUTO,
  574. nd6_ignore_ipv6_only_ra, CTLFLAG_VNET | CTLFLAG_RW,
  575. &VNET_NAME(nd6_ignore_ipv6_only_ra), 0,
  576. "Ignore the 'IPv6-Only flag' in RA messages in compliance with "
  577. "draft-ietf-6man-ipv6only-flag");
  578. #endif