Skip to content

Commit a6cc63e

Browse files
Eric Garvergregkh
authored andcommitted
openvswitch: Fix pop_vlan action for double tagged frames
[ Upstream commit c48e747 ] 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: 5108bba ("openvswitch: add processing of L3 packets") Signed-off-by: Eric Garver <e@erig.me> Reviewed-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bf07030 commit a6cc63e

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎net/openvswitch/flow.c‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)
532532
return -EINVAL;
533533

534534
skb_reset_network_header(skb);
535+
key->eth.type = skb->protocol;
535536
} else {
536537
eth = eth_hdr(skb);
537538
ether_addr_copy(key->eth.src, eth->h_source);
@@ -545,15 +546,23 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)
545546
if (unlikely(parse_vlan(skb, key)))
546547
return -ENOMEM;
547548

548-
skb->protocol = parse_ethertype(skb);
549-
if (unlikely(skb->protocol == htons(0)))
549+
key->eth.type = parse_ethertype(skb);
550+
if (unlikely(key->eth.type == htons(0)))
550551
return -ENOMEM;
551552

553+
/* Multiple tagged packets need to retain TPID to satisfy
554+
* skb_vlan_pop(), which will later shift the ethertype into
555+
* skb->protocol.
556+
*/
557+
if (key->eth.cvlan.tci & htons(VLAN_TAG_PRESENT))
558+
skb->protocol = key->eth.cvlan.tpid;
559+
else
560+
skb->protocol = key->eth.type;
561+
552562
skb_reset_network_header(skb);
553563
__skb_push(skb, skb->data - skb_mac_header(skb));
554564
}
555565
skb_reset_mac_len(skb);
556-
key->eth.type = skb->protocol;
557566

558567
/* Network layer. */
559568
if (key->eth.type == htons(ETH_P_IP)) {

0 commit comments

Comments
 (0)