Follow BSD/OS and NetBSD, keep the ip_id field in network order all the time.

Requested by:	wollman
This commit is contained in:
Ruslan Ermilov 2000-09-14 14:42:04 +00:00
parent 5dde620ab1
commit e30177e024
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=65837
11 changed files with 7 additions and 36 deletions

View File

@ -32,7 +32,7 @@
.\" @(#)ip.4 8.2 (Berkeley) 11/30/93
.\" $FreeBSD$
.\"
.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.

View File

@ -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 ;

View File

@ -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);

View File

@ -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 */

View File

@ -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

View File

@ -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);
/*

View File

@ -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;

View File

@ -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);

View File

@ -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) {

View File

@ -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++;

View File

@ -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
}