]> git.karo-electronics.de Git - linux-beck.git/commitdiff
net: Fix GRE RX to use skb_transport_header for GRE header offset
authorTom Herbert <therbert@google.com>
Mon, 8 Sep 2014 15:29:12 +0000 (08:29 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Sep 2014 22:23:05 +0000 (15:23 -0700)
GRE assumes that the GRE header is at skb_network_header +
ip_hrdlen(skb). It is more general to use skb_transport_header
and this allows the possbility of inserting additional header
between IP and GRE (which is what we will done in Generic UDP
Encapsulation for GRE).

Signed-off-by: Tom Herbert <therbert@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/gre_demux.c

index 7e0756da873776aad0e534d0c85ed08629878ed4..4a7b5b2a1ce3ddbd79e9282051020a4509dd7fe5 100644 (file)
@@ -98,7 +98,6 @@ EXPORT_SYMBOL_GPL(gre_build_header);
 static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
                            bool *csum_err)
 {
-       unsigned int ip_hlen = ip_hdrlen(skb);
        const struct gre_base_hdr *greh;
        __be32 *options;
        int hdr_len;
@@ -106,7 +105,7 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
        if (unlikely(!pskb_may_pull(skb, sizeof(struct gre_base_hdr))))
                return -EINVAL;
 
-       greh = (struct gre_base_hdr *)(skb_network_header(skb) + ip_hlen);
+       greh = (struct gre_base_hdr *)skb_transport_header(skb);
        if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING)))
                return -EINVAL;
 
@@ -116,7 +115,7 @@ 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);
+       greh = (struct gre_base_hdr *)skb_transport_header(skb);
        tpi->proto = greh->protocol;
 
        options = (__be32 *)(greh + 1);