Deleted Added
sdiff udiff text old ( 190963 ) new ( 191672 )
full compact
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 $");
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 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
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;
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;
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
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:
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 ---