Deleted Added
full compact
udp6_usrreq.c (253571) udp6_usrreq.c (254889)
1/*-
2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
3 * Copyright (c) 2010-2011 Juniper Networks, Inc.
4 * All rights reserved.
5 *
6 * Portions of this software were developed by Robert N. M. Watson under
7 * contract to Juniper Networks, Inc.
8 *

--- 53 unchanged lines hidden (view full) ---

62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.
65 *
66 * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
67 */
68
69#include <sys/cdefs.h>
1/*-
2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
3 * Copyright (c) 2010-2011 Juniper Networks, Inc.
4 * All rights reserved.
5 *
6 * Portions of this software were developed by Robert N. M. Watson under
7 * contract to Juniper Networks, Inc.
8 *

--- 53 unchanged lines hidden (view full) ---

62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.
65 *
66 * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
67 */
68
69#include <sys/cdefs.h>
70__FBSDID("$FreeBSD: head/sys/netinet6/udp6_usrreq.c 253571 2013-07-23 14:14:24Z ae $");
70__FBSDID("$FreeBSD: head/sys/netinet6/udp6_usrreq.c 254889 2013-08-25 21:54:41Z markj $");
71
72#include "opt_inet.h"
73#include "opt_inet6.h"
74#include "opt_ipfw.h"
75#include "opt_ipsec.h"
71
72#include "opt_inet.h"
73#include "opt_inet6.h"
74#include "opt_ipfw.h"
75#include "opt_ipsec.h"
76#include "opt_kdtrace.h"
76
77#include <sys/param.h>
78#include <sys/jail.h>
79#include <sys/kernel.h>
80#include <sys/lock.h>
81#include <sys/mbuf.h>
82#include <sys/priv.h>
83#include <sys/proc.h>
84#include <sys/protosw.h>
77
78#include <sys/param.h>
79#include <sys/jail.h>
80#include <sys/kernel.h>
81#include <sys/lock.h>
82#include <sys/mbuf.h>
83#include <sys/priv.h>
84#include <sys/proc.h>
85#include <sys/protosw.h>
86#include <sys/sdt.h>
85#include <sys/signalvar.h>
86#include <sys/socket.h>
87#include <sys/socketvar.h>
88#include <sys/sx.h>
89#include <sys/sysctl.h>
90#include <sys/syslog.h>
91#include <sys/systm.h>
92
93#include <net/if.h>
94#include <net/if_types.h>
95#include <net/route.h>
96
97#include <netinet/in.h>
87#include <sys/signalvar.h>
88#include <sys/socket.h>
89#include <sys/socketvar.h>
90#include <sys/sx.h>
91#include <sys/sysctl.h>
92#include <sys/syslog.h>
93#include <sys/systm.h>
94
95#include <net/if.h>
96#include <net/if_types.h>
97#include <net/route.h>
98
99#include <netinet/in.h>
100#include <netinet/in_kdtrace.h>
98#include <netinet/in_pcb.h>
99#include <netinet/in_systm.h>
100#include <netinet/in_var.h>
101#include <netinet/ip.h>
102#include <netinet/ip_icmp.h>
103#include <netinet/ip6.h>
104#include <netinet/icmp_var.h>
105#include <netinet/icmp6.h>

--- 266 unchanged lines hidden (view full) ---

372 */
373 UDPSTAT_INC(udps_noport);
374 UDPSTAT_INC(udps_noportmcast);
375 goto badheadlocked;
376 }
377 INP_RLOCK(last);
378 INP_INFO_RUNLOCK(&V_udbinfo);
379 up = intoudpcb(last);
101#include <netinet/in_pcb.h>
102#include <netinet/in_systm.h>
103#include <netinet/in_var.h>
104#include <netinet/ip.h>
105#include <netinet/ip_icmp.h>
106#include <netinet/ip6.h>
107#include <netinet/icmp_var.h>
108#include <netinet/icmp6.h>

--- 266 unchanged lines hidden (view full) ---

375 */
376 UDPSTAT_INC(udps_noport);
377 UDPSTAT_INC(udps_noportmcast);
378 goto badheadlocked;
379 }
380 INP_RLOCK(last);
381 INP_INFO_RUNLOCK(&V_udbinfo);
382 up = intoudpcb(last);
383 UDP_PROBE(receive, NULL, last, ip6, last, uh);
380 if (up->u_tun_func == NULL) {
381 udp6_append(last, m, off, &fromsa);
382 } else {
383 /*
384 * Engage the tunneling protocol.
385 */
386 (*up->u_tun_func)(m, off, last);
387 }

