Skip to contentSkip to conversation

erspan: fix version 1 check in gre_parse_header()

PATCH In review Cong Wang 2 participants 2 messages Dec 26, 2020 – Dec 28, 2020

Subsystems (2)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 erspan: fix version 1 check in gre_parse_header()

From: Cong Wang <[email protected]>

Both version 0 and version 1 use ETH_P_ERSPAN, but version 0 does not have an erspan header. So the check in gre_parse_header() is wrong, we have to distinguish version 1 from version 0.

We can just check the gre header length like is_erspan_type1().

Fixes cb73ee40b1b3 ("net: ip_gre: use erspan key field for tunnel lookup")
Reported-by [email protected]
Cc William Tu <[email protected]>
Cc Lorenzo Bianconi <[email protected]>
---
 net/ipv4/gre_demux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/gre_demux.c +1 -1
index 66fdbfe5447c..5d1e6fe9d838 100644
@@ -128,7 +128,7 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 	 * to 0 and sets the configured key in the
 	 * inner erspan header field
 	 */
-	if (greh->protocol == htons(ETH_P_ERSPAN) ||
+	if ((greh->protocol == htons(ETH_P_ERSPAN) && hdr_len != 4) ||
 	    greh->protocol == htons(ETH_P_ERSPAN2)) {
 		struct erspan_base_hdr *ershdr;
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw

From: Cong Wang <[email protected]>
Date: Sat, 26 Dec 2020 15:44:53 -0800

Quoted 6 lines

From: Cong Wang <[email protected]>

Both version 0 and version 1 use ETH_P_ERSPAN, but version 0 does not have an erspan header. So the check in gre_parse_header() is wrong, we have to distinguish version 1 from version 0.

Quoted 7 lines

We can just check the gre header length like is_erspan_type1().

Fixes cb73ee40b1b3 ("net: ip_gre: use erspan key field for tunnel lookup")
Reported-by [email protected]
Cc William Tu <[email protected]>
Cc Lorenzo Bianconi <[email protected]>

Applied and queued up for -stable, thanks.