Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/netinet/udp_usrreq.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/netinet/udp_usrreq.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.75.2.9 retrieving revision 1.93.4.2 diff -u -p -r1.75.2.9 -r1.93.4.2 --- src/sys/netinet/udp_usrreq.c 2002/08/27 23:48:07 1.75.2.9 +++ src/sys/netinet/udp_usrreq.c 2004/03/31 20:10:29 1.93.4.2 @@ -1,9 +1,9 @@ -/* $NetBSD: udp_usrreq.c,v 1.75.2.9 2002/08/27 23:48:07 nathanw Exp $ */ +/* $NetBSD: udp_usrreq.c,v 1.93.4.2 2004/03/31 20:10:29 tron Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -15,7 +15,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.75.2.9 2002/08/27 23:48:07 nathanw Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.93.4.2 2004/03/31 20:10:29 tron Exp $"); #include "opt_inet.h" #include "opt_ipsec.h" @@ -216,7 +216,6 @@ udp_input(m, va_alist) int iphlen, proto; int len; int n; - u_int16_t ip_len; va_start(ap, m); iphlen = va_arg(ap, int); @@ -263,7 +262,6 @@ udp_input(m, va_alist) return; } #endif - KASSERT(UDP_HDR_ALIGNED_P(uh)); /* destination port of 0 is illegal, based on RFC768. */ if (uh->uh_dport == 0) @@ -273,14 +271,13 @@ udp_input(m, va_alist) * Make mbuf data length reflect UDP length. * If not enough data to reflect UDP length, drop. */ - ip_len = ntohs(ip->ip_len); len = ntohs((u_int16_t)uh->uh_ulen); - if (ip_len != iphlen + len) { - if (ip_len < iphlen + len || len < sizeof(struct udphdr)) { + if (ip->ip_len != iphlen + len) { + if (ip->ip_len < iphlen + len || len < sizeof(struct udphdr)) { udpstat.udps_badlen++; goto bad; } - m_adj(m, iphlen + len - ip_len); + m_adj(m, iphlen + len - ip->ip_len); } /* @@ -421,7 +418,6 @@ udp6_input(mp, offp, proto) return IPPROTO_DONE; } #endif - KASSERT(UDP_HDR_ALIGNED_P(uh)); ulen = ntohs((u_short)uh->uh_ulen); /* * RFC2675 section 4: jumbograms will have 0 in the UDP header field, @@ -449,9 +445,11 @@ udp6_input(mp, offp, proto) /* * Checksum extended UDP header and data. */ - if (uh->uh_sum == 0) + if (uh->uh_sum == 0) { udp6stat.udp6s_nosum++; - else if (in6_cksum(m, IPPROTO_UDP, off, ulen) != 0) { + goto bad; + } + if (in6_cksum(m, IPPROTO_UDP, off, ulen) != 0) { udp6stat.udp6s_badsum++; goto bad; } @@ -894,7 +892,7 @@ udp_output(m, va_alist) * Compute the packet length of the IP header, and * punt if the length looks bogus. */ - if (len + sizeof(struct udpiphdr) > IP_MAXPACKET) { + if ((len + sizeof(struct udpiphdr)) > IP_MAXPACKET) { error = EMSGSIZE; goto release; } @@ -926,7 +924,7 @@ udp_output(m, va_alist) m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); } else ui->ui_sum = 0; - ((struct ip *)ui)->ip_len = htons(sizeof (struct udpiphdr) + len); + ((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len; ((struct ip *)ui)->ip_ttl = inp->inp_ip.ip_ttl; /* XXX */ ((struct ip *)ui)->ip_tos = inp->inp_ip.ip_tos; /* XXX */ udpstat.udps_opackets++; @@ -1141,7 +1139,7 @@ udp_sysctl(name, namelen, oldp, oldlenp, return (sysctl_int(oldp, oldlenp, newp, newlen, &udp_sendspace)); case UDPCTL_RECVSPACE: - return (sysctl_int(oldp, oldlenp, newp, newlen, + return (sysctl_int(oldp, oldlenp, newp, newlen, &udp_recvspace)); default: return (ENOPROTOOPT);