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.93.2.2 retrieving revision 1.96 diff -u -p -r1.93.2.2 -r1.96 --- src/sys/netinet/udp_usrreq.c 2002/07/15 10:37:03 1.93.2.2 +++ src/sys/netinet/udp_usrreq.c 2002/08/14 00:23:36 1.96 @@ -1,4 +1,4 @@ -/* $NetBSD: udp_usrreq.c,v 1.93.2.2 2002/07/15 10:37:03 gehenna Exp $ */ +/* $NetBSD: udp_usrreq.c,v 1.96 2002/08/14 00:23:36 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.93.2.2 2002/07/15 10:37:03 gehenna Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.96 2002/08/14 00:23:36 itojun Exp $"); #include "opt_inet.h" #include "opt_ipsec.h" @@ -216,6 +216,7 @@ 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); @@ -272,13 +273,14 @@ 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->ip_len != iphlen + len) { - if (ip->ip_len < iphlen + len || len < sizeof(struct udphdr)) { + if (ip_len != iphlen + len) { + if (ip_len < iphlen + len || len < sizeof(struct udphdr)) { udpstat.udps_badlen++; goto bad; } - m_adj(m, iphlen + len - ip->ip_len); + m_adj(m, iphlen + len - ip_len); } /* @@ -892,7 +894,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; } @@ -924,7 +926,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 = sizeof (struct udpiphdr) + len; + ((struct ip *)ui)->ip_len = htons(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++;