udp6_usrreq.c (54952) | udp6_usrreq.c (55009) |
---|---|
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 --- 46 unchanged lines hidden (view full) --- 55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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_var.h 8.1 (Berkeley) 6/10/93 | 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 --- 46 unchanged lines hidden (view full) --- 55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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_var.h 8.1 (Berkeley) 6/10/93 |
63 * $FreeBSD: head/sys/netinet6/udp6_usrreq.c 54952 1999-12-21 11:14:12Z eivind $ | 63 * $FreeBSD: head/sys/netinet6/udp6_usrreq.c 55009 1999-12-22 19:13:38Z shin $ |
64 */ 65 | 64 */ 65 |
66#include "opt_ipsec.h" 67 |
|
66#include <sys/param.h> 67#include <sys/kernel.h> 68#include <sys/malloc.h> 69#include <sys/mbuf.h> 70#include <sys/protosw.h> 71#include <sys/socket.h> 72#include <sys/socketvar.h> 73#include <sys/sysctl.h> --- 19 unchanged lines hidden (view full) --- 93#include <netinet6/ip6_var.h> 94#include <netinet6/in6_pcb.h> 95#include <netinet6/icmp6.h> 96#include <netinet6/udp6_var.h> 97#include <netinet6/ip6protosw.h> 98 99#ifdef IPSEC 100#include <netinet6/ipsec.h> | 68#include <sys/param.h> 69#include <sys/kernel.h> 70#include <sys/malloc.h> 71#include <sys/mbuf.h> 72#include <sys/protosw.h> 73#include <sys/socket.h> 74#include <sys/socketvar.h> 75#include <sys/sysctl.h> --- 19 unchanged lines hidden (view full) --- 95#include <netinet6/ip6_var.h> 96#include <netinet6/in6_pcb.h> 97#include <netinet6/icmp6.h> 98#include <netinet6/udp6_var.h> 99#include <netinet6/ip6protosw.h> 100 101#ifdef IPSEC 102#include <netinet6/ipsec.h> |
103#include <netinet6/ipsec6.h> |
|
101#endif /*IPSEC*/ 102 103#include "faith.h" 104 105/* 106 * UDP protocol inplementation. 107 * Per RFC 768, August, 1980. 108 */ --- 137 unchanged lines hidden (view full) --- 246 247 if (last != NULL) { 248 struct mbuf *n; 249 250#ifdef IPSEC 251 /* 252 * Check AH/ESP integrity. 253 */ | 104#endif /*IPSEC*/ 105 106#include "faith.h" 107 108/* 109 * UDP protocol inplementation. 110 * Per RFC 768, August, 1980. 111 */ --- 137 unchanged lines hidden (view full) --- 249 250 if (last != NULL) { 251 struct mbuf *n; 252 253#ifdef IPSEC 254 /* 255 * Check AH/ESP integrity. 256 */ |
254 if (last != NULL && 255 ipsec6_in_reject_so(m, last->inp_socket)) { | 257 if (ipsec6_in_reject_so(m, last->inp_socket)) |
256 ipsec6stat.in_polvio++; 257 /* do not inject data into pcb */ | 258 ipsec6stat.in_polvio++; 259 /* do not inject data into pcb */ |
258 } else | 260 else |
259#endif /*IPSEC*/ 260 if ((n = m_copy(m, 0, M_COPYALL)) != NULL) { 261 /* 262 * KAME NOTE: do not 263 * m_copy(m, offset, ...) above. 264 * sbappendaddr() expects M_PKTHDR, 265 * and m_copy() will copy M_PKTHDR 266 * only if offset is 0. --- 38 unchanged lines hidden (view full) --- 305 udpstat.udps_noport++; 306 udpstat.udps_noportmcast++; 307 goto bad; 308 } 309#ifdef IPSEC 310 /* 311 * Check AH/ESP integrity. 312 */ | 261#endif /*IPSEC*/ 262 if ((n = m_copy(m, 0, M_COPYALL)) != NULL) { 263 /* 264 * KAME NOTE: do not 265 * m_copy(m, offset, ...) above. 266 * sbappendaddr() expects M_PKTHDR, 267 * and m_copy() will copy M_PKTHDR 268 * only if offset is 0. --- 38 unchanged lines hidden (view full) --- 307 udpstat.udps_noport++; 308 udpstat.udps_noportmcast++; 309 goto bad; 310 } 311#ifdef IPSEC 312 /* 313 * Check AH/ESP integrity. 314 */ |
313 if (last != NULL && ipsec6_in_reject_so(m, last->inp_socket)) { | 315 if (ipsec6_in_reject_so(m, last->inp_socket)) { |
314 ipsec6stat.in_polvio++; 315 goto bad; 316 } 317#endif /*IPSEC*/ 318 if (last->in6p_flags & IN6P_CONTROLOPTS 319 || last->in6p_socket->so_options & SO_TIMESTAMP) 320 ip6_savecontrol(last, &opts, ip6, m); 321 --- 31 unchanged lines hidden (view full) --- 353 } 354 icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0); 355 return IPPROTO_DONE; 356 } 357#ifdef IPSEC 358 /* 359 * Check AH/ESP integrity. 360 */ | 316 ipsec6stat.in_polvio++; 317 goto bad; 318 } 319#endif /*IPSEC*/ 320 if (last->in6p_flags & IN6P_CONTROLOPTS 321 || last->in6p_socket->so_options & SO_TIMESTAMP) 322 ip6_savecontrol(last, &opts, ip6, m); 323 --- 31 unchanged lines hidden (view full) --- 355 } 356 icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0); 357 return IPPROTO_DONE; 358 } 359#ifdef IPSEC 360 /* 361 * Check AH/ESP integrity. 362 */ |
361 if (in6p != NULL && ipsec6_in_reject_so(m, in6p->in6p_socket)) { | 363 if (ipsec6_in_reject_so(m, in6p->in6p_socket)) { |
362 ipsec6stat.in_polvio++; 363 goto bad; 364 } 365#endif /*IPSEC*/ 366 367 /* 368 * Construct sockaddr format source address. 369 * Stuff source address and datagram in user buffer. --- 100 unchanged lines hidden (view full) --- 470 error = SYSCTL_IN(req, addrs, sizeof(addrs)); 471 if (error) 472 return (error); 473 s = splnet(); 474 inp = in6_pcblookup_hash(&udbinfo, &addrs[1].sin6_addr, 475 addrs[1].sin6_port, 476 &addrs[0].sin6_addr, addrs[0].sin6_port, 477 1, NULL); | 364 ipsec6stat.in_polvio++; 365 goto bad; 366 } 367#endif /*IPSEC*/ 368 369 /* 370 * Construct sockaddr format source address. 371 * Stuff source address and datagram in user buffer. --- 100 unchanged lines hidden (view full) --- 472 error = SYSCTL_IN(req, addrs, sizeof(addrs)); 473 if (error) 474 return (error); 475 s = splnet(); 476 inp = in6_pcblookup_hash(&udbinfo, &addrs[1].sin6_addr, 477 addrs[1].sin6_port, 478 &addrs[0].sin6_addr, addrs[0].sin6_port, 479 1, NULL); |
478 if (!inp || !inp->inp_socket || !inp->inp_socket->so_cred) { | 480 if (!inp || !inp->inp_socket) { |
479 error = ENOENT; 480 goto out; 481 } 482 error = SYSCTL_OUT(req, inp->inp_socket->so_cred, 483 sizeof(struct ucred)); 484 485out: 486 splx(s); --- 64 unchanged lines hidden (view full) --- 551 splx(s); 552 goto release; 553 } 554 555 /* 556 * Stuff checksum and output datagram. 557 */ 558 ip6 = mtod(m, struct ip6_hdr *); | 481 error = ENOENT; 482 goto out; 483 } 484 error = SYSCTL_OUT(req, inp->inp_socket->so_cred, 485 sizeof(struct ucred)); 486 487out: 488 splx(s); --- 64 unchanged lines hidden (view full) --- 553 splx(s); 554 goto release; 555 } 556 557 /* 558 * Stuff checksum and output datagram. 559 */ 560 ip6 = mtod(m, struct ip6_hdr *); |
559 ip6->ip6_flow = in6p->in6p_flowinfo & IPV6_FLOWINFO_MASK; 560 ip6->ip6_vfc = IPV6_VERSION; | 561 ip6->ip6_flow = (ip6->ip6_flow & ~IPV6_FLOWINFO_MASK) | 562 (in6p->in6p_flowinfo & IPV6_FLOWINFO_MASK); 563 ip6->ip6_vfc = (ip6->ip6_vfc & ~IPV6_VERSION_MASK) | 564 (IPV6_VERSION & IPV6_VERSION_MASK); |
561 /* ip6_plen will be filled in ip6_output. */ 562 ip6->ip6_nxt = IPPROTO_UDP; 563 ip6->ip6_hlim = in6_selecthlim(in6p, 564 in6p->in6p_route.ro_rt ? 565 in6p->in6p_route.ro_rt->rt_ifp : 566 NULL); 567 ip6->ip6_src = in6p->in6p_laddr; 568 ip6->ip6_dst = in6p->in6p_faddr; --- 10 unchanged lines hidden (view full) --- 579 } 580 581 udpstat.udps_opackets++; 582 583#ifdef IPSEC 584 m->m_pkthdr.rcvif = (struct ifnet *)in6p->in6p_socket; 585#endif /*IPSEC*/ 586 error = ip6_output(m, in6p->in6p_outputopts, &in6p->in6p_route, | 565 /* ip6_plen will be filled in ip6_output. */ 566 ip6->ip6_nxt = IPPROTO_UDP; 567 ip6->ip6_hlim = in6_selecthlim(in6p, 568 in6p->in6p_route.ro_rt ? 569 in6p->in6p_route.ro_rt->rt_ifp : 570 NULL); 571 ip6->ip6_src = in6p->in6p_laddr; 572 ip6->ip6_dst = in6p->in6p_faddr; --- 10 unchanged lines hidden (view full) --- 583 } 584 585 udpstat.udps_opackets++; 586 587#ifdef IPSEC 588 m->m_pkthdr.rcvif = (struct ifnet *)in6p->in6p_socket; 589#endif /*IPSEC*/ 590 error = ip6_output(m, in6p->in6p_outputopts, &in6p->in6p_route, |
587 0, in6p->in6p_moptions, NULL); | 591 IPV6_SOCKINMRCVIF, in6p->in6p_moptions, NULL); |
588 589 if (addr6) { 590 in6_pcbdisconnect(in6p); 591 in6p->in6p_laddr = laddr6; 592 splx(s); 593 } 594 goto releaseopt; 595 --- 241 unchanged lines hidden --- | 592 593 if (addr6) { 594 in6_pcbdisconnect(in6p); 595 in6p->in6p_laddr = laddr6; 596 splx(s); 597 } 598 goto releaseopt; 599 --- 241 unchanged lines hidden --- |