Skip to contentSkip to conversation

openvswitch: Fix pop_vlan action for double tagged frames

PATCH In review Eric Garver 3 participants 5 messages Dec 20, 2017 – Dec 21, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 openvswitch: Fix pop_vlan action for double tagged frames

skb_vlan_pop() expects skb->protocol to be a valid TPID for double tagged frames. So set skb->protocol to the TPID and let skb_vlan_pop() shift the true ethertype into position for us.

Fixes 5108bbaddc37 ("openvswitch: add processing of L3 packets")
---
 net/openvswitch/flow.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
net/openvswitch/flow.c +12 -3
index dbe2379329c5..f039064ce922 100644
@@ -579,6 +579,7 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)
 			return -EINVAL;
 
 		skb_reset_network_header(skb);
+		key->eth.type = skb->protocol;
 	} else {
 		eth = eth_hdr(skb);
 		ether_addr_copy(key->eth.src, eth->h_source);
@@ -592,15 +593,23 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)
 		if (unlikely(parse_vlan(skb, key)))
 			return -ENOMEM;
 
-		skb->protocol = parse_ethertype(skb);
-		if (unlikely(skb->protocol == htons(0)))
+		key->eth.type = parse_ethertype(skb);
+		if (unlikely(key->eth.type == htons(0)))
 			return -ENOMEM;
 
+		/* Multiple tagged packets need to retain TPID to satisfy
+		 * skb_vlan_pop(), which will later shift the ethertype into
+		 * skb->protocol.
+		 */
+		if (key->eth.cvlan.tci & htons(VLAN_TAG_PRESENT))
+			skb->protocol = key->eth.cvlan.tpid;
+		else
+			skb->protocol = key->eth.type;
+
 		skb_reset_network_header(skb);
 		__skb_push(skb, skb->data - skb_mac_header(skb));
 	}
 	skb_reset_mac_len(skb);
-	key->eth.type = skb->protocol;
 
 	/* Network layer. */
 	if (key->eth.type == htons(ETH_P_IP)) {
Signature · 1 line
2.12.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 6 lines · Eric Garver

skb_vlan_pop() expects skb->protocol to be a valid TPID for double tagged frames. So set skb->protocol to the TPID and let skb_vlan_pop() shift the true ethertype into position for us.

Fixes 5108bbaddc37 ("openvswitch: add processing of L3 packets")

Thanks!

maintainer
#3 lore raw
In reply to Eric Garver

From: Eric Garver <[email protected]>
Date: Wed, 20 Dec 2017 15:09:22 -0500

Quoted 6 lines

skb_vlan_pop() expects skb->protocol to be a valid TPID for double tagged frames. So set skb->protocol to the TPID and let skb_vlan_pop() shift the true ethertype into position for us.

Fixes 5108bbaddc37 ("openvswitch: add processing of L3 packets")

Applied and queued up for -stable, thanks.

maintainer
#4 lore raw
In reply to Eric Garver

From: Eric Garver <[email protected]>
Date: Wed, 20 Dec 2017 15:09:22 -0500

Quoted 6 lines

skb_vlan_pop() expects skb->protocol to be a valid TPID for double tagged frames. So set skb->protocol to the TPID and let skb_vlan_pop() shift the true ethertype into position for us.

Fixes 5108bbaddc37 ("openvswitch: add processing of L3 packets")

Applied and queued up for -stable, thanks.