gre: better support for ICMP messages for gre+ipv6
authorEric Dumazet <edumazet@google.com>
Sun, 19 Jun 2016 04:52:05 +0000 (21:52 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 19 Jun 2016 05:11:39 +0000 (22:11 -0700)
ipgre_err() can call ip6_err_gen_icmpv6_unreach() for proper
support of ipv4+gre+icmp+ipv6+... frames, used for example
by traceroute/mtr.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ip_tunnels.h
net/ipv4/gre_demux.c
net/ipv4/ip_gre.c

index 9222678426a1430058a3d41fc4073b3ffef64043..a5e7035fb93f784e9b46cbe4db82dee578b670d8 100644 (file)
@@ -157,6 +157,7 @@ struct tnl_ptk_info {
        __be16 proto;
        __be32 key;
        __be32 seq;
+       int hdr_len;
 };
 
 #define PACKET_RCVD    0
index 4c39f4fd332a3569267c5c1330e692c5f40a49e7..c4c3e439f4249cca0c508b453132a770a4fafd32 100644 (file)
@@ -117,6 +117,7 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
                if ((*(u8 *)options & 0xF0) != 0x40)
                        hdr_len += 4;
        }
+       tpi->hdr_len = hdr_len;
        return hdr_len;
 }
 EXPORT_SYMBOL(gre_parse_header);
index 0f8ca3fca00a06663bf1597d1d23d6848b8e7022..ab4cff8e563dd1226af21cea650b3ccdbb122aa4 100644 (file)
@@ -187,6 +187,12 @@ static void ipgre_err(struct sk_buff *skb, u32 info,
        if (!t)
                return;
 
+#if IS_ENABLED(CONFIG_IPV6)
+       if (tpi->proto == htons(ETH_P_IPV6) &&
+           !ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4 + tpi->hdr_len, type))
+               return;
+#endif
+
        if (t->parms.iph.daddr == 0 ||
            ipv4_is_multicast(t->parms.iph.daddr))
                return;