--- 62 unchanged lines hidden (view full) ---

450 goto badunlocked;
451 if (badport_bandlim(BANDLIM_ICMP6_UNREACH) < 0)
452 goto badunlocked;
453 icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
454 return (IPPROTO_DONE);
455 }
456 INP_RLOCK_ASSERT(inp);
457 up = intoudpcb(inp);
384 if (up->u_tun_func == NULL) {
385 udp6_append(last, m, off, &fromsa);
386 } else {
387 /*
388 * Engage the tunneling protocol.
389 */
390 (*up->u_tun_func)(m, off, last);
391 }

--- 62 unchanged lines hidden (view full) ---

454 goto badunlocked;
455 if (badport_bandlim(BANDLIM_ICMP6_UNREACH) < 0)
456 goto badunlocked;
457 icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
458 return (IPPROTO_DONE);
459 }
460 INP_RLOCK_ASSERT(inp);
461 up = intoudpcb(inp);
462 UDP_PROBE(receive, NULL, inp, ip6, inp, uh);
458 if (up->u_tun_func == NULL) {
459 udp6_append(inp, m, off, &fromsa);
460 } else {
461 /*
462 * Engage the tunneling protocol.
463 */
464
465 (*up->u_tun_func)(m, off, inp);

--- 300 unchanged lines hidden (view full) ---

766 udp6->uh_sum = 0;
767
768 switch (af) {
769 case AF_INET6:
770 ip6 = mtod(m, struct ip6_hdr *);
771 ip6->ip6_flow = inp->inp_flow & IPV6_FLOWINFO_MASK;
772 ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
773 ip6->ip6_vfc |= IPV6_VERSION;
463 if (up->u_tun_func == NULL) {
464 udp6_append(inp, m, off, &fromsa);
465 } else {
466 /*
467 * Engage the tunneling protocol.
468 */
469
470 (*up->u_tun_func)(m, off, inp);

--- 300 unchanged lines hidden (view full) ---

771 udp6->uh_sum = 0;
772
773 switch (af) {
774 case AF_INET6:
775 ip6 = mtod(m, struct ip6_hdr *);
776 ip6->ip6_flow = inp->inp_flow & IPV6_FLOWINFO_MASK;
777 ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
778 ip6->ip6_vfc |= IPV6_VERSION;
774#if 0 /* ip6_plen will be filled in ip6_output. */
775 ip6->ip6_plen = htons((u_short)plen);
779 ip6->ip6_plen = htons((u_short)plen);
776#endif
777 ip6->ip6_nxt = IPPROTO_UDP;
778 ip6->ip6_hlim = in6_selecthlim(inp, NULL);
779 ip6->ip6_src = *laddr;
780 ip6->ip6_dst = *faddr;
781
782 udp6->uh_sum = in6_cksum_pseudo(ip6, plen, IPPROTO_UDP, 0);
783 m->m_pkthdr.csum_flags = CSUM_UDP_IPV6;
784 m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum);
785
786 flags = 0;
787
780 ip6->ip6_nxt = IPPROTO_UDP;
781 ip6->ip6_hlim = in6_selecthlim(inp, NULL);
782 ip6->ip6_src = *laddr;
783 ip6->ip6_dst = *faddr;
784
785 udp6->uh_sum = in6_cksum_pseudo(ip6, plen, IPPROTO_UDP, 0);
786 m->m_pkthdr.csum_flags = CSUM_UDP_IPV6;
787 m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum);
788
789 flags = 0;
790
791 UDP_PROBE(send, NULL, inp, ip6, inp, udp6);
788 UDPSTAT_INC(udps_opackets);
789 error = ip6_output(m, optp, NULL, flags, inp->in6p_moptions,
790 NULL, inp);
791 break;
792 case AF_INET:
793 error = EAFNOSUPPORT;
794 goto release;
795 }

--- 366 unchanged lines hidden ---
792 UDPSTAT_INC(udps_opackets);
793 error = ip6_output(m, optp, NULL, flags, inp->in6p_moptions,
794 NULL, inp);
795 break;
796 case AF_INET:
797 error = EAFNOSUPPORT;
798 goto release;
799 }

--- 366 unchanged lines hidden ---