diff options
author | glebius <glebius@FreeBSD.org> | 2012-10-22 21:09:03 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2012-10-22 21:09:03 +0000 |
commit | 5cc3ac590262ed14bfbf8392f27f90923b7cc7a1 (patch) | |
tree | 6e8c53bf2442763edea3176e3bef68bfec20a183 /sys/netinet/in_gif.c | |
parent | aef46581d91a912fc587677321f83f81ce6df527 (diff) | |
download | FreeBSD-src-5cc3ac590262ed14bfbf8392f27f90923b7cc7a1.zip FreeBSD-src-5cc3ac590262ed14bfbf8392f27f90923b7cc7a1.tar.gz |
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 <mdounin mdounin.ru>
Tested by: ray, Olivier Cochard-Labbe <olivier cochard.me>
Diffstat (limited to 'sys/netinet/in_gif.c')
-rw-r--r-- | sys/netinet/in_gif.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/netinet/in_gif.c b/sys/netinet/in_gif.c index 6c60390..6ccd17f 100644 --- a/sys/netinet/in_gif.c +++ b/sys/netinet/in_gif.c @@ -192,7 +192,7 @@ in_gif_output(struct ifnet *ifp, int family, struct mbuf *m) iphdr.ip_p = proto; /* version will be set in ip_output() */ iphdr.ip_ttl = V_ip_gif_ttl; - iphdr.ip_len = m->m_pkthdr.len + sizeof(struct ip); + iphdr.ip_len = htons(m->m_pkthdr.len + sizeof(struct ip)); ip_ecn_ingress((ifp->if_flags & IFF_LINK1) ? ECN_ALLOWED : ECN_NOCARE, &iphdr.ip_tos, &tos); |