[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOrHB_B1-29CM=DWpWuRVbTRriW2ViJRZULMS22+NSPwW_J_=Q@mail.gmail.com>
Date: Tue, 18 Oct 2016 22:13:45 -0700
From: Pravin Shelar <pshelar@....org>
To: Jiri Benc <jbenc@...hat.com>
Cc: Linux Kernel Network Developers <netdev@...r.kernel.org>,
ovs dev <dev@...nvswitch.org>,
Lorand Jakab <lojakab@...co.com>,
Simon Horman <simon.horman@...ronome.com>
Subject: Re: [PATCH net-next v12 5/9] openvswitch: add processing of L3 packets
On Mon, Oct 17, 2016 at 6:02 AM, Jiri Benc <jbenc@...hat.com> wrote:
> Support receiving, extracting flow key and sending of L3 packets (packets
> without an Ethernet header).
>
> Note that even after this patch, non-Ethernet interfaces are still not
> allowed to be added to bridges. Similarly, netlink interface for sending and
> receiving L3 packets to/from user space is not in place yet.
>
> Based on previous versions by Lorand Jakab and Simon Horman.
>
> Signed-off-by: Lorand Jakab <lojakab@...co.com>
> Signed-off-by: Simon Horman <simon.horman@...ronome.com>
> Signed-off-by: Jiri Benc <jbenc@...hat.com>
> ---
> net/openvswitch/datapath.c | 17 ++------
> net/openvswitch/flow.c | 101 ++++++++++++++++++++++++++++++++++-----------
> net/openvswitch/vport.c | 16 +++++++
> 3 files changed, 96 insertions(+), 38 deletions(-)
>
...
> @@ -505,28 +511,35 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)
>
> skb_reset_mac_header(skb);
>
> - /* Link layer. We are guaranteed to have at least the 14 byte Ethernet
> - * header in the linear data area.
> - */
> - eth = eth_hdr(skb);
> - ether_addr_copy(key->eth.src, eth->h_source);
> - ether_addr_copy(key->eth.dst, eth->h_dest);
> + /* Link layer. */
> + clear_vlan(key);
> + if (key->mac_proto == MAC_PROTO_NONE) {
> + if (unlikely(eth_type_vlan(skb->protocol)))
> + return -EINVAL;
>
> - __skb_pull(skb, 2 * ETH_ALEN);
> - /* We are going to push all headers that we pull, so no need to
> - * update skb->csum here.
> - */
> + skb_reset_network_header(skb);
> + } else {
> + eth = eth_hdr(skb);
> + ether_addr_copy(key->eth.src, eth->h_source);
> + ether_addr_copy(key->eth.dst, eth->h_dest);
>
> - if (unlikely(parse_vlan(skb, key)))
> - return -ENOMEM;
> + __skb_pull(skb, 2 * ETH_ALEN);
> + /* We are going to push all headers that we pull, so no need to
> + * update skb->csum here.
> + */
>
> - key->eth.type = parse_ethertype(skb);
> - if (unlikely(key->eth.type == htons(0)))
> - return -ENOMEM;
> + if (unlikely(parse_vlan(skb, key)))
> + return -ENOMEM;
>
> - skb_reset_network_header(skb);
> + skb->protocol = parse_ethertype(skb);
I am not sure about changing skb->protocol here.
By changing this skb loosing information about packet type. Therefore
if packet re-enters OVS (through different bridge), this packet would
look like L3 packet. function key_extract_mac_proto() would not see
TEB type packet.
> + if (unlikely(skb->protocol == htons(0)))
> + return -ENOMEM;
> +
> + skb_reset_network_header(skb);
> + __skb_push(skb, skb->data - skb_mac_header(skb));
> + }
> skb_reset_mac_len(skb);
> - __skb_push(skb, skb->data - skb_mac_header(skb));
> + key->eth.type = skb->protocol;
>
> /* Network layer. */
> if (key->eth.type == htons(ETH_P_IP)) {
> @@ -721,6 +734,20 @@ int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key)
> return key_extract(skb, key);
> }
>
> +static u8 key_extract_mac_proto(struct sk_buff *skb)
> +{
> + switch (skb->dev->type) {
> + case ARPHRD_ETHER:
> + return MAC_PROTO_ETHERNET;
> + case ARPHRD_NONE:
> + if (skb->protocol == htons(ETH_P_TEB))
> + return MAC_PROTO_ETHERNET;
> + return MAC_PROTO_NONE;
> + }
> + WARN_ON_ONCE(1);
> + return MAC_PROTO_ETHERNET;
> +}
> +
Powered by blists - more mailing lists