Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[firefly-linux-kernel-4.4.55.git] / net / ipv4 / ip_gre.c
index ad662e906f7e403e895c600d909776807070a016..987a4e5e07e2d3d5352de4cd8115909449183015 100644 (file)
@@ -159,14 +159,14 @@ static int ip_gre_calc_hlen(__be16 o_flags)
 static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
                            bool *csum_err, int *hdr_len)
 {
-       struct iphdr *iph = ip_hdr(skb);
-       struct gre_base_hdr *greh;
+       unsigned int ip_hlen = ip_hdrlen(skb);
+       const struct gre_base_hdr *greh;
        __be32 *options;
 
        if (unlikely(!pskb_may_pull(skb, sizeof(struct gre_base_hdr))))
                return -EINVAL;
 
-       greh = (struct gre_base_hdr *)((u8 *)iph + (iph->ihl << 2));
+       greh = (struct gre_base_hdr *)(skb_network_header(skb) + ip_hlen);
        if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING)))
                return -EINVAL;
 
@@ -176,6 +176,8 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
        if (!pskb_may_pull(skb, *hdr_len))
                return -EINVAL;
 
+       greh = (struct gre_base_hdr *)(skb_network_header(skb) + ip_hlen);
+
        tpi->proto = greh->protocol;
 
        options = (__be32 *)(greh + 1);
@@ -660,7 +662,6 @@ static void __gre_tunnel_init(struct net_device *dev)
 
        dev->needed_headroom    = LL_MAX_HEADER + sizeof(struct iphdr) + 4;
        dev->mtu                = ETH_DATA_LEN - sizeof(struct iphdr) - 4;
-       dev->iflink             = 0;
 
        dev->features           |= NETIF_F_NETNS_LOCAL | GRE_FEATURES;
        dev->hw_features        |= GRE_FEATURES;