From 5cc3ac590262ed14bfbf8392f27f90923b7cc7a1 Mon Sep 17 00:00:00 2001 From: glebius Date: Mon, 22 Oct 2012 21:09:03 +0000 Subject: Switch the entire IPv4 stack to keep the IP packet header in network byte order. Any host byte order processing is done in local variables and host byte order values are never[1] written to a packet. After this change a packet processed by the stack isn't modified at all[2] except for TTL. After this change a network stack hacker doesn't need to scratch his head trying to figure out what is the byte order at the given place in the stack. [1] One exception still remains. The raw sockets convert host byte order before pass a packet to an application. Probably this would remain for ages for compatibility. [2] The ip_input() still subtructs header len from ip->ip_len, but this is planned to be fixed soon. Reviewed by: luigi, Maxim Dounin Tested by: ray, Olivier Cochard-Labbe --- sys/net/if_stf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sys/net/if_stf.c') diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index 90dac40..edde456 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -524,7 +524,7 @@ stf_output(ifp, m, dst, ro) bcopy(&in4, &ip->ip_dst, sizeof(ip->ip_dst)); ip->ip_p = IPPROTO_IPV6; ip->ip_ttl = ip_stf_ttl; - ip->ip_len = m->m_pkthdr.len; /*host order*/ + ip->ip_len = htons(m->m_pkthdr.len); if (ifp->if_flags & IFF_LINK1) ip_ecn_ingress(ECN_ALLOWED, &ip->ip_tos, &tos); else -- cgit v1.1