]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - net/ipv4/ip_gre.c
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[linux.git] / net / ipv4 / ip_gre.c
index 52690bb3e40f9f52d533e531838e34fdebdcf3cf..572b6307a2dff1a29c6686fb963aeb4a51410447 100644 (file)
@@ -340,6 +340,8 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
                                  iph->saddr, iph->daddr, tpi->key);
 
        if (tunnel) {
+               const struct iphdr *tnl_params;
+
                if (__iptunnel_pull_header(skb, hdr_len, tpi->proto,
                                           raw_proto, false) < 0)
                        goto drop;
@@ -348,7 +350,9 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
                        skb_pop_mac_header(skb);
                else
                        skb_reset_mac_header(skb);
-               if (tunnel->collect_md) {
+
+               tnl_params = &tunnel->parms.iph;
+               if (tunnel->collect_md || tnl_params->daddr == 0) {
                        __be16 flags;
                        __be64 tun_id;
 
@@ -509,9 +513,9 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
        key = &tun_info->key;
        if (!(tun_info->key.tun_flags & TUNNEL_ERSPAN_OPT))
                goto err_free_skb;
-       md = ip_tunnel_info_opts(tun_info);
-       if (!md)
+       if (tun_info->options_len < sizeof(*md))
                goto err_free_skb;
+       md = ip_tunnel_info_opts(tun_info);
 
        /* ERSPAN has fixed 8 byte GRE header */
        version = md->version;