Skip to content

Commit c48e747

Browse files
Eric Garverdavem330
authored andcommitted
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: 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>
1 parent 58acfd7 commit c48e747

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
@@ -579,6 +579,7 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)
579579
return -EINVAL;
580580

581581
skb_reset_network_header(skb);
582+
key->eth.type = skb->protocol;
582583
} else {
583584
eth = eth_hdr(skb);
584585
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)
592593
if (unlikely(parse_vlan(skb, key)))
593594
return -ENOMEM;
594595

595-
skb->protocol = parse_ethertype(skb);
596-
if (unlikely(skb->protocol == htons(0)))
596+
key->eth.type = parse_ethertype(skb);
597+
if (unlikely(key->eth.type == htons(0)))
597598
return -ENOMEM;
598599

600+
/* Multiple tagged packets need to retain TPID to satisfy
601+
* skb_vlan_pop(), which will later shift the ethertype into
602+
* skb->protocol.
603+
*/
604+
if (key->eth.cvlan.tci & htons(VLAN_TAG_PRESENT))
605+
skb->protocol = key->eth.cvlan.tpid;
606+
else
607+
skb->protocol = key->eth.type;
608+
599609
skb_reset_network_header(skb);
600610
__skb_push(skb, skb->data - skb_mac_header(skb));
601611
}
602612
skb_reset_mac_len(skb);
603-
key->eth.type = skb->protocol;
604613

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

0 commit comments

Comments
 (0)