ip6_input.c (201794) | ip6_input.c (207369) |
---|---|
1/*- 2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 47 unchanged lines hidden (view full) --- 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * SUCH DAMAGE. 59 * 60 * @(#)ip_input.c 8.2 (Berkeley) 1/4/94 61 */ 62 63#include <sys/cdefs.h> | 1/*- 2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 47 unchanged lines hidden (view full) --- 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * SUCH DAMAGE. 59 * 60 * @(#)ip_input.c 8.2 (Berkeley) 1/4/94 61 */ 62 63#include <sys/cdefs.h> |
64__FBSDID("$FreeBSD: head/sys/netinet6/ip6_input.c 201794 2010-01-08 15:44:49Z trasz $"); | 64__FBSDID("$FreeBSD: head/sys/netinet6/ip6_input.c 207369 2010-04-29 11:52:42Z bz $"); |
65 66#include "opt_inet.h" 67#include "opt_inet6.h" 68#include "opt_ipsec.h" 69 70#include <sys/param.h> 71#include <sys/systm.h> 72#include <sys/malloc.h> --- 38 unchanged lines hidden (view full) --- 111#include <netipsec/ipsec6.h> 112#endif /* IPSEC */ 113 114#include <netinet6/ip6protosw.h> 115 116extern struct domain inet6domain; 117 118u_char ip6_protox[IPPROTO_MAX]; | 65 66#include "opt_inet.h" 67#include "opt_inet6.h" 68#include "opt_ipsec.h" 69 70#include <sys/param.h> 71#include <sys/systm.h> 72#include <sys/malloc.h> --- 38 unchanged lines hidden (view full) --- 111#include <netipsec/ipsec6.h> 112#endif /* IPSEC */ 113 114#include <netinet6/ip6protosw.h> 115 116extern struct domain inet6domain; 117 118u_char ip6_protox[IPPROTO_MAX]; |
119VNET_DEFINE(struct in6_ifaddrhead, in6_ifaddrhead); |
|
119 120static struct netisr_handler ip6_nh = { 121 .nh_name = "ip6", 122 .nh_handler = ip6_input, 123 .nh_proto = NETISR_IPV6, 124 .nh_policy = NETISR_POLICY_FLOW, 125}; 126 | 120 121static struct netisr_handler ip6_nh = { 122 .nh_name = "ip6", 123 .nh_handler = ip6_input, 124 .nh_proto = NETISR_IPV6, 125 .nh_policy = NETISR_POLICY_FLOW, 126}; 127 |
127VNET_DEFINE(struct in6_ifaddrhead, in6_ifaddrhead); 128VNET_DEFINE(struct ip6stat, ip6stat); 129 | |
130VNET_DECLARE(struct callout, in6_tmpaddrtimer_ch); | 128VNET_DECLARE(struct callout, in6_tmpaddrtimer_ch); |
131VNET_DECLARE(int, dad_init); 132VNET_DECLARE(int, pmtu_expire); 133VNET_DECLARE(int, pmtu_probe); 134VNET_DECLARE(u_long, rip6_sendspace); 135VNET_DECLARE(u_long, rip6_recvspace); 136VNET_DECLARE(int, icmp6errppslim); 137VNET_DECLARE(int, icmp6_nodeinfo); 138VNET_DECLARE(int, udp6_sendspace); 139VNET_DECLARE(int, udp6_recvspace); 140 | |
141#define V_in6_tmpaddrtimer_ch VNET(in6_tmpaddrtimer_ch) | 129#define V_in6_tmpaddrtimer_ch VNET(in6_tmpaddrtimer_ch) |
142#define V_dad_init VNET(dad_init) 143#define V_pmtu_expire VNET(pmtu_expire) 144#define V_pmtu_probe VNET(pmtu_probe) 145#define V_rip6_sendspace VNET(rip6_sendspace) 146#define V_rip6_recvspace VNET(rip6_recvspace) 147#define V_icmp6errppslim VNET(icmp6errppslim) 148#define V_icmp6_nodeinfo VNET(icmp6_nodeinfo) 149#define V_udp6_sendspace VNET(udp6_sendspace) 150#define V_udp6_recvspace VNET(udp6_recvspace) | |
151 | 130 |
131VNET_DEFINE(struct pfil_head, inet6_pfil_hook); 132 133VNET_DEFINE(struct ip6stat, ip6stat); 134 |
|
152struct rwlock in6_ifaddr_lock; 153RW_SYSINIT(in6_ifaddr_lock, &in6_ifaddr_lock, "in6_ifaddr_lock"); 154 | 135struct rwlock in6_ifaddr_lock; 136RW_SYSINIT(in6_ifaddr_lock, &in6_ifaddr_lock, "in6_ifaddr_lock"); 137 |
155VNET_DEFINE (struct pfil_head, inet6_pfil_hook); 156 | |
157static void ip6_init2(void *); 158static struct ip6aux *ip6_setdstifaddr(struct mbuf *, struct in6_ifaddr *); 159static int ip6_hopopts_input(u_int32_t *, u_int32_t *, struct mbuf **, int *); 160#ifdef PULLDOWN_TEST 161static struct mbuf *ip6_pullexthdr(struct mbuf *, size_t, int); 162#endif 163 164/* 165 * IP6 initialization: fill in IP6 protocol switch table. 166 * All protocols not implemented in kernel go to raw IP6 protocol handler. 167 */ 168void 169ip6_init(void) 170{ 171 struct ip6protosw *pr; 172 int i; 173 | 138static void ip6_init2(void *); 139static struct ip6aux *ip6_setdstifaddr(struct mbuf *, struct in6_ifaddr *); 140static int ip6_hopopts_input(u_int32_t *, u_int32_t *, struct mbuf **, int *); 141#ifdef PULLDOWN_TEST 142static struct mbuf *ip6_pullexthdr(struct mbuf *, size_t, int); 143#endif 144 145/* 146 * IP6 initialization: fill in IP6 protocol switch table. 147 * All protocols not implemented in kernel go to raw IP6 protocol handler. 148 */ 149void 150ip6_init(void) 151{ 152 struct ip6protosw *pr; 153 int i; 154 |
174 V_in6_maxmtu = 0; 175#ifdef IP6_AUTO_LINKLOCAL 176 V_ip6_auto_linklocal = IP6_AUTO_LINKLOCAL; 177#else 178 V_ip6_auto_linklocal = 1; /* enabled by default */ 179#endif | |
180 TUNABLE_INT_FETCH("net.inet6.ip6.auto_linklocal", 181 &V_ip6_auto_linklocal); 182 | 155 TUNABLE_INT_FETCH("net.inet6.ip6.auto_linklocal", 156 &V_ip6_auto_linklocal); 157 |
183#ifndef IPV6FORWARDING 184#ifdef GATEWAY6 185#define IPV6FORWARDING 1 /* forward IP6 packets not for us */ 186#else 187#define IPV6FORWARDING 0 /* don't forward IP6 packets not for us */ 188#endif /* GATEWAY6 */ 189#endif /* !IPV6FORWARDING */ 190 191#ifndef IPV6_SENDREDIRECTS 192#define IPV6_SENDREDIRECTS 1 193#endif 194 195 V_ip6_forwarding = IPV6FORWARDING; /* act as router? */ 196 V_ip6_sendredirects = IPV6_SENDREDIRECTS; 197 V_ip6_defhlim = IPV6_DEFHLIM; 198 V_ip6_defmcasthlim = IPV6_DEFAULT_MULTICAST_HOPS; 199 V_ip6_accept_rtadv = 0; 200 V_ip6_log_interval = 5; 201 V_ip6_hdrnestlimit = 15; /* How many header options will we process? */ 202 V_ip6_dad_count = 1; /* DupAddrDetectionTransmits */ 203 V_ip6_auto_flowlabel = 1; 204 V_ip6_use_deprecated = 1;/* allow deprecated addr (RFC2462 5.5.4) */ 205 V_ip6_rr_prune = 5; /* router renumbering prefix 206 * walk list every 5 sec. */ 207 V_ip6_mcast_pmtu = 0; /* enable pMTU discovery for multicast? */ 208 V_ip6_v6only = 1; 209 V_ip6_keepfaith = 0; 210 V_ip6_log_time = (time_t)0L; 211#ifdef IPSTEALTH 212 V_ip6stealth = 0; 213#endif 214 V_nd6_onlink_ns_rfc4861 = 0; /* allow 'on-link' nd6 NS (RFC 4861) */ 215 216 V_pmtu_expire = 60*10; 217 V_pmtu_probe = 60*2; 218 219 /* raw IP6 parameters */ 220 /* 221 * Nominal space allocated to a raw ip socket. 222 */ 223#define RIPV6SNDQ 8192 224#define RIPV6RCVQ 8192 225 V_rip6_sendspace = RIPV6SNDQ; 226 V_rip6_recvspace = RIPV6RCVQ; 227 228 /* ICMPV6 parameters */ 229 V_icmp6_rediraccept = 1; /* accept and process redirects */ 230 V_icmp6_redirtimeout = 10 * 60; /* 10 minutes */ 231 V_icmp6errppslim = 100; /* 100pps */ 232 /* control how to respond to NI queries */ 233 V_icmp6_nodeinfo = (ICMP6_NODEINFO_FQDNOK|ICMP6_NODEINFO_NODEADDROK); 234 235 /* UDP on IP6 parameters */ 236 V_udp6_sendspace = 9216; /* really max datagram size */ 237 V_udp6_recvspace = 40 * (1024 + sizeof(struct sockaddr_in6)); 238 /* 40 1K datagrams */ 239 V_dad_init = 0; 240 | |
241 TAILQ_INIT(&V_in6_ifaddrhead); 242 | 158 TAILQ_INIT(&V_in6_ifaddrhead); 159 |
243 scope6_init(); 244 addrsel_policy_init(); 245 nd6_init(); 246 frag6_init(); 247 248 V_ip6_desync_factor = arc4random() % MAX_TEMP_DESYNC_FACTOR; 249 | |
250 /* Initialize packet filter hooks. */ 251 V_inet6_pfil_hook.ph_type = PFIL_TYPE_AF; 252 V_inet6_pfil_hook.ph_af = AF_INET6; 253 if ((i = pfil_head_register(&V_inet6_pfil_hook)) != 0) 254 printf("%s: WARNING: unable to register pfil hook, " 255 "error %d\n", __func__, i); 256 | 160 /* Initialize packet filter hooks. */ 161 V_inet6_pfil_hook.ph_type = PFIL_TYPE_AF; 162 V_inet6_pfil_hook.ph_af = AF_INET6; 163 if ((i = pfil_head_register(&V_inet6_pfil_hook)) != 0) 164 printf("%s: WARNING: unable to register pfil hook, " 165 "error %d\n", __func__, i); 166 |
167 scope6_init(); 168 addrsel_policy_init(); 169 nd6_init(); 170 frag6_init(); 171 172 V_ip6_desync_factor = arc4random() % MAX_TEMP_DESYNC_FACTOR; 173 |
|
257 /* Skip global initialization stuff for non-default instances. */ 258 if (!IS_DEFAULT_VNET(curvnet)) 259 return; 260 261#ifdef DIAGNOSTIC 262 if (sizeof(struct protosw) != sizeof(struct ip6protosw)) 263 panic("sizeof(protosw) != sizeof(ip6protosw)"); 264#endif --- 1474 unchanged lines hidden --- | 174 /* Skip global initialization stuff for non-default instances. */ 175 if (!IS_DEFAULT_VNET(curvnet)) 176 return; 177 178#ifdef DIAGNOSTIC 179 if (sizeof(struct protosw) != sizeof(struct ip6protosw)) 180 panic("sizeof(protosw) != sizeof(ip6protosw)"); 181#endif --- 1474 unchanged lines hidden --- |