diff options
author | Lorenzo Bianconi <lorenzo.bianconi@redhat.com> | 2019-01-18 12:05:39 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-01-22 20:52:17 +0100 |
commit | cb73ee40b1b381eaf3749e6dbeed567bb38e5258 (patch) | |
tree | 4a46c80cac3f7bb0f044f1cbf2d73a66129a9456 /net/ipv4/gre_demux.c | |
parent | net: sun: cassini: Cleanup license conflict (diff) | |
download | linux-cb73ee40b1b381eaf3749e6dbeed567bb38e5258.tar.xz linux-cb73ee40b1b381eaf3749e6dbeed567bb38e5258.zip |
net: ip_gre: use erspan key field for tunnel lookup
Use ERSPAN key header field as tunnel key in gre_parse_header routine
since ERSPAN protocol sets the key field of the external GRE header to
0 resulting in a tunnel lookup fail in ip6gre_err.
In addition remove key field parsing and pskb_may_pull check in
erspan_rcv and ip6erspan_rcv
Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/gre_demux.c')
-rw-r--r-- | net/ipv4/gre_demux.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c index a4bf22ee3aed..7c4a41dc04bb 100644 --- a/net/ipv4/gre_demux.c +++ b/net/ipv4/gre_demux.c @@ -25,6 +25,7 @@ #include <linux/spinlock.h> #include <net/protocol.h> #include <net/gre.h> +#include <net/erspan.h> #include <net/icmp.h> #include <net/route.h> @@ -119,6 +120,22 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, hdr_len += 4; } tpi->hdr_len = hdr_len; + + /* ERSPAN ver 1 and 2 protocol sets GRE key field + * to 0 and sets the configured key in the + * inner erspan header field + */ + if (greh->protocol == htons(ETH_P_ERSPAN) || + greh->protocol == htons(ETH_P_ERSPAN2)) { + struct erspan_base_hdr *ershdr; + + if (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr))) + return -EINVAL; + + ershdr = (struct erspan_base_hdr *)options; + tpi->key = cpu_to_be32(get_session_id(ershdr)); + } + return hdr_len; } EXPORT_SYMBOL(gre_parse_header); |