All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Benc <jbenc@redhat.com>
To: Eric Garver <e@erig.me>
Cc: netdev@vger.kernel.org, ovs-dev@openvswitch.org
Subject: Re: [PATCH net] openvswitch: Fix pop_vlan action for double tagged frames
Date: Tue, 19 Dec 2017 20:39:29 +0100	[thread overview]
Message-ID: <20171219203929.12c1cb93@redhat.com> (raw)
In-Reply-To: <20171219185753.23012-1-e@erig.me>

On Tue, 19 Dec 2017 13:57:53 -0500, Eric Garver wrote:
> --- 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)) {

Unfortunately, this does not work. key_extract must set skb->protocol
even for Ethernet frames that come from a mixed L2/L3 tunnel. Such
packets will have key->mac_proto set to MAC_PROTO_ETHERNET and
skb->protocol set to ETH_P_TEB (see key_extract_mac_proto). In
key_extract, skb->protocol has to be correctly set to the dissected
value.

Which means that we have to check for the existence of inner vlan tag
(by checking key->eth.cvlan.tci or, perhaps better, by returning it
from parse_vlan) and set skb->protocol accordingly.

 Jiri

  parent reply	other threads:[~2017-12-19 19:39 UTC|newest]

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

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=20171219203929.12c1cb93@redhat.com \
    --to=jbenc@redhat.com \
    --cc=e@erig.me \
    --cc=netdev@vger.kernel.org \
    --cc=ovs-dev@openvswitch.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.