public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Eric Garver <e@erig•me>
To: netdev@vger•kernel.org
Cc: Jiri Benc <jbenc@redhat•com>, ovs-dev@openvswitch•org
Subject: [PATCH net] openvswitch: Fix pop_vlan action for double tagged frames
Date: Tue, 19 Dec 2017 13:57:53 -0500	[thread overview]
Message-ID: <20171219185753.23012-1-e@erig.me> (raw)

skb_vlan_pop() expects skb->protocol to be a valid TPID for double
tagged frames. As such don't override skb->protocol for normal ethernet
frames when extracting the key.

Fixes: 5108bbaddc37 ("openvswitch: add processing of L3 packets")
Signed-off-by: Eric Garver <e@erig•me>
---
 net/openvswitch/flow.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index dbe2379329c5..06d32ba3dd69 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -559,8 +559,9 @@ static int parse_nsh(struct sk_buff *skb, struct sw_flow_key *key)
  *      of a correct length, otherwise the same as skb->network_header.
  *      For other key->eth.type values it is left untouched.
  *
- *    - skb->protocol: the type of the data starting at skb->network_header.
- *      Equals to key->eth.type.
+ *    - skb->protocol: For Ethernet, the ethertype or VLAN TPID.
+ *      For non-Ethernet, the type of the data starting at skb->network_header
+ *      (also equal to key->eth.type).
  */
 static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)
 {
@@ -579,6 +580,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 +594,14 @@ 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;
 
 		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)) {
-- 
2.12.0

             reply	other threads:[~2017-12-19 18:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-19 18:57 Eric Garver [this message]
2017-12-19 19:39 ` [PATCH net] openvswitch: Fix pop_vlan action for double tagged frames Jiri Benc
2017-12-19 20:42   ` Eric Garver
2017-12-19 20:59     ` Eric Garver
2017-12-19 20:42   ` Eric Garver
2017-12-19 19:39 ` Jiri Benc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171219185753.23012-1-e@erig.me \
    --to=e@erig$(echo .)me \
    --cc=jbenc@redhat$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=ovs-dev@openvswitch$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox