From: William Tu <[email protected]>

Upstream commit:
    commit d91e8db5b629a3c8c81db4dc317a66c7b5591821
    Author: William Tu <[email protected]>
    Date:   Fri Dec 15 14:27:44 2017 -0800

    net: erspan: reload pointer after pskb_may_pull

    pskb_may_pull() can change skb->data, so we need to re-load pkt_md
    and ershdr at the right place.

    Fixes: 94d7d8f29287 ("ip6_gre: add erspan v2 support")
    Fixes: f551c91de262 ("net: erspan: introduce erspan v2 for ip_gre")
    Signed-off-by: William Tu <[email protected]>
    Cc: Haishuang Yan <[email protected]>
    Signed-off-by: David S. Miller <[email protected]>

Only the ip_gre portion of the upstream commit.  The ipv6 portion
is pulled in with later patch in series.

Cc: William Tu <[email protected]>
Signed-off-by: Greg Rose <[email protected]>
---
 datapath/linux/compat/ip_gre.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c
index 183b451..9863dd7 100644
--- a/datapath/linux/compat/ip_gre.c
+++ b/datapath/linux/compat/ip_gre.c
@@ -161,7 +161,6 @@ static int erspan_rcv(struct sk_buff *skb, struct 
tnl_ptk_info *tpi,
         * Use ERSPAN 10-bit session ID as key.
         */
        tpi->key = cpu_to_be32(ntohs(ershdr->session_id) & ID_MASK);
-       pkt_md = (struct erspan_metadata *)(ershdr + 1);
        tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex,
                                  tpi->flags | TUNNEL_KEY,
                                  iph->saddr, iph->daddr, tpi->key);
@@ -171,6 +170,9 @@ static int erspan_rcv(struct sk_buff *skb, struct 
tnl_ptk_info *tpi,
                if (unlikely(!pskb_may_pull(skb, len)))
                        return PACKET_REJECT;
 
+               ershdr = (struct erspan_base_hdr *)skb->data;
+               pkt_md = (struct erspan_metadata *)(ershdr + 1);
+
                if (__iptunnel_pull_header(skb,
                                           len,
                                           htons(ETH_P_TEB),
-- 
1.8.3.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to