Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Sep 2000 17:21:45 +0300
From:      Ruslan Ermilov <ru@sunbay.com>
To:        Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Cc:        net@FreeBSD.org
Subject:   Re: cvs commit: src/sys/netinet ip_divert.c ip_icmp.c ip_input.c ip_mroute.c ip_output.c raw_ip.c udp_usrreq.c
Message-ID:  <20000908172145.A27354@sunbay.com>
In-Reply-To: <200009071630.MAA30115@khavrinen.lcs.mit.edu>; from wollman@khavrinen.lcs.mit.edu on Thu, Sep 07, 2000 at 12:30:29PM -0400
References:  <200009011233.FAA69145@freefall.freebsd.org> <200009061845.OAA20964@khavrinen.lcs.mit.edu> <20000907092610.A46475@sunbay.com> <200009071630.MAA30115@khavrinen.lcs.mit.edu>

next in thread | previous in thread | raw e-mail | index | archive | help

--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii

On Thu, Sep 07, 2000 at 12:30:29PM -0400, Garrett Wollman wrote:
> <<On Thu, 7 Sep 2000 09:26:10 +0300, Ruslan Ermilov <ru@sunbay.com> said:
> 
> > The same does NetBSD, but I feel more logical is to have all these fields
> > in host byte order right after ip_input() processing.
> 
> Why?  There is no earthly reason for ip_id to *ever* be swapped.
> 
Ok, here is the patch that completely eliminates `ip_id' swapping,
bringing us in sync with BSD/OS and NetBSD.  It reverts part of
my previously committed `icmp error generation fixes' patch.

-- 
Ruslan Ermilov		Oracle Developer/DBA,
ru@sunbay.com		Sunbay Software AG,
ru@FreeBSD.org		FreeBSD committer,
+380.652.512.251	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age

--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch-5.0-CURRENT"

Index: man4/ip.4
===================================================================
RCS file: /home/ncvs/src/share/man/man4/ip.4,v
retrieving revision 1.16
diff -u -p -r1.16 ip.4
--- man4/ip.4	2000/09/01 13:06:57	1.16
+++ man4/ip.4	2000/09/08 14:17:14
@@ -32,7 +32,7 @@
 .\"     @(#)ip.4	8.2 (Berkeley) 11/30/93
 .\" $FreeBSD: src/share/man/man4/ip.4,v 1.16 2000/09/01 13:06:57 sheldonh Exp $
 .\"
-.Dd September 1, 2000
+.Dd November 30, 1993
 .Dt IP 4
 .Os BSD 4.2
 .Sh NAME
@@ -368,10 +368,6 @@ ip->ip_off = offset;
 If the header source address is set to 
 .Dv INADDR_ANY,
 the kernel will choose an appropriate address.
-.Pp
-The header identification field
-.Dq Li ip_id
-is expected in host byte order.
 .Sh DIAGNOSTICS
 A socket operation may fail with one of the following errors returned:
 .Bl -tag -width [EADDRNOTAVAIL]
@@ -420,11 +416,3 @@ The
 .Nm
 protocol appeared in
 .Bx 4.2 .
-.Pp
-If the
-.Dv IP_HDRINCL
-option is in use,
-.Fx 4.2
-and above expect the
-.Dq Li ip_id
-field in host byte order.
Index: net/bridge.c
===================================================================
RCS file: /home/ncvs/src/sys/net/bridge.c,v
retrieving revision 1.23
diff -u -p -r1.23 bridge.c
--- net/bridge.c	2000/07/29 02:00:12	1.23
+++ net/bridge.c	2000/09/08 14:17:14
@@ -718,7 +718,6 @@ bdg_forward(struct mbuf **m0, struct eth
 	 */
 	ip = mtod(m, struct ip *);
 	NTOHS(ip->ip_len);
-	NTOHS(ip->ip_id);
 	NTOHS(ip->ip_off);
 
 	/*
@@ -744,7 +743,6 @@ bdg_forward(struct mbuf **m0, struct eth
 	 * Then, if canfree==1, also restore *m0.
 	 */
 	HTONS(ip->ip_len);
-	HTONS(ip->ip_id);
 	HTONS(ip->ip_off);
 	if (canfree) /* m was a reference to *m0, so update *m0 */
 	    *m0 = m ;
Index: netinet/ip_auth.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_auth.c,v
retrieving revision 1.18
diff -u -p -r1.18 ip_auth.c
--- netinet/ip_auth.c	2000/08/01 17:14:38	1.18
+++ netinet/ip_auth.c	2000/09/08 14:17:14
@@ -250,7 +250,7 @@ ip_t *ip;
 
 		bo = ip->ip_len;
 		ip->ip_len = htons(bo);
-# if !SOLARIS && !defined(__NetBSD__)
+# if !SOLARIS && !defined(__NetBSD__) && !defined(__FreeBSD__)
 		/* 4.4BSD converts this ip_input.c, but I don't in solaris.c */
 		bo = ip->ip_id;
 		ip->ip_id = htons(bo);
Index: netinet/ip_divert.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_divert.c,v
retrieving revision 1.46
diff -u -p -r1.46 ip_divert.c
--- netinet/ip_divert.c	2000/09/01 12:33:03	1.46
+++ netinet/ip_divert.c	2000/09/08 14:17:14
@@ -293,7 +293,6 @@ div_output(so, m, addr, control)
 
 		/* Convert fields to host order for ip_output() */
 		NTOHS(ip->ip_len);
-		NTOHS(ip->ip_id);
 		NTOHS(ip->ip_off);
 
 		/* Send packet to output processing */
Index: netinet/ip_fil.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_fil.c,v
retrieving revision 1.21
diff -u -p -r1.21 ip_fil.c
--- netinet/ip_fil.c	2000/08/13 04:31:05	1.21
+++ netinet/ip_fil.c	2000/09/08 14:17:14
@@ -1369,7 +1369,9 @@ frdest_t *fdp;
 			i = 1;
 # endif
 # ifndef sparc
+#  ifndef __FreeBSD__
 		ip->ip_id = htons(ip->ip_id);
+#  endif
 		ip->ip_len = htons(ip->ip_len);
 		ip->ip_off = htons(ip->ip_off);
 # endif
Index: netinet/ip_icmp.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_icmp.c,v
retrieving revision 1.44
diff -u -p -r1.44 ip_icmp.c
--- netinet/ip_icmp.c	2000/09/01 12:33:03	1.44
+++ netinet/ip_icmp.c	2000/09/08 14:17:14
@@ -196,7 +196,6 @@ icmp_error(n, type, code, dest, destifp)
 	 * Convert fields to network representation.
 	 */
 	HTONS(nip->ip_len);
-	HTONS(nip->ip_id);
 	HTONS(nip->ip_off);
 
 	/*
Index: netinet/ip_input.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.139
diff -u -p -r1.139 ip_input.c
--- netinet/ip_input.c	2000/09/01 12:33:03	1.139
+++ netinet/ip_input.c	2000/09/08 14:17:15
@@ -346,7 +346,6 @@ ip_input(struct mbuf *m)
 		ipstat.ips_badlen++;
 		goto bad;
 	}
-	NTOHS(ip->ip_id);
 	NTOHS(ip->ip_off);
 
 	/*
@@ -692,10 +691,8 @@ found:
 				ip->ip_len += hlen;
 				HTONS(ip->ip_len);
 				HTONS(ip->ip_off);
-				HTONS(ip->ip_id);
 				ip->ip_sum = 0;
 				ip->ip_sum = in_cksum_hdr(ip);
-				NTOHS(ip->ip_id);
 				NTOHS(ip->ip_off);
 				NTOHS(ip->ip_len);
 				ip->ip_len -= hlen;
@@ -725,7 +722,6 @@ found:
 		ip->ip_len += hlen;
 		HTONS(ip->ip_len);
 		HTONS(ip->ip_off);
-		HTONS(ip->ip_id);
 
 		/* Deliver packet to divert input routine */
 		ip_divert_cookie = divert_cookie;
Index: netinet/ip_mroute.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_mroute.c,v
retrieving revision 1.58
diff -u -p -r1.58 ip_mroute.c
--- netinet/ip_mroute.c	2000/09/01 12:33:03	1.58
+++ netinet/ip_mroute.c	2000/09/08 14:17:16
@@ -1581,7 +1581,7 @@ encap_send(ip, vifp, m)
      */
     ip_copy = mtod(mb_copy, struct ip *);
     *ip_copy = multicast_encap_iphdr;
-    ip_copy->ip_id = ip_id++;
+    ip_copy->ip_id = htons(ip_id++);
     ip_copy->ip_len += len;
     ip_copy->ip_src = vifp->v_lcl_addr;
     ip_copy->ip_dst = vifp->v_rmt_addr;
@@ -1592,7 +1592,6 @@ encap_send(ip, vifp, m)
     ip = (struct ip *)((caddr_t)ip_copy + sizeof(multicast_encap_iphdr));
     --ip->ip_ttl;
     HTONS(ip->ip_len);
-    HTONS(ip->ip_id);
     HTONS(ip->ip_off);
     ip->ip_sum = 0;
     mb_copy->m_data += sizeof(multicast_encap_iphdr);
Index: netinet/ip_output.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_output.c,v
retrieving revision 1.110
diff -u -p -r1.110 ip_output.c
--- netinet/ip_output.c	2000/09/01 12:33:03	1.110
+++ netinet/ip_output.c	2000/09/08 14:17:16
@@ -211,7 +211,7 @@ ip_output(m0, opt, ro, flags, imo)
 	if ((flags & (IP_FORWARDING|IP_RAWOUTPUT)) == 0) {
 		ip->ip_vhl = IP_MAKE_VHL(IPVERSION, hlen >> 2);
 		ip->ip_off &= IP_DF;
-		ip->ip_id = ip_id++;
+		ip->ip_id = htons(ip_id++);
 		ipstat.ips_localout++;
 	} else {
 		hlen = IP_VHL_HL(ip->ip_vhl) << 2;
@@ -520,7 +520,6 @@ sendit:
 
 			/* Restore packet header fields to original values */
 			HTONS(ip->ip_len);
-			HTONS(ip->ip_id);
 			HTONS(ip->ip_off);
 
 			/* Deliver packet to divert input routine */
@@ -595,7 +594,6 @@ sendit:
 				m->m_pkthdr.csum_flags |=
 				    CSUM_IP_CHECKED | CSUM_IP_VALID;
 				HTONS(ip->ip_len);
-				HTONS(ip->ip_id);
 				HTONS(ip->ip_off);
 				ip_input(m);
 				goto done;
@@ -715,7 +713,6 @@ pass:
 	}
 
 	HTONS(ip->ip_len);
-	HTONS(ip->ip_id);
 	HTONS(ip->ip_off);
 
 	error = ipsec4_output(&state, sp, flags);
@@ -776,7 +773,6 @@ pass:
 
 	/* make it flipped, again. */
 	NTOHS(ip->ip_len);
-	NTOHS(ip->ip_id);
 	NTOHS(ip->ip_off);
 skip_ipsec:
 #endif /*IPSEC*/
@@ -796,7 +792,6 @@ skip_ipsec:
 	if ((u_short)ip->ip_len <= ifp->if_mtu ||
 	    ifp->if_hwassist & CSUM_FRAGMENT) {
 		HTONS(ip->ip_len);
-		HTONS(ip->ip_id);
 		HTONS(ip->ip_off);
 		ip->ip_sum = 0;
 		if (sw_csum & CSUM_DELAY_IP) {
@@ -892,7 +887,6 @@ skip_ipsec:
 		m->m_pkthdr.len = mhlen + len;
 		m->m_pkthdr.rcvif = (struct ifnet *)0;
 		m->m_pkthdr.csum_flags = m0->m_pkthdr.csum_flags;
-		HTONS(mhip->ip_id);
 		HTONS(mhip->ip_off);
 		mhip->ip_sum = 0;
 		if (sw_csum & CSUM_DELAY_IP) {
@@ -921,7 +915,6 @@ skip_ipsec:
 	m_adj(m, hlen + firstlen - (u_short)ip->ip_len);
 	m->m_pkthdr.len = hlen + firstlen;
 	ip->ip_len = htons((u_short)m->m_pkthdr.len);
-	HTONS(ip->ip_id);
 	ip->ip_off |= IP_MF;
 	HTONS(ip->ip_off);
 	ip->ip_sum = 0;
@@ -1864,7 +1857,6 @@ ip_mloopback(ifp, m, dst, hlen)
 		 */
 		ip = mtod(copym, struct ip *);
 		HTONS(ip->ip_len);
-		HTONS(ip->ip_id);
 		HTONS(ip->ip_off);
 		ip->ip_sum = 0;
 		if (ip->ip_vhl == IP_VHL_BORING) {
Index: netinet/raw_ip.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/raw_ip.c,v
retrieving revision 1.68
diff -u -p -r1.68 raw_ip.c
--- netinet/raw_ip.c	2000/09/01 12:33:03	1.68
+++ netinet/raw_ip.c	2000/09/08 14:17:16
@@ -221,7 +221,7 @@ rip_output(m, so, dst)
 			return EINVAL;
 		}
 		if (ip->ip_id == 0)
-			ip->ip_id = ip_id++;
+			ip->ip_id = htons(ip_id++);
 		/* XXX prevent ip_output from overwriting header fields */
 		flags |= IP_RAWOUTPUT;
 		ipstat.ips_rawout++;
Index: netinet6/ah_input.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet6/ah_input.c,v
retrieving revision 1.4
diff -u -p -r1.4 ah_input.c
--- netinet6/ah_input.c	2000/08/16 09:56:45	1.4
+++ netinet6/ah_input.c	2000/09/08 14:17:16
@@ -291,7 +291,6 @@ ah4_input(m, va_alist)
 	 * convert them back to network endian.  VERY stupid.
 	 */
 	ip->ip_len = htons(ip->ip_len + hlen);
-	ip->ip_id = htons(ip->ip_id);
 	ip->ip_off = htons(ip->ip_off);
 #endif
 	if (ah4_calccksum(m, (caddr_t)cksum, siz1, algo, sav)) {
@@ -305,7 +304,6 @@ ah4_input(m, va_alist)
 	 * flip them back.
 	 */
 	ip->ip_len = ntohs(ip->ip_len) - hlen;
-	ip->ip_id = ntohs(ip->ip_id);
 	ip->ip_off = ntohs(ip->ip_off);
 #endif
     }

--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch-4.1-STABLE"

Index: net/bridge.c
===================================================================
RCS file: /home/ncvs/src/sys/net/bridge.c,v
retrieving revision 1.16.2.4
diff -u -p -r1.16.2.4 bridge.c
--- net/bridge.c	2000/08/03 00:09:34	1.16.2.4
+++ net/bridge.c	2000/09/08 14:18:14
@@ -713,7 +713,6 @@ bdg_forward(struct mbuf **m0, struct eth
 	 */
 	ip = mtod(m, struct ip *);
 	NTOHS(ip->ip_len);
-	NTOHS(ip->ip_id);
 	NTOHS(ip->ip_off);
 
 	/*
@@ -739,7 +738,6 @@ bdg_forward(struct mbuf **m0, struct eth
 	 * Then, if canfree==1, also restore *m0.
 	 */
 	HTONS(ip->ip_len);
-	HTONS(ip->ip_id);
 	HTONS(ip->ip_off);
 	if (canfree) /* m was a reference to *m0, so update *m0 */
 	    *m0 = m ;
Index: netinet/ip_auth.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_auth.c,v
retrieving revision 1.14.2.3
diff -u -p -r1.14.2.3 ip_auth.c
--- netinet/ip_auth.c	2000/08/04 17:52:23	1.14.2.3
+++ netinet/ip_auth.c	2000/09/08 14:18:14
@@ -250,7 +250,7 @@ ip_t *ip;
 
 		bo = ip->ip_len;
 		ip->ip_len = htons(bo);
-# if !SOLARIS && !defined(__NetBSD__)
+# if !SOLARIS && !defined(__NetBSD__) && !defined(__FreeBSD__)
 		/* 4.4BSD converts this ip_input.c, but I don't in solaris.c */
 		bo = ip->ip_id;
 		ip->ip_id = htons(bo);
Index: netinet/ip_fil.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_fil.c,v
retrieving revision 1.14.2.2
diff -u -p -r1.14.2.2 ip_fil.c
--- netinet/ip_fil.c	2000/07/19 23:27:55	1.14.2.2
+++ netinet/ip_fil.c	2000/09/08 14:18:14
@@ -1364,7 +1364,9 @@ frdest_t *fdp;
 			i = 1;
 # endif
 # ifndef sparc
+#  ifndef __FreeBSD__
 		ip->ip_id = htons(ip->ip_id);
+#  endif
 		ip->ip_len = htons(ip->ip_len);
 		ip->ip_off = htons(ip->ip_off);
 # endif
Index: netinet/ip_icmp.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_icmp.c,v
retrieving revision 1.39.2.1
diff -u -p -r1.39.2.1 ip_icmp.c
--- netinet/ip_icmp.c	2000/06/08 15:11:21	1.39.2.1
+++ netinet/ip_icmp.c	2000/09/08 14:18:14
@@ -199,7 +199,12 @@ icmp_error(n, type, code, dest, destifp)
 	icp->icmp_code = code;
 	bcopy((caddr_t)oip, (caddr_t)&icp->icmp_ip, icmplen);
 	nip = &icp->icmp_ip;
-	nip->ip_len = htons((u_short)(nip->ip_len + oiplen));
+
+	/*
+	 * Convert fields to network representation.
+	 */
+	HTONS(nip->ip_len);
+	HTONS(nip->ip_off);
 
 	/*
 	 * Now, copy old ip header (without options)
Index: netinet/ip_input.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.130.2.5
diff -u -p -r1.130.2.5 ip_input.c
--- netinet/ip_input.c	2000/07/15 07:14:30	1.130.2.5
+++ netinet/ip_input.c	2000/09/08 14:18:14
@@ -341,7 +341,6 @@ ip_input(struct mbuf *m)
 		ipstat.ips_badlen++;
 		goto bad;
 	}
-	NTOHS(ip->ip_id);
 	NTOHS(ip->ip_off);
 
 	/*
@@ -508,18 +507,12 @@ pass:
 			 * The packet is returned (relatively) intact; if
 			 * ip_mforward() returns a non-zero value, the packet
 			 * must be discarded, else it may be accepted below.
-			 *
-			 * (The IP ident field is put in the same byte order
-			 * as expected when ip_mforward() is called from
-			 * ip_output().)
 			 */
-			ip->ip_id = htons(ip->ip_id);
 			if (ip_mforward(ip, m->m_pkthdr.rcvif, m, 0) != 0) {
 				ipstat.ips_cantforward++;
 				m_freem(m);
 				return;
 			}
-			ip->ip_id = ntohs(ip->ip_id);
 
 			/*
 			 * The process-level routing demon needs to receive
@@ -680,10 +673,8 @@ found:
 				ip->ip_len += hlen;
 				HTONS(ip->ip_len);
 				HTONS(ip->ip_off);
-				HTONS(ip->ip_id);
 				ip->ip_sum = 0;
 				ip->ip_sum = in_cksum_hdr(ip);
-				NTOHS(ip->ip_id);
 				NTOHS(ip->ip_off);
 				NTOHS(ip->ip_len);
 				ip->ip_len -= hlen;
@@ -713,7 +704,6 @@ found:
 		ip->ip_len += hlen;
 		HTONS(ip->ip_len);
 		HTONS(ip->ip_off);
-		HTONS(ip->ip_id);
 
 		/* Deliver packet to divert input routine */
 		ip_divert_cookie = divert_cookie;
@@ -1272,7 +1262,6 @@ nosourcerouting:
 	}
 	return (0);
 bad:
-	ip->ip_len -= IP_VHL_HL(ip->ip_vhl) << 2;   /* XXX icmp_error adds in hdr length */
 	icmp_error(m, type, code, 0, 0);
 	ipstat.ips_badoptions++;
 	return (1);
@@ -1478,7 +1467,6 @@ ip_forward(m, srcrt)
 		m_freem(m);
 		return;
 	}
-	HTONS(ip->ip_id);
 #ifdef IPSTEALTH
 	if (!ipstealth) {
 #endif
@@ -1487,7 +1475,6 @@ ip_forward(m, srcrt)
 			    dest, 0);
 			return;
 		}
-		ip->ip_ttl -= IPTTLDEC;
 #ifdef IPSTEALTH
 	}
 #endif
@@ -1516,6 +1503,16 @@ ip_forward(m, srcrt)
 	 * we need to generate an ICMP message to the src.
 	 */
 	mcopy = m_copy(m, 0, imin((int)ip->ip_len, 64));
+	if (mcopy && (mcopy->m_flags & M_EXT))
+		m_copydata(mcopy, 0, sizeof(struct ip), mtod(mcopy, caddr_t));
+
+#ifdef IPSTEALTH
+	if (!ipstealth) {
+#endif
+		ip->ip_ttl -= IPTTLDEC;
+#ifdef IPSTEALTH
+	}
+#endif
 
 	/*
 	 * If forwarding packet using same interface that it came in on,
@@ -1654,6 +1651,8 @@ ip_forward(m, srcrt)
 		m_freem(mcopy);
 		return;
 	}
+	if (mcopy->m_flags & M_EXT)
+		m_copyback(mcopy, 0, sizeof(struct ip), mtod(mcopy, caddr_t));
 	icmp_error(mcopy, type, code, dest, destifp);
 }
 
Index: netinet/ip_output.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_output.c,v
retrieving revision 1.99.2.6
diff -u -p -r1.99.2.6 ip_output.c
--- netinet/ip_output.c	2000/07/15 07:14:30	1.99.2.6
+++ netinet/ip_output.c	2000/09/08 14:18:15
@@ -576,8 +576,8 @@ sendit:
 				}
 				m->m_pkthdr.csum_flags |=
 				    CSUM_IP_CHECKED | CSUM_IP_VALID;
-				ip->ip_len = htons((u_short)ip->ip_len);
-				ip->ip_off = htons((u_short)ip->ip_off);
+				HTONS(ip->ip_len);
+				HTONS(ip->ip_off);
 				ip_input(m);
 				goto done;
 			}
@@ -695,8 +695,8 @@ pass:
 		m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA;
 	}
 
-	ip->ip_len = htons((u_short)ip->ip_len);
-	ip->ip_off = htons((u_short)ip->ip_off);
+	HTONS(ip->ip_len);
+	HTONS(ip->ip_off);
 
 	error = ipsec4_output(&state, sp, flags);
 
@@ -755,8 +755,8 @@ pass:
 	}
 
 	/* make it flipped, again. */
-	ip->ip_len = ntohs((u_short)ip->ip_len);
-	ip->ip_off = ntohs((u_short)ip->ip_off);
+	NTOHS(ip->ip_len);
+	NTOHS(ip->ip_off);
 skip_ipsec:
 #endif /*IPSEC*/
 
@@ -774,8 +774,8 @@ skip_ipsec:
 	 */
 	if ((u_short)ip->ip_len <= ifp->if_mtu ||
 	    ifp->if_hwassist & CSUM_FRAGMENT) {
-		ip->ip_len = htons((u_short)ip->ip_len);
-		ip->ip_off = htons((u_short)ip->ip_off);
+		HTONS(ip->ip_len);
+		HTONS(ip->ip_off);
 		ip->ip_sum = 0;
 		if (sw_csum & CSUM_DELAY_IP) {
 			if (ip->ip_vhl == IP_VHL_BORING) {
@@ -870,7 +870,7 @@ skip_ipsec:
 		m->m_pkthdr.len = mhlen + len;
 		m->m_pkthdr.rcvif = (struct ifnet *)0;
 		m->m_pkthdr.csum_flags = m0->m_pkthdr.csum_flags;
-		mhip->ip_off = htons((u_short)mhip->ip_off);
+		HTONS(mhip->ip_off);
 		mhip->ip_sum = 0;
 		if (sw_csum & CSUM_DELAY_IP) {
 			if (mhip->ip_vhl == IP_VHL_BORING) {
@@ -898,7 +898,8 @@ skip_ipsec:
 	m_adj(m, hlen + firstlen - (u_short)ip->ip_len);
 	m->m_pkthdr.len = hlen + firstlen;
 	ip->ip_len = htons((u_short)m->m_pkthdr.len);
-	ip->ip_off = htons((u_short)(ip->ip_off | IP_MF));
+	ip->ip_off |= IP_MF;
+	HTONS(ip->ip_off);
 	ip->ip_sum = 0;
 	if (sw_csum & CSUM_DELAY_IP) {
 		if (ip->ip_vhl == IP_VHL_BORING) {
@@ -1838,8 +1839,8 @@ ip_mloopback(ifp, m, dst, hlen)
 		 * than the interface's MTU.  Can this possibly matter?
 		 */
 		ip = mtod(copym, struct ip *);
-		ip->ip_len = htons((u_short)ip->ip_len);
-		ip->ip_off = htons((u_short)ip->ip_off);
+		HTONS(ip->ip_len);
+		HTONS(ip->ip_off);
 		ip->ip_sum = 0;
 		if (ip->ip_vhl == IP_VHL_BORING) {
 			ip->ip_sum = in_cksum_hdr(ip);
Index: netinet/udp_usrreq.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/udp_usrreq.c,v
retrieving revision 1.64.2.3
diff -u -p -r1.64.2.3 udp_usrreq.c
--- netinet/udp_usrreq.c	2000/08/03 00:09:36	1.64.2.3
+++ netinet/udp_usrreq.c	2000/09/08 14:18:15
@@ -353,15 +353,15 @@ udp_input(m, off, proto)
 			udpstat.udps_noportbcast++;
 			goto bad;
 		}
-		*ip = save_ip;
 #ifdef ICMP_BANDLIM
 		if (badport_bandlim(0) < 0)
 			goto bad;
 #endif
-		if (!blackhole)
-			icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0);
-		else
+		if (blackhole)
 			goto bad;
+		*ip = save_ip;
+		ip->ip_len += iphlen;
+		icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0);
 		return;
 	}
 #ifdef IPSEC
Index: netinet6/ah_input.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet6/ah_input.c,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 ah_input.c
--- netinet6/ah_input.c	2000/07/15 07:14:32	1.1.2.1
+++ netinet6/ah_input.c	2000/09/08 14:18:15
@@ -291,7 +291,6 @@ ah4_input(m, va_alist)
 	 * convert them back to network endian.  VERY stupid.
 	 */
 	ip->ip_len = htons(ip->ip_len + hlen);
-	ip->ip_id = htons(ip->ip_id);
 	ip->ip_off = htons(ip->ip_off);
 #endif
 	if (ah4_calccksum(m, (caddr_t)cksum, siz1, algo, sav)) {
@@ -305,7 +304,6 @@ ah4_input(m, va_alist)
 	 * flip them back.
 	 */
 	ip->ip_len = ntohs(ip->ip_len) - hlen;
-	ip->ip_id = ntohs(ip->ip_id);
 	ip->ip_off = ntohs(ip->ip_off);
 #endif
     }

--OXfL5xGRrasGEqWY--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000908172145.A27354>