udp6_usrreq.c (190963) | udp6_usrreq.c (191672) |
---|---|
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 --- 49 unchanged lines hidden (view full) --- 58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 60 * SUCH DAMAGE. 61 * 62 * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95 63 */ 64 65#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 --- 49 unchanged lines hidden (view full) --- 58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 60 * SUCH DAMAGE. 61 * 62 * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95 63 */ 64 65#include <sys/cdefs.h> |
66__FBSDID("$FreeBSD: head/sys/netinet6/udp6_usrreq.c 190963 2009-04-12 11:53:12Z rwatson $"); | 66__FBSDID("$FreeBSD: head/sys/netinet6/udp6_usrreq.c 191672 2009-04-29 19:19:13Z bms $"); |
67 68#include "opt_inet.h" 69#include "opt_inet6.h" 70#include "opt_ipsec.h" 71#include "opt_mac.h" 72 73#include <sys/param.h> 74#include <sys/jail.h> --- 97 unchanged lines hidden (view full) --- 172} 173 174int 175udp6_input(struct mbuf **mp, int *offp, int proto) 176{ 177 INIT_VNET_INET(curvnet); 178 INIT_VNET_INET6(curvnet); 179 struct mbuf *m = *mp; | 67 68#include "opt_inet.h" 69#include "opt_inet6.h" 70#include "opt_ipsec.h" 71#include "opt_mac.h" 72 73#include <sys/param.h> 74#include <sys/jail.h> --- 97 unchanged lines hidden (view full) --- 172} 173 174int 175udp6_input(struct mbuf **mp, int *offp, int proto) 176{ 177 INIT_VNET_INET(curvnet); 178 INIT_VNET_INET6(curvnet); 179 struct mbuf *m = *mp; |
180 struct ifnet *ifp; |
|
180 struct ip6_hdr *ip6; 181 struct udphdr *uh; 182 struct inpcb *inp; 183 int off = *offp; 184 int plen, ulen; 185 struct sockaddr_in6 fromsa; 186 | 181 struct ip6_hdr *ip6; 182 struct udphdr *uh; 183 struct inpcb *inp; 184 int off = *offp; 185 int plen, ulen; 186 struct sockaddr_in6 fromsa; 187 |
188 ifp = m->m_pkthdr.rcvif; |
|
187 ip6 = mtod(m, struct ip6_hdr *); 188 189 if (faithprefix_p != NULL && (*faithprefix_p)(&ip6->ip6_dst)) { 190 /* XXX send icmp6 host/port unreach? */ 191 m_freem(m); 192 return (IPPROTO_DONE); 193 } 194 --- 39 unchanged lines hidden (view full) --- 234 * Construct sockaddr format source address. 235 */ 236 init_sin6(&fromsa, m); 237 fromsa.sin6_port = uh->uh_sport; 238 239 INP_INFO_RLOCK(&V_udbinfo); 240 if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { 241 struct inpcb *last; | 189 ip6 = mtod(m, struct ip6_hdr *); 190 191 if (faithprefix_p != NULL && (*faithprefix_p)(&ip6->ip6_dst)) { 192 /* XXX send icmp6 host/port unreach? */ 193 m_freem(m); 194 return (IPPROTO_DONE); 195 } 196 --- 39 unchanged lines hidden (view full) --- 236 * Construct sockaddr format source address. 237 */ 238 init_sin6(&fromsa, m); 239 fromsa.sin6_port = uh->uh_sport; 240 241 INP_INFO_RLOCK(&V_udbinfo); 242 if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { 243 struct inpcb *last; |
244 struct ip6_moptions *imo; |
|
242 243 /* 244 * In the event that laddr should be set to the link-local 245 * address (this happens in RIPng), the multicast address 246 * specified in the received packet will not match laddr. To 247 * handle this situation, matching is relaxed if the 248 * receiving interface is the same as one specified in the 249 * socket and if the destination multicast address matches --- 6 unchanged lines hidden (view full) --- 256 * later. 257 */ 258 last = NULL; 259 LIST_FOREACH(inp, &V_udb, inp_list) { 260 if ((inp->inp_vflag & INP_IPV6) == 0) 261 continue; 262 if (inp->inp_lport != uh->uh_dport) 263 continue; | 245 246 /* 247 * In the event that laddr should be set to the link-local 248 * address (this happens in RIPng), the multicast address 249 * specified in the received packet will not match laddr. To 250 * handle this situation, matching is relaxed if the 251 * receiving interface is the same as one specified in the 252 * socket and if the destination multicast address matches --- 6 unchanged lines hidden (view full) --- 259 * later. 260 */ 261 last = NULL; 262 LIST_FOREACH(inp, &V_udb, inp_list) { 263 if ((inp->inp_vflag & INP_IPV6) == 0) 264 continue; 265 if (inp->inp_lport != uh->uh_dport) 266 continue; |
264 /* 265 * XXX: Do not check source port of incoming datagram 266 * unless inp_connect() has been called to bind the 267 * fport part of the 4-tuple; the source could be 268 * trying to talk to us with an ephemeral port. 269 */ | |
270 if (inp->inp_fport != 0 && 271 inp->inp_fport != uh->uh_sport) 272 continue; 273 if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) { 274 if (!IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, 275 &ip6->ip6_dst)) 276 continue; 277 } 278 if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) { 279 if (!IN6_ARE_ADDR_EQUAL(&inp->in6p_faddr, 280 &ip6->ip6_src) || 281 inp->inp_fport != uh->uh_sport) 282 continue; 283 } 284 | 267 if (inp->inp_fport != 0 && 268 inp->inp_fport != uh->uh_sport) 269 continue; 270 if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) { 271 if (!IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, 272 &ip6->ip6_dst)) 273 continue; 274 } 275 if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) { 276 if (!IN6_ARE_ADDR_EQUAL(&inp->in6p_faddr, 277 &ip6->ip6_src) || 278 inp->inp_fport != uh->uh_sport) 279 continue; 280 } 281 |
282 INP_RLOCK(inp); 283 284 /* 285 * Handle socket delivery policy for any-source 286 * and source-specific multicast. [RFC3678] 287 */ 288 imo = inp->in6p_moptions; 289 if (imo && IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { 290 struct sockaddr_in6 mcaddr; 291 int blocked; 292 293 bzero(&mcaddr, sizeof(struct sockaddr_in6)); 294 mcaddr.sin6_len = sizeof(struct sockaddr_in6); 295 mcaddr.sin6_family = AF_INET6; 296 mcaddr.sin6_addr = ip6->ip6_dst; 297 298 blocked = im6o_mc_filter(imo, ifp, 299 (struct sockaddr *)&mcaddr, 300 (struct sockaddr *)&fromsa); 301 if (blocked != MCAST_PASS) { 302 if (blocked == MCAST_NOTGMEMBER) 303 IP6STAT_INC(ip6s_notmember); 304 if (blocked == MCAST_NOTSMEMBER || 305 blocked == MCAST_MUTED) 306 UDPSTAT_INC(udps_filtermcast); 307 INP_RUNLOCK(inp); 308 continue; 309 } 310 } |
|
285 if (last != NULL) { 286 struct mbuf *n; 287 288 if ((n = m_copy(m, 0, M_COPYALL)) != NULL) { 289 INP_RLOCK(last); 290 if (last->inp_ppcb != NULL) { 291 /* 292 * Engage the tunneling --- 99 unchanged lines hidden (view full) --- 392 INP_RUNLOCK(inp); 393 return (IPPROTO_DONE); 394 } 395 udp6_append(inp, m, off, &fromsa); 396 INP_RUNLOCK(inp); 397 return (IPPROTO_DONE); 398 399badheadlocked: | 311 if (last != NULL) { 312 struct mbuf *n; 313 314 if ((n = m_copy(m, 0, M_COPYALL)) != NULL) { 315 INP_RLOCK(last); 316 if (last->inp_ppcb != NULL) { 317 /* 318 * Engage the tunneling --- 99 unchanged lines hidden (view full) --- 418 INP_RUNLOCK(inp); 419 return (IPPROTO_DONE); 420 } 421 udp6_append(inp, m, off, &fromsa); 422 INP_RUNLOCK(inp); 423 return (IPPROTO_DONE); 424 425badheadlocked: |
426 if (inp) 427 INP_RUNLOCK(inp); |
|
400 INP_INFO_RUNLOCK(&V_udbinfo); 401badunlocked: 402 if (m) 403 m_freem(m); 404 return (IPPROTO_DONE); 405} 406 407void --- 688 unchanged lines hidden --- | 428 INP_INFO_RUNLOCK(&V_udbinfo); 429badunlocked: 430 if (m) 431 m_freem(m); 432 return (IPPROTO_DONE); 433} 434 435void --- 688 unchanged lines hidden --- |