Fix returned tc and hoplimit values for route with IPv6 encapsulation
authorQuentin Armitage <quentin@armitage.org.uk>
Sun, 27 Mar 2016 16:06:11 +0000 (17:06 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Mar 2016 02:35:02 +0000 (22:35 -0400)
For a route with IPv6 encapsulation, the traffic class and hop limit
values are interchanged when returned to userspace by the kernel.
For example, see below.

># ip route add 192.168.0.1 dev eth0.2 encap ip6 dst 0x50 tc 0x50 hoplimit 100 table 1000
># ip route show table 1000
192.168.0.1  encap ip6 id 0 src :: dst fe83::1 hoplimit 80 tc 100 dev eth0.2  scope link

Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ip_tunnel_core.c

index 02dd990af542bcfe78cd21a80507ba8be1d30335..6165f30c4d722bb5dee152b01e19ab4a0938faf2 100644 (file)
@@ -372,8 +372,8 @@ static int ip6_tun_fill_encap_info(struct sk_buff *skb,
        if (nla_put_be64(skb, LWTUNNEL_IP6_ID, tun_info->key.tun_id) ||
            nla_put_in6_addr(skb, LWTUNNEL_IP6_DST, &tun_info->key.u.ipv6.dst) ||
            nla_put_in6_addr(skb, LWTUNNEL_IP6_SRC, &tun_info->key.u.ipv6.src) ||
-           nla_put_u8(skb, LWTUNNEL_IP6_HOPLIMIT, tun_info->key.tos) ||
-           nla_put_u8(skb, LWTUNNEL_IP6_TC, tun_info->key.ttl) ||
+           nla_put_u8(skb, LWTUNNEL_IP6_TC, tun_info->key.tos) ||
+           nla_put_u8(skb, LWTUNNEL_IP6_HOPLIMIT, tun_info->key.ttl) ||
            nla_put_be16(skb, LWTUNNEL_IP6_FLAGS, tun_info->key.tun_flags))
                return -ENOMEM;