* [PATCH] endianness bug in ip6_tunnel
@ 2007-07-21 8:12 Al Viro
2007-07-22 2:10 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Al Viro @ 2007-07-21 8:12 UTC (permalink / raw)
To: davem; +Cc: netdev
IPV6_TCLASS_MASK is net-endian; what happens here is that we take
a value and shove it into bits 20--27 of net-endian 32bit word.
IOW, it's misannotated (it's really htonl, not ntohl) *and* the
mask should be applied after conversion to net-endian, not before it.
The former is harmless, the latter gives the wrong value on little-endian;
As the matter of fact, on l-e it gives 0 - IPV6_TCLASS_MASK will be
htonl(0x0ff00000), i.e. on little-endian we have (something << 20) & 0xff0...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -962,8 +962,8 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
dsfield = ipv4_get_dsfield(iph);
if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS))
- fl.fl6_flowlabel |= ntohl(((__u32)iph->tos << IPV6_TCLASS_SHIFT)
- & IPV6_TCLASS_MASK);
+ fl.fl6_flowlabel |= htonl((__u32)iph->tos << IPV6_TCLASS_SHIFT)
+ & IPV6_TCLASS_MASK;
err = ip6_tnl_xmit2(skb, dev, dsfield, &fl, encap_limit, &mtu);
if (err != 0) {
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] endianness bug in ip6_tunnel
2007-07-21 8:12 [PATCH] endianness bug in ip6_tunnel Al Viro
@ 2007-07-22 2:10 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2007-07-22 2:10 UTC (permalink / raw)
To: viro; +Cc: netdev
From: Al Viro <viro@ftp.linux.org.uk>
Date: Sat, 21 Jul 2007 09:12:31 +0100
> IPV6_TCLASS_MASK is net-endian; what happens here is that we take
> a value and shove it into bits 20--27 of net-endian 32bit word.
> IOW, it's misannotated (it's really htonl, not ntohl) *and* the
> mask should be applied after conversion to net-endian, not before it.
> The former is harmless, the latter gives the wrong value on little-endian;
> As the matter of fact, on l-e it gives 0 - IPV6_TCLASS_MASK will be
> htonl(0x0ff00000), i.e. on little-endian we have (something << 20) & 0xff0...
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Applied, thanks Al.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-07-22 2:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-21 8:12 [PATCH] endianness bug in ip6_tunnel Al Viro
2007-07-22 2:10 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).