summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/in6_proto.c
diff options
context:
space:
mode:
authoritojun <itojun@FreeBSD.org>2000-07-04 16:35:15 +0000
committeritojun <itojun@FreeBSD.org>2000-07-04 16:35:15 +0000
commit5f4e854de19331a53788d6100bbcd42845056bc1 (patch)
tree3ff8c876a5868b103fb8713055d83e29a3fa38d5 /sys/netinet6/in6_proto.c
parentbdc16885232d771a99d7dfc247cd27a44cd061f9 (diff)
downloadFreeBSD-src-5f4e854de19331a53788d6100bbcd42845056bc1.zip
FreeBSD-src-5f4e854de19331a53788d6100bbcd42845056bc1.tar.gz
sync with kame tree as of july00. tons of bug fixes/improvements.
API changes: - additional IPv6 ioctls - IPsec PF_KEY API was changed, it is mandatory to upgrade setkey(8). (also syntax change)
Diffstat (limited to 'sys/netinet6/in6_proto.c')
-rw-r--r--sys/netinet6/in6_proto.c217
1 files changed, 176 insertions, 41 deletions
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
index 318dcab..8af642f 100644
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -1,3 +1,6 @@
+/* $FreeBSD$ */
+/* $KAME: in6_proto.c,v 1.64 2000/06/20 16:20:27 itojun Exp $ */
+
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
@@ -25,8 +28,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
@@ -65,6 +66,7 @@
*/
#include "opt_inet.h"
+#include "opt_inet6.h"
#include "opt_ipsec.h"
#include <sys/param.h>
@@ -84,11 +86,12 @@
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/in_var.h>
+#include <netinet/ip_encap.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
-#include <netinet6/ip6.h>
+#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
-#include <netinet6/icmp6.h>
+#include <netinet/icmp6.h>
#include <netinet/tcp.h>
#include <netinet/tcp_timer.h>
@@ -96,6 +99,7 @@
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet6/tcp6_var.h>
+
#include <netinet6/udp6_var.h>
#include <netinet6/pim6_var.h>
@@ -105,13 +109,15 @@
#ifdef IPSEC
#include <netinet6/ipsec.h>
-#include <netinet6/ah.h>
#include <netinet6/ipsec6.h>
+#include <netinet6/ah.h>
#include <netinet6/ah6.h>
#ifdef IPSEC_ESP
#include <netinet6/esp.h>
#include <netinet6/esp6.h>
#endif
+#include <netinet6/ipcomp.h>
+#include <netinet6/ipcomp6.h>
#endif /*IPSEC*/
#include <netinet6/ip6protosw.h>
@@ -129,8 +135,8 @@
* TCP/IP protocol family: IP6, ICMP6, UDP, TCP.
*/
-extern struct domain inet6domain;
-static struct pr_usrreqs nousrreqs;
+extern struct domain inet6domain;
+static struct pr_usrreqs nousrreqs;
struct ip6protosw inet6sw[] = {
{ 0, &inet6domain, IPPROTO_IPV6, 0,
@@ -151,12 +157,12 @@ struct ip6protosw inet6sw[] = {
#ifdef INET /* don't call timeout routines twice */
tcp_init, 0, 0, tcp_drain,
#else
- tcp_init, 0, tcp_slowtimo, tcp_drain,
+ tcp_init, tcp_fasttimo, tcp_slowtimo, tcp_drain,
#endif
&tcp6_usrreqs,
},
{ SOCK_RAW, &inet6domain, IPPROTO_RAW, PR_ATOMIC | PR_ADDR,
- rip6_input, rip6_output, 0, rip6_ctloutput,
+ rip6_input, rip6_output, rip6_ctlinput, rip6_ctloutput,
0,
0, 0, 0, 0,
&rip6_usrreqs
@@ -169,68 +175,88 @@ struct ip6protosw inet6sw[] = {
},
{ SOCK_RAW, &inet6domain, IPPROTO_DSTOPTS,PR_ATOMIC|PR_ADDR,
dest6_input, 0, 0, 0,
- 0,
+ 0,
0, 0, 0, 0,
&nousrreqs
},
{ SOCK_RAW, &inet6domain, IPPROTO_ROUTING,PR_ATOMIC|PR_ADDR,
route6_input, 0, 0, 0,
- 0,
+ 0,
0, 0, 0, 0,
&nousrreqs
},
{ SOCK_RAW, &inet6domain, IPPROTO_FRAGMENT,PR_ATOMIC|PR_ADDR,
frag6_input, 0, 0, 0,
- 0,
+ 0,
0, 0, 0, 0,
&nousrreqs
},
#ifdef IPSEC
{ SOCK_RAW, &inet6domain, IPPROTO_AH, PR_ATOMIC|PR_ADDR,
ah6_input, 0, 0, 0,
- 0,
+ 0,
0, 0, 0, 0,
&nousrreqs,
},
#ifdef IPSEC_ESP
{ SOCK_RAW, &inet6domain, IPPROTO_ESP, PR_ATOMIC|PR_ADDR,
esp6_input, 0, 0, 0,
- 0,
+ 0,
0, 0, 0, 0,
&nousrreqs,
},
#endif
+{ SOCK_RAW, &inet6domain, IPPROTO_IPCOMP, PR_ATOMIC|PR_ADDR,
+ ipcomp6_input, 0, 0, 0,
+ 0,
+ 0, 0, 0, 0,
+ &nousrreqs,
+},
#endif /* IPSEC */
-#if NGIF > 0
+#ifdef INET
{ SOCK_RAW, &inet6domain, IPPROTO_IPV4, PR_ATOMIC|PR_ADDR,
- in6_gif_input,0, 0, 0,
- 0,
+ encap6_input, rip6_output, 0, rip6_ctloutput,
+ 0,
0, 0, 0, 0,
- &nousrreqs
+ &rip6_usrreqs
},
+#endif /*INET*/
{ SOCK_RAW, &inet6domain, IPPROTO_IPV6, PR_ATOMIC|PR_ADDR,
- in6_gif_input,0, 0, 0,
+ encap6_input, rip6_output, 0, rip6_ctloutput,
0,
+#ifndef INET
+ encap_init, 0, 0, 0,
+#else
0, 0, 0, 0,
- &nousrreqs
+#endif
+ &rip6_usrreqs
},
-#endif /* GIF */
{ SOCK_RAW, &inet6domain, IPPROTO_PIM, PR_ATOMIC|PR_ADDR,
- pim6_input, rip6_output, 0, rip6_ctloutput,
+ pim6_input, rip6_output, 0, rip6_ctloutput,
0,
- 0, 0, 0, 0,
+ 0, 0, 0, 0,
&rip6_usrreqs
},
/* raw wildcard */
{ SOCK_RAW, &inet6domain, 0, PR_ATOMIC | PR_ADDR,
rip6_input, rip6_output, 0, rip6_ctloutput,
- 0,
- 0, 0, 0, 0,
+ 0, 0,
+ 0, 0, 0,
&rip6_usrreqs
},
};
-extern int in6_inithead __P((void **, int));
+#if NGIF > 0
+struct ip6protosw in6_gif_protosw =
+{ SOCK_RAW, &inet6domain, 0/*IPPROTO_IPV[46]*/, PR_ATOMIC|PR_ADDR,
+ in6_gif_input, rip6_output, 0, rip6_ctloutput,
+ 0,
+ 0, 0, 0, 0,
+ &rip6_usrreqs
+};
+#endif /*NGIF*/
+
+extern int in6_inithead __P((void **, int));
struct domain inet6domain =
{ AF_INET6, "internet6", 0, 0, 0,
@@ -266,7 +292,7 @@ int ip6_maxfragpackets = 200;
int ip6_log_interval = 5;
int ip6_hdrnestlimit = 50; /* appropriate? */
int ip6_dad_count = 1; /* DupAddrDetectionTransmits */
-u_int32_t ip6_flow_seq;
+u_int32_t ip6_flow_seq;
int ip6_auto_flowlabel = 1;
#if NGIF > 0
int ip6_gif_hlim = GIF_HLIM;
@@ -288,8 +314,8 @@ time_t ip6_log_time = (time_t)0L;
* XXX: what if we don't define INET? Should we define pmtu6_expire
* or so? (jinmei@kame.net 19990310)
*/
-int pmtu_expire = 60*10;
-int pmtu_probe = 60*2;
+int pmtu_expire = 60*10;
+int pmtu_probe = 60*2;
/* raw IP6 parameters */
/*
@@ -304,7 +330,84 @@ u_long rip6_recvspace = RIPV6RCVQ;
/* ICMPV6 parameters */
int icmp6_rediraccept = 1; /* accept and process redirects */
int icmp6_redirtimeout = 10 * 60; /* 10 minutes */
-u_int icmp6errratelim = 1000; /* 1000usec = 1msec */
+struct timeval icmp6errratelim = { 0, 0 }; /* no ratelimit */
+int icmp6errppslim = 100; /* 100pps */
+int icmp6_nodeinfo = 1; /* enable/disable NI response */
+
+#ifdef TCP6
+/* TCP on IP6 parameters */
+int tcp6_sendspace = 1024 * 8;
+int tcp6_recvspace = 1024 * 8;
+int tcp6_mssdflt = TCP6_MSS;
+int tcp6_rttdflt = TCP6TV_SRTTDFLT / PR_SLOWHZ;
+int tcp6_do_rfc1323 = 1;
+int tcp6_conntimeo = TCP6TV_KEEP_INIT; /* initial connection timeout */
+int tcp6_43maxseg = 0;
+int tcp6_pmtu = 0;
+
+/*
+ * Parameters for keepalive option.
+ * Connections for which SO_KEEPALIVE is set will be probed
+ * after being idle for a time of tcp6_keepidle (in units of PR_SLOWHZ).
+ * Starting at that time, the connection is probed at intervals
+ * of tcp6_keepintvl (same units) until a response is received
+ * or until tcp6_keepcnt probes have been made, at which time
+ * the connection is dropped. Note that a tcp6_keepidle value
+ * under 2 hours is nonconformant with RFC-1122, Internet Host Requirements.
+ */
+int tcp6_keepidle = TCP6TV_KEEP_IDLE; /* time before probing idle */
+int tcp6_keepintvl = TCP6TV_KEEPINTVL; /* interval betwn idle probes */
+int tcp6_keepcnt = TCP6TV_KEEPCNT; /* max idle probes */
+int tcp6_maxpersistidle = TCP6TV_KEEP_IDLE; /* max idle time in persist */
+
+#ifndef INET_SERVER
+#define TCP6_LISTEN_HASH_SIZE 17
+#define TCP6_CONN_HASH_SIZE 97
+#define TCP6_SYN_HASH_SIZE 293
+#define TCP6_SYN_BUCKET_SIZE 35
+#else
+#define TCP6_LISTEN_HASH_SIZE 97
+#define TCP6_CONN_HASH_SIZE 9973
+#define TCP6_SYN_HASH_SIZE 997
+#define TCP6_SYN_BUCKET_SIZE 35
+#endif
+int tcp6_listen_hash_size = TCP6_LISTEN_HASH_SIZE;
+int tcp6_conn_hash_size = TCP6_CONN_HASH_SIZE;
+struct tcp6_hash_list tcp6_listen_hash[TCP6_LISTEN_HASH_SIZE],
+ tcp6_conn_hash[TCP6_CONN_HASH_SIZE];
+
+int tcp6_syn_cache_size = TCP6_SYN_HASH_SIZE;
+int tcp6_syn_cache_limit = TCP6_SYN_HASH_SIZE*TCP6_SYN_BUCKET_SIZE;
+int tcp6_syn_bucket_limit = 3*TCP6_SYN_BUCKET_SIZE;
+struct syn_cache_head6 tcp6_syn_cache[TCP6_SYN_HASH_SIZE];
+struct syn_cache_head6 *tcp6_syn_cache_first;
+int tcp6_syn_cache_interval = 8; /* runs timer every 4 seconds */
+int tcp6_syn_cache_timeo = TCP6TV_KEEP_INIT;
+
+/*
+ * Parameters for computing a desirable data segment size
+ * given an upper bound (either interface MTU, or peer's MSS option)_.
+ * As applications tend to use a buffer size that is a multiple
+ * of kilobytes, try for something that divides evenly. However,
+ * do not round down too much.
+ *
+ * Round segment size down to a multiple of TCP6_ROUNDSIZE if this
+ * does not result in lowering by more than (size/TCP6_ROUNDFRAC).
+ * For example, round 536 to 512. Older versions of the system
+ * effectively used MCLBYTES (1K or 2K) as TCP6_ROUNDSIZE, with
+ * a value of 1 for TCP6_ROUNDFRAC (eliminating its effect).
+ * We round to a multiple of 256 for SLIP.
+ */
+#ifndef TCP6_ROUNDSIZE
+#define TCP6_ROUNDSIZE 256 /* round to multiple of 256 */
+#endif
+#ifndef TCP6_ROUNDFRAC
+#define TCP6_ROUNDFRAC 10 /* round down at most N/10, or 10% */
+#endif
+
+int tcp6_roundsize = TCP6_ROUNDSIZE;
+int tcp6_roundfrac = TCP6_ROUNDFRAC;
+#endif /*TCP6*/
/* UDP on IP6 parameters */
int udp6_sendspace = 9216; /* really max datagram size */
@@ -344,30 +447,57 @@ sysctl_ip6_forwarding(SYSCTL_HANDLER_ARGS)
changed = (ip6_forwarding ? 1 : 0) ^ (old_ip6_forwarding ? 1 : 0);
if (changed == 0)
return (error);
+ /*
+ * XXX while host->router removes prefix got from RA,
+ * router->host case nukes all the prefixes managed by in6_prefix.c
+ * (both RR and static). therefore, switching from host->router->host
+ * will remove statically configured addresses/prefixes.
+ * not sure if it is intended behavior or not.
+ */
if (ip6_forwarding != 0) { /* host becomes router */
int s = splnet();
struct nd_prefix *pr, *next;
- for (pr = LIST_FIRST(&nd_prefix); pr; pr = next) {
- next = LIST_NEXT(pr, ndpr_entry);
+ for (pr = nd_prefix.lh_first; pr; pr = next) {
+ next = pr->ndpr_next;
if (!IN6_IS_ADDR_UNSPECIFIED(&pr->ndpr_addr))
in6_ifdel(pr->ndpr_ifp, &pr->ndpr_addr);
prelist_remove(pr);
}
splx(s);
} else { /* router becomes host */
- struct socket so;
-
- /* XXX: init dummy so */
- bzero(&so, sizeof(so));
while(!LIST_EMPTY(&rr_prefix))
- delete_each_prefix(&so, LIST_FIRST(&rr_prefix),
+ delete_each_prefix(LIST_FIRST(&rr_prefix),
PR_ORIG_KERNEL);
}
return (error);
}
+static int
+sysctl_icmp6_ratelimit (SYSCTL_HANDLER_ARGS)
+{
+ int rate_usec, error, s;
+
+ /*
+ * The sysctl specifies the rate in usec-between-icmp,
+ * so we must convert from/to a timeval.
+ */
+ rate_usec = (icmp6errratelim.tv_sec * 1000000) +
+ icmp6errratelim.tv_usec;
+ error = sysctl_handle_int(oidp, &rate_usec, 0, req);
+ if (error)
+ return (error);
+ if (rate_usec < 0)
+ return (EINVAL);
+ s = splnet();
+ icmp6errratelim.tv_sec = rate_usec / 1000000;
+ icmp6errratelim.tv_usec = rate_usec % 1000000;
+ splx(s);
+
+ return (0);
+}
+
SYSCTL_OID(_net_inet6_ip6, IPV6CTL_FORWARDING, forwarding,
CTLTYPE_INT|CTLFLAG_RW, &ip6_forwarding, 0, sysctl_ip6_forwarding,
"I", "");
@@ -409,8 +539,9 @@ SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT,
redirtimeout, CTLFLAG_RW, &icmp6_redirtimeout, 0, "");
SYSCTL_STRUCT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats, CTLFLAG_RD,
&icmp6stat, icmp6stat, "");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ERRRATELIMIT,
- errratelimit, CTLFLAG_RW, &icmp6errratelim, 0, "");
+SYSCTL_PROC(_net_inet6_icmp6, ICMPV6CTL_ERRRATELIMIT,
+ errratelimit, CTLTYPE_INT|CTLFLAG_RW,
+ 0, sizeof(int), sysctl_icmp6_ratelimit, "I", "");
SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE,
nd6_prune, CTLFLAG_RW, &nd6_prune, 0, "");
SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DELAY,
@@ -421,5 +552,9 @@ SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MMAXTRIES,
nd6_mmaxtries, CTLFLAG_RW, &nd6_mmaxtries, 0, "");
SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_USELOOPBACK,
nd6_useloopback, CTLFLAG_RW, &nd6_useloopback, 0, "");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PROXYALL,
- nd6_proxyall, CTLFLAG_RW, &nd6_proxyall, 0, "");
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO,
+ nodeinfo, CTLFLAG_RW, &icmp6_nodeinfo, 0, "");
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ERRPPSLIMIT,
+ errppslimit, CTLFLAG_RW, &icmp6errppslim, 0, "");
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MAXNUDHINT,
+ nd6_maxnudhint, CTLFLAG_RW, &nd6_maxnudhint, 0, "");
OpenPOWER on IntegriCloud