From 92269e49c439d44bb3b525cc86f3a6f60cae7ed9 Mon Sep 17 00:00:00 2001 From: ru Date: Thu, 14 Sep 2000 14:42:04 +0000 Subject: Follow BSD/OS and NetBSD, keep the ip_id field in network order all the time. Requested by: wollman --- sys/contrib/ipfilter/netinet/ip_auth.c | 2 +- sys/contrib/ipfilter/netinet/ip_fil.c | 2 ++ sys/net/bridge.c | 2 -- sys/netinet/ip_auth.c | 2 +- sys/netinet/ip_divert.c | 1 - sys/netinet/ip_fil.c | 2 ++ sys/netinet/ip_icmp.c | 1 - sys/netinet/ip_input.c | 4 ---- sys/netinet/ip_mroute.c | 3 +-- sys/netinet/ip_output.c | 10 +--------- sys/netinet/raw_ip.c | 2 +- sys/netinet6/ah_input.c | 2 -- 12 files changed, 9 insertions(+), 24 deletions(-) (limited to 'sys') diff --git a/sys/contrib/ipfilter/netinet/ip_auth.c b/sys/contrib/ipfilter/netinet/ip_auth.c index ff72825..4ce6a69 100644 --- a/sys/contrib/ipfilter/netinet/ip_auth.c +++ b/sys/contrib/ipfilter/netinet/ip_auth.c @@ -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); diff --git a/sys/contrib/ipfilter/netinet/ip_fil.c b/sys/contrib/ipfilter/netinet/ip_fil.c index bd76b39..d609f25 100644 --- a/sys/contrib/ipfilter/netinet/ip_fil.c +++ b/sys/contrib/ipfilter/netinet/ip_fil.c @@ -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 diff --git a/sys/net/bridge.c b/sys/net/bridge.c index ec9aada..7827a0c 100644 --- a/sys/net/bridge.c +++ b/sys/net/bridge.c @@ -718,7 +718,6 @@ bdg_forward(struct mbuf **m0, struct ether_header *const eh, struct ifnet *dst) */ 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 ether_header *const eh, struct ifnet *dst) * 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 ; diff --git a/sys/netinet/ip_auth.c b/sys/netinet/ip_auth.c index ff72825..4ce6a69 100644 --- a/sys/netinet/ip_auth.c +++ b/sys/netinet/ip_auth.c @@ -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); diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 12acdfd..b2f92b8 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -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 */ diff --git a/sys/netinet/ip_fil.c b/sys/netinet/ip_fil.c index bd76b39..d609f25 100644 --- a/sys/netinet/ip_fil.c +++ b/sys/netinet/ip_fil.c @@ -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 diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index 91c0bc0..dc2040e 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -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); /* diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 5ba5750..bd04b01 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -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; diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 73ab039..1d165f5 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -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); diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 9fe7001..baaf332 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -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) { diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 94046e8..5d056ce 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -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++; diff --git a/sys/netinet6/ah_input.c b/sys/netinet6/ah_input.c index c50f72b..1aaa0c4 100644 --- a/sys/netinet6/ah_input.c +++ b/sys/netinet6/ah_input.c @@ -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 } -- cgit v1.1