All of lore.kernel.org
 help / color / mirror / Atom feed
From: pravin shelar <pshelar@ovn.org>
To: Simon Horman <simon.horman@netronome.com>
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>,
	ovs dev <dev@openvswitch.org>
Subject: Re: [ovs-dev] [PATCH net-next v11 5/6] openvswitch: add layer 3 flow/port support
Date: Fri, 15 Jul 2016 14:07:37 -0700	[thread overview]
Message-ID: <CAOrHB_A1ri6fouFH0H4KpEqg1icCmz+U1tcgn-5BoryX5pb1gw@mail.gmail.com> (raw)
In-Reply-To: <20160713073152.GC29661@penelope.isobedori.kobe.vergenet.net>

On Wed, Jul 13, 2016 at 12:31 AM, Simon Horman
<simon.horman@netronome.com> wrote:
> Hi Pravin,
>
> On Thu, Jul 07, 2016 at 01:54:15PM -0700, pravin shelar wrote:
>> On Wed, Jul 6, 2016 at 10:59 AM, Simon Horman
>> <simon.horman@netronome.com> wrote:
>
> ...

>
>> > diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
>> > index 0ea128eeeab2..86f2cfb19de3 100644
>> > --- a/net/openvswitch/flow.c
>> > +++ b/net/openvswitch/flow.c
>> ...
>>
>> > @@ -723,9 +729,17 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info,
>> >         key->phy.skb_mark = skb->mark;
>> >         ovs_ct_fill_key(skb, key);
>> >         key->ovs_flow_hash = 0;
>> > +       key->phy.is_layer3 = skb->mac_len == 0;
>>
>> I do not think mac_len can be used. mac_header needs to be checked.
>> ...
>
> Yes, indeed. The update to use skb_mac_header_was_set() here accidently
> slipped into the following patch, sorry about that.
>
> With that change in place I believe that this patch is internally
> consistent because mac_header and mac_len are set correctly by the
> call to key_extract() which is called by ovs_flow_key_extract() just
> after where the excerpt above ends.
>
> That said, I do think that it is possible to rely on skb_mac_header_was_set
> throughout the datapath, including action processing etc... I have provided
> an incremental patch - which I created on top of this entire series - at
> the end of this email. If you prefer that approach I am happy to take it,
> though I do feel that using mac_len leads to slightly cleaner code. Let me
> know what you think.
>


I am not sure if you can use only mac_len to detect L3 packet. This
does not work with MPLS packets, mac_len is used to account MPLS
headers pushed on skb. Therefore in case of a MPLS header on L3
packet, mac_len would be non zero and we have to look at either
mac_header or some other metadata like is_layer3 flag from key to
check for L3 packet.


>> > diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c
>> > index 4e3972344aa6..733e7914f6bd 100644
>> > --- a/net/openvswitch/vport-netdev.c
>> > +++ b/net/openvswitch/vport-netdev.c
>> > @@ -57,8 +57,10 @@ static void netdev_port_receive(struct sk_buff *skb)
>> >         if (unlikely(!skb))
>> >                 return;
>> >
>> > -       skb_push(skb, ETH_HLEN);
>> > -       skb_postpush_rcsum(skb, skb->data, ETH_HLEN);
>> > +       if (vport->dev->type == ARPHRD_ETHER) {
>> > +               skb_push(skb, ETH_HLEN);
>> > +               skb_postpush_rcsum(skb, skb->data, ETH_HLEN);
>> > +       }
>> This is still required for tunnel device of ARPHRD_NONE which can
>> handle l2 packets.
>
> That is not necessary given the current implementation (of ipgre) as it
> supplies an skb with the mac header in place if the inner packet was an
> Ethernet packet. This scheme could of course be adjusted.
>
> ...
>

I think we should send L2 header with l2 header pushed on skb. This is
what OVS expect. The skb-push should be done for all l2 packets rather
than for particular type of device.

>
>
> Update to use skb_mac_header_was_set() more as mentioned above.
> Please let me know what you think about this approach.
>
>  include/net/mpls.h                   |    4 ++-
>  net/openvswitch/actions.c            |   42 ++++++++++++++++++++---------------
>  net/openvswitch/flow.c               |   23 +++++++++++--------
>  net/openvswitch/vport-internal_dev.c |    2 -
>  net/openvswitch/vport-netdev.c       |    4 +--
>  5 files changed, 44 insertions(+), 31 deletions(-)
>
> diff --git a/include/net/mpls.h b/include/net/mpls.h
> index 5b3b5addfb08..296b68661be0 100644
> --- a/include/net/mpls.h
> +++ b/include/net/mpls.h
> @@ -34,6 +34,8 @@ static inline bool eth_p_mpls(__be16 eth_type)
>   */
>  static inline unsigned char *skb_mpls_header(struct sk_buff *skb)
>  {
> -       return skb_mac_header(skb) + skb->mac_len;
> +       return skb_mac_header_was_set(skb) ?
> +               skb_mac_header(skb) + skb->mac_len :
> +               skb->data;
>  }

This function is also called from GSO layer. issue is in GSO layer, it
does reset mac header and mac length and then calls mpls-gso-handler.
So all subsequent check for L3 packet fails.
So far we have explored three different ways to detect L3 packet but
each has its own issue.
1. skb mac header : GSO can reset mac header.
2. skb mac length : MPLS uses mac_len to account for MPLS header
length along with L2 header
3. skb protocol: ETH_P_TEB is not set for all L2 frames, networking
stack is not ready to handle this type for given skb.

So none of them works consistently. I think the only option to detect
L3 packet reliably (and without adding field to skb) is to use
skb-protocol along with ARPHRD_NONE device type. If ARPHRD_NONE type
device generates L2 packet it needs to set protocol to ETH_P_TEB. Some
networking stack function also needs to be fixed to handle this
protocol type, e.g. vlan_get_protocol(), br_dev_queue_push_xmit(),
etc.

  reply	other threads:[~2016-07-15 21:07 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-06 17:59 [PATCH net-next v11 0/6] openvswitch: support for layer 3 encapsulated packets Simon Horman
     [not found] ` <1467827996-32547-1-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-07-06 17:59   ` [PATCH net-next v11 1/6] net: introduce skb_transport_header_was_set() Simon Horman
     [not found]     ` <1467827996-32547-2-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-07-07 20:51       ` pravin shelar
2016-07-06 17:59   ` [PATCH net-next v11 2/6] gre: unset mac header for non-TEB packets received by ipgre device Simon Horman
2016-07-07 20:51     ` [ovs-dev] " pravin shelar
2016-07-06 17:59   ` [PATCH net-next v11 3/6] openvswitch: set skb protocol and mac_len when receiving on internal device Simon Horman
     [not found]     ` <1467827996-32547-4-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-07-07 20:52       ` pravin shelar
     [not found]         ` <CAOrHB_B2VDPcEe0B471J+XjmviAbTO0JRPTHiS7jHzF5V8uHZg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-13  7:17           ` Simon Horman
2016-07-06 17:59   ` [PATCH net-next v11 4/6] openvswitch: add support to push and pop mpls for layer3 packets Simon Horman
     [not found]     ` <1467827996-32547-5-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-07-07 20:52       ` pravin shelar
2016-07-10 11:14         ` [ovs-dev] " Simon Horman
2016-07-06 17:59   ` [PATCH net-next v11 5/6] openvswitch: add layer 3 flow/port support Simon Horman
2016-07-07 20:54     ` [ovs-dev] " pravin shelar
     [not found]       ` <CAOrHB_BYD40ZkWbU0dvhPOCcaCVgooksOUkejxyFoagyoiBTNw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-13  7:31         ` Simon Horman
2016-07-15 21:07           ` pravin shelar [this message]
2016-07-18  4:50             ` [ovs-dev] " Simon Horman
2016-07-18 22:34               ` pravin shelar
     [not found]                 ` <CAOrHB_C3Hq-V4uPWLELSc2VMywjYSnKiFJ4VJQDnPpCu7s1Xkw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-20  0:02                   ` Simon Horman
     [not found]                     ` <20160720000243.GA4688-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-07-20 18:06                       ` pravin shelar
2016-08-08 15:17                         ` [ovs-dev] " Simon Horman
2016-08-08 15:28                           ` Jiri Benc
2016-08-10 10:16                             ` Simon Horman
     [not found]                           ` <20160808151716.GA8477-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-08-09 15:47                             ` pravin shelar
     [not found]                               ` <CAOrHB_BYtGsWPSs2pxTjPajqFEP=5YySmqjc93NbdtY96-dYfw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-10 10:20                                 ` Simon Horman
     [not found]                                   ` <20160810102043.GE5451-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-08-10 17:17                                     ` Joe Stringer
2016-08-22 11:04                                       ` [ovs-dev] " Simon Horman
     [not found]                                         ` <20160822110444.GA29971-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-08-22 21:47                                           ` Joe Stringer
     [not found]                                             ` <CAPWQB7EQhbcDEk==AmN58Qxndmd6oHpw8z78kj2Q4M4-mD7+Dw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-23  8:51                                               ` Simon Horman
     [not found]                                                 ` <20160823085144.GA22304-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-08-25 10:08                                                   ` Simon Horman
     [not found]                                                     ` <20160825100833.GA31926-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-08-26  0:33                                                       ` Joe Stringer
     [not found]                                                         ` <CAPWQB7G8RekHoTMNR5jAJGu7n2i8fNZ1=Fvj4XX_tXVSovpGug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-26  9:13                                                           ` Simon Horman
     [not found]                                                             ` <20160826091322.GE22464-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-08-30 23:23                                                               ` Joe Stringer
     [not found]               ` <20160718045025.GA2490-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-07-21 15:39                 ` Jiri Benc
2016-09-26 16:53             ` [ovs-dev] " Jiri Benc
2016-09-27  4:09               ` pravin shelar
2016-07-06 17:59   ` [PATCH net-next v11 6/6] openvswitch: use ipgre tunnel rather than gretap tunnel Simon Horman

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=CAOrHB_A1ri6fouFH0H4KpEqg1icCmz+U1tcgn-5BoryX5pb1gw@mail.gmail.com \
    --to=pshelar@ovn.org \
    --cc=dev@openvswitch.org \
    --cc=netdev@vger.kernel.org \
    --cc=simon.horman@netronome.com \
    /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.