Re: [ovs-dev] [PATCH v3 3/3] xlate: call tnl_neigh_snoop() from terminate_native_tunnel()

2018-04-05 Thread Zoltán Balogh
Hi,

Could you use the e-mail address zoltan.balogh.eth@gmail, please?

Thanks,
Zoltan

On 4 April 2018 at 01:52, Jan Scheurich <jan.scheur...@ericsson.com> wrote:
> Hi,
>
> I took this over from Zoltan and investigated the failing unit test a bit 
> further.
>
> The essential difference between master and Zoltan's (rebased) patches is 
> that the dynamic "ARP cache" flow entry
>
>table=66,priority=100,reg0=0xa02,reg15=0x2,metadata=0x1 
> actions=set_field:f0:00:00:01:02:04->eth_dst
>
> (which OVN installs in response to the ARP reply it receives from OVS in 
> PACKET_IN after the first injected IP packet) triggers different behavior in 
> the subsequent revalidation:
>
> In the case of master the existing datapath flow entry
>
> recirc_id(0),in_port(3),packet_type(ns=0,id=0),eth(src=f0:00:00:01:02:03,dst=00:00:00:01:02:03),eth_type(0x0800),ipv4(src=192.168.1.2/255.255.255.254,dst=10.0.0.2/248.0.0.0,ttl=64,frag=no),
>  
> actions:ct_clear,set(eth(src=00:00:00:01:02:04,dst=00:00:00:00:00:00)),set(ipv4(src=192.168.1.2/255.255.255.254,dst=8.0.0.0/248.0.0.0,ttl=63)),userspace(pid=0,controller(reason=1,dont_send=0,continuation=0,recirc_id=1,rule_cookie=0x62066318,controller_id=0,max_len=65535))
>
> is correctly deleted during revalidation due to the presence of the new rule 
> in table 66, while with Zoltan's patch that same datapath flow entry remains 
> untouched. It seems as if with the patch the revalidation of the datapath 
> flow does not reach the new rule in table 66.
>
> Consequently the next IP packet injected by netdev-dummy/receive then matches 
> the datapath flow and is sent up to OVN again, where it triggers the same ARP 
> query procedure as before.
>
> However, if I add a "sleep 11" before injecting the second IP packet to let 
> the datapath flow entry time out, the test succeeds, proving that the OF 
> pipeline behaves correctly for a real packet but not when revalidating the 
> datapath flow entry with the userspace(controller(...)) action.
>
> I still do not understand how the (passive) tunnel ARP snooping patch can 
> possibly change the translation behavior for an IP packet in such a way that 
> it affects the revalidation result.
>
> Any idea is welcome.
>
> Regards, Jan
>
>
> BTW: The “pseudo” tunnel neighbor cache entry we get in this test on master 
> for the tenant IP address 10.0.0.2
>
> IP  MAC Bridge
> ==
> 10.0.0.2f0:00:00:01:02:04   br-int
> 192.168.0.2 5e:97:6a:82:7d:41   br-phys
>
> is a good example why we need Zoltan's patch. Any IP address in an ARP reply 
> is blindly inserted into the tunnel neighbor cache. Overlapping IP addresses 
> among tenants can cause frequent overwriting of cache entries, in the worst 
> case leading to continuous configuration changes and revalidation.
>
>
>> -Original Message-
>> From: Zoltán Balogh
>> Sent: Friday, 02 February, 2018 15:42
>> To: Justin Pettit <jpet...@ovn.org>; Ben Pfaff <b...@ovn.org>
>> Cc: g...@ovn.org; d...@openvswitch.org; Jan Scheurich 
>> <jan.scheur...@ericsson.com>
>> Subject: RE: [ovs-dev] [PATCH v3 3/3] xlate: call tnl_neigh_snoop() from 
>> terminate_native_tunnel()
>>
>> Hi Justin,
>>
>> I rebased the patches to recent master. Please find them attached.
>>
>> Best regards,
>> Zoltan
>>
>> > -Original Message-
>> > From: Justin Pettit [mailto:jpet...@ovn.org]
>> > Sent: Friday, February 02, 2018 12:00 AM
>> > To: Ben Pfaff <mailto:b...@ovn.org>
>> > Cc: Zoltán Balogh <mailto:zoltan.bal...@ericsson.com>; 
>> > mailto:g...@ovn.org; mailto:d...@openvswitch.org; Jan Scheurich
>> > <mailto:jan.scheur...@ericsson.com>
>> > Subject: Re: [ovs-dev] [PATCH v3 3/3] xlate: call tnl_neigh_snoop() from 
>> > terminate_native_tunnel()
>> >
>> > I wasn't able to get this patch to apply to the tip of master.  Zoltan, 
>> > can you rebase this patch and repost?
>> >
>> > The main thing my patch series does is make it so that packets that have a 
>> > controller action aren't processed
>> > entirely in userspace.  If, for example, the patches expect packets to be 
>> > in userspace without an explicit slow-path
>> > request when generating the datapath flow, then that would be a problem.
>> >
>> > --Justin
>> >
>> >
>> > > On Feb 1, 2018, at 2:17 PM, Ben Pfaff <mailto:b...@ovn.org> wrote:
>> > >
>> > > Justin, I think 

Re: [ovs-dev] [PATCH v3 3/3] xlate: call tnl_neigh_snoop() from terminate_native_tunnel()

2018-02-02 Thread Zoltán Balogh
Hi Justin,

I rebased the patches to recent master. Please find them attached.

Best regards,
Zoltan

> -Original Message-
> From: Justin Pettit [mailto:jpet...@ovn.org]
> Sent: Friday, February 02, 2018 12:00 AM
> To: Ben Pfaff <b...@ovn.org>
> Cc: Zoltán Balogh <zoltan.bal...@ericsson.com>; g...@ovn.org; 
> d...@openvswitch.org; Jan Scheurich
> <jan.scheur...@ericsson.com>
> Subject: Re: [ovs-dev] [PATCH v3 3/3] xlate: call tnl_neigh_snoop() from 
> terminate_native_tunnel()
> 
> I wasn't able to get this patch to apply to the tip of master.  Zoltan, can 
> you rebase this patch and repost?
> 
> The main thing my patch series does is make it so that packets that have a 
> controller action aren't processed
> entirely in userspace.  If, for example, the patches expect packets to be in 
> userspace without an explicit slow-path
> request when generating the datapath flow, then that would be a problem.
> 
> --Justin
> 
> 
> > On Feb 1, 2018, at 2:17 PM, Ben Pfaff <b...@ovn.org> wrote:
> >
> > Justin, I think this is mainly a question about your patches, can you
> > take a look?
> >
> > On Fri, Jan 26, 2018 at 01:08:35PM +, Zoltán Balogh wrote:
> >> Hi,
> >>
> >> I've been investigating the failing unit test. I can confirm, it does fail
> >> with my series on master. However, when I created the series and sent it to
> >> the mailing list it did not.
> >>
> >> I've rebased my series to this commit before I sent it to the mailing list.
> >>  commit f59cb331c481d08f9a851c07cf31e9d826650485
> >>  Author: Yi Yang <yi.y.y...@intel.com>
> >>  Date:   Sat Jan 6 13:47:51 2018 +0800
> >>
> >> If I apply the series to the commit below, the test does pass.
> >>
> >> So, I started to search for any commits between the one from Yi Yang and 
> >> the
> >> Last one on master which could make my series fail on the OVN unit test
> >> "/32 router IP address".
> >>
> >> I found, that reverting the series of two commits from Justin Pettit below,
> >> makes my series pass the unit test again. Even rebased to master.
> >>
> >>  commit 74c4530dca939109f3fb79776b60b8722e149738
> >>  Author: Justin Pettit <jpet...@ovn.org>
> >>  Date:   Wed Oct 18 23:16:22 2017 -0700
> >>
> >>  ofproto-dpif: Don't slow-path controller actions with pause.
> >>
> >>  A previous patch removed slow-pathing for controller actions with the
> >>  exception of ones that specified "pause".  This commit removes that
> >>  restriction so that no controller actions are slow-pathed.
> >>
> >>  Signed-off-by: Justin Pettit <jpet...@ovn.org>
> >>  Acked-by: Ben Pfaff <b...@ovn.org>
> >>
> >>  commit d39ec23de38464ee35b3098b9f6c5f06d5191015
> >>  Author: Justin Pettit <jpet...@ovn.org>
> >>  Date:   Wed Jul 5 15:17:52 2017 -0700
> >>
> >>  ofproto-dpif: Don't slow-path controller actions.
> >>
> >>  Controller actions have become more commonly used for purposes other
> >>  than just making forwarding decisions (e.g., packet logging).  A 
> >> packet
> >>  that needs to be copied to the controller and forwarded would always 
> >> be
> >>  sent to ovs-vswitchd to be handled, which could negatively affect
> >>  performance and cause heavier CPU utilization in ovs-vswitchd.
> >>
> >>  This commit changes the behavior so that OpenFlow controller actions
> >>  become userspace datapath actions while continuing to let packet
> >>  forwarding and manipulation continue to be handled by the datapath
> >>  directly.
> >>
> >>  This patch still slow-paths controller actions with the "pause" flag
> >>  set.  A future patch will stop slow-pathing these pause actions as
> >>  well.
> >>
> >>  Signed-off-by: Justin Pettit <jpet...@ovn.org>
> >>  Acked-by: Ben Pfaff <b...@ovn.org>
> >>
> >> The main difference, my series does compared to master, is not putting the
> >> ARP entry of {10.0.0.2, f0:00:00:01:02:04, br-int} into tunnel neighbor
> >> cache. All the OF rules are almost the same, except loading different
> >> numbers into NXM_NX_REGx and using different metadata.
> >>
> >> How should this be related to Justin's series?
> >>
> >> If I modify the unit test and populate the missing A

Re: [ovs-dev] [PATCH v3 3/3] xlate: call tnl_neigh_snoop() from terminate_native_tunnel()

2018-01-26 Thread Zoltán Balogh
Hi,

I've been investigating the failing unit test. I can confirm, it does fail
with my series on master. However, when I created the series and sent it to
the mailing list it did not. 

I've rebased my series to this commit before I sent it to the mailing list.
  commit f59cb331c481d08f9a851c07cf31e9d826650485
  Author: Yi Yang <yi.y.y...@intel.com>
  Date:   Sat Jan 6 13:47:51 2018 +0800

If I apply the series to the commit below, the test does pass.

So, I started to search for any commits between the one from Yi Yang and the 
Last one on master which could make my series fail on the OVN unit test 
"/32 router IP address".

I found, that reverting the series of two commits from Justin Pettit below,
makes my series pass the unit test again. Even rebased to master.

  commit 74c4530dca939109f3fb79776b60b8722e149738
  Author: Justin Pettit <jpet...@ovn.org>
  Date:   Wed Oct 18 23:16:22 2017 -0700

  ofproto-dpif: Don't slow-path controller actions with pause.
  
  A previous patch removed slow-pathing for controller actions with the
  exception of ones that specified "pause".  This commit removes that
  restriction so that no controller actions are slow-pathed.
  
  Signed-off-by: Justin Pettit <jpet...@ovn.org>
  Acked-by: Ben Pfaff <b...@ovn.org>

  commit d39ec23de38464ee35b3098b9f6c5f06d5191015
  Author: Justin Pettit <jpet...@ovn.org>
  Date:   Wed Jul 5 15:17:52 2017 -0700

  ofproto-dpif: Don't slow-path controller actions.
  
  Controller actions have become more commonly used for purposes other
  than just making forwarding decisions (e.g., packet logging).  A packet
  that needs to be copied to the controller and forwarded would always be
  sent to ovs-vswitchd to be handled, which could negatively affect
  performance and cause heavier CPU utilization in ovs-vswitchd.
  
  This commit changes the behavior so that OpenFlow controller actions
  become userspace datapath actions while continuing to let packet
  forwarding and manipulation continue to be handled by the datapath
  directly.
  
  This patch still slow-paths controller actions with the "pause" flag
  set.  A future patch will stop slow-pathing these pause actions as
  well.
  
  Signed-off-by: Justin Pettit <jpet...@ovn.org>
  Acked-by: Ben Pfaff <b...@ovn.org>

The main difference, my series does compared to master, is not putting the 
ARP entry of {10.0.0.2, f0:00:00:01:02:04, br-int} into tunnel neighbor 
cache. All the OF rules are almost the same, except loading different 
numbers into NXM_NX_REGx and using different metadata. 

How should this be related to Justin's series?

If I modify the unit test and populate the missing ARP entry then the test 
does pass.

Should this entry be present in the ARP neighbor cache in order to make the
test pass? If yes, then why? 

Best regards,
Zoltan

> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Tuesday, January 23, 2018 8:02 PM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>
> Cc: d...@openvswitch.org; Jan Scheurich <jan.scheur...@ericsson.com>
> Subject: Re: [ovs-dev] [PATCH v3 3/3] xlate: call tnl_neigh_snoop() from 
> terminate_native_tunnel()
> 
> On Tue, Jan 09, 2018 at 07:54:33PM +0100, Zoltan Balogh wrote:
> > Currenlty, OVS snoops any ARP or ND packets in any bridge and populates
> > the tunnel neighbor cache with the retreived data. For instance, when
> > ARP reply originated by a tenant is received in an overlay bridge, the
> > ARP message is snooped and tunnel neighbor cache is filled with tenant
> > data, however only tunnel neighbor data should be stored there.
> >
> > This patch moves tunnel neighbor snooping from do_xlate_actions() to
> > terminate_native_tunnel() where native tunnel is terminated, in order to
> > keep ARP neighbor cache clean, i.e. only packets comming from a native
> > tunnel are snooped.
> >
> > By applying the patch, only ARP and Neighbor Advertisement messages
> > addressing a tunnel endpoint (LOCAL port of underlay bridge) are
> > snooped. In order to achieve this, IP addresses of the bridge are
> > retrieved and then stored in xbridge by calling xlate_xbridge_set().
> > These data is then matched against the data extracted from an ARP or
> > Neighbor Advertisement message in is_neighbor_reply_correct() which is
> > invoked from terminate_native_tunnel().
> >
> > Signed-off-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> 
> Thanks a lot!
> 
> It appears to me that this patch makes the following test consistently
> fail.  When I revert the test, it passes for me again.  Can you take a
> look?
> 
> Thanks,
> 
> Ben.
> 
> # 

Re: [ovs-dev] [PATCH] bfd: Send BFD packets with DSCP CS6

2018-01-16 Thread Zoltán Balogh
Hi,

Acked-by: Zoltan Balogh 

Ben, is there a chance to get this into 2.9?

Best regards,
Zoltan

> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Venkatesan Pradeep
> Sent: Wednesday, January 10, 2018 6:02 AM
> To: d...@openvswitch.org
> Subject: Re: [ovs-dev] [PATCH] bfd: Send BFD packets with DSCP CS6
> 
> Gentle reminder to review this patch.
> 
> Regards,
> 
> Pradeep
> 
> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Venkatesan Pradeep
> Sent: Monday, December 25, 2017 10:29 PM
> To: d...@openvswitch.org
> Subject: [ovs-dev] [PATCH] bfd: Send BFD packets with DSCP CS6
> 
> Send BFD packets with TOS value equivalent to DSCP CS6 so that the network 
> can apply the right QoS for those
> packets. This can help avoid BFD flaps due to network congestion.
> 
> Signed-off-by: Venkatesan Pradeep 
> ---
>  lib/bfd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/bfd.c b/lib/bfd.c
> index 40cd0be..8d291bb 100644
> --- a/lib/bfd.c
> +++ b/lib/bfd.c
> @@ -612,7 +612,7 @@ bfd_put_packet(struct bfd *bfd, struct dp_packet *p,
>  ip->ip_ihl_ver = IP_IHL_VER(5, 4);
>  ip->ip_tot_len = htons(sizeof *ip + sizeof *udp + sizeof *msg);
>  ip->ip_ttl = MAXTTL;
> -ip->ip_tos = IPTOS_LOWDELAY | IPTOS_THROUGHPUT;
> +ip->ip_tos = IPTOS_PREC_INTERNETCONTROL;
>  ip->ip_proto = IPPROTO_UDP;
>  put_16aligned_be32(>ip_src, bfd->ip_src);
>  put_16aligned_be32(>ip_dst, bfd->ip_dst); 
> ___
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
> ___
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v2 3/3] xlate: call tnl_neigh_snoop() from terminate_native_tunnel()

2018-01-08 Thread Zoltán Balogh
Hi Ben,

> I don't understand yet the motivation here.  What does it mean "to keep
> ARP neighbor cache clean"?  Is this a bug fix, a performance fix, a
> cleanup, or something else?
> 
> What is the goal of the filtering you mention?  Is that a second change,
> that can and should be a separate patch, or is it closely coupled to the
> first change you mention?

Jan gave a very good summary in his mail:
https://mail.openvswitch.org/pipermail/ovs-dev/2018-January/342662.html

> This gives me the following Clang errors:
> 
> ../ofproto/ofproto-dpif-xlate.c:3749:13: error: cast from 'const uint8_t 
> *' (aka 'const unsigned char *') to
> 'const struct in6_addr *' increases required alignment from 1 to 4 
> [-Werror,-Wcast-align]
> /usr/include/netinet/in.h:454:36: note: expanded from macro 
> 'IN6_ARE_ADDR_EQUAL'
> ../ofproto/ofproto-dpif-xlate.c:3749:13: error: cast from 'const uint8_t 
> *' (aka 'const unsigned char *') to
> 'const struct in6_addr *' increases required alignment from 1 to 4 
> [-Werror,-Wcast-align]
> /usr/include/netinet/in.h:455:36: note: expanded from macro 
> 'IN6_ARE_ADDR_EQUAL'

Thank you for the review, I'm going to fix this.

> The change to tnl-neigh-cache.c that just adds an #include directive
> seems odd to me.

Sorry, this is a leftover from a previous version. There is no need for the 
include.

> 
> The treatment of the new xbridge_addr is different from the treatment of
> everything already handled in xlate_ofproto_set().  Why does it need
> special treatment?  Is it RCU safe?  Why does it need a refcount (none
> of the other structs do)?
> 

The xbridge_addr holds the current IP addresses assigned to the bridge. These
can change by time. Xbridge_addr is passed to xlate_xbridge_set(), where it is
set as xbridge->addr. Most of the xbridge members are handled the same way
(counting references etc.) in xlate_xbridge_set().
Maybe it's disturbing to retrieve xbridge_addr in xlate_ofproto_set() and then
pass it to xlate_bridge_set().
Do you think, would it be better to store xbridge_addr in ofproto and update it
when an IP address is added or removed, then pass an ofproto member to
xlate_ofproto_set()?

Best regards,
Zoltan

> Thanks,
> 
> Ben.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] xlate: fix xport lookup for recirc

2018-01-05 Thread Zoltán Balogh
Hello Jan,

> As far as I can see the frozen state already contains the ofproto UUID and in 
> frozen_metadata the OF port ID.
> Together these should be sufficient to look up the xport in 
> xlate_lookup_ofproto_():

I know, that ofproto_uuid (bridge to resume from) and in_port (incoming port) 
are 
stored in frozen_state and frozen_metadata. As I mentioned these in a private 
message yesterday. I also wrote to you, that the stored ofproto_uuid refers to 
the 
bridge to resume from, and this can differ from the one xlate_lookup_ofproto_() 
could provide. For instance, in the case of using patch ports and recirculate 
in 
the second bridge. Please, double check your mail-box.

> 
> First look up the xbridge through xbridge_lookup_by_uuid() and afterwards 
> scan the xports hmap of the xbridge for
> the OF port ID as done in static function get_ofp_port(xbridge, ofp_port).
> 
> Thus, there should be no need to add a UUID to the xport and store that in 
> frozen_state.
> 

Actually, because of xlate_lookup_ofproto_() could provide a different ofproto, 
than stored in frozen_state, we cannot use ofproto_uuid from frozen_state to 
retrieve the correct xport. Am I wrong?

> Please also consider and deal with the other bug we found in xlate_actions:
> 

I hope, Ben (or the competent maintainer) will answer my question in my previous
e-mail and clarify if the code you mentioned below needs to be modified or not.

Best regards,
Zoltan

> diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
> index d94e9dc..bfa3acd 100644
> --- a/ofproto/ofproto-dpif-xlate.c
> +++ b/ofproto/ofproto-dpif-xlate.c
> @@ -7037,11 +7037,28 @@ xlate_actions(struct xlate_in *xin, struct xlate_out 
> *xout)
>  }
>  ctx.wc->masks.tunnel.metadata.tab = flow->tunnel.metadata.tab;
> 
> +/* FIXME: The line below looks up the ingress xport from the in_port
> + * in base_flow, which is populated with the initial OF port
> + * determined early in the upcall from the ODP port in the dp_packet's
> + * flow. In the case of recirculation in a subsequent bridge (think patch
> + * port or tunnel port) the ODP port is a port in the initial bridge,
> + * and its OF port number has no meaning in the current bridge. In the
> + * best case there is a miss, in the worst case the base_flow.in_port
> + * matches a bogus port in the current bridge. */
> +
>  /* Get the proximate input port of the packet.  (If xin->frozen_state,
>   * flow->in_port is the ultimate input port of the packet.) */
>  struct xport *in_port = get_ofp_port(xbridge,
>   ctx.base_flow.in_port.ofp_port);
> 
> +/* It would be more correct to look up the xport from
> + * ctx.in.flow.in_port, which after recirculation has already been set
> + * with the thawed in_port in frozen_metadata_to_flow() above.
> + * Only in the case of bond recirculation there will be no valid in_port
> + * in the static recirculation context. But perhaps this is not a real
> + * problem as the output to bond action is typically the last action
> + * and the in_port won't matter anymore. */
> +
>  if (flow->packet_type != htonl(PT_ETH) && in_port &&
>  in_port->pt_mode == NETDEV_PT_LEGACY_L3 && ctx.table_id == 0) {
>  /* Add dummy Ethernet header to non-L2 packet if it's coming from a
> 
> BR, Jan
> 
> 
> > -Original Message-
> > From: ovs-dev-boun...@openvswitch.org 
> > [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> > Sent: Friday, 05 January, 2018 12:27
> > To: Ben Pfaff <b...@ovn.org>
> > Cc: 'd...@openvswitch.org' <d...@openvswitch.org>
> > Subject: Re: [ovs-dev] [PATCH] xlate: fix xport lookup for recirc
> >
> > > On Thu, Dec 21, 2017 at 02:22:43PM +, Zoltán Balogh wrote:
> > > > Xlate_lookup and xlate_lookup_ofproto_() provides in_port and ofproto
> > > > based on xport determined using flow, which is extracted from packet.
> > > > The lookup can happen due to recirculation as well. It can happen, that
> > > > packet_type has been modified during xlate before recirculation is
> > > > triggered, so the lookup fails or delivers wrong xport.
> > > > This can be worked around by propagating xport to ctx->xin after the 
> > > > very
> > > > first lookup and store it in frozen state of the recirculation.
> > > > So, when lookup is performed due to recirculation, the xport can be
> > > > retrieved from the frozen state.
> > > >
> > > > Signed-off-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> > &g

Re: [ovs-dev] [PATCH v2 1/3] ofproto-dpif-sflow: propagate actions within clone

2018-01-05 Thread Zoltán Balogh
> On Thu, Dec 14, 2017 at 09:56:19AM +0100, Zoltan Balogh wrote:
> > By avoiding Tx recirculation and embracing tnl_push action within clone,
> > the tunnel metadata is not propagated. Unless clone action is handled in
> > the dpif_sflow_read_actions() function as well. This commit resolves
> > this issue.
> > In addition, some sflow data needs to be stored and restored in
> > ofproto-dpif-xlate when native_tunnel_output() is invoked. Otherwise the
> > output action of underlay bridge is getting counted as well if sFlow is
> > set on the overlay bridge.
> >
> > Signed-off-by: Zoltan Balogh 
> 
> Thanks for working on bug fixes.
> 
> I don't yet understand the first problem that you mention.  Could you
> give an example of something that does not work properly without the
> patch, and how the patch fixes it?

Hi Ben,

As a performance improvement, an "avoid Tx recirculaion" patch was introduced 
in OVS 2.8:

commit 7c12dfc527a5f6e35eb47494d6284d5a7dbc352c
tunneling: Avoid datapath-recirc by combining recirc actions at xlate.

With this patch, instead of having two datapath flows (one for over- and one
for underlay bridge) there is only a single combined flow in datapath when
sending packet to native tunnel.
This single flow has a clone() action, which holds the actions from the 
underlay bridge.

Now, when configuring sflow in the overlay bridge, tunnel metadata is not
processed by OVS when reading sflow, because push tunnel action is embedded 
within the clone action. This is fixed by the patch.

> 
> It sounds like this patch addresses two independent bugs.  Could it be
> broken into two patches?

The second bug is connected to the "avoid Tx recirculation" patch as well.
Without fixing this second bug, the number of output ports provided by sflow
is not correct. 

Both are side-effects of the performance improvement patch mentioned above and
both affect sflow handling. That's why I put them into a single patch. 
Furthermore, fixing the one would introduce modifications which should be
removed when fixing the other one later.
By looking at the patch again, I see there these leftover modifications... 
I need to fix it.

Best regards,
Zoltan

> 
> Thanks,
> 
> Ben.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] xlate: fix xport lookup for recirc

2018-01-05 Thread Zoltán Balogh
> On Thu, Dec 21, 2017 at 02:22:43PM +0000, Zoltán Balogh wrote:
> > Xlate_lookup and xlate_lookup_ofproto_() provides in_port and ofproto
> > based on xport determined using flow, which is extracted from packet.
> > The lookup can happen due to recirculation as well. It can happen, that
> > packet_type has been modified during xlate before recirculation is
> > triggered, so the lookup fails or delivers wrong xport.
> > This can be worked around by propagating xport to ctx->xin after the very
> > first lookup and store it in frozen state of the recirculation.
> > So, when lookup is performed due to recirculation, the xport can be
> > retrieved from the frozen state.
> >
> > Signed-off-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> > CC: Jan Scheurich <jan.scheur...@ericsson.com>
> 
> Thanks for working on finding and fixing bugs.
> 
> Storing a pointer to an xport, then checking later that it points to a
> valid xport, is risky because it opens up the possibility that the
> pointer points to a different xport that just happens to have the same
> address.  It's hard to guess how likely that coincidence is, but it
> would be better to avoid it.  This is the reason that frozen_state uses
> a random UUID to locate "ofprotos".  Probably, that approach would be
> better for xports too.

I see, thank you for the explanation. I'm going to create a new patch using
xport UUIDs.

> 
> When xport_in is nonnull but invalid, wouldn't it be better to abort
> than to search for an xport the fallback way? 

Yes, that would be better. Especially if UUID is used to get the xport.

> 
> What is the reason for the special case for patch ports?

I've performed some tests before created the patch. I had a setup with two
bridges connected with patch ports:

  p1 +---+ +---+ p2
  ->-o   | |   o->-
 |  br1  o-o  br2  |
 +---+ +---+

Recirculation can occur in the 2nd bridge as well, for instance when pop_mpls
action is followed by resubmit. In this case a new upcall is performed and
xlate_lookup_ofproto_() and xport_lookup() are invoked again. As I observed,
xport_lookup() returns xport referring to p1 in br1, i.e. the very first port
where the packet was received on. I assume, this is not a bug in OVS, is it?

So, I would like to store this very first port in the frozen state. That's the
reason why I do store xport in ctx.xin->xport_in only if xport is not a patch
port. If it's not a patch port, it can be only the very first input port.

> 
> Can you provide a good example of where this is important?

The main goal of this patch is to avoid invocation of xlate_lookup() in case of
recirculation (except recirc due to bond), because it can return a wrong xport. 
For instance, if L3 packet with MPLS label is received on a L3 tunnel port and
pop_mpls + resubmit actions are performed, then first packet_type is changed
due to pushing a dummy ethernet header, MPLS label is removed, then resubmit
action is processed. This triggers recirculation, where xport_lookup() fails
due to former change of packet_type as I noted in the commit message.

> 
> Thanks,
> 
> Ben.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] tunnel: fix tnl_find() after packet_type changed

2017-12-21 Thread Zoltán Balogh
Hi,

I sent a new version to dev list. Please ignore this one.
I changed the subject, since the problem does not seem to be restricted to 
tunnel handling.

https://patchwork.ozlabs.org/patch/851949/

Best regards,
Zoltan

> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> Sent: Monday, December 11, 2017 4:39 PM
> To: Jan Scheurich <jan.scheur...@ericsson.com>; d...@openvswitch.org; Ben 
> Pfaff <b...@ovn.org>
> Subject: Re: [ovs-dev] [PATCH] tunnel: fix tnl_find() after packet_type 
> changed
> 
> Hi,
> 
> I've been working on the solution proposed by Jan. I faced a new issue with
> patch ports. Let's have a config like in unit test 1025:
> "1025: ofproto-dpif - balance-tcp bonding, different recirc flow "
> 
> 
> +-+
> |   br-int| p5 (OF 5)
> | o--<---
> +---o-+
> | br1- (patch port: OF 101)
> |
> +--+
>|
>| br1+ (patch port: OF 100)
> +--o--+
> |   br1   |
> | |
> +---o-o---+
>  p3 | | p4
>   (OF 3)| | (OF 4)
> |bond1|
> +--+--+
>|
> 
> In the unit test, a packet is received on port p5. The packet is then output 
> to
> 'br1-' which is a patch port, its pair is 'br1+' on br1. Ports p3 and p4 are 
> in
> bond0, the packet is recirculated in br1, before it is sent out on bond1.
> 
> So, when it's recirculated, ofproto xlate will end up in 
> xlate_lookup_ofproto_()
> at some point in time. The vanilla code does xport_lookup() based on the flow
> which is built up based on dp_packet (due to miniflow_extract/expand) which 
> has
> in port 5 (p5). So the flow has in port 5 as well. Furthermore, the returned
> ofproto_dpif will be xport->xbridge->ofproto: br-int.
> 
> If we do use the recirc ID extracted from the flow (or from dp_packet) which 
> is
> 2, then the state's uuid will refer to the bridge br1. This is the bridge 
> where
> the recirc action was added to odp_actions. On the other hand the in port
> stored in the state is 0x (undefined). It's neither 5 (p5) nor 100 (br1+).
> 
> So, If we want to build our code based on the recirc ID extracted from flow 
> (or
> dp_packet) we won't get the same result as the vanilla code in case of using
> patch ports and recirculate in the second bridge.
> 
> Does anyone have a idea how to resolve this?
> Maybe the vanilla code or patch port concept is broken?
> 
> If we would use the original value of packet_type in tnl_find() we could still
> workaround this.
> 
> Best regards,
> Zoltan
> 
> > -Original Message-
> > From: Jan Scheurich
> > Sent: Friday, December 08, 2017 5:18 PM
> > To: Zoltán Balogh <zoltan.bal...@ericsson.com>; d...@openvswitch.org
> > Cc: Ben Pfaff <b...@ovn.org>
> > Subject: RE: [PATCH] tunnel: fix tnl_find() after packet_type changed
> >
> > Hi Zoltan,
> > Please find answers below.
> > Regards, Jan
> >
> > > -Original Message-
> > > From: Zoltán Balogh
> > > Sent: Friday, 08 December, 2017 12:56
> > > To: Jan Scheurich <jan.scheur...@ericsson.com>; d...@openvswitch.org
> > > Cc: Ben Pfaff <b...@ovn.org>
> > > Subject: RE: [PATCH] tunnel: fix tnl_find() after packet_type changed
> > >
> > > Hello Jan,
> > >
> > > Thank you for the review.
> > > The recirc_id_node, and thus the frozen_state with the the ofproto_uuid 
> > > can be retrieved from recirc ID via
> > recirc_id_node_find(). So I
> > > think, it would be feasible to get the ofproto from the recirc ID without 
> > > calling tnl_find(). In addition we
> would
> > need to store in_port in the
> > > frozen_state.
> >
> > Yes, my thinking was to lookup the recirculation context in 
> > xlate_lookup_ofproto_() if flow->recirc_id != 0 and
> get
> > bridge and in_port from the frozen data in that case. But I was looking for 
> > a way to store the recirc context
> > pointer so that it need not be looked up once more later during 
> > xlate_actions().
> >
> > BTW: in_port is already stored in frozen_state.metdata.in_port
> >
> > >
> > > However, if we do not fix this in tnl_find(), then we need to make sure, 
> > > that neither xlate_lookup_ofproto() nor
> > xlate_lookup() are called
> > > after flow->packet_type has changed during xlate, don't we? For instance, 
> > > calling revalidate() can lead

[ovs-dev] [PATCH] xlate: don't add dummy eth header when doing recirc

2017-12-21 Thread Zoltán Balogh
In xlate_actions(), when packet comes from a L3 port and its packet_type
is not Ethernet, then a dummy Ethernet header is added to the packet by
setting flow->packet_type to Ethernet and zero out flow->dl_src and
flow->dl_dst. This process should be avoided if packet is recirculated,
i.e. xin->frozen_state is set properly.

Signed-off-by: Zoltan Balogh 
CC: Jan Scheurich 
---
 ofproto/ofproto-dpif-xlate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 9b3a2f28a..d85441cb4 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -7041,7 +7041,7 @@ xlate_actions(struct xlate_in *xin, struct xlate_out 
*xout)
 struct xport *in_port = get_ofp_port(xbridge,
  ctx.base_flow.in_port.ofp_port);
 
-if (flow->packet_type != htonl(PT_ETH) && in_port &&
+if (!xin->frozen_state && flow->packet_type != htonl(PT_ETH) && in_port &&
 in_port->pt_mode == NETDEV_PT_LEGACY_L3 && ctx.table_id == 0) {
 /* Add dummy Ethernet header to non-L2 packet if it's coming from a
  * L3 port. So all packets will be L2 packets for lookup.
-- 
2.14.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] xlate: fix xport lookup for recirc

2017-12-21 Thread Zoltán Balogh
Xlate_lookup and xlate_lookup_ofproto_() provides in_port and ofproto
based on xport determined using flow, which is extracted from packet.
The lookup can happen due to recirculation as well. It can happen, that
packet_type has been modified during xlate before recirculation is
triggered, so the lookup fails or delivers wrong xport.
This can be worked around by propagating xport to ctx->xin after the very
first lookup and store it in frozen state of the recirculation.
So, when lookup is performed due to recirculation, the xport can be
retrieved from the frozen state.

Signed-off-by: Zoltan Balogh 
CC: Jan Scheurich 
---
 ofproto/ofproto-dpif-rid.c|  4 +++-
 ofproto/ofproto-dpif-rid.h|  1 +
 ofproto/ofproto-dpif-upcall.c |  2 ++
 ofproto/ofproto-dpif-xlate.c  | 30 ++
 ofproto/ofproto-dpif-xlate.h  |  3 +++
 5 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/ofproto/ofproto-dpif-rid.c b/ofproto/ofproto-dpif-rid.c
index fc5700489..79de90520 100644
--- a/ofproto/ofproto-dpif-rid.c
+++ b/ofproto/ofproto-dpif-rid.c
@@ -158,7 +158,8 @@ frozen_state_equal(const struct frozen_state *a, const 
struct frozen_state *b)
 && ofpacts_equal(a->ofpacts, a->ofpacts_len,
  b->ofpacts, b->ofpacts_len)
 && ofpacts_equal(a->action_set, a->action_set_len,
- b->action_set, b->action_set_len));
+ b->action_set, b->action_set_len)
+&& a->xport_in == b->xport_in);
 }
 
 /* Lockless RCU protected lookup.  If node is needed accross RCU quiescent
@@ -285,6 +286,7 @@ recirc_alloc_id(struct ofproto_dpif *ofproto)
 .ipv6_dst = in6addr_any,
 },
 .in_port = OFPP_NONE },
+.xport_in = NULL,
 };
 return recirc_alloc_id__(, frozen_state_hash())->id;
 }
diff --git a/ofproto/ofproto-dpif-rid.h b/ofproto/ofproto-dpif-rid.h
index 19fc27c7c..f02221094 100644
--- a/ofproto/ofproto-dpif-rid.h
+++ b/ofproto/ofproto-dpif-rid.h
@@ -143,6 +143,7 @@ struct frozen_state {
 size_t stack_size;
 mirror_mask_t mirrors;/* Mirrors already output. */
 bool conntracked; /* Conntrack occurred prior to freeze. */
+const struct xport *xport_in; /* Port packet was received on. */
 
 /* Actions to be translated when thawing. */
 struct ofpact *ofpacts;
diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index 02cf5415b..92a92d288 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -236,6 +236,8 @@ struct upcall {
 const struct nlattr *out_tun_key;  /* Datapath output tunnel key. */
 
 uint64_t odp_actions_stub[1024 / 8]; /* Stub for odp_actions. */
+
+const struct xport *xport_in;   /* Port the packet was received on. */
 };
 
 /* Ukeys must transition through these states using transition_ukey(). */
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 9b3a2f28a..c9fb32338 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -1362,12 +1362,36 @@ xlate_lookup_ofproto_(const struct dpif_backer *backer, 
const struct flow *flow,
 struct xlate_cfg *xcfg = ovsrcu_get(struct xlate_cfg *, );
 const struct xport *xport;
 
+/* If packet is recirculated, xport can be retrieved from frozen state. */
+if (flow->recirc_id) {
+const struct recirc_id_node *recirc_id_node;
+
+recirc_id_node = recirc_id_node_find(flow->recirc_id);
+
+if (OVS_UNLIKELY(!recirc_id_node)) {
+return NULL;
+}
+
+/* If recirculation was initiated due to bond (in_port = OFPP_NONE),
+ * xport cannot be retrieved from frozen state. */
+if (recirc_id_node->state.metadata.in_port != OFPP_NONE) {
+xport = recirc_id_node->state.xport_in;
+/* Verify, if xport is valid. */
+if (xport && hmap_contains(>xports, >hmap_node) &&
+xport->xbridge && xport->xbridge->ofproto) {
+goto out;
+}
+}
+}
+
 xport = xport_lookup(xcfg, tnl_port_should_receive(flow)
  ? tnl_port_receive(flow)
  : odp_port_to_ofport(backer, flow->in_port.odp_port));
 if (OVS_UNLIKELY(!xport)) {
 return NULL;
 }
+
+out:
 *xportp = xport;
 if (ofp_in_port) {
 *ofp_in_port = xport->ofp_port;
@@ -4623,6 +4647,7 @@ finish_freezing__(struct xlate_ctx *ctx, uint8_t table)
 .stack_size = ctx->stack.size,
 .mirrors = ctx->mirrors,
 .conntracked = ctx->conntracked,
+.xport_in = ctx->xin->xport_in,
 .ofpacts = ctx->frozen_actions.data,
 .ofpacts_len = ctx->frozen_actions.size,
 .action_set = ctx->action_set.data,
@@ -6613,6 +6638,7 @@ xlate_in_init(struct xlate_in *xin, struct ofproto_dpif 
*ofproto,
 xin->odp_actions 

Re: [ovs-dev] [PATCH 0/3] Fix tunnel neighbor cache population

2017-12-13 Thread Zoltán Balogh
> > Currenlty, OVS snoops any ARP or ND packets in any bridge and populates
> > the tunnel neighbor cache with the retreived data. For instance, when
> > ARP reply originated by a tenant is received on an overlay bridge, the
> > ARP message is snooped and tunnel neighbor cache is filled with tenant
> > data, however only tunnel neighbor data should be stored there.
> > In worst case tunnel peer data could be overwritten in the cache. Which
> > triggers revalidation as well.
> >
> > This series resolves the issue, by trying to snoop ARP and ND messages
> > addressing tunnel end point in current bridge.
> >
> > Zoltan Balogh (3):
> >ofproto-dpif-sflow: propagate actions within clone
> >tests: modify ARP snoop tests for tunneling with clone
> >xlate: call tnl_neigh_snoop() from terminate_native_tunnel()
> >
> >   include/sparse/netinet/in.h   |  10 +++
> >   lib/tnl-neigh-cache.c |   1 +
> >   ofproto/ofproto-dpif-sflow.c  |  19 --
> >   ofproto/ofproto-dpif-sflow.h  |   2 +-
> >   ofproto/ofproto-dpif-upcall.c |   2 +-
> >   ofproto/ofproto-dpif-xlate.c  | 150 
> > --
> >   tests/ofproto-dpif.at |   2 +-
> >   tests/tunnel-push-pop-ipv6.at |  78 --
> >   tests/tunnel-push-pop.at  |  91 +
> >   9 files changed, 319 insertions(+), 36 deletions(-)
> >
> 
> Zoltan,
> 
> Thanks for your work on this.  I have tested and reviewed your patches
> and everything looks OK to me
> except for some checkpatch errors on the first patch in the series. If
> you can fix that up and resubmit
> then I'll be happy to provide tested-by and reviewed-by acks.
> 
> Thanks!
> 
> - Greg


Hi Greg,

Thank you for the review! I've seen the checkpatch warnings too. Actually,
some of the lines in vanilla code do have tabs instead of spaces. I modified
some of these lines and kept the leading tabs as there are other untouched 
lines with leading tabs as well. 
Do you want me to change the tabs to spaces in the patch?
Is it ok, if I replace all the tabs in the source files?

ofproto/ofproto-dpif-sflow.c
ofproto/ofproto-dpif-sflow.h

There is an additional warning due to line length over 79 characters. I'm
going to fix this.

Best regards,
Zoltan

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] tunnel: fix tnl_find() after packet_type changed

2017-12-11 Thread Zoltán Balogh
Hi,

I've been working on the solution proposed by Jan. I faced a new issue with 
patch ports. Let's have a config like in unit test 1025:
"1025: ofproto-dpif - balance-tcp bonding, different recirc flow "


+-+
|   br-int| p5 (OF 5)
| o--<---
+---o-+
| br1- (patch port: OF 101)
|
+--+
   |
   | br1+ (patch port: OF 100)
+--o--+
|   br1   |
| |
+---o-o---+
 p3 | | p4
  (OF 3)| | (OF 4)
|bond1|
+--+--+
   |
   
In the unit test, a packet is received on port p5. The packet is then output to
'br1-' which is a patch port, its pair is 'br1+' on br1. Ports p3 and p4 are in
bond0, the packet is recirculated in br1, before it is sent out on bond1.

So, when it's recirculated, ofproto xlate will end up in xlate_lookup_ofproto_()
at some point in time. The vanilla code does xport_lookup() based on the flow
which is built up based on dp_packet (due to miniflow_extract/expand) which has
in port 5 (p5). So the flow has in port 5 as well. Furthermore, the returned 
ofproto_dpif will be xport->xbridge->ofproto: br-int.

If we do use the recirc ID extracted from the flow (or from dp_packet) which is
2, then the state's uuid will refer to the bridge br1. This is the bridge where 
the recirc action was added to odp_actions. On the other hand the in port 
stored in the state is 0x (undefined). It's neither 5 (p5) nor 100 (br1+).

So, If we want to build our code based on the recirc ID extracted from flow (or
dp_packet) we won't get the same result as the vanilla code in case of using 
patch ports and recirculate in the second bridge.

Does anyone have a idea how to resolve this?
Maybe the vanilla code or patch port concept is broken?

If we would use the original value of packet_type in tnl_find() we could still
workaround this.

Best regards,
Zoltan

> -Original Message-
> From: Jan Scheurich
> Sent: Friday, December 08, 2017 5:18 PM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>; d...@openvswitch.org
> Cc: Ben Pfaff <b...@ovn.org>
> Subject: RE: [PATCH] tunnel: fix tnl_find() after packet_type changed
> 
> Hi Zoltan,
> Please find answers below.
> Regards, Jan
> 
> > -Original Message-
> > From: Zoltán Balogh
> > Sent: Friday, 08 December, 2017 12:56
> > To: Jan Scheurich <jan.scheur...@ericsson.com>; d...@openvswitch.org
> > Cc: Ben Pfaff <b...@ovn.org>
> > Subject: RE: [PATCH] tunnel: fix tnl_find() after packet_type changed
> >
> > Hello Jan,
> >
> > Thank you for the review.
> > The recirc_id_node, and thus the frozen_state with the the ofproto_uuid can 
> > be retrieved from recirc ID via
> recirc_id_node_find(). So I
> > think, it would be feasible to get the ofproto from the recirc ID without 
> > calling tnl_find(). In addition we would
> need to store in_port in the
> > frozen_state.
> 
> Yes, my thinking was to lookup the recirculation context in 
> xlate_lookup_ofproto_() if flow->recirc_id != 0 and get
> bridge and in_port from the frozen data in that case. But I was looking for a 
> way to store the recirc context
> pointer so that it need not be looked up once more later during 
> xlate_actions().
> 
> BTW: in_port is already stored in frozen_state.metdata.in_port
> 
> >
> > However, if we do not fix this in tnl_find(), then we need to make sure, 
> > that neither xlate_lookup_ofproto() nor
> xlate_lookup() are called
> > after flow->packet_type has changed during xlate, don't we? For instance, 
> > calling revalidate() can lead to call
> xlate_lookup().
> 
> revalidate() is called from revalidator threads to pass an artificial packet 
> representing the megaflow through the
> pipeline. The flow constructed from the ukey will contain the recirc_id and 
> it should still hit the same
> recirculation context with the frozen_state as a MISS upcall for the 
> originally recirculated packet.
> 
> >
> > Btw, what about the case, when we have a L2 and L3 port with the same local 
> > IP. A packet is received on one of
> them, but the packet_type has changed during xlate and later revalidate leads 
> to calling xlate_lookup()? It will
> provide the wrong tunnel port as in_port. Is this a valid case?
> 
> I think xlate_lookup() is only executed once at the beginning of each upcall 
> or ukey revalidation to initiatilize
> some data. It is never done again later during the xlation process.
> 
> >
> > I was thinking about storing the original value of packet_type of received 
> > packet in dp_packet or in the flow
> structure. Then use the
> > original value in tnl

Re: [ovs-dev] [PATCH] tunnel: fix tnl_find() after packet_type changed

2017-12-08 Thread Zoltán Balogh
Hello Jan,

Thank you for the review.
The recirc_id_node, and thus the frozen_state with the the ofproto_uuid can be 
retrieved from recirc ID via recirc_id_node_find(). So I think, it would be 
feasible to get the ofproto from the recirc ID without calling tnl_find(). In 
addition we would need to store in_port in the frozen_state.

However, if we do not fix this in tnl_find(), then we need to make sure, that 
neither xlate_lookup_ofproto() nor xlate_lookup() are called after 
flow->packet_type has changed during xlate, don't we? For instance, calling 
revalidate() can lead to call xlate_lookup().

Btw, what about the case, when we have a L2 and L3 port with the same local IP. 
A packet is received on one of them, but the packet_type has changed during 
xlate and later revalidate leads to calling xlate_lookup()? It will provide the 
wrong tunnel port as in_port. Is this a valid case?

I was thinking about storing the original value of packet_type of received 
packet in dp_packet or in the flow structure. Then use the original value in 
tnl_find().

Best regards,
Zoltan

> -Original Message-
> From: Jan Scheurich
> Sent: Friday, December 08, 2017 11:30 AM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>; d...@openvswitch.org
> Cc: Ben Pfaff <b...@ovn.org>
> Subject: RE: [PATCH] tunnel: fix tnl_find() after packet_type changed
> 
> Hi Zoltan,
> 
> My feeling here is that it is conceptually wrong to do another tunnel lookup 
> if the packet is recirculated after it
> has already been de-tunneled. You are trying to fix the symptoms and I am not 
> sure that the more liberal check on
> packet type won't lead to incorrect proper tunnel port lookups.
> 
> The actual bridge is stored in the frozen state of the recirculation context, 
> and the OF in_port should be stored
> there as well (if it is not yet). I believe a recirculation should never 
> change the bridge and the OF in_port. @Ben:
> Can you confirm?
> 
> I think the order of things is wrong in an upcall. First ofproto should check 
> if it is a recirculation upcall, and
> only if it is not, it should derive the bridge and the in_port from the flow. 
> Today the first recirculation check
> happens later in upcall_xlate().
> 
> Can you look into that option and propose a better way to solve the issue?
> 
> Thanks, Jan
> 
> > -Original Message-----
> > From: Zoltán Balogh
> > Sent: Friday, 08 December, 2017 10:56
> > To: d...@openvswitch.org
> > Cc: Zoltán Balogh <zoltan.bal...@ericsson.com>; Jan Scheurich 
> > <jan.scheur...@ericsson.com>; Ben Pfaff
> <b...@ovn.org>
> > Subject: [PATCH] tunnel: fix tnl_find() after packet_type changed
> >
> > During xlate, it can happen that tnl_find() is invoked when flow
> > packet_type has been already changed. For instance, pop_mpls and
> > resubmit actions should be applied to the packet in overlay bridge after
> > packet was received on a legacy_l3 tunnel port.
> > In this case, packet is recirculated after pop_mpls, a new tunnel lookup
> > is performed in order to find the proper ofproto, however packet_type of
> > flow is already PT_ETHERNET while the tunnel port mode is
> > NETDEV_PT_LEGACY_L3. So, no tunnel port is found and the packet is
> > dropped.
> >
> > This fix does an additional tnl_find() if no port is found. It looks for
> > L3 tunnel port in case of L2 packet and vice versa.
> >
> > Signed-off-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> > CC: Jan Scheurich <jan.scheur...@ericsson.com>
> > CC: Ben Pfaff <b...@ovn.org>
> > Fixes: 875ab13020b1 ("userspace: Handling of versatile tunnel ports")
> > ---
> >  ofproto/tunnel.c | 13 +
> >  1 file changed, 13 insertions(+)
> >
> > diff --git a/ofproto/tunnel.c b/ofproto/tunnel.c
> > index 1676f4d46..d497f026b 100644
> > --- a/ofproto/tunnel.c
> > +++ b/ofproto/tunnel.c
> > @@ -585,6 +585,19 @@ tnl_find(const struct flow *flow) 
> > OVS_REQ_RDLOCK(rwlock)
> >  if (tnl_port) {
> >  return tnl_port;
> >  }
> > +
> > +/* Maybe flow->packet_type has been already changed 
> > during
> > + * xlate, so let's try to find L2 port for L3 packet or
> > + * L3 port for L2 packet. */
> > +if (pt_ns(flow->packet_type) == OFPHTN_ETHERTYPE) {
> > +match.pt_mode = NETDEV_PT_LEGACY_L2;
> > +} else {
> > +match.pt_mode = NETDEV_PT_LEGACY_L3;
> > +}
> > +tnl_port = tnl_find_exact(, map);
> > +if (tnl_port) {
> > +return tnl_port;
> > +}
> >  }
> >
> >  i++;
> > --
> > 2.14.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 2/2] xlate: normalize the actions after translation

2017-12-06 Thread Zoltán Balogh
Hello Ben,

I added 'const' to the ctx members to be copied during backup in order to see
how big the code impact would be in case of using copy-on-write like method
as you proposed when we were talking about this problem in a conference break.
Actually there were more than 80 places indicated by the compiler in the code.
These were mostly in function headers, so I would say several hundreds of code
lines would be involved.

Instead of this approach I reduced the size of backup data structure by two
times the size of 'struct flow' and used bitwise operations instead of memcpy
for storing backup data. I moved backup data into 'struct ctx', its
initialization is performed when 'ctx' is created in xlate_actions().

I sent this second version of the series to the mailing list. Could you review
it, please? Do you think, copy-on-write is still needed?

https://mail.openvswitch.org/pipermail/ovs-dev/2017-December/341655.html
https://mail.openvswitch.org/pipermail/ovs-dev/2017-December/341657.html
https://mail.openvswitch.org/pipermail/ovs-dev/2017-December/341658.html

https://patchwork.ozlabs.org/patch/845118/
https://patchwork.ozlabs.org/patch/845127/

Best regards,
Zoltan

> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Monday, November 13, 2017 8:02 PM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>
> Cc: Chandran, Sugesh <sugesh.chand...@intel.com>; d...@openvswitch.org; Jan 
> Scheurich <jan.scheur...@ericsson.com>
> Subject: Re: [ovs-dev] [PATCH 2/2] xlate: normalize the actions after 
> translation
> 
> Here is an idea that just occurred to me.  What if we used a kind of
> copy-on-write approach?  That is, whenever the flow is modified, we
> first check whether we need to do a "backup" of it?  This should reduce
> the number of copies greatly, because flow modifications are relatively
> rare compared to, say, "resubmit" actions.  It will require a little
> work to make the code in ofproto-dpif-xlate call the right function to
> do the copying, but I think that it would be easier to implement and
> maintain than the approaches you suggest (assuming that I understand
> them correctly).
> 
> On Mon, Nov 13, 2017 at 05:28:24PM +, Zoltán Balogh wrote:
> > Hello Ben,
> >
> > Thank you for the review. I have been thinking about possible solutions.
> >
> > 1) We could use non-temporary (non-cached) copy when backing up data. That 
> > would avoid using write cache and make
> writing memory faster. In turn reading data back right after the write would 
> be slower but that should not be the
> regular case. Furthermore it should not be available for all hardware 
> platforms.
> >
> > 2) Sugesh came up with the idea to do conditional backup and restore of 
> > data. We should keep track if xlate flow,
> wildcard and base_flow are modified in translation and only copy needed 
> fields. I think this would be the best
> choice but has large code impact and would make code maintenance more 
> complicated.
> >
> > 3) Another option would be to spilt up the flow structure into partitions. 
> > Then instead of copying the whole
> structure, partitions could be checked for change by using memcmp(), then do 
> the copy in case of change. We could
> use something like this:
> >
> > #define FLOW_PART_LEN(start, end) \
> > ((char *)&((struct flow *)0)->end) - ((char *)&((struct flow 
> > *)0)->start)
> >
> > #define COMPARE_FLOW_PART(dst, src, start, end) \
> > memcmp(>start, >start, FLOW_PART_LEN(start, end))
> >
> > #define COPY_FLOW_PART(dst, src, start, end) \
> > memcpy(>start, >start, FLOW_PART_LEN(start, end))
> >
> > static void
> > copy_altered_flow_data(struct flow *dst, const struct flow *src)
> > {
> > BUILD_ASSERT_DECL(FLOW_WC_SEQ == 40);
> >
> > /* Metadata 1 */
> > if (!COMPARE_FLOW_PART(dst, src, tunnel, metadata)) {
> > COPY_FLOW_PART(dst, src, tunnel, metadata);
> > }
> >
> > /* Metadata 2 */
> > if (!COMPARE_FLOW_PART(dst, src, metadata, dl_dst)) {
> > COPY_FLOW_PART(dst, src, metadata, dl_dst);
> > }
> >
> > /* L2 */
> > if (!COMPARE_FLOW_PART(dst, src, dl_dst, nw_src)) {
> > COPY_FLOW_PART(dst, src, dl_dst, nw_src);
> > }
> >
> > /* L3 */
> > if (!COMPARE_FLOW_PART(dst, src, nw_src, tp_src)) {
> > COPY_FLOW_PART(dst, src, nw_src, tp_src);
> > }
> >
> > /* L4 */
> > if (!COMPARE_FLOW_PART(dst, src, tp_src, pad3)) {
> > COPY_FLOW_PART(dst, src, tp_src, pad3);
> > }
> > }
> >
&g

Re: [ovs-dev] [PATCH 2/2] xlate: normalize the actions after translation

2017-12-06 Thread Zoltán Balogh
Subject is incorrect, missing v2. Please use this instead:
https://mail.openvswitch.org/pipermail/ovs-dev/2017-December/341658.html


> -Original Message-
> From: Zoltán Balogh
> Sent: Wednesday, December 06, 2017 11:55 AM
> To: d...@openvswitch.org
> Cc: Zoltán Balogh <zoltan.bal...@ericsson.com>; Sugesh Chandran 
> <sugesh.chand...@intel.com>; Ben Pfaff <b...@ovn.org>
> Subject: [PATCH 2/2] xlate: normalize the actions after translation
> 
> When all OF actions have been translated, there could be actions at
> the end of list of odp actions which are not needed to be executed.
> So, the list can be normalized at the end of xlate_actions().
> 
> Signed-off-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> Signed-off-by: Sugesh Chandran <sugesh.chand...@intel.com>
> Co-authored-by: Sugesh Chandran <sugesh.chand...@intel.com>
> CC: Ben Pfaff <b...@ovn.org>
> ---
>  ofproto/ofproto-dpif-xlate.c | 67 
> 
>  tests/ofproto-dpif.at| 48 +++
>  2 files changed, 115 insertions(+)
> 
> diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
> index 36d0a0e1f..2af1ec1e8 100644
> --- a/ofproto/ofproto-dpif-xlate.c
> +++ b/ofproto/ofproto-dpif-xlate.c
> @@ -6954,6 +6954,70 @@ xlate_wc_finish(struct xlate_ctx *ctx)
>  }
>  }
> 
> +/* Returns true if the action stored in 'nla' can be a valid last action of a
> + * datapath flow. */
> +static bool
> +is_valid_last_action(const struct nlattr *nla)
> +{
> +enum ovs_action_attr action_type = nl_attr_type(nla);
> +
> +switch (action_type) {
> +case OVS_ACTION_ATTR_USERSPACE:
> +case OVS_ACTION_ATTR_SAMPLE:
> +case OVS_ACTION_ATTR_TRUNC:
> +case OVS_ACTION_ATTR_RECIRC:
> +case OVS_ACTION_ATTR_TUNNEL_PUSH:
> +case OVS_ACTION_ATTR_TUNNEL_POP:
> +case OVS_ACTION_ATTR_OUTPUT:
> +case OVS_ACTION_ATTR_CLONE:
> +case OVS_ACTION_ATTR_CT:
> +return true;
> +case OVS_ACTION_ATTR_UNSPEC:
> +case OVS_ACTION_ATTR_SET:
> +case OVS_ACTION_ATTR_PUSH_VLAN:
> +case OVS_ACTION_ATTR_POP_VLAN:
> +case OVS_ACTION_ATTR_HASH:
> +case OVS_ACTION_ATTR_PUSH_MPLS:
> +case OVS_ACTION_ATTR_POP_MPLS:
> +case OVS_ACTION_ATTR_SET_MASKED:
> +case OVS_ACTION_ATTR_PUSH_ETH:
> +case OVS_ACTION_ATTR_POP_ETH:
> +case OVS_ACTION_ATTR_METER:
> +case OVS_ACTION_ATTR_ENCAP_NSH:
> +case OVS_ACTION_ATTR_DECAP_NSH:
> +case __OVS_ACTION_ATTR_MAX:
> +default:
> +return false;
> +}
> +}
> +
> +/* Returns offset of last netlink attribute storing valid action in array
> + * 'data'. Execution of actions beyond this last attribute does not make 
> sense.
> + */
> +static size_t
> +last_action_offset(const struct nlattr *data, const size_t data_len)
> +{
> +const struct nlattr *last = data;
> +
> +uint16_t left;
> +const struct nlattr *a;
> +NL_ATTR_FOR_EACH (a, left, data, data_len) {
> +if (is_valid_last_action(a)) {
> +last = nl_attr_next(a);
> +}
> +}
> +
> +return (char *) last - (char *) data;
> +}
> +
> +/* Get rid of any unneeded actions at the tail end. */
> +static void
> +normalize_odp_actions(struct xlate_ctx *ctx)
> +{
> +struct ofpbuf *oa = ctx->odp_actions;
> +oa->size = last_action_offset(oa->data, oa->size);
> +}
> +
>  /* Translates the flow, actions, or rule in 'xin' into datapath actions in
>   * 'xout'.
>   * The caller must take responsibility for eventually freeing 'xout', with
> @@ -7364,7 +7428,10 @@ exit:
>  if (xin->odp_actions) {
>  ofpbuf_clear(xin->odp_actions);
>  }
> +} else {
> +normalize_odp_actions();
>  }
> +
>  return ctx.error;
>  }
> 
> diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
> index e7df1504a..5bcd8bb46 100644
> --- a/tests/ofproto-dpif.at
> +++ b/tests/ofproto-dpif.at
> @@ -10133,3 +10133,51 @@ AT_CHECK([grep "Datapath actions" stdout], [0],
> 
>  OVS_VSWITCHD_STOP
>  AT_CLEANUP
> +
> +AT_SETUP([ofproto-dpif - xlate error - normalize actions])
> +
> +#  ->-+
> +# | p1
> +#   +-o---+
> +#   |   br0   |
> +#   +-o-o-+
> +#   patch0| |patch1
> +# +-->--+
> +
> +OVS_VSWITCHD_START([dnl
> +-- add-port br0 patch0 \
> +-- set interface patch0 type=patch options:peer=patch1 ofport_request=10 
> \
> +-- add-port br0 patch1 \
> +-- set interface patch1 type=patch options:peer=patch0 ofport_request=20
> +])
&g

Re: [ovs-dev] [PATCH 2/2] xlate: normalize the actions after translation

2017-11-13 Thread Zoltán Balogh
Hello Ben,

Thank you for the review. I have been thinking about possible solutions.

1) We could use non-temporary (non-cached) copy when backing up data. That 
would avoid using write cache and make writing memory faster. In turn reading 
data back right after the write would be slower but that should not be the 
regular case. Furthermore it should not be available for all hardware platforms.

2) Sugesh came up with the idea to do conditional backup and restore of data. 
We should keep track if xlate flow, wildcard and base_flow are modified in 
translation and only copy needed fields. I think this would be the best choice 
but has large code impact and would make code maintenance more complicated.

3) Another option would be to spilt up the flow structure into partitions. Then 
instead of copying the whole structure, partitions could be checked for change 
by using memcmp(), then do the copy in case of change. We could use something 
like this:

#define FLOW_PART_LEN(start, end) \
((char *)&((struct flow *)0)->end) - ((char *)&((struct flow *)0)->start)

#define COMPARE_FLOW_PART(dst, src, start, end) \
memcmp(>start, >start, FLOW_PART_LEN(start, end))

#define COPY_FLOW_PART(dst, src, start, end) \
memcpy(>start, >start, FLOW_PART_LEN(start, end))

static void
copy_altered_flow_data(struct flow *dst, const struct flow *src)
{
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 40);

/* Metadata 1 */
if (!COMPARE_FLOW_PART(dst, src, tunnel, metadata)) {
COPY_FLOW_PART(dst, src, tunnel, metadata);
}

/* Metadata 2 */
if (!COMPARE_FLOW_PART(dst, src, metadata, dl_dst)) {
COPY_FLOW_PART(dst, src, metadata, dl_dst);
}

/* L2 */
if (!COMPARE_FLOW_PART(dst, src, dl_dst, nw_src)) {
COPY_FLOW_PART(dst, src, dl_dst, nw_src);
}

/* L3 */
if (!COMPARE_FLOW_PART(dst, src, nw_src, tp_src)) {
COPY_FLOW_PART(dst, src, nw_src, tp_src);
}

/* L4 */
if (!COMPARE_FLOW_PART(dst, src, tp_src, pad3)) {
COPY_FLOW_PART(dst, src, tp_src, pad3);
}
}

static void
store_ctx_xlate_data(struct xlate_backup_data *data,
 const struct xlate_ctx *ctx, bool force)
{
data->odp_actions_size = ctx->odp_actions->size;
if (force) {
data->wc_masks = ctx->wc->masks;
data->flow = ctx->xin->flow;
data->base_flow = ctx->base_flow;
} else {
copy_altered_flow_data(>wc_masks, >wc->masks);
copy_altered_flow_data(>flow, >xin->flow);
copy_altered_flow_data(>base_flow, >base_flow);
}
}

What do you think?

Best regards,
Zoltan


> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Tuesday, October 31, 2017 9:30 PM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>
> Cc: d...@openvswitch.org
> Subject: Re: [ovs-dev] [PATCH 2/2] xlate: normalize the actions after 
> translation
> 
> On Mon, Oct 30, 2017 at 12:22:50PM +0100, Zoltan Balogh wrote:
> > When all OF actions have been translated, there could be actions at
> > the end of list of odp actions which are not needed to be executed.
> > So, the list can be normalized at the end of xlate_actions().
> >
> > Signed-off-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> > Signed-off-by: Sugesh Chandran <sugesh.chand...@intel.com>
> > Co-authored-by: Sugesh Chandran <sugesh.chand...@intel.com>
> > Tested-by: Sugesh Chandran <sugesh.chand...@intel.com>
> 
> Thanks for working on this.  I wasn't previously aware that there was a
> problem, but now I see what you mean.
> 
> The description in 0/2 is necessary to properly understand the problem,
> but that description will get lost when the patches are committed.  I
> recommend adding all or most of it to patch 1.
> 
> This approach to saving and restoring is going to be super-expensive
> during translation.  On i386, struct xlate_backup_data is 1996 bytes,
> and as I read the patch, that's getting copied every time we visit a new
> OpenFlow table.  Do you have any idea about how to make it cheaper, or
> how to make fewer backups?
> 
> Thanks,
> 
> Ben.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v2] tests: fix PTAP system test to check only OF stats

2017-10-31 Thread Zoltán Balogh

Hi Ben,

I rebased the patch and sent v3 to the dev list:
https://mail.openvswitch.org/pipermail/ovs-dev/2017-October/340225.html
https://patchwork.ozlabs.org/patch/832300/

Best regards,
Zoltan

> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Monday, October 30, 2017 10:33 PM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>
> Cc: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: Re: [ovs-dev] [PATCH v2] tests: fix PTAP system test to check only 
> OF stats
> 
> On Wed, Jul 12, 2017 at 07:22:58AM +, Zoltán Balogh wrote:
> >
> > It turned out, checking datapath flow statistics during system-userspace
> > test is not reliable. Unwanted packets can be injected depending on
> > system configuration. As a workaround, this commit removes checking
> > statistics of datapath flows and does check OpenFlow statistics of the
> > integrator bridges. Datapath flows can be checked in normal PTAP unit
> > tests by running 'make check'.
> >
> > Reported-by: Darrell Ball <db...@vmware.com>
> > Suggested-by: Jan Scheurich <jan.scheur...@ericsson.com>
> > Tested-by: Darrell Ball <db...@vmware.com>
> > Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
> 
> It seems that this patch was never properly reviewed and applied, but it
> no longer applies cleanly.  Is there any chance you'd be willing to
> rebase and re-post it?
> 
> Thanks,
> 
> Ben.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] review request

2017-10-02 Thread Zoltán Balogh
Hi,

Could somebody have a look at these old patches, please?
https://patchwork.ozlabs.org/patch/803889/
https://patchwork.ozlabs.org/patch/787037/

Best regards,
Zoltan
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v2] netdev-dpdk: reset packet_type for reused dp_packets

2017-09-11 Thread Zoltán Balogh
Hi Darrell,

Thank you for the clarification! I removed the line below from the source. I 
sent v5 to the dev list:
https://mail.openvswitch.org/pipermail/ovs-dev/2017-September/338567.html
https://patchwork.ozlabs.org/patch/812245/

Best regards,
Zoltan


> -Original Message-
> From: Darrell Ball [mailto:db...@vmware.com]
> Sent: Friday, September 08, 2017 6:24 PM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>; 'd...@openvswitch.org' 
> <d...@openvswitch.org>
> Subject: Re: [ovs-dev] [PATCH v2] netdev-dpdk: reset packet_type for reused 
> dp_packets
> 
> Hi Zoltan
> 
> The packet_type initialization that I was referring to as becoming redundant 
> now was the one moved from to
> 
> void
> dp_packet_init_dpdk(struct dp_packet *b, size_t allocated)
> {
> dp_packet_set_allocated(b, allocated);
> b->source = DPBUF_DPDK;
> b->packet_type = htonl(PT_ETH);   <<<<<<<<<<<<<<<<<<<<<<<<
> }
> 
> Essentially , it was ‘split out’ from dp_packet_init__ for dpdk.
> 
> Since the new packet_type was not being reset as would be needed if the 
> buffer pool only init is done,
> we are now initing all packets for packet_type with this patch, hence the 
> above line for dpdk buffer
> pool init becomes redundant.
> 
> Thanks Darrell
> 
> 
> On 9/8/17, 3:01 AM, "Zoltán Balogh" <zoltan.bal...@ericsson.com> wrote:
> 
> Hi,
> 
> Please ignore this patch. It's faulty. We cannot remove initialization
> of packet_type from dp_packet_init__(). Beacause of non-dpdk netdevs
> still need it. Here is a link to the corrected patch on patchwork:
> https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__patchwork.ozlabs.org_patch_811445_=DwIFAw=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-
> uEs=dGZmbKhBG9tJHY4odedsGA=8TOx50_GxR8BEr45vTRIK07hVU3zdUM74V8mfYZ71Pc=7M6jjf8mR02x3pm7OqQKPVuq0RoVq7odJtobax0
> JYJw=
> 
> Best regards,
> Zoltan
> 
> 
> > -Original Message-
> > From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> > Sent: Friday, September 08, 2017 10:43 AM
> > To: 'd...@openvswitch.org' <d...@openvswitch.org>
> > Subject: [ovs-dev] [PATCH v2] netdev-dpdk: reset packet_type for reused 
> dp_packets
> >
> > DPDK uses dp-packet pool for storing received packets. The pool is
> > reused by rxq_recv funcions of the DPDK netdevs. The datapath is
> > capable to modify the packet_type property of packets. For instance
> > when encapsulated L3 packets are received on a ptap gre port.
> > In this case the packet_type property of struct dp_packet can be
> > modified and later the same dp_packet with the modified packet_type
> > can be reused in the rxq_rec function, so it can contain corrupted
> > data.
> >
> > The dp_packet_batch_init_cutlen() in the rxq_recv functions iterates
> > over dp_packets and sets their cutlen. So I modified this function
> > to set packet_type to Ethernet for the dp_packets as well. I also
> > renamed this function because of the added functionality.
> >
> > The dp_packet_batch_init_cutlen() iterates over batch->count dp_packet.
> > Therefore setting of batch->count = nb_rx needs to be done before the
> > former function is invoked. This is an additional fix.
> >
> > This commit also removes initialization of packet_type from
> > dp_packet_init__(), since that was moved to dp_packet_init_dpdk() 
> before.
> >
> > Signed-off-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> > Signed-off-by: Laszlo Suru <laszlo.s...@ericsson.com>
> > Co-authored-by: Laszlo Suru <laszlo.s...@ericsson.com>
> > CC: Jan Scheurich <jan.scheur...@ericsson.com>
> > CC: Sugesh Chandran <sugesh.chand...@intel.com>
> > CC: Darrell Ball <dlu...@gmail.com>
> > ---
> >  lib/dp-packet.c   | 2 --
> >  lib/dp-packet.h   | 3 ++-
> >  lib/netdev-dpdk.c | 7 ---
> >  3 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/lib/dp-packet.c b/lib/dp-packet.c
> > index e5d16a6..21dfe39 100644
> > --- a/lib/dp-packet.c
> > +++ b/lib/dp-packet.c
> > @@ -33,8 +33,6 @@ dp_packet_init__(struct dp_packet *b, size_t 
> allocated, enum dp_packet_source so
> >  dp_packet_rss_invalidate(b);
> >  dp_packet_mbuf_init(b);
> >  dp_packet_reset_cutlen(b);
>  

[ovs-dev] [PATCH v5] netdev-dpdk: reset packet_type for reused dp_packets

2017-09-11 Thread Zoltán Balogh
DPDK uses dp-packet pool for storing received packets. The pool is
reused by rxq_recv funcions of the DPDK netdevs. The datapath is
capable to modify the packet_type property of packets. For instance
when encapsulated L3 packets are received on a ptap gre port.
In this case the packet_type property of struct dp_packet can be
modified and later the same dp_packet with the modified packet_type
can be reused in the rxq_rec function, so it can contain corrupted
data.

The dp_packet_batch_init_cutlen() in the rxq_recv functions iterates
over dp_packets and sets their cutlen. So I modified this function
to set packet_type to Ethernet for the dp_packets as well. I also
renamed this function because of the added functionality.

The dp_packet_batch_init_cutlen() iterates over batch->count dp_packet.
Therefore setting of batch->count = nb_rx needs to be done before the
former function is invoked. This is an additional fix.

Signed-off-by: Zoltan Balogh 
Signed-off-by: Laszlo Suru 
Co-authored-by: Laszlo Suru 
CC: Jan Scheurich 
CC: Sugesh Chandran 
CC: Darrell Ball 
---
 lib/dp-packet.c   | 1 -
 lib/dp-packet.h   | 3 ++-
 lib/netdev-dpdk.c | 7 ---
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/dp-packet.c b/lib/dp-packet.c
index e5d16a6..443c225 100644
--- a/lib/dp-packet.c
+++ b/lib/dp-packet.c
@@ -103,7 +103,6 @@ dp_packet_init_dpdk(struct dp_packet *b, size_t allocated)
 {
 dp_packet_set_allocated(b, allocated);
 b->source = DPBUF_DPDK;
-b->packet_type = htonl(PT_ETH);
 }
 
 /* Initializes 'b' as an empty dp_packet with an initial capacity of 'size'
diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index 046f3ab..b4b721c 100644
--- a/lib/dp-packet.h
+++ b/lib/dp-packet.h
@@ -805,12 +805,13 @@ dp_packet_delete_batch(struct dp_packet_batch *batch, 
bool may_steal)
 }
 
 static inline void
-dp_packet_batch_init_cutlen(struct dp_packet_batch *batch)
+dp_packet_batch_init_packet_fields(struct dp_packet_batch *batch)
 {
 struct dp_packet *packet;
 
 DP_PACKET_BATCH_FOR_EACH (packet, batch) {
 dp_packet_reset_cutlen(packet);
+packet->packet_type = htonl(PT_ETH);
 }
 }
 
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index f58e9be..b9a 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1644,8 +1644,9 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
  nb_rx, dropped);
 rte_spinlock_unlock(>stats_lock);
 
-dp_packet_batch_init_cutlen(batch);
-batch->count = (int) nb_rx;
+batch->count = nb_rx;
+dp_packet_batch_init_packet_fields(batch);
+
 return 0;
 }
 
@@ -1684,8 +1685,8 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct 
dp_packet_batch *batch)
 rte_spinlock_unlock(>stats_lock);
 }
 
-dp_packet_batch_init_cutlen(batch);
 batch->count = nb_rx;
+dp_packet_batch_init_packet_fields(batch);
 
 return 0;
 }
-- 
1.9.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v3] netdev-dpdk: reset packet_type for reused dp_packets

2017-09-08 Thread Zoltán Balogh
I'm sorry, this one became corrupt because of my e-mail client.
Sent a 4th one:
https://patchwork.ozlabs.org/patch/811617/
https://mail.openvswitch.org/pipermail/ovs-dev/2017-September/338486.html

Zoltan

> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> Sent: Friday, September 08, 2017 12:01 PM
> To: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: [ovs-dev] [PATCH v3] netdev-dpdk: reset packet_type for reused 
> dp_packets
> 
> DPDK uses dp-packet pool for storing received packets. The pool is
> reused by rxq_recv funcions of the DPDK netdevs. The datapath is
> capable to modify the packet_type property of packets. For instance
> when encapsulated L3 packets are received on a ptap gre port.
> In this case the packet_type property of struct dp_packet can be
> modified and later the same dp_packet with the modified packet_type
> can be reused in the rxq_rec function, so it can contain corrupted
> data.
> 
> The dp_packet_batch_init_cutlen() in the rxq_recv functions iterates
> over dp_packets and sets their cutlen. So I modified this function
> to set packet_type to Ethernet for the dp_packets as well. I also
> renamed this function because of the added functionality.
> 
> The dp_packet_batch_init_cutlen() iterates over batch->count dp_packet.
> Therefore setting of batch->count = nb_rx needs to be done before the
> former function is invoked. This is an additional fix.
> 
> Signed-off-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> Signed-off-by: Laszlo Suru <laszlo.s...@ericsson.com>
> Co-authored-by: Laszlo Suru <laszlo.s...@ericsson.com>
> CC: Jan Scheurich <jan.scheur...@ericsson.com>
> CC: Sugesh Chandran <sugesh.chand...@intel.com>
> CC: Darrell Ball <dlu...@gmail.com>
> ---
> lib/dp-packet.h   | 3 ++-
> lib/netdev-dpdk.c | 7 ---
> 2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/dp-packet.h b/lib/dp-packet.h
> index 046f3ab..b4b721c 100644
> --- a/lib/dp-packet.h
> +++ b/lib/dp-packet.h
> @@ -805,12 +805,13 @@ dp_packet_delete_batch(struct dp_packet_batch *batch, 
> bool may_steal)
> }
>  static inline void
> -dp_packet_batch_init_cutlen(struct dp_packet_batch *batch)
> +dp_packet_batch_init_packet_fields(struct dp_packet_batch *batch)
> {
>  struct dp_packet *packet;
>  DP_PACKET_BATCH_FOR_EACH (packet, batch) {
>  dp_packet_reset_cutlen(packet);
> +packet->packet_type = htonl(PT_ETH);
>  }
> }
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index f58e9be..b9a 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -1644,8 +1644,9 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
>   nb_rx, dropped);
>  rte_spinlock_unlock(>stats_lock);
> -dp_packet_batch_init_cutlen(batch);
> -batch->count = (int) nb_rx;
> +batch->count = nb_rx;
> +dp_packet_batch_init_packet_fields(batch);
> +
>  return 0;
> }
> @@ -1684,8 +1685,8 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct 
> dp_packet_batch *batch)
>  rte_spinlock_unlock(>stats_lock);
>  }
> -dp_packet_batch_init_cutlen(batch);
>  batch->count = nb_rx;
> +dp_packet_batch_init_packet_fields(batch);
>  return 0;
> }
> --
> 1.9.1
> 
> ___
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v2] netdev-dpdk: reset packet_type for reused dp_packets

2017-09-08 Thread Zoltán Balogh
Hi,

Please ignore this patch. It's faulty. We cannot remove initialization
of packet_type from dp_packet_init__(). Beacause of non-dpdk netdevs 
still need it. Here is a link to the corrected patch on patchwork:
https://patchwork.ozlabs.org/patch/811445/

Best regards,
Zoltan


> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> Sent: Friday, September 08, 2017 10:43 AM
> To: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: [ovs-dev] [PATCH v2] netdev-dpdk: reset packet_type for reused 
> dp_packets
> 
> DPDK uses dp-packet pool for storing received packets. The pool is
> reused by rxq_recv funcions of the DPDK netdevs. The datapath is
> capable to modify the packet_type property of packets. For instance
> when encapsulated L3 packets are received on a ptap gre port.
> In this case the packet_type property of struct dp_packet can be
> modified and later the same dp_packet with the modified packet_type
> can be reused in the rxq_rec function, so it can contain corrupted
> data.
> 
> The dp_packet_batch_init_cutlen() in the rxq_recv functions iterates
> over dp_packets and sets their cutlen. So I modified this function
> to set packet_type to Ethernet for the dp_packets as well. I also
> renamed this function because of the added functionality.
> 
> The dp_packet_batch_init_cutlen() iterates over batch->count dp_packet.
> Therefore setting of batch->count = nb_rx needs to be done before the
> former function is invoked. This is an additional fix.
> 
> This commit also removes initialization of packet_type from
> dp_packet_init__(), since that was moved to dp_packet_init_dpdk() before.
> 
> Signed-off-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> Signed-off-by: Laszlo Suru <laszlo.s...@ericsson.com>
> Co-authored-by: Laszlo Suru <laszlo.s...@ericsson.com>
> CC: Jan Scheurich <jan.scheur...@ericsson.com>
> CC: Sugesh Chandran <sugesh.chand...@intel.com>
> CC: Darrell Ball <dlu...@gmail.com>
> ---
>  lib/dp-packet.c   | 2 --
>  lib/dp-packet.h   | 3 ++-
>  lib/netdev-dpdk.c | 7 ---
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/dp-packet.c b/lib/dp-packet.c
> index e5d16a6..21dfe39 100644
> --- a/lib/dp-packet.c
> +++ b/lib/dp-packet.c
> @@ -33,8 +33,6 @@ dp_packet_init__(struct dp_packet *b, size_t allocated, 
> enum dp_packet_source so
>  dp_packet_rss_invalidate(b);
>  dp_packet_mbuf_init(b);
>  dp_packet_reset_cutlen(b);
> -/* By default assume the packet type to be Ethernet. */
> -b->packet_type = htonl(PT_ETH);
>  }
> 
>  static void
> diff --git a/lib/dp-packet.h b/lib/dp-packet.h
> index 046f3ab..b4b721c 100644
> --- a/lib/dp-packet.h
> +++ b/lib/dp-packet.h
> @@ -805,12 +805,13 @@ dp_packet_delete_batch(struct dp_packet_batch *batch, 
> bool may_steal)
>  }
> 
>  static inline void
> -dp_packet_batch_init_cutlen(struct dp_packet_batch *batch)
> +dp_packet_batch_init_packet_fields(struct dp_packet_batch *batch)
>  {
>  struct dp_packet *packet;
> 
>  DP_PACKET_BATCH_FOR_EACH (packet, batch) {
>  dp_packet_reset_cutlen(packet);
> +packet->packet_type = htonl(PT_ETH);
>  }
>  }
> 
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index f58e9be..b9a 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -1644,8 +1644,9 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
>   nb_rx, dropped);
>  rte_spinlock_unlock(>stats_lock);
> 
> -dp_packet_batch_init_cutlen(batch);
> -batch->count = (int) nb_rx;
> +batch->count = nb_rx;
> +dp_packet_batch_init_packet_fields(batch);
> +
>  return 0;
>  }
> 
> @@ -1684,8 +1685,8 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct 
> dp_packet_batch *batch)
>  rte_spinlock_unlock(>stats_lock);
>  }
> 
> -dp_packet_batch_init_cutlen(batch);
>  batch->count = nb_rx;
> +dp_packet_batch_init_packet_fields(batch);
> 
>  return 0;
>  }
> --
> 1.9.1
> 
> ___
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v3] netdev-dpdk: reset packet_type for reused dp_packets

2017-09-08 Thread Zoltán Balogh
DPDK uses dp-packet pool for storing received packets. The pool is
reused by rxq_recv funcions of the DPDK netdevs. The datapath is
capable to modify the packet_type property of packets. For instance
when encapsulated L3 packets are received on a ptap gre port.
In this case the packet_type property of struct dp_packet can be
modified and later the same dp_packet with the modified packet_type
can be reused in the rxq_rec function, so it can contain corrupted
data.

The dp_packet_batch_init_cutlen() in the rxq_recv functions iterates
over dp_packets and sets their cutlen. So I modified this function
to set packet_type to Ethernet for the dp_packets as well. I also
renamed this function because of the added functionality.

The dp_packet_batch_init_cutlen() iterates over batch->count dp_packet.
Therefore setting of batch->count = nb_rx needs to be done before the
former function is invoked. This is an additional fix.

Signed-off-by: Zoltan Balogh 
Signed-off-by: Laszlo Suru 
Co-authored-by: Laszlo Suru 
CC: Jan Scheurich 
CC: Sugesh Chandran 
CC: Darrell Ball 
---
lib/dp-packet.h   | 3 ++-
lib/netdev-dpdk.c | 7 ---
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index 046f3ab..b4b721c 100644
--- a/lib/dp-packet.h
+++ b/lib/dp-packet.h
@@ -805,12 +805,13 @@ dp_packet_delete_batch(struct dp_packet_batch *batch, 
bool may_steal)
}
 static inline void
-dp_packet_batch_init_cutlen(struct dp_packet_batch *batch)
+dp_packet_batch_init_packet_fields(struct dp_packet_batch *batch)
{
 struct dp_packet *packet;
 DP_PACKET_BATCH_FOR_EACH (packet, batch) {
 dp_packet_reset_cutlen(packet);
+packet->packet_type = htonl(PT_ETH);
 }
}
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index f58e9be..b9a 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1644,8 +1644,9 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
  nb_rx, dropped);
 rte_spinlock_unlock(>stats_lock);
-dp_packet_batch_init_cutlen(batch);
-batch->count = (int) nb_rx;
+batch->count = nb_rx;
+dp_packet_batch_init_packet_fields(batch);
+
 return 0;
}
@@ -1684,8 +1685,8 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct 
dp_packet_batch *batch)
 rte_spinlock_unlock(>stats_lock);
 }
-dp_packet_batch_init_cutlen(batch);
 batch->count = nb_rx;
+dp_packet_batch_init_packet_fields(batch);
 return 0;
}
--
1.9.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] netdev-dpdk: reset packet_type for reused dp_packets

2017-09-08 Thread Zoltán Balogh
Hi Darrell,

Thank you for your comments! I created a second version and sent it to the dev 
list:
https://patchwork.ozlabs.org/patch/811387/

Best regards,
Zoltan

> -Original Message-
> From: Darrell Ball [mailto:db...@vmware.com]
> Sent: Thursday, September 07, 2017 12:45 AM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>; 'd...@openvswitch.org' 
> <d...@openvswitch.org>
> Subject: Re: [ovs-dev] [PATCH] netdev-dpdk: reset packet_type for reused 
> dp_packets
> 
> 
> 
> On 9/6/17, 5:12 AM, "ovs-dev-boun...@openvswitch.org on behalf of Zoltán 
> Balogh" <ovs-dev-boun...@openvswitch.org on
> behalf of zoltan.bal...@ericsson.com> wrote:
> 
> DPDK uses dp-packet pool for storing received packets. The pool is
> reused by rxq_recv funcions of the DPDK netdevs. The datapath is
> capable to modify the packet_type property of packets. For instance
> when encapsulated L3 packets are received on a ptap gre port.
> In this case the packet_type property of struct dp_packet can be
> modified and later the same dp_packet with the modified packet_type
> can be reused in the rxq_rec function, so it can contain corrupted
> data.
> 
> The dp_packet_batch_init_cutlen() in the rxq_recv functions iterates
> over dp_packets and sets their cutlen. So I modified this function
> to set packet_type to Ethernet for the dp_packets as well. I also
> renamed this function because of the added functionality.
> 
> The dp_packet_batch_init_cutlen() iterates over batch->count dp_packet.
> Therefore setting of batch->count = nb_rx needs to be done before the
> former function is invoked. This is an additional fix.
> 
> Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
> Signed-off-by: László Sürü <laszlo.s...@ericsson.com>
> Co-authored-by: László Sürü <laszlo.s...@ericsson.com>
> CC: Jan Scheurich <jan.scheur...@ericsson.com>
> CC: Sugesh Chandran <sugesh.chand...@intel.com>
> CC: Darrell Ball <dlu...@gmail.com>
> ---
>  lib/dp-packet.h   | 4 +++-
>  lib/netdev-dpdk.c | 5 +++--
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/dp-packet.h b/lib/dp-packet.h
> index 046f3ab..0046d0a 100644
> --- a/lib/dp-packet.h
> +++ b/lib/dp-packet.h
> @@ -805,12 +805,14 @@ dp_packet_delete_batch(struct dp_packet_batch 
> *batch, bool may_steal)
>  }
> 
>  static inline void
> -dp_packet_batch_init_cutlen(struct dp_packet_batch *batch)
> +dp_packet_batch_init_transient_fields(struct dp_packet_batch *batch)
> 
> [Darrell]
> Can we just call this function dp_packet_batch_init_packet_fields() now that 
> it has wider scope than just cutlen,
> as the name makes it clear that we are initing the individual packet fields 
> of a batch, rather than the batch
> context fields ?
> ‘transient’ is maybe implied ?
> 
> 
>  {
>  struct dp_packet *packet;
> 
>  DP_PACKET_BATCH_FOR_EACH (packet, batch) {
>  dp_packet_reset_cutlen(packet);
> +/* Set packet_type to Ethernet. */
> +packet->packet_type = PACKET_TYPE_BE(OFPHTN_ONF, 0x);
> 
> 
> [Darrell] The original dp_packet init code for PTAP has
>  b->packet_type = htonl(PT_ETH);
> This form seems preferred and intuitive (comment would even be unnecessary); 
> can we use this form ?
> 
> Also, the original dp_packet init code for PTAP was in dp_packet_init__ and 
> then moved to dp_packet_init_dpdk
> I think we can just remove it from there, as it is redundant with the new 
> code.
> 
> 
>  }
>  }
> 
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index f58e9be..2422741 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -1644,8 +1644,9 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
>   nb_rx, dropped);
>  rte_spinlock_unlock(>stats_lock);
> 
> -dp_packet_batch_init_cutlen(batch);
>  batch->count = (int) nb_rx;
> 
> [Darrell] Although nothing to do with this patch, can we remove the cast 
> ‘(int)’ above ?
> 
> 
> +dp_packet_batch_init_transient_fields(batch);
> 
> [Darrell]
> Good catch; this should work better than initializing 0 of the entries (
> 
> +
>  return 0;
>  }
> 
> @@ -1684,8 +1685,8 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct 
> dp_packet_batch *batch)
>  rte_spinlock_unlock(>stats_lock);
>  }
> 
> -dp_packet_batch_init_cutlen(batch);
>  batch-

[ovs-dev] [PATCH v2] netdev-dpdk: reset packet_type for reused dp_packets

2017-09-08 Thread Zoltán Balogh
DPDK uses dp-packet pool for storing received packets. The pool is
reused by rxq_recv funcions of the DPDK netdevs. The datapath is
capable to modify the packet_type property of packets. For instance
when encapsulated L3 packets are received on a ptap gre port.
In this case the packet_type property of struct dp_packet can be
modified and later the same dp_packet with the modified packet_type
can be reused in the rxq_rec function, so it can contain corrupted
data.

The dp_packet_batch_init_cutlen() in the rxq_recv functions iterates
over dp_packets and sets their cutlen. So I modified this function
to set packet_type to Ethernet for the dp_packets as well. I also
renamed this function because of the added functionality.

The dp_packet_batch_init_cutlen() iterates over batch->count dp_packet.
Therefore setting of batch->count = nb_rx needs to be done before the
former function is invoked. This is an additional fix.

This commit also removes initialization of packet_type from
dp_packet_init__(), since that was moved to dp_packet_init_dpdk() before.

Signed-off-by: Zoltan Balogh 
Signed-off-by: Laszlo Suru 
Co-authored-by: Laszlo Suru 
CC: Jan Scheurich 
CC: Sugesh Chandran 
CC: Darrell Ball 
---
 lib/dp-packet.c   | 2 --
 lib/dp-packet.h   | 3 ++-
 lib/netdev-dpdk.c | 7 ---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/dp-packet.c b/lib/dp-packet.c
index e5d16a6..21dfe39 100644
--- a/lib/dp-packet.c
+++ b/lib/dp-packet.c
@@ -33,8 +33,6 @@ dp_packet_init__(struct dp_packet *b, size_t allocated, enum 
dp_packet_source so
 dp_packet_rss_invalidate(b);
 dp_packet_mbuf_init(b);
 dp_packet_reset_cutlen(b);
-/* By default assume the packet type to be Ethernet. */
-b->packet_type = htonl(PT_ETH);
 }
 
 static void
diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index 046f3ab..b4b721c 100644
--- a/lib/dp-packet.h
+++ b/lib/dp-packet.h
@@ -805,12 +805,13 @@ dp_packet_delete_batch(struct dp_packet_batch *batch, 
bool may_steal)
 }
 
 static inline void
-dp_packet_batch_init_cutlen(struct dp_packet_batch *batch)
+dp_packet_batch_init_packet_fields(struct dp_packet_batch *batch)
 {
 struct dp_packet *packet;
 
 DP_PACKET_BATCH_FOR_EACH (packet, batch) {
 dp_packet_reset_cutlen(packet);
+packet->packet_type = htonl(PT_ETH);
 }
 }
 
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index f58e9be..b9a 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1644,8 +1644,9 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
  nb_rx, dropped);
 rte_spinlock_unlock(>stats_lock);
 
-dp_packet_batch_init_cutlen(batch);
-batch->count = (int) nb_rx;
+batch->count = nb_rx;
+dp_packet_batch_init_packet_fields(batch);
+
 return 0;
 }
 
@@ -1684,8 +1685,8 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct 
dp_packet_batch *batch)
 rte_spinlock_unlock(>stats_lock);
 }
 
-dp_packet_batch_init_cutlen(batch);
 batch->count = nb_rx;
+dp_packet_batch_init_packet_fields(batch);
 
 return 0;
 }
-- 
1.9.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] netdev-dpdk: reset packet_type for reused dp_packets

2017-09-06 Thread Zoltán Balogh
DPDK uses dp-packet pool for storing received packets. The pool is
reused by rxq_recv funcions of the DPDK netdevs. The datapath is
capable to modify the packet_type property of packets. For instance
when encapsulated L3 packets are received on a ptap gre port.
In this case the packet_type property of struct dp_packet can be
modified and later the same dp_packet with the modified packet_type
can be reused in the rxq_rec function, so it can contain corrupted
data.

The dp_packet_batch_init_cutlen() in the rxq_recv functions iterates
over dp_packets and sets their cutlen. So I modified this function
to set packet_type to Ethernet for the dp_packets as well. I also
renamed this function because of the added functionality.

The dp_packet_batch_init_cutlen() iterates over batch->count dp_packet.
Therefore setting of batch->count = nb_rx needs to be done before the
former function is invoked. This is an additional fix.

Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
Signed-off-by: László Sürü <laszlo.s...@ericsson.com>
Co-authored-by: László Sürü <laszlo.s...@ericsson.com>
CC: Jan Scheurich <jan.scheur...@ericsson.com>
CC: Sugesh Chandran <sugesh.chand...@intel.com>
CC: Darrell Ball <dlu...@gmail.com>
---
 lib/dp-packet.h   | 4 +++-
 lib/netdev-dpdk.c | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index 046f3ab..0046d0a 100644
--- a/lib/dp-packet.h
+++ b/lib/dp-packet.h
@@ -805,12 +805,14 @@ dp_packet_delete_batch(struct dp_packet_batch *batch, 
bool may_steal)
 }
 
 static inline void
-dp_packet_batch_init_cutlen(struct dp_packet_batch *batch)
+dp_packet_batch_init_transient_fields(struct dp_packet_batch *batch)
 {
 struct dp_packet *packet;
 
 DP_PACKET_BATCH_FOR_EACH (packet, batch) {
 dp_packet_reset_cutlen(packet);
+/* Set packet_type to Ethernet. */
+packet->packet_type = PACKET_TYPE_BE(OFPHTN_ONF, 0x);
 }
 }
 
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index f58e9be..2422741 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1644,8 +1644,9 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
  nb_rx, dropped);
 rte_spinlock_unlock(>stats_lock);
 
-dp_packet_batch_init_cutlen(batch);
 batch->count = (int) nb_rx;
+dp_packet_batch_init_transient_fields(batch);
+
 return 0;
 }
 
@@ -1684,8 +1685,8 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct 
dp_packet_batch *batch)
 rte_spinlock_unlock(>stats_lock);
 }
 
-dp_packet_batch_init_cutlen(batch);
 batch->count = nb_rx;
+dp_packet_batch_init_transient_fields(batch);
 
 return 0;
 }
-- 
1.9.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v3 0/2] basic encap/decap

2017-07-27 Thread Zoltán Balogh
Hi,

As Yi wrote before, we would appreciate if somebody could review the series. I 
won't be available for the next two weeks and Jan is on vacation until 4th 
August. So, none of us will be able to update the patches next week.

Best regards,
Zoltan

> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Yang, Yi Y
> Sent: Wednesday, July 26, 2017 12:52 AM
> To: Zoltán Balogh <zoltan.balogh@gmail.com>; d...@openvswitch.org
> Subject: Re: [ovs-dev] [PATCH v3 0/2] basic encap/decap
> 
> Hi, folks
> 
> It seems Ben is out of office in these days, can anybody help review or merge 
> this patch series? I heard 2.8 branch
> would be created end of July, but we still have NSH patch series waiting for 
> review except this series.
> 
> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> Sent: Saturday, July 22, 2017 1:08 AM
> To: d...@openvswitch.org
> Subject: [ovs-dev] [PATCH v3 0/2] basic encap/decap
> 
> From: Zoltan Balogh <zoltan.bal...@ericsson.com>
> 
> This series is a continuation of other patch series initiated by Jan 
> Scheurich before. These were already applied to
> the master branch:
>  - userspace: Support for L3 tunneling
>https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/87.html
>  - Packet type aware pipeline
>https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/334512.html
> 
> The main purpose of this series is to add support for the OpenFlow actions 
> generic encap and decap (ONF EXT-382) to
> the OVS control plane. It implements a skeleton for translation of generic 
> encap and decap actions in ofproto-dpif
> and provides support to encap and decap an Ethernet header.
> 
> v2->v3
>  - NEWS updated.
>  - fix: drop VLAN tagged packet trying to decap it.
>  - New unit tests for the fix.
>  - Some tests were updated due to change in recirculation on master branch.
> 
> v1->v2
>  - Squash 1/4 and 2/4 commits of v1.
>  - Put unit tests in a separate commit.
>  - Use aligned cast.
>  - Nicira extension numbers for encap/decap action numbers and error codes.
>  - Small fixes according to comments.
> 
> Jan Scheurich (1):
>   OF support and translation of generic encap and decap
> 
> Zoltan Balogh (1):
>   tests: Extend PTAP unit tests with decap action
> 
>  NEWS   |   6 +
>  include/openflow/openflow-common.h |   1 +
>  include/openvswitch/automake.mk|   1 +
>  include/openvswitch/ofp-actions.h  |  31 +++  
> include/openvswitch/ofp-ed-props.h |  69 +++
>  include/openvswitch/ofp-errors.h   |   9 +
>  lib/automake.mk|   1 +
>  lib/odp-util.c |  84 +---
>  lib/odp-util.h |   3 +-
>  lib/ofp-actions.c  | 378 +-
>  lib/ofp-ed-props.c | 150 ++
>  lib/packets.h  |   3 +-
>  ofproto/ofproto-dpif-xlate.c   | 116 ++-
>  tests/packet-type-aware.at | 405 
> +
>  14 files changed, 1215 insertions(+), 42 deletions(-)  create mode 100644 
> include/openvswitch/ofp-ed-props.h
>  create mode 100644 lib/ofp-ed-props.c
> 
> --
> 1.9.1
> 
> ___
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
> ___
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v3 1/2] OF support and translation of generic encap and decap

2017-07-21 Thread Zoltán Balogh
From: Jan Scheurich 

This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.

CLI syntax for encap action with properties:
  encap(hdr=)
  encap(hdr=,
prop(class=,type=,val=),
prop(class=,type=,val()))

CLI syntax for decap action:
  decap()
  decap(packet_type(ns=,type=))

The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).

This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.

In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.

The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.

Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.

Signed-off-by: Jan Scheurich 
Signed-off-by: Yi Yang 
Signed-off-by: Zoltan Balogh 
Co-authored-by: Zoltan Balogh 
---
 NEWS   |   6 +
 include/openflow/openflow-common.h |   1 +
 include/openvswitch/automake.mk|   1 +
 include/openvswitch/ofp-actions.h  |  31 +++
 include/openvswitch/ofp-ed-props.h |  69 +++
 include/openvswitch/ofp-errors.h   |   9 +
 lib/automake.mk|   1 +
 lib/odp-util.c |  84 ++---
 lib/odp-util.h |   3 +-
 lib/ofp-actions.c  | 378 -
 lib/ofp-ed-props.c | 150 +++
 lib/packets.h  |   3 +-
 ofproto/ofproto-dpif-xlate.c   | 116 +++-
 13 files changed, 810 insertions(+), 42 deletions(-)
 create mode 100644 include/openvswitch/ofp-ed-props.h
 create mode 100644 lib/ofp-ed-props.c

diff --git a/NEWS b/NEWS
index b2deac5..105f67d 100644
--- a/NEWS
+++ b/NEWS
@@ -61,11 +61,17 @@ Post-v2.7.0
  * The "learn" action now supports a "limit" option (see ovs-ofctl(8)).
  * The port status bit OFPPS_LIVE now reflects link aliveness.
  * OpenFlow 1.5 packet-out is now supported.
+ * Support for OpenFlow 1.5 field packet_type and packet-type-aware
+   pipeline (PTAP).
+ * Added generic encap and decap actions (EXT-382).
+   First supported use case is encap/decap for Ethernet.
- Fedora Packaging:
  * OVN services are no longer restarted automatically after upgrade.
- Add --cleanup option to command 'ovs-appctl exit' (see ovs-vswitchd(8)).
- L3 tunneling:
  * Use new tunnel port option "packet_type" to configure L2 vs. L3.
+ * In conjunction with PTAP tunnel ports can handle a mix of L2 and L3
+   payload.
  * New vxlan tunnel extension "gpe" to support VXLAN-GPE tunnels.
  * New support for non-Ethernet (L3) payloads in GRE and VXLAN-GPE.
- The BFD detection multiplier is now user-configurable.
diff --git a/include/openflow/openflow-common.h 
b/include/openflow/openflow-common.h
index 410f392..1e22ea5 100644
--- a/include/openflow/openflow-common.h
+++ b/include/openflow/openflow-common.h
@@ -467,6 +467,7 @@ enum ofp_header_type_namespaces {
 OFPHTN_IP_PROTO = 2,/* ns_type is a IP protocol number. */
 OFPHTN_UDP_TCP_PORT = 3,/* ns_type is a TCP or UDP port. */
 OFPHTN_IPV4_OPTION = 4, /* ns_type is an IPv4 option number. */
+OFPHTN_N_TYPES
 };
 
 #endif /* openflow/openflow-common.h */
diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk
index 699d9d7..c8e67a2 100644
--- a/include/openvswitch/automake.mk
+++ b/include/openvswitch/automake.mk
@@ -12,6 +12,7 @@ openvswitchinclude_HEADERS = \
include/openvswitch/meta-flow.h \
include/openvswitch/ofpbuf.h \
include/openvswitch/ofp-actions.h \
+   include/openvswitch/ofp-ed-props.h \
include/openvswitch/ofp-errors.h \
include/openvswitch/ofp-msgs.h \

[ovs-dev] [PATCH v3 2/2] tests: Extend PTAP unit tests with decap action

2017-07-21 Thread Zoltán Balogh
From: Zoltan Balogh 

  - Checking decap() prerequisits.
  - Encap/decap VLAN tagged Ethernet frames.
  - Send L3 packet over patch port.
  - Output L2/L3 packet to ports with different packet_type properties.

Signed-off-by: Zoltan Balogh 
Suggested-by: Jan Scheurich 
---
 tests/packet-type-aware.at | 405 +
 1 file changed, 405 insertions(+)

diff --git a/tests/packet-type-aware.at b/tests/packet-type-aware.at
index 883d9a0..8034e80 100644
--- a/tests/packet-type-aware.at
+++ b/tests/packet-type-aware.at
@@ -510,3 +510,408 @@ 
tunnel(src=20.0.0.3,dst=20.0.0.2,flags(-df-csum)),recirc_id(0),in_port(gre_sys),
 
 OVS_VSWITCHD_STOP(["/The Open vSwitch kernel module is probably not loaded/d"])
 AT_CLEANUP
+
+
+AT_SETUP([ptap - check decap() prerequisits])
+OVS_VSWITCHD_START
+
+# Decap IP header, then set IP destination address. This should fail.
+AT_CHECK([
+ovs-ofctl add-flow br0 
"in_port=1,packet_type=(1,0x800),actions=decap(),set_field:1.1.1.1->nw_dst"
+], [1], [stdout], [stderr])
+
+AT_CHECK([
+cat stderr | cut -d '|' -f 3-
+], [0], [dnl
+ofp_actions|WARN|set_field ip_dst lacks correct prerequisites
+ovs-ofctl: actions are invalid with specified match (OFPBAC_MATCH_INCONSISTENT)
+])
+
+# Decap Ethernet header, then set IP destination address. This should work.
+AT_CHECK([
+ovs-ofctl add-flow br0 -OOpenFlow13 
"in_port=1,ip,actions=decap(),set_field:1.1.1.1->nw_dst"
+], [0])
+
+# Decap IP header, then set metadata. This should work.
+AT_CHECK([
+ovs-ofctl add-flow br0 -OOpenFlow13 
"in_port=1,packet_type=(1,0x800),actions=decap(),set_field:1234->metadata"
+], [0])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+
+AT_SETUP([ptap - check encap/decap VLAN tagged Ethernet frame])
+OVS_VSWITCHD_START([dnl
+-- add-port br0 n1 -- set interface n1 type=dummy ofport_request=1 \
+-- add-port br0 n2 -- set interface n2 type=dummy ofport_request=2 \
+-- add-port br0 p1 -- set interface p1 type=patch options:peer=p2 
ofport_request=3 \
+-- add-port br0 p2 -- set interface p2 type=patch options:peer=p1 
ofport_request=4
+])
+
+# Decap VLAN tagged Ethernet frames -> should be dropped
+AT_CHECK([
+ovs-ofctl add-flow br0 -OOpenFlow13 
"in_port=1,actions=push_vlan:0x8100,mod_vlan_vid:100,decap(),3"
+ovs-ofctl add-flow br0 -OOpenFlow13 
"in_port=4,actions=encap(hdr=ethernet),2"
+], [0])
+
+AT_CHECK([
+ovs-appctl netdev-dummy/receive n1 
1e2ce92a669e3a6dd2099cab080045548a53400040011addc0a80a0ac0a80a1e08006f200a4d0001fc509a5827150200101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637
+ovs-appctl netdev-dummy/receive n1 
1e2ce92a669e3a6dd2099cab080045548a83400040011aadc0a80a0ac0a80a1e0800b7170a4d0002fd509a58de1c0200101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637
+], [0], [ignore])
+
+ovs-appctl time/warp 1000
+
+AT_CHECK([
+ovs-appctl dpctl/dump-flows | strip_used | grep -v ipv6 | sort
+], [0], [flow-dump from non-dpdk interfaces:
+recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), 
packets:1, bytes:98, used:0.0s, actions:drop
+])
+
+# Encap(hdr=ethernet) on Ethernet frame -> should be droped
+AT_CHECK([
+ovs-ofctl del-flows br0
+ovs-ofctl add-flow br0 -OOpenFlow13 "in_port=1,actions=3"
+ovs-ofctl add-flow br0 -OOpenFlow13 
"in_port=4,actions=encap(hdr=ethernet),2"
+])
+
+ovs-appctl time/warp 11000
+
+AT_CHECK([
+ovs-appctl netdev-dummy/receive n1 
1e2ce92a669e3a6dd2099cab080045548a53400040011addc0a80a0ac0a80a1e08006f200a4d0001fc509a5827150200101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637
+ovs-appctl netdev-dummy/receive n1 
1e2ce92a669e3a6dd2099cab080045548a83400040011aadc0a80a0ac0a80a1e0800b7170a4d0002fd509a58de1c0200101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637
+], [0], [ignore])
+
+ovs-appctl time/warp 1000
+
+AT_CHECK([
+ovs-appctl dpctl/dump-flows | strip_used | grep -v ipv6 | sort
+], [0], [flow-dump from non-dpdk interfaces:
+recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), 
packets:1, bytes:98, used:0.0s, actions:drop
+])
+
+# Encap(hdr=ethernet) on VLAN tagged Ethernet frame -> should be droped
+AT_CHECK([
+ovs-ofctl del-flows br0
+ovs-ofctl add-flow br0 -OOpenFlow13 
"in_port=1,actions=push_vlan:0x8100,mod_vlan_vid:100,encap(hdr=ethernet),3"
+ovs-ofctl add-flow br0 -OOpenFlow13 "in_port=4,actions=2"
+])
+
+ovs-appctl time/warp 11000
+
+AT_CHECK([
+ovs-appctl netdev-dummy/receive n1 
1e2ce92a669e3a6dd2099cab080045548a53400040011addc0a80a0ac0a80a1e08006f200a4d0001fc509a5827150200101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637
+ovs-appctl netdev-dummy/receive n1 

[ovs-dev] [PATCH v3 0/2] basic encap/decap

2017-07-21 Thread Zoltán Balogh
From: Zoltan Balogh 

This series is a continuation of other patch series initiated by Jan Scheurich 
before. These were already applied to the master branch:
 - userspace: Support for L3 tunneling
   https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/87.html
 - Packet type aware pipeline
   https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/334512.html

The main purpose of this series is to add support for the OpenFlow actions 
generic encap and decap (ONF EXT-382) to the OVS control plane. It implements
a skeleton for translation of generic encap and decap actions in ofproto-dpif
and provides support to encap and decap an Ethernet header. 

v2->v3
 - NEWS updated.
 - fix: drop VLAN tagged packet trying to decap it.
 - New unit tests for the fix.
 - Some tests were updated due to change in recirculation on master branch.

v1->v2
 - Squash 1/4 and 2/4 commits of v1.
 - Put unit tests in a separate commit.
 - Use aligned cast.
 - Nicira extension numbers for encap/decap action numbers and error codes.
 - Small fixes according to comments.

Jan Scheurich (1):
  OF support and translation of generic encap and decap

Zoltan Balogh (1):
  tests: Extend PTAP unit tests with decap action

 NEWS   |   6 +
 include/openflow/openflow-common.h |   1 +
 include/openvswitch/automake.mk|   1 +
 include/openvswitch/ofp-actions.h  |  31 +++
 include/openvswitch/ofp-ed-props.h |  69 +++
 include/openvswitch/ofp-errors.h   |   9 +
 lib/automake.mk|   1 +
 lib/odp-util.c |  84 +---
 lib/odp-util.h |   3 +-
 lib/ofp-actions.c  | 378 +-
 lib/ofp-ed-props.c | 150 ++
 lib/packets.h  |   3 +-
 ofproto/ofproto-dpif-xlate.c   | 116 ++-
 tests/packet-type-aware.at | 405 +
 14 files changed, 1215 insertions(+), 42 deletions(-)
 create mode 100644 include/openvswitch/ofp-ed-props.h
 create mode 100644 lib/ofp-ed-props.c

-- 
1.9.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v2 4/4] tunneling: Avoid datapath-recirc by combining recirc actions at xlate.

2017-07-17 Thread Zoltán Balogh

Hi Joe,

I used the setup below to measure Tx performance using a single core and 2 x 
10G Ethernet links. I generated traffic of 64 byte packets to utilize the 10G 
bandwidth and measured the Tx processing cost per transmitted packet in nsec.

+-+  
  dpdk0 | |  
 -->obr-in|  
| o--> gre0  
+-+  
 
   --> LOCAL 
+---o-+  
| | dpdk1
|br-p1o--> 
| |  
+-+  

This is the result of OVS master with DPDK 16.11.2:

 # dpdk0

 RX packets : 7037641.60  / sec
 RX packet errors   : 0  / sec
 RX packets dropped : 7730632.90  / sec
 RX rate: 402.69 MB/sec

 # dpdk1

 TX packets : 7037641.60  / sec
 TX packet errors   : 0  / sec
 TX packets dropped : 0  / sec
 TX rate: 657.73 MB/sec
 TX processing cost per TX packets in nsec : 142.09


This is the result of OVS master + patch with DPDK 16.11.2:

 # dpdk0

 RX packets : 9386809.60  / sec
 RX packet errors   : 0  / sec
 RX packets dropped : 5381496.40  / sec
 RX rate: 537.11 MB/sec

 # dpdk1

 TX packets : 9386809.60  / sec
 TX packet errors   : 0  / sec
 TX packets dropped : 0  / sec
 TX rate: 877.29 MB/sec
 TX processing cost per TX packets in nsec : 106.53

As you can see the number of transmitted packets per second increased from 7M 
to 9.3M. The gain is above 30%

Best regards,
Zoltan

> -Original Message-
> From: Joe Stringer [mailto:j...@ovn.org]
> Sent: Saturday, July 15, 2017 1:46 AM
> To: Sugesh Chandran <sugesh.chand...@intel.com>
> Cc: ovs dev <d...@openvswitch.org>; Andy Zhou <az...@ovn.org>; Zoltán Balogh 
> <zoltan.bal...@ericsson.com>
> Subject: Re: [PATCH v2 4/4] tunneling: Avoid datapath-recirc by combining 
> recirc actions at xlate.
> 
> On 4 July 2017 at 02:46, Sugesh Chandran <sugesh.chand...@intel.com> wrote:
> > This patch set removes the recirculation of encapsulated tunnel packets
> > if possible. It is done by computing the post tunnel actions at the time of
> > translation. The combined nested action set are programmed in the datapath
> > using CLONE action.
> >
> > Signed-off-by: Sugesh Chandran <sugesh.chand...@intel.com>
> > Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
> > Co-authored-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
> > ---
> 
> Hi Sugesh, Zoltán,
> 
> Thanks for working on this, it's subtle code but it seems like you've
> found a useful optimization here. Hopefully we can move this forward
> soon.
> 
> Would you be able to put your performance numbers into the commit
> message here? They could be useful to refer back to in the future.
> 
> This patch needs rebasing.
> 
> More feedback below.
> 
> >  lib/dpif-netdev.c  |  18 +--
> >  ofproto/ofproto-dpif-xlate-cache.c |  14 +-
> >  ofproto/ofproto-dpif-xlate-cache.h |  12 +-
> >  ofproto/ofproto-dpif-xlate.c   | 295 
> > -
> >  ofproto/ofproto-dpif-xlate.h   |   1 +
> >  ofproto/ofproto-dpif.c |   3 +-
> >  tests/packet-type-aware.at |  24 +--
> >  7 files changed, 324 insertions(+), 43 deletions(-)
> >
> > diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> > index 4e29085..4d996c1 100644
> > --- a/lib/dpif-netdev.c
> > +++ b/lib/dpif-netdev.c
> > @@ -5028,24 +5028,8 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
> > *packets_,
> >
> >  case OVS_ACTION_ATTR_TUNNEL_PUSH:
> >  if (*depth < MAX_RECIRC_DEPTH) {
> > -struct dp_packet_batch tnl_pkt;
> > -struct dp_packet_batch *orig_packets_ = packets_;
> > -int err;
> > -
> > -if (!may_steal) {
> > -dp_packet_batch_clone(_pkt, packets_);
> > -packets_ = _pkt;
> > -dp_packet_batch_reset_cutlen(orig_packets_);
> > -}
> > -
> >  dp_packet_batch_apply_cutlen(packets_);
> > -
> > -err = push_tnl_action(pmd, a, packets_);
> > -if (!err) {
> > -(*depth)++;
> > -dp_netdev_recirculate(pmd, packets_);
> > -(*depth)--;
> > -}
> > +push_tnl_action(pmd, a, packets_);
> 
> If I follow, this was the previo

[ovs-dev] [PATCH v2 3/3] tests: Extend PTAP unit tests with decap action

2017-07-14 Thread Zoltán Balogh
From: Zoltán Balogh <zoltan.bal...@ericsson.com>

  - Checking decap() prerequisits.
  - Send L3 packet over patch port.
  - Output L2/L3 packet to ports with different packet_type properties.

Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
Suggested-by: Jan Scheurich <jan.scheur...@ericsson.com>
---
 tests/packet-type-aware.at | 333 +
 1 file changed, 333 insertions(+)

diff --git a/tests/packet-type-aware.at b/tests/packet-type-aware.at
index c335b88ca..e90ba0d4a 100644
--- a/tests/packet-type-aware.at
+++ b/tests/packet-type-aware.at
@@ -519,3 +519,336 @@ 
tunnel(src=20.0.0.3,dst=20.0.0.2,flags(-df-csum)),recirc_id(0),in_port(gre_sys),
 
 OVS_VSWITCHD_STOP(["/The Open vSwitch kernel module is probably not loaded/d"])
 AT_CLEANUP
+
+
+AT_SETUP([ptap - check decap() prerequisits])
+OVS_VSWITCHD_START
+
+# Decap IP header, then set IP destination address. This should fail.
+AT_CHECK([
+ovs-ofctl add-flow br0 
"in_port=1,packet_type=(1,0x800),actions=decap(),set_field:1.1.1.1->nw_dst"
+], [1], [stdout], [stderr])
+
+AT_CHECK([
+cat stderr | cut -d '|' -f 3-
+], [0], [dnl
+ofp_actions|WARN|set_field ip_dst lacks correct prerequisites
+ovs-ofctl: actions are invalid with specified match (OFPBAC_MATCH_INCONSISTENT)
+])
+
+# Decap Ethernet header, then set IP destination address. This should work.
+AT_CHECK([
+ovs-ofctl add-flow br0 -OOpenFlow13 
"in_port=1,ip,actions=decap(),set_field:1.1.1.1->nw_dst"
+], [0])
+
+# Decap IP header, then set metadata. This should work.
+AT_CHECK([
+ovs-ofctl add-flow br0 -OOpenFlow13 
"in_port=1,packet_type=(1,0x800),actions=decap(),set_field:1234->metadata"
+], [0])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+
+AT_SETUP([ptap - L3 over patch port])
+
+
+# L3 over patch port
+#
+# (192.168.10.10) (192.168.10.30)
+#n0  n1
+# |   |
+#  +--o--+ +--o--+
+#  |   br0   | |   br1   |
+#  +--o--+ +--o---o--+
+#  p0 |p1 |   gre1 (ptap)
+# +---+   10.0.0.1
+#
+# LOCAL
+#  +--o--+
+#  |   br2   |
+#  +--o--+
+# |
+#n2
+# 10.0.0.2
+
+HWADDR_BRP2=aa:55:00:00:00:02
+
+OVS_VSWITCHD_START([dnl
+-- add-br br1 \
+-- set bridge br1 datapath_type=dummy fail-mode=secure \
+-- add-br br2 \
+-- set bridge br2 datapath_type=dummy fail-mode=secure \
+   other_config:hwaddr=\"$HWADDR_BRP2\" \
+-- add-port br0 p0 \
+-- set interface p0 type=patch options:peer=p1 ofport_request=10 \
+-- add-port br1 p1 \
+-- set interface p1 type=patch options:peer=p0 ofport_request=20 \
+-- add-port br0 n0 \
+-- set interface n0 type=dummy ofport_request=30 \
+-- add-port br1 n1 \
+-- set interface n1 type=dummy options:tx_pcap=n1.pcap ofport_request=40 \
+-- add-port br2 n2 \
+-- set interface n2 type=dummy options:tx_pcap=n2.pcap ofport_request=50 \
+-- add-port br1 gre1 \
+-- set interface gre1 type=gre options:remote_ip=10.0.0.2 \
+   options:packet_type=ptap ofport_request=100
+])
+
+### Verify datapath configuration
+AT_CHECK([
+ovs-appctl dpif/show | grep -v hit | sed 's/\t//g' | sed 
's./[[0-9]]\{1,\}..'
+], [0], [dnl
+br0:
+br0 65534: (dummy-internal)
+n0 30: (dummy)
+p0 10/none: (patch: peer=p1)
+br1:
+br1 65534: (dummy-internal)
+gre1 100: (gre: packet_type=ptap, remote_ip=10.0.0.2)
+n1 40: (dummy)
+p1 20/none: (patch: peer=p0)
+br2:
+br2 65534: (dummy-internal)
+n2 50: (dummy)
+])
+
+AT_CHECK([
+ovs-appctl netdev-dummy/ip4addr br2 10.0.0.1/24 &&
+ovs-appctl ovs/route/add 10.0.0.0/24 br2 &&
+ovs-appctl tnl/arp/set br2 10.0.0.2 de:af:be:ef:ba:be
+], [0], [ignore])
+
+AT_CHECK([
+ovs-appctl ovs/route/show | grep User:
+], [0], [dnl
+User: 10.0.0.0/24 dev br2 SRC 10.0.0.1
+])
+
+
+AT_CHECK([
+ovs-ofctl del-flows br0 &&
+ovs-ofctl del-flows br1 &&
+ovs-ofctl del-flows br2 &&
+ovs-ofctl add-flow br0 in_port=n0,actions=decap,output=p0 -OOpenFlow13 &&
+ovs-ofctl add-flow br1 in_port=p1,actions=output=gre1 &&
+ovs-ofctl add-flow br2 in_port=LOCAL,actions=output=n2
+], [0])
+
+AT_CHECK([ovs-ofctl -OOpenFlow13 dump-flows br0 | ofctl_strip | grep actions],
+[0], [dnl
+ in_port=30 actions=decap(),output:10
+])
+
+AT_CHECK([ovs-ofctl -OOpenFlow13 dump-flows br1 | ofctl_strip | grep actions],
+[0], [dnl
+ reset_counts in_port=20 actions=output:100
+])
+
+AT_CHECK([ovs-ofctl -OOpenFlow13 dump-flows br2 | ofctl_strip

[ovs-dev] [PATCH v2 2/3] OF support and translation of generic encap and decap

2017-07-14 Thread Zoltán Balogh
From: Jan Scheurich <jan.scheur...@ericsson.com>

This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.

CLI syntax for encap action with properties:
  encap(hdr=)
  encap(hdr=,
prop(class=,type=,val=),
prop(class=,type=,val()))

CLI syntax for decap action:
  decap()
  decap(packet_type(ns=,type=))

The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).

This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.

In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.

The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.

Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.

Signed-off-by: Jan Scheurich <jan.scheur...@ericsson.com>
Signed-off-by: Yi Yang <yi.y.y...@intel.com>
Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
Co-authored-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
---
 include/openflow/openflow-common.h |   1 +
 include/openvswitch/automake.mk|   1 +
 include/openvswitch/ofp-actions.h  |  31 +++
 include/openvswitch/ofp-ed-props.h |  69 +++
 include/openvswitch/ofp-errors.h   |   9 +
 lib/automake.mk|   1 +
 lib/odp-util.c |  84 ++---
 lib/odp-util.h |   3 +-
 lib/ofp-actions.c  | 378 -
 lib/ofp-ed-props.c | 150 +++
 lib/packets.h  |   3 +-
 ofproto/ofproto-dpif-xlate.c   | 108 ++-
 12 files changed, 796 insertions(+), 42 deletions(-)
 create mode 100644 include/openvswitch/ofp-ed-props.h
 create mode 100644 lib/ofp-ed-props.c

diff --git a/include/openflow/openflow-common.h 
b/include/openflow/openflow-common.h
index 3a0a57550..ff19cf5ca 100644
--- a/include/openflow/openflow-common.h
+++ b/include/openflow/openflow-common.h
@@ -465,6 +465,7 @@ enum ofp_header_type_namespaces {
 OFPHTN_IP_PROTO = 2,/* ns_type is a IP protocol number. */
 OFPHTN_UDP_TCP_PORT = 3,/* ns_type is a TCP or UDP port. */
 OFPHTN_IPV4_OPTION = 4, /* ns_type is an IPv4 option number. */
+OFPHTN_N_TYPES
 };
 
 #endif /* openflow/openflow-common.h */
diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk
index 699d9d74e..c8e67a236 100644
--- a/include/openvswitch/automake.mk
+++ b/include/openvswitch/automake.mk
@@ -12,6 +12,7 @@ openvswitchinclude_HEADERS = \
include/openvswitch/meta-flow.h \
include/openvswitch/ofpbuf.h \
include/openvswitch/ofp-actions.h \
+   include/openvswitch/ofp-ed-props.h \
include/openvswitch/ofp-errors.h \
include/openvswitch/ofp-msgs.h \
include/openvswitch/ofp-parse.h \
diff --git a/include/openvswitch/ofp-actions.h 
b/include/openvswitch/ofp-actions.h
index 7b4aa9201..7b9f6c199 100644
--- a/include/openvswitch/ofp-actions.h
+++ b/include/openvswitch/ofp-actions.h
@@ -25,6 +25,7 @@
 #include "openvswitch/ofp-util.h"
 #include "openvswitch/ofp-errors.h"
 #include "openvswitch/types.h"
+#include "openvswitch/ofp-ed-props.h"
 
 struct vl_mff_map;
 
@@ -89,6 +90,10 @@ struct vl_mff_map;
 OFPACT(PUSH_MPLS,   ofpact_push_mpls,   ofpact, "push_mpls")\
 OFPACT(POP_MPLS,ofpact_pop_mpls,ofpact, "pop_mpls") \
 \
+/* Generic encap & decap */ \
+OFPACT(ENCAP,   ofpact_encap,   props, "encap") \
+OFPACT(DECAP,   ofpact_decap,   ofpact, "decap")\
+\
 /* Metadata. *

[ovs-dev] [PATCH v2 1/3] ofproto-dpif-xlate: drop L3 packets on L2 legacy port

2017-07-14 Thread Zoltán Balogh
From: Zoltán Balogh <zoltan.bal...@ericsson.com>

This commit drops packet during xlate if it is a L3 packet and output
port packet_type is legacy_l2. New PTAP unit test is added.

Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
---
 ofproto/ofproto-dpif-xlate.c | 23 +++-
 tests/packet-type-aware.at   | 64 +---
 2 files changed, 77 insertions(+), 10 deletions(-)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 089c7f170..08dd9fe6d 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -3312,6 +3312,14 @@ check_output_prerequisites(struct xlate_ctx *ctx,
 return false;
 }
 }
+
+if (xport->pt_mode == NETDEV_PT_LEGACY_L2 &&
+flow->packet_type != htonl(PT_ETH)) {
+xlate_report(ctx, OFT_WARN, "Trying to send non-Ethernet packet "
+ "through legacy L2 port. Dropping packet.");
+return false;
+}
+
 return true;
 }
 
@@ -3345,6 +3353,10 @@ compose_output_action__(struct xlate_ctx *ctx, 
ofp_port_t ofp_port,
 odp_port_t out_port, odp_port, odp_tnl_port;
 bool is_native_tunnel = false;
 uint8_t dscp;
+struct eth_addr flow_dl_dst = flow->dl_dst;
+struct eth_addr flow_dl_src = flow->dl_src;
+ovs_be32 flow_packet_type = flow->packet_type;
+ovs_be16 flow_dl_type = flow->dl_type;
 
 /* If 'struct flow' gets additional metadata, we'll need to zero it out
  * before traversing a patch port. */
@@ -3361,13 +3373,6 @@ compose_output_action__(struct xlate_ctx *ctx, 
ofp_port_t ofp_port,
 flow->packet_type = PACKET_TYPE_BE(OFPHTN_ETHERTYPE,
ntohs(flow->dl_type));
 }
-} else {
-/* Add dummy Ethernet header for legacy L2 port. */
-if (xport->pt_mode == NETDEV_PT_LEGACY_L2) {
-flow->packet_type = htonl(PT_ETH);
-flow->dl_dst = eth_addr_zero;
-flow->dl_src = eth_addr_zero;
-}
 }
 
 if (xport->peer) {
@@ -3627,6 +3632,10 @@ compose_output_action__(struct xlate_ctx *ctx, 
ofp_port_t ofp_port,
 /* Restore flow */
 memcpy(flow->vlans, flow_vlans, sizeof flow->vlans);
 flow->nw_tos = flow_nw_tos;
+flow->dl_dst = flow_dl_dst;
+flow->dl_src = flow_dl_src;
+flow->packet_type = flow_packet_type;
+flow->dl_type = flow_dl_type;
 }
 
 static void
diff --git a/tests/packet-type-aware.at b/tests/packet-type-aware.at
index 110407857..c335b88ca 100644
--- a/tests/packet-type-aware.at
+++ b/tests/packet-type-aware.at
@@ -64,9 +64,9 @@ AT_SETUP([ptap - triangle bridge setup with L2 and L3 GRE 
tunnels])
 #  1030   br-in1  gre-13  legacy-l2   br-in3 3010 (l2)
 #  2010   br-in2  gre-21  ptapbr-in1 1020 (l2), 1021 (l3)
 #  2030   br-in2  gre-23  ptapbr-in3 3020 (l2), 3021 (l3)
-#  3010   br-in1  gre-31  legacy-l2   br-in1 1030 (l2)
-#  3020   br-in1  gre-32  legacy-l2   br-in2 2010 (ptap)
-#  3021   br-in1  gre-32_l3   legacy-l3 same
+#  3010   br-in3  gre-31  legacy-l2   br-in1 1030 (l2)
+#  3020   br-in3  gre-32  legacy-l2   br-in2 2010 (ptap)
+#  3021   br-in3  gre-32_l3   legacy-l3 same
 
 HWADDR_BRP1=aa:55:00:00:00:01
 HWADDR_BRP2=aa:55:00:00:00:02
@@ -459,5 +459,63 @@ 
aa55aa550003461e7d1a95a108004554f7d440004001ad51c0a80a14c0a80a1e08000e760c1e
 
aa55aa550003461e7d1a95a108004554f89540004001ac90c0a80a14c0a80a1e0800736f0c1e000232519a58e1f30b00101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637
 ])
 
+
+# N3 to N2, from L3 GRE to PTAP port between br-in3 and br-in2. Dropping L3 
packet on L2 dummy port in br-in2.
+
+# Strips 'n_packets=...' from ovs-ofctl output.
+strip_n_packets () {
+sed 's/n_packets=[[0-9]]*, //'
+}
+
+# Strips 'n_bytes=...' from ovs-ofctl output.
+strip_n_bytes () {
+sed 's/n_bytes=[[0-9]]*, //'
+}
+
+# Modify flow rules to receive L3 packet in br-in2.
+AT_CHECK([
+ovs-ofctl add-flow br-in2 
packet_type=\(1,0x800\),nw_dst=$N2_IP,actions=$N2_OFPORT # Route L3 packet to 
N2 in br-in2
+ovs-ofctl add-flow br-in3 ip,nw_dst=$N2_IP,actions=3021 # Route to N2 via 
the L3 tunnel
+], [0])
+
+AT_CHECK([
+ovs-ofctl dump-flows br-in2 | ofctl_strip | strip_n_bytes | 
strip_n_packets | sort | grep actions
+], [0], [dnl
+ ip,nw_dst=192.168.10.10 actions=output:2010
+ ip,nw_dst=192.168.10.20 actions=mod_dl_dst:aa:55:aa:55:00:02,output:20
+ ip,nw_dst=192.168.10.30 actions=output:2010
+ packet_type=(1,0x800),nw_dst=192.168.10.10 actions=output:2010
+ packet_type=(1,0x800),nw_dst=192.168.10.20 actions=output:20
+ packet_type=(1,0x800),nw_dst=192.168.10.30 actions=output:2030
+])
+
+AT_CHECK([
+ovs-ofctl dump-flows br-in3 | ofctl_strip | strip_n_b

[ovs-dev] [PATCH v2 0/3] basic encap/decap

2017-07-14 Thread Zoltán Balogh
From: Zoltán Balogh <zoltan.bal...@ericsson.com>


This series is a continuation of other patch series initiated by Jan Scheurich 
before. These were already applied to the master branch:
 - userspace: Support for L3 tunneling
   https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/87.html
 - Packet type aware pipeline
   https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/334512.html

The main purpose of this series is to add support for the OpenFlow actions 
generic encap and decap (ONF EXT-382) to the OVS control plane. It implements
a skeleton for translation of generic encap and decap actions in ofproto-dpif
and provides support to encap and decap an Ethernet header. 

v1->v2
 - Squash 1/4 and 2/4 commits of v1.
 - Put unit tests in a separate commit.
 - Use aligned cast.
 - Nicira extension numbers for encap/decap action numbers and error codes.
 - Small fixes according to comments.

Jan Scheurich (1):
  OF support and translation of generic encap and decap

Zoltán Balogh  (2):
  ofproto-dpif-xlate: drop L3 packets on L2 legacy port
  tests: Extend PTAP unit tests with decap action

 include/openflow/openflow-common.h |   1 +
 include/openvswitch/automake.mk|   1 +
 include/openvswitch/ofp-actions.h  |  31 +++
 include/openvswitch/ofp-ed-props.h |  69 +++
 include/openvswitch/ofp-errors.h   |   9 +
 lib/automake.mk|   1 +
 lib/odp-util.c |  84 +---
 lib/odp-util.h |   3 +-
 lib/ofp-actions.c  | 378 ++-
 lib/ofp-ed-props.c | 150 ++
 lib/packets.h  |   3 +-
 ofproto/ofproto-dpif-xlate.c   | 131 +++-
 tests/packet-type-aware.at | 397 -
 13 files changed, 1206 insertions(+), 52 deletions(-)
 create mode 100644 include/openvswitch/ofp-ed-props.h
 create mode 100644 lib/ofp-ed-props.c

-- 
2.11.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 1/4] Add OF actions for generic encap and decap

2017-07-13 Thread Zoltán Balogh
Hello Ben,


> GCC says:
> 
> ../lib/ofp-actions.c:4189:13: error: cast from 'char *' to 'struct 
> ofpact_encap *' increases required alignment
> from 1 to 4 [-Werror,-Wcast-align]
> ../lib/ofp-actions.c:4222:16: error: cast from 'const uint8_t *' (aka 
> 'const unsigned char *') to 'const struct
> ofpact_ed_prop *' increases required alignment from 1 to 2 
> [-Werror,-Wcast-align]

I cannot see these errors. I've tested with GCC 4.8.4 on Ubuntu 14.04.5 LTS and 
with GCC 6.3.0 on Ubuntu 17.04. 
Which version of GCC and Linux distro did you use? Did you pass any special 
args to make or to the configure script?

Best regards,
Zoltan

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 3/4] ofproto-dpif-xlate: drop L3 packets on L2 legacy port

2017-07-12 Thread Zoltán Balogh
Hello Jan,

I'll create the stand-alone commit. However, sending L3 packet from ptap tunnel 
to veth port won't work. The veth port would handle received packets as L2. I 
can use patch ports instead.

Best regards,
Zoltan


> -Original Message-
> From: Jan Scheurich
> Sent: Wednesday, July 12, 2017 8:55 AM
> To: Ben Pfaff <b...@ovn.org>; Zoltán Balogh <zoltan.bal...@ericsson.com>
> Cc: 'd...@openvswitch.org' <d...@openvswitch.org>; Georg Schmuecking 
> <georg.schmueck...@ericsson.com>; Jiri Benc
> (jb...@redhat.com) <jb...@redhat.com>; Yang, Yi Y <yi.y.y...@intel.com>
> Subject: RE: [PATCH 3/4] ofproto-dpif-xlate: drop L3 packets on L2 legacy port
> 
> Yes, this is a bug fix for the merged PTAP series. It could be merged 
> independently from patches 1 and 2.
> I'm sure it is possible to strip down the PTAP unit tests additions in this 
> patch to cover the fixed issue without
> using decap action (e.g. by sending a L3 packet from a ptap tunnel to the 
> veth port)?
> @Zoltan: could you perhaps create a stand-alone commit for this and keep the 
> remainder of the encap/decap unit tests
> for v2 of this series?
> Thanks, Jan
> 
> > -Original Message-----
> > From: Ben Pfaff [mailto:b...@ovn.org]
> > Sent: Wednesday, 12 July, 2017 02:31
> > To: Zoltán Balogh <zoltan.bal...@ericsson.com>
> > Cc: 'd...@openvswitch.org' <d...@openvswitch.org>; Jan Scheurich 
> > <jan.scheur...@ericsson.com>; Georg Schmuecking
> > <georg.schmueck...@ericsson.com>; Jiri Benc (jb...@redhat.com) 
> > <jb...@redhat.com>; Yang, Yi Y
> <yi.y.y...@intel.com>
> > Subject: Re: [PATCH 3/4] ofproto-dpif-xlate: drop L3 packets on L2 legacy 
> > port
> >
> > On Fri, Jun 30, 2017 at 03:29:35PM +, Zoltán Balogh wrote:
> > > This commit drops packet during xlate if it is a L3 packet and output port
> > > packet_type is legacy_l2. It completes PTAP unit tests with:
> > >
> > >   - Send L3 packet over patch port.
> > >   - Output L2/L3 packet to ports with different packet_type properties.
> > >
> > > Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
> >
> > This looks to me like a bug fix that should be applied even without
> > patches 1 and 2.  Is that right?  I guess that the test does use the
> > "decap" action--can the bug be triggered without "decap"?
> >
> > Thanks,
> >
> > Ben.

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] tests: fix PTAP system test to check only OF stats

2017-07-12 Thread Zoltán Balogh
Thank you for pointing this out! I've sent v2 to the list.
https://patchwork.ozlabs.org/patch/787037/

/Zoltan

> -Original Message-
> From: Darrell Ball [mailto:db...@vmware.com]
> Sent: Tuesday, July 11, 2017 6:11 PM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>; 'd...@openvswitch.org' 
> <d...@openvswitch.org>
> Subject: Re: [ovs-dev] [PATCH] tests: fix PTAP system test to check only OF 
> stats
> 
> signoff is missing
> maybe suggested by Jan ?
> 
> On 7/11/17, 9:07 AM, "ovs-dev-boun...@openvswitch.org on behalf of Zoltán 
> Balogh" <ovs-dev-boun...@openvswitch.org
> on behalf of zoltan.bal...@ericsson.com> wrote:
> 
> 
> It turned out, checking datapath flow statistics during system-userspace
> test is not reliable. Unwanted packets can be injected depending on
> system configuration. As a workaround, this commit removes checking
> statistics of datapath flows and does check OpenFlow statistics of the
> integrator bridges. Datapath flows can be checked in normal PTAP unit
> tests by running 'make check'.
> 
> Reported-by: Darrell Ball <db...@vmware.com>
> ---
>  tests/system-userspace-packet-type-aware.at | 127 
> +++-
>  1 file changed, 67 insertions(+), 60 deletions(-)
> 
> diff --git a/tests/system-userspace-packet-type-aware.at 
> b/tests/system-userspace-packet-type-aware.at
> index 65d81ce8e..24a7698ab 100644
> --- a/tests/system-userspace-packet-type-aware.at
> +++ b/tests/system-userspace-packet-type-aware.at
> @@ -33,9 +33,9 @@ AT_SETUP([ptap - triangle bridge setup with L2 and L3 
> GRE tunnels])
>  #  1030   br-in1  gre-13  l2  br-in3 3010 (l2)
>  #  2010   br-in2  gre-21  ptapbr-in1 1020 (l2), 1021 
> (l3)
>  #  2030   br-in2  gre-23  ptapbr-in3 3020 (l2), 3021 
> (l3)
> -#  3010   br-in1  gre-31  l2  br-in1 1030 (l2)
> -#  3020   br-in1  gre-32  l2  br-in2 2010 (ptap)
> -#  3021   br-in1  gre-32_l3   l3same
> +#  3010   br-in3  gre-31  l2  br-in1 1030 (l2)
> +#  3020   br-in3  gre-32  l2  br-in2 2010 (ptap)
> +#  3021   br-in3  gre-32_l3   l3same
> 
> 
>  AT_SKIP_IF([test $HAVE_NC = no])
> @@ -176,15 +176,15 @@ AT_CHECK([
> 
>  ### Flows in br-pto twist TEP IP addresses in tunnel IP headers
>  AT_CHECK([
> -ovs-ofctl add-flow br-p1 in_port:LOCAL,actions=2
> +ovs-ofctl add-flow br-p1 in_port:LOCAL,ip,actions=2
>  ovs-ofctl add-flow br-p1 
> in_port:2,ip,nw_dst:20.0.0.1,actions=mod_nw_dst:10.0.0.1,mod_nw_src:10.0.0.2,LOCAL
>  ovs-ofctl add-flow br-p1 
> in_port:2,ip,nw_dst:30.0.0.1,actions=mod_nw_dst:10.0.0.1,mod_nw_src:10.0.0.3,LOCAL
> 
> -ovs-ofctl add-flow br-p2 in_port:LOCAL,actions=2
> +ovs-ofctl add-flow br-p2 in_port:LOCAL,ip,actions=2
>  ovs-ofctl add-flow br-p2 
> in_port:2,ip,nw_dst:10.0.0.2,actions=mod_nw_dst:20.0.0.2,mod_nw_src:20.0.0.1,LOCAL
>  ovs-ofctl add-flow br-p2 
> in_port:2,ip,nw_dst:30.0.0.2,actions=mod_nw_dst:20.0.0.2,mod_nw_src:20.0.0.3,LOCAL
> 
> -ovs-ofctl add-flow br-p3 in_port:LOCAL,actions=2
> +ovs-ofctl add-flow br-p3 in_port:LOCAL,ip,actions=2
>  ovs-ofctl add-flow br-p3 
> in_port:2,ip,nw_dst:10.0.0.3,actions=mod_nw_dst:30.0.0.3,mod_nw_src:30.0.0.1,LOCAL
>  ovs-ofctl add-flow br-p3 
> in_port:2,ip,nw_dst:20.0.0.3,actions=mod_nw_dst:30.0.0.3,mod_nw_src:30.0.0.2,LOCAL
>  ], [0])
> @@ -204,15 +204,15 @@ AT_CHECK([
>  ovs-ofctl dump-flows br-p2 | ofctl_strip | strip_n_packets | 
> strip_n_bytes | sort | grep actions
>  ovs-ofctl dump-flows br-p3 | ofctl_strip | strip_n_packets | 
> strip_n_bytes | sort | grep actions
>  ], [0], [dnl
> - in_port=LOCAL actions=output:2
>   ip,in_port=2,nw_dst=20.0.0.1 
> actions=mod_nw_dst:10.0.0.1,mod_nw_src:10.0.0.2,LOCAL
>   ip,in_port=2,nw_dst=30.0.0.1 
> actions=mod_nw_dst:10.0.0.1,mod_nw_src:10.0.0.3,LOCAL
> - in_port=LOCAL actions=output:2
> + ip,in_port=LOCAL actions=output:2
>   ip,in_port=2,nw_dst=10.0.0.2 
> actions=mod_nw_dst:20.0.0.2,mod_nw_src:20.0.0.1,LOCAL
>   ip,in_port=2,nw_dst=30.0.0.2 
> actions=mod_nw_dst:20.0.0.2,mod_nw_src:20.0.0.3,LOCAL
> - in_port=LOCAL actions=output:2
> + ip,in_port=LOCAL actions=output:2
>   ip,in_port=2,nw_dst=10.0.0.3 
> actions=mod_nw_dst:30.0.0.3,mod_nw_src:30.0.0.1,LOCAL
>   ip,in_port=2,nw_dst=20.0.0.3 
> actions=mod_nw_dst:30.0.0.3,mod_nw_src:30.0.0.2,LOCAL
>   

[ovs-dev] [PATCH v2] tests: fix PTAP system test to check only OF stats

2017-07-12 Thread Zoltán Balogh

It turned out, checking datapath flow statistics during system-userspace
test is not reliable. Unwanted packets can be injected depending on
system configuration. As a workaround, this commit removes checking
statistics of datapath flows and does check OpenFlow statistics of the
integrator bridges. Datapath flows can be checked in normal PTAP unit 
tests by running 'make check'.

Reported-by: Darrell Ball <db...@vmware.com>
Suggested-by: Jan Scheurich <jan.scheur...@ericsson.com>
Tested-by: Darrell Ball <db...@vmware.com>
Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
---
 tests/system-userspace-packet-type-aware.at | 127 +++-
 1 file changed, 67 insertions(+), 60 deletions(-)

diff --git a/tests/system-userspace-packet-type-aware.at 
b/tests/system-userspace-packet-type-aware.at
index 65d81ce8e..24a7698ab 100644
--- a/tests/system-userspace-packet-type-aware.at
+++ b/tests/system-userspace-packet-type-aware.at
@@ -33,9 +33,9 @@ AT_SETUP([ptap - triangle bridge setup with L2 and L3 GRE 
tunnels])
 #  1030   br-in1  gre-13  l2  br-in3 3010 (l2)
 #  2010   br-in2  gre-21  ptapbr-in1 1020 (l2), 1021 (l3)
 #  2030   br-in2  gre-23  ptapbr-in3 3020 (l2), 3021 (l3)
-#  3010   br-in1  gre-31  l2  br-in1 1030 (l2)
-#  3020   br-in1  gre-32  l2  br-in2 2010 (ptap)
-#  3021   br-in1  gre-32_l3   l3same
+#  3010   br-in3  gre-31  l2  br-in1 1030 (l2)
+#  3020   br-in3  gre-32  l2  br-in2 2010 (ptap)
+#  3021   br-in3  gre-32_l3   l3same
 
 
 AT_SKIP_IF([test $HAVE_NC = no])
@@ -176,15 +176,15 @@ AT_CHECK([
 
 ### Flows in br-pto twist TEP IP addresses in tunnel IP headers
 AT_CHECK([
-ovs-ofctl add-flow br-p1 in_port:LOCAL,actions=2
+ovs-ofctl add-flow br-p1 in_port:LOCAL,ip,actions=2
 ovs-ofctl add-flow br-p1 
in_port:2,ip,nw_dst:20.0.0.1,actions=mod_nw_dst:10.0.0.1,mod_nw_src:10.0.0.2,LOCAL
 ovs-ofctl add-flow br-p1 
in_port:2,ip,nw_dst:30.0.0.1,actions=mod_nw_dst:10.0.0.1,mod_nw_src:10.0.0.3,LOCAL
 
-ovs-ofctl add-flow br-p2 in_port:LOCAL,actions=2
+ovs-ofctl add-flow br-p2 in_port:LOCAL,ip,actions=2
 ovs-ofctl add-flow br-p2 
in_port:2,ip,nw_dst:10.0.0.2,actions=mod_nw_dst:20.0.0.2,mod_nw_src:20.0.0.1,LOCAL
 ovs-ofctl add-flow br-p2 
in_port:2,ip,nw_dst:30.0.0.2,actions=mod_nw_dst:20.0.0.2,mod_nw_src:20.0.0.3,LOCAL
 
-ovs-ofctl add-flow br-p3 in_port:LOCAL,actions=2
+ovs-ofctl add-flow br-p3 in_port:LOCAL,ip,actions=2
 ovs-ofctl add-flow br-p3 
in_port:2,ip,nw_dst:10.0.0.3,actions=mod_nw_dst:30.0.0.3,mod_nw_src:30.0.0.1,LOCAL
 ovs-ofctl add-flow br-p3 
in_port:2,ip,nw_dst:20.0.0.3,actions=mod_nw_dst:30.0.0.3,mod_nw_src:30.0.0.2,LOCAL
 ], [0])
@@ -204,15 +204,15 @@ AT_CHECK([
 ovs-ofctl dump-flows br-p2 | ofctl_strip | strip_n_packets | strip_n_bytes 
| sort | grep actions
 ovs-ofctl dump-flows br-p3 | ofctl_strip | strip_n_packets | strip_n_bytes 
| sort | grep actions
 ], [0], [dnl
- in_port=LOCAL actions=output:2
  ip,in_port=2,nw_dst=20.0.0.1 
actions=mod_nw_dst:10.0.0.1,mod_nw_src:10.0.0.2,LOCAL
  ip,in_port=2,nw_dst=30.0.0.1 
actions=mod_nw_dst:10.0.0.1,mod_nw_src:10.0.0.3,LOCAL
- in_port=LOCAL actions=output:2
+ ip,in_port=LOCAL actions=output:2
  ip,in_port=2,nw_dst=10.0.0.2 
actions=mod_nw_dst:20.0.0.2,mod_nw_src:20.0.0.1,LOCAL
  ip,in_port=2,nw_dst=30.0.0.2 
actions=mod_nw_dst:20.0.0.2,mod_nw_src:20.0.0.3,LOCAL
- in_port=LOCAL actions=output:2
+ ip,in_port=LOCAL actions=output:2
  ip,in_port=2,nw_dst=10.0.0.3 
actions=mod_nw_dst:30.0.0.3,mod_nw_src:30.0.0.1,LOCAL
  ip,in_port=2,nw_dst=20.0.0.3 
actions=mod_nw_dst:30.0.0.3,mod_nw_src:30.0.0.2,LOCAL
+ ip,in_port=LOCAL actions=output:2
 ])
 
 ### Setup test ports for traffic injection
@@ -331,9 +331,6 @@ AT_CHECK([
 ])
 
 
-# Clear up megaflow cache
-sleep 10
-
 # Ping between N1 and N3, via the L2 GRE tunnel between br-in1 and br-in3
 NS_CHECK_EXEC([ns1], [ping -q -c 3 -i 0.3 -w 2 $N3_IP | FORMAT_PING], [0], [dnl
 3 packets transmitted, 3 received, 0% packet loss, time 0ms
@@ -342,26 +339,25 @@ NS_CHECK_EXEC([ns1], [ping -q -c 3 -i 0.3 -w 2 $N3_IP | 
FORMAT_PING], [0], [dnl
 sleep 1
 
 AT_CHECK([
-ovs-appctl dpctl/dump-flows | strip_used | grep -v ipv6 | grep -v arp |sort
-], [0], [flow-dump from non-dpdk interfaces:
-recirc_id(0),in_port(10),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:03),eth_type(0x0800),ipv4(src=10.0.0.1,dst=10.0.0.3,proto=47,frag=no),
 packets:2, bytes:272, used:0.0s, 
actions:set(ipv4(src=30.0.0.1,dst=30.0.0.3)),tnl_pop(14)
-recirc_id(0),in_port(11),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:03),eth_type(0x0800),ipv4(frag=no),
 packets:2, bytes:272, used:0.0s, actions:13
-recirc_id(0),in_port(12),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:01),eth_type(0x0800),ipv4(frag=no),
 packets:2, bytes:244, used:0.0s, actions:11

Re: [ovs-dev] [PATCH v4 0/7] Packet type aware pipeline

2017-07-11 Thread Zoltán Balogh
Hi, 

I've created a new patch, that does check the OpenFlow statistics of 
integration bridges instead of the statistics of datapath flows. 
I sent the patch to the dev list:
https://patchwork.ozlabs.org/patch/786669/

Best regards,
Zoltan


> -Original Message-
> From: Jan Scheurich
> Sent: Tuesday, July 11, 2017 10:26 AM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>; Darrell Ball 
> <db...@vmware.com>; Yang, Yi Y <yi.y.y...@intel.com>;
> Eric Garver <e...@erig.me>
> Cc: 'd...@openvswitch.org' <d...@openvswitch.org>; 
> simon.hor...@netronome.com; Jiri Benc <jb...@redhat.com>
> Subject: RE: [ovs-dev] [PATCH v4 0/7] Packet type aware pipeline
> 
> I think the dropped packets are indeed noise generated by the host kernel 
> when bringing up interfaces and are
> dependent on system configuration and timing. Dumping datapath flows seems 
> pretty vulnerable to such noise in system
> tests and it may be hard to create filters that work reliably on all systems.
> 
> Since we are checking DP flows in the normal PTAP unit tests already, perhaps 
> we can remove the check here and
> instead check on something more predictable, e.g. tunnel port or stats or 
> OpenFlow stats.
> 
> BR, Jan
> 
> > -Original Message-----
> > From: ovs-dev-boun...@openvswitch.org 
> > [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> > Sent: Monday, 10 July, 2017 16:37
> > To: Darrell Ball <db...@vmware.com>; Yang, Yi Y <yi.y.y...@intel.com>; Eric 
> > Garver <e...@erig.me>
> > Cc: 'd...@openvswitch.org' <d...@openvswitch.org>; 
> > simon.hor...@netronome.com; Jiri Benc <jb...@redhat.com>
> > Subject: Re: [ovs-dev] [PATCH v4 0/7] Packet type aware pipeline
> >
> > Hi Darrell,
> >
> > Thank you for the log and the investigation. Unfortunately, I wasn't able 
> > to reproduce the fault.
> > I used two systems:
> >  - Ubuntu 17.04
> >Linux host1 4.10.0-26-generic #30-Ubuntu SMP Tue Jun 27 09:30:12 UTC 
> > 2017 x86_64 x86_64 x86_64 GNU/Linux
> >
> >  - Ubuntu 14.04.5 LTS
> >Linux host2 3.16.0-70-generic #90~14.04.1-Ubuntu SMP Wed Apr 6 22:56:34 
> > UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
> >
> > The dp ports 8-13 below are veth ports. Maybe, there is a system 
> > configuration, that affects behavior of the veth
> ports.
> >
> > +recirc_id(0),in_port(10),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(dst=255.255.255.255/128.0.0.0,frag=no),
> packets:2, bytes:684,
> > used:0.0s, actions:drop
> > +recirc_id(0),in_port(11),packet_type(ns=0,id=0),eth(dst=ff:ff:ff:ff:ff:ff),eth_type(0x0800),ipv4(frag=no),
> packets:2, bytes:684, used:0.0s,
> > actions:drop
> > +recirc_id(0),in_port(12),packet_type(ns=0,id=0),eth(dst=ff:ff:ff:ff:ff:ff),eth_type(0x0800),ipv4(frag=no),
> packets:2, bytes:684, used:0.0s,
> > actions:drop
> > +recirc_id(0),in_port(13),packet_type(ns=0,id=0),eth(dst=ff:ff:ff:ff:ff:ff),eth_type(0x0800),ipv4(frag=no),
> packets:2, bytes:684, used:0.0s,
> > actions:drop
> > +recirc_id(0),in_port(8),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(dst=255.255.255.255/128.0.0.0,frag=no),
> packets:2, bytes:684,
> > used:0.0s, actions:drop
> > +recirc_id(0),in_port(9),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(dst=255.255.255.255/128.0.0.0,frag=no),
> packets:3, bytes:1026,
> > used:0.0s, actions:drop
> >
> >
> > However there are other veth ports (dp ports: 15-17) used in the unit test 
> > setup, they connect namespaces to
> bridges. If it's about a system
> > level configuration that causes veth ports 8-13 to behave differently, I 
> > guess we should see broadcast packets
> from the ports connecting
> > namespaces and bridges too. But we do not. Those ports connect a namespace 
> > to a bridge, and there is an m4 macro
> in the system-
> > common-macros.at file to do this:
> >
> > # ADD_VETH([port], [namespace], [ovs-br], [ip_addr] [mac_addr [gateway]])
> > #
> > # Add a pair of veth ports. 'port' will be added to name space 'namespace',
> > # and "ovs-'port'" will be added to ovs bridge 'ovs-br'.
> > #
> > # The 'port' in 'namespace' will be brought up with static IP address
> > # with 'ip_addr' in CIDR notation.
> > #
> > # Optionally, one can specify the 'mac_addr' for 'port' and the default
> > # 'gateway'.
> > #
> > # The existing 'port' or 'ovs-port' will be removed before new ones are 
> > added.
> > #
> > m4_define([ADD_VETH],
> > [ AT_CHECK([ip link add $1 type veth peer name ovs-$1 || return 77])
> >   CONFIGURE_

[ovs-dev] [PATCH] tests: fix PTAP system test to check only OF stats

2017-07-11 Thread Zoltán Balogh

It turned out, checking datapath flow statistics during system-userspace
test is not reliable. Unwanted packets can be injected depending on
system configuration. As a workaround, this commit removes checking
statistics of datapath flows and does check OpenFlow statistics of the
integrator bridges. Datapath flows can be checked in normal PTAP unit 
tests by running 'make check'.

Reported-by: Darrell Ball 
---
 tests/system-userspace-packet-type-aware.at | 127 +++-
 1 file changed, 67 insertions(+), 60 deletions(-)

diff --git a/tests/system-userspace-packet-type-aware.at 
b/tests/system-userspace-packet-type-aware.at
index 65d81ce8e..24a7698ab 100644
--- a/tests/system-userspace-packet-type-aware.at
+++ b/tests/system-userspace-packet-type-aware.at
@@ -33,9 +33,9 @@ AT_SETUP([ptap - triangle bridge setup with L2 and L3 GRE 
tunnels])
 #  1030   br-in1  gre-13  l2  br-in3 3010 (l2)
 #  2010   br-in2  gre-21  ptapbr-in1 1020 (l2), 1021 (l3)
 #  2030   br-in2  gre-23  ptapbr-in3 3020 (l2), 3021 (l3)
-#  3010   br-in1  gre-31  l2  br-in1 1030 (l2)
-#  3020   br-in1  gre-32  l2  br-in2 2010 (ptap)
-#  3021   br-in1  gre-32_l3   l3same
+#  3010   br-in3  gre-31  l2  br-in1 1030 (l2)
+#  3020   br-in3  gre-32  l2  br-in2 2010 (ptap)
+#  3021   br-in3  gre-32_l3   l3same
 
 
 AT_SKIP_IF([test $HAVE_NC = no])
@@ -176,15 +176,15 @@ AT_CHECK([
 
 ### Flows in br-pto twist TEP IP addresses in tunnel IP headers
 AT_CHECK([
-ovs-ofctl add-flow br-p1 in_port:LOCAL,actions=2
+ovs-ofctl add-flow br-p1 in_port:LOCAL,ip,actions=2
 ovs-ofctl add-flow br-p1 
in_port:2,ip,nw_dst:20.0.0.1,actions=mod_nw_dst:10.0.0.1,mod_nw_src:10.0.0.2,LOCAL
 ovs-ofctl add-flow br-p1 
in_port:2,ip,nw_dst:30.0.0.1,actions=mod_nw_dst:10.0.0.1,mod_nw_src:10.0.0.3,LOCAL
 
-ovs-ofctl add-flow br-p2 in_port:LOCAL,actions=2
+ovs-ofctl add-flow br-p2 in_port:LOCAL,ip,actions=2
 ovs-ofctl add-flow br-p2 
in_port:2,ip,nw_dst:10.0.0.2,actions=mod_nw_dst:20.0.0.2,mod_nw_src:20.0.0.1,LOCAL
 ovs-ofctl add-flow br-p2 
in_port:2,ip,nw_dst:30.0.0.2,actions=mod_nw_dst:20.0.0.2,mod_nw_src:20.0.0.3,LOCAL
 
-ovs-ofctl add-flow br-p3 in_port:LOCAL,actions=2
+ovs-ofctl add-flow br-p3 in_port:LOCAL,ip,actions=2
 ovs-ofctl add-flow br-p3 
in_port:2,ip,nw_dst:10.0.0.3,actions=mod_nw_dst:30.0.0.3,mod_nw_src:30.0.0.1,LOCAL
 ovs-ofctl add-flow br-p3 
in_port:2,ip,nw_dst:20.0.0.3,actions=mod_nw_dst:30.0.0.3,mod_nw_src:30.0.0.2,LOCAL
 ], [0])
@@ -204,15 +204,15 @@ AT_CHECK([
 ovs-ofctl dump-flows br-p2 | ofctl_strip | strip_n_packets | strip_n_bytes 
| sort | grep actions
 ovs-ofctl dump-flows br-p3 | ofctl_strip | strip_n_packets | strip_n_bytes 
| sort | grep actions
 ], [0], [dnl
- in_port=LOCAL actions=output:2
  ip,in_port=2,nw_dst=20.0.0.1 
actions=mod_nw_dst:10.0.0.1,mod_nw_src:10.0.0.2,LOCAL
  ip,in_port=2,nw_dst=30.0.0.1 
actions=mod_nw_dst:10.0.0.1,mod_nw_src:10.0.0.3,LOCAL
- in_port=LOCAL actions=output:2
+ ip,in_port=LOCAL actions=output:2
  ip,in_port=2,nw_dst=10.0.0.2 
actions=mod_nw_dst:20.0.0.2,mod_nw_src:20.0.0.1,LOCAL
  ip,in_port=2,nw_dst=30.0.0.2 
actions=mod_nw_dst:20.0.0.2,mod_nw_src:20.0.0.3,LOCAL
- in_port=LOCAL actions=output:2
+ ip,in_port=LOCAL actions=output:2
  ip,in_port=2,nw_dst=10.0.0.3 
actions=mod_nw_dst:30.0.0.3,mod_nw_src:30.0.0.1,LOCAL
  ip,in_port=2,nw_dst=20.0.0.3 
actions=mod_nw_dst:30.0.0.3,mod_nw_src:30.0.0.2,LOCAL
+ ip,in_port=LOCAL actions=output:2
 ])
 
 ### Setup test ports for traffic injection
@@ -331,9 +331,6 @@ AT_CHECK([
 ])
 
 
-# Clear up megaflow cache
-sleep 10
-
 # Ping between N1 and N3, via the L2 GRE tunnel between br-in1 and br-in3
 NS_CHECK_EXEC([ns1], [ping -q -c 3 -i 0.3 -w 2 $N3_IP | FORMAT_PING], [0], [dnl
 3 packets transmitted, 3 received, 0% packet loss, time 0ms
@@ -342,26 +339,25 @@ NS_CHECK_EXEC([ns1], [ping -q -c 3 -i 0.3 -w 2 $N3_IP | 
FORMAT_PING], [0], [dnl
 sleep 1
 
 AT_CHECK([
-ovs-appctl dpctl/dump-flows | strip_used | grep -v ipv6 | grep -v arp |sort
-], [0], [flow-dump from non-dpdk interfaces:
-recirc_id(0),in_port(10),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:03),eth_type(0x0800),ipv4(src=10.0.0.1,dst=10.0.0.3,proto=47,frag=no),
 packets:2, bytes:272, used:0.0s, 
actions:set(ipv4(src=30.0.0.1,dst=30.0.0.3)),tnl_pop(14)
-recirc_id(0),in_port(11),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:03),eth_type(0x0800),ipv4(frag=no),
 packets:2, bytes:272, used:0.0s, actions:13
-recirc_id(0),in_port(12),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:01),eth_type(0x0800),ipv4(frag=no),
 packets:2, bytes:244, used:0.0s, actions:11
-recirc_id(0),in_port(13),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:02),eth_type(0x0800),ipv4(frag=no),
 packets:2, bytes:244, used:0.0s, actions:12

Re: [ovs-dev] [PATCH v4 0/7] Packet type aware pipeline

2017-07-10 Thread Zoltán Balogh
ff --git a/tests/system-userspace-packet-type-aware.at 
b/tests/system-userspace-packet-type-aware.at
index 1ec6fa7f6..9b0ace0fd 100644
--- a/tests/system-userspace-packet-type-aware.at
+++ b/tests/system-userspace-packet-type-aware.at
@@ -348,7 +348,7 @@ NS_CHECK_EXEC([ns1], [ping -q -c 3 -i 0.3 -w 2 $N3_IP | 
FORMAT_PING], [0], [dnl
 sleep 1
 
 AT_CHECK([
-ovs-appctl dpctl/dump-flows | strip_used | grep -v ipv6 | grep -v arp |sort
+ovs-appctl dpctl/dump-flows | strip_used | grep -v ipv6 | grep -v arp | 
grep -v drop| sort
 ], [0], [flow-dump from non-dpdk interfaces:
 
recirc_id(0),in_port(10),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:03),eth_type(0x0800),ipv4(src=10.0.0.1,dst=10.0.0.3,proto=47,frag=no),
 packets:2, bytes:272, used:0.0s, 
actions:set(ipv4(src=30.0.0.1,dst=30.0.0.3)),tnl_pop(14)
 
recirc_id(0),in_port(11),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:03),eth_type(0x0800),ipv4(frag=no),
 packets:2, bytes:272, used:0.0s, actions:13
@@ -377,7 +377,7 @@ NS_CHECK_EXEC([ns1], [ping -q -c 3 -i 0.3 -w 2 $N2_IP | 
FORMAT_PING], [0], [dnl
 sleep 1
 
 AT_CHECK([
-ovs-appctl dpctl/dump-flows | strip_used | grep -v ipv6 | grep -v arp | 
sort
+ovs-appctl dpctl/dump-flows | strip_used | grep -v ipv6 | grep -v arp | 
grep -v drop | sort
 ], [0], [flow-dump from non-dpdk interfaces:
 
recirc_id(0),in_port(11),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:02),eth_type(0x0800),ipv4(frag=no),
 packets:2, bytes:272, used:0.0s, actions:12
 
recirc_id(0),in_port(12),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:01),eth_type(0x0800),ipv4(frag=no),
 packets:2, bytes:272, used:0.0s, actions:11
@@ -402,7 +402,7 @@ NS_CHECK_EXEC([ns3], [ping -q -c 3 -i 0.3 -w 2 $N1_IP | 
FORMAT_PING], [0], [dnl
 sleep 1
 
 AT_CHECK([
-ovs-appctl dpctl/dump-flows | strip_used | grep -v ipv6 | grep -v arp | 
sort
+ovs-appctl dpctl/dump-flows | strip_used | grep -v ipv6 | grep -v arp | 
grep -v drop | sort
 ], [0], [flow-dump from non-dpdk interfaces:
 
recirc_id(0),in_port(10),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:03),eth_type(0x0800),ipv4(src=10.0.0.1,dst=10.0.0.3,proto=47,frag=no),
 packets:2, bytes:272, used:0.0s, 
actions:set(ipv4(src=30.0.0.1,dst=30.0.0.3)),tnl_pop(14)
 
recirc_id(0),in_port(11),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:03),eth_type(0x0800),ipv4(frag=no),
 packets:2, bytes:272, used:0.0s, actions:13
---

Could you verify if any of the patches solves the problem?

Otherwise we could simply remove the verification of dp flows.

Best regards,
Zoltan



> -Original Message-
> From: Darrell Ball [mailto:db...@vmware.com]
> Sent: Friday, July 07, 2017 6:56 PM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>; Yang, Yi Y 
> <yi.y.y...@intel.com>; Eric Garver <e...@erig.me>
> Cc: 'd...@openvswitch.org' <d...@openvswitch.org>; 
> simon.hor...@netronome.com; Jiri Benc <jb...@redhat.com>
> Subject: Re: [ovs-dev] [PATCH v4 0/7] Packet type aware pipeline
> 
> A few points worth noting:
> 
> 1/ This test only uses the ping application and there are no advanced 
> options, so my first guess is
>  distro should not matter, but I could be wrong.
> 
> 2/ This will not be fixed by increasing the sleep time before the check 
> below; there are extra
>  drops for broadcast packets.
> There are 6 extra lines of them for this failure – see the below o/p.
> The trailing checks in the test may fail of course.
>  If these are noise, then they can be filtered. But an 
> explanation would be needed.
> 
> I assume you added sleep because you want to make sure datapath 
> flows are established and stats are as
> expected
> Again, adding more sleep for this part will not help here.
> 
>3/ Your group needs to be able to reproduce the issue in house.
> We used standard Ubuntu 14.04 and 16.04 and also Ubuntu with 
> upgraded kernel.
> 
>4/ The system tests should pass the far majority of the time.
> 
> 
> Portion of test:
> 
>  # Ping between N1 and N3, via the L2 GRE tunnel between br-in1 and br-in3
> NS_CHECK_EXEC([ns1], [ping -q -c 3 -i 0.3 -w 2 $N3_IP | FORMAT_PING], [0], 
> [dnl
> 3 packets transmitted, 3 received, 0% packet loss, time 0ms
> ])
> 
> sleep 1
> 
> AT_CHECK([
> ovs-appctl dpctl/dump-flows | strip_used | grep -v ipv6 | grep -v arp 
> |sort
> ], [0], [flow-dump from non-dpdk interfaces:
> recirc_id(0),in_port(10),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:03),eth_type(0x0800),ipv4(src=10.0.0.1,dst=10
> .0.0.3,proto=47,frag=no), packets:2, bytes:272, used:0.0s, 
> actions:set(ipv4(src=30.0.0.1,dst=30.0.0.3)),tnl_pop(14)
> recirc_id(0),in_port(11),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:03),eth_type(0x0800),ipv4(frag=no),
> packets:2, bytes:272, used:0.0s, actions:13
> recirc_id(0),in_port(

Re: [ovs-dev] [PATCH v2] dpif-netlink: convert packet_type netlink attribute

2017-07-10 Thread Zoltán Balogh
Hi Eric,

Thank you for fixing this. I'm fine with your solution. Tests do pass.

Best regards,
Zoltan

> This still did not do the trick. The ETHERTYPE is placed at the same
> level of the message as OVS_FLOW_ATTR_MASK, rather than being place
> _inside_ OVS_FLOW_ATTR_MASK.
> 
> Below is what I came up with. All test cases pass unchanged. It also
> works for my series to add kernel L3 VXLAN-GPE/GRE.
> 
> https://github.com/erig0/ovs/commits/46aafc3ad12e30772f9d8561e6750e6c6334077c
> 
> Let me know how it works for you.
> 
> Eric.
> 
> --->8---
> 
> diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
> index 562f6134c3a5..0654ba1b2131 100644
> --- a/lib/dpif-netlink.c
> +++ b/lib/dpif-netlink.c
> @@ -3434,31 +3434,47 @@ dpif_netlink_flow_from_ofpbuf(struct 
> dpif_netlink_flow *flow,
> 
> 
>  /*
> - * If PACKET_TYPE attribute is present in 'data', it filters PACKET_TYPE out,
> - * then puts 'data' to 'buf'.
> + * If PACKET_TYPE attribute is present in 'data', it filters PACKET_TYPE out.
> + * If the flow is not Ethernet, packet_type is converted to ETHERTYPE.
> + * Puts 'data' to 'buf'.
>   */
>  static void
>  put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
> -const struct nlattr *data, uint16_t data_len)
> +const struct nlattr *data, size_t data_len)
>  {
>  const struct nlattr *packet_type;
> 
>  packet_type = nl_attr_find__(data, data_len, OVS_KEY_ATTR_PACKET_TYPE);
> 
>  if (packet_type) {
> -/* exclude PACKET_TYPE Netlink attribute. */
> -ovs_assert(NLA_ALIGN(packet_type->nla_len) == NL_A_U32_SIZE);
> -size_t packet_type_len = NL_A_U32_SIZE;
> -size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data;
> -size_t second_chunk_size = data_len - first_chunk_size
> -   - packet_type_len;
> -uint8_t *first_attr = NULL;
> -struct nlattr *next_attr = nl_attr_next(packet_type);
> -
> -first_attr = nl_msg_put_unspec_uninit(buf, type,
> -  data_len - packet_type_len);
> -memcpy(first_attr, data, first_chunk_size);
> -memcpy(first_attr + first_chunk_size, next_attr, second_chunk_size);
> +struct odputil_keybuf new_attrs_buf;
> +struct nlattr *new_attrs;
> +const struct nlattr *ethernet;
> +size_t new_attrs_len;
> +ovs_be32 packet_type_value = nl_attr_get_be32(packet_type);
> +
> +new_attrs = (struct nlattr *) _attrs_buf;
> +memcpy(new_attrs, data, data_len);
> +new_attrs_len = data_len;
> +
> +nl_attrs_filter(new_attrs, _attrs_len, OVS_KEY_ATTR_PACKET_TYPE);
> +
> +/* If it's not Ethernet, then we need to override or add the 
> Ethertype
> + * with the one from the packet_type. */
> +ethernet = nl_attr_find__(data, data_len, OVS_KEY_ATTR_ETHERNET);
> +if (!ethernet) {
> +struct ofpbuf new_buf;
> +
> +nl_attrs_filter(new_attrs, _attrs_len, 
> OVS_KEY_ATTR_ETHERTYPE);
> +
> +ofpbuf_use_stack(_buf, new_attrs, sizeof new_attrs_buf);
> +nl_msg_put_uninit(_buf, new_attrs_len);
> +nl_msg_put_be16(_buf, OVS_KEY_ATTR_ETHERTYPE,
> +pt_ns_type_be(packet_type_value));
> +new_attrs_len = new_buf.size;
> +}
> +
> +nl_msg_put_unspec(buf, type, new_attrs, new_attrs_len);
>  } else {
>  nl_msg_put_unspec(buf, type, data, data_len);
>  }
> diff --git a/lib/netlink.c b/lib/netlink.c
> index 4cf1aaca621c..c9b83fc681c4 100644
> --- a/lib/netlink.c
> +++ b/lib/netlink.c
> @@ -927,3 +927,23 @@ nl_attr_find_nested(const struct nlattr *nla, uint16_t 
> type)
>  {
>  return nl_attr_find__(nl_attr_get(nla), nl_attr_get_size(nla), type);
>  }
> +
> +/*
> + * Filter nlattr type from set of nlattrs.
> + * This changes the data in place. So caller should make a copy if required.
> + */
> +void
> +nl_attrs_filter(struct nlattr *attrs, size_t *attrs_len, uint16_t type)
> +{
> +size_t size = *attrs_len;
> +struct nlattr *nla;
> +size_t left;
> +
> +NL_ATTR_FOR_EACH (nla, left, attrs, size) {
> +if (nl_attr_type(nla) == type) {
> +*attrs_len -= nl_attr_len_pad(nla, left);
> +memmove(nla, nl_attr_next(nla), left - nl_attr_len_pad(nla, 
> left));
> +return;
> +}
> +}
> +}
> diff --git a/lib/netlink.h b/lib/netlink.h
> index 6dfac27c9d4b..744c9520966f 100644
> --- a/lib/netlink.h
> +++ b/lib/netlink.h
> @@ -240,5 +240,6 @@ const struct nlattr *nl_attr_find(const struct ofpbuf *, 
> size_t hdr_len,
>  const struct nlattr *nl_attr_find_nested(const struct nlattr *, uint16_t 
> type);
>  const struct nlattr *nl_attr_find__(const struct nlattr *attrs, size_t size,
>  uint16_t type);
> +void nl_attrs_filter(struct nlattr *attrs, size_t *attrs_len, uint16_t type);
> 
>  #endif /* 

Re: [ovs-dev] [PATCH v2] dpif-netlink: convert packet_type netlink attribute

2017-07-07 Thread Zoltán Balogh
Hi Eric,

I agree, my last patch did not help at all. We have reworked it with Jan, 
removed the unneeded code parts, it's simpler now. This way, removal of the 
PACKET_TYPE netlink attribute and adding of ETHER_TYPE netlink attribute 
happens at the same place.
Could you have a look at it and test it, please?

--->8---

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 562f6134c..4ef8d9965 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -3434,31 +3434,35 @@ dpif_netlink_flow_from_ofpbuf(struct dpif_netlink_flow 
*flow,
 
 
 /*
- * If PACKET_TYPE attribute is present in 'data', it filters PACKET_TYPE out,
- * then puts 'data' to 'buf'.
+ * If PACKET_TYPE attribute is present in 'data', converts it to ETHERNET and
+ * ETHERTYPE attributes, then puts 'data' to 'buf'.
  */
 static void
 put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
 const struct nlattr *data, uint16_t data_len)
 {
-const struct nlattr *packet_type;
-
-packet_type = nl_attr_find__(data, data_len, OVS_KEY_ATTR_PACKET_TYPE);
-
+const struct nlattr *packet_type =
+nl_attr_find__(data, data_len, OVS_KEY_ATTR_PACKET_TYPE);
 if (packet_type) {
-/* exclude PACKET_TYPE Netlink attribute. */
 ovs_assert(NLA_ALIGN(packet_type->nla_len) == NL_A_U32_SIZE);
 size_t packet_type_len = NL_A_U32_SIZE;
 size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data;
 size_t second_chunk_size = data_len - first_chunk_size
- packet_type_len;
-uint8_t *first_attr = NULL;
-struct nlattr *next_attr = nl_attr_next(packet_type);
+struct nlattr *second_chunk = nl_attr_next(packet_type);
+const struct nlattr *ethernet = nl_attr_find__(data, data_len,
+   OVS_KEY_ATTR_ETHERNET);
+size_t offset = buf->size;
+
+nl_msg_put_unspec(buf, type, data, first_chunk_size);
 
-first_attr = nl_msg_put_unspec_uninit(buf, type,
-  data_len - packet_type_len);
-memcpy(first_attr, data, first_chunk_size);
-memcpy(first_attr + first_chunk_size, next_attr, second_chunk_size);
+if (!ethernet) {
+ovs_be32 value = nl_attr_get_be32(packet_type);
+nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, pt_ns_type_be(value));
+}
+
+nl_msg_put(buf, second_chunk, second_chunk_size);
+nl_msg_end_nested(buf, offset);
 } else {
 nl_msg_put_unspec(buf, type, data, data_len);
 }
@@ -3489,12 +3493,13 @@ dpif_netlink_flow_to_ofpbuf(const struct 
dpif_netlink_flow *flow,
 }
 if (!flow->ufid_terse || !flow->ufid_present) {
 if (flow->key_len) {
-put_exclude_packet_type(buf, OVS_FLOW_ATTR_KEY, flow->key,
-   flow->key_len);
+put_exclude_packet_type(buf, OVS_FLOW_ATTR_KEY,
+flow->key, flow->key_len);
 }
+
 if (flow->mask_len) {
-put_exclude_packet_type(buf, OVS_FLOW_ATTR_MASK, flow->mask,
-   flow->mask_len);
+put_exclude_packet_type(buf, OVS_FLOW_ATTR_MASK,
+flow->mask, flow->mask_len);
 }
 if (flow->actions || flow->actions_len) {
 nl_msg_put_unspec(buf, OVS_FLOW_ATTR_ACTIONS,

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v2] dpif-netlink: convert packet_type netlink attribute

2017-07-06 Thread Zoltán Balogh
Hi Eric,

Thank you for clarifying. 

...
[OVS_FLOW_ATTR_KEY]
...
[OVS_KEY_ATTR_IPV4] = ...
...
[OVS_KEY_ATTR_ETHERTYPE] = ...  <--- the one inserted

I have not found any API that would extend a nested attribute. 
Maybe I'm wrong, but I thought 'buf' holds a single nested attribute. If this 
is true, isn't possible to add the ethertype to it and increase its size?

  nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, ns_type);
  buf->size += NL_A_U16_SIZE;

Or should I create a new nested attribute instead and copy the content of the 
original one plus the ethernet attribute? What would you propose?

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index cf4e98f29..98a97b3a2 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -3497,6 +3497,7 @@ put_convert_packet_type(struct ofpbuf *buf,
 ovs_assert(nl_attr_get_be16(eth_type) == ns_type);
 } else {
 nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, ns_type);
+buf->size += NL_A_U16_SIZE;
 }
 }
 } else {
@@ -3514,15 +3515,14 @@ put_convert_packet_type(struct ofpbuf *buf,
 mask_data, mask_len,
 packet_type);
 /* Put OVS_KEY_ATTR_ETHERTYPE if needed. */
-if (ntohl(value) != PT_ETH) {
+if (!ethernet_present) {
 const struct nlattr *eth_type;
 
-ovs_assert(ethernet_present == false);
-
 eth_type = nl_attr_find__(mask_data, mask_len,
   OVS_KEY_ATTR_ETHERTYPE);
 if (!eth_type) {
 nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, OVS_BE16_MAX);
+buf->size += NL_A_U16_SIZE;
 }
 }
 } else {


---

Best regards,
Zoltan

> -Original Message-
> From: Eric Garver [mailto:e...@erig.me]
> Sent: Thursday, July 06, 2017 2:54 PM
> To: Yang, Yi Y <yi.y.y...@intel.com>
> Cc: Zoltán Balogh <zoltan.bal...@ericsson.com>; 'd...@openvswitch.org' 
> <d...@openvswitch.org>
> Subject: Re: [ovs-dev] [PATCH v2] dpif-netlink: convert packet_type netlink 
> attribute
> 
> On Thu, Jul 06, 2017 at 10:14:06AM +, Yang, Yi Y wrote:
> > I misunderstood Eric, he means we shouldn't have ETHERTYPE if packet_type 
> > is L3 type. I tried this one just now,
> it works.
> 
> No. That's not what I meant. We _need_ ETHERTYPE for L3-type (NS 1). The
> kernel expects this since it does not understand packet_type.
> 
> See my additional comments below.
> 
> >
> > diff --git a/lib/odp-util.c b/lib/odp-util.c
> > index 20373ec..2bf30bb 100644
> > --- a/lib/odp-util.c
> > +++ b/lib/odp-util.c
> > @@ -4883,7 +4883,9 @@ odp_flow_key_from_flow__(const struct 
> > odp_flow_key_parms *parms,
> >  goto unencap;
> >  }
> >
> > -nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, data->dl_type);
> > +if (flow->packet_type == htonl(PT_ETH)) {
> > +nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, data->dl_type);
> > +}
> >
> >  if (eth_type_vlan(flow->dl_type)) {
> >  goto unencap;
> >
> > -Original Message-
> > From: Zoltán Balogh [mailto:zoltan.bal...@ericsson.com]
> > Sent: Thursday, July 6, 2017 6:12 PM
> > To: Yang, Yi Y <yi.y.y...@intel.com>; Eric Garver <e...@erig.me>
> > Cc: 'd...@openvswitch.org' <d...@openvswitch.org>; Jan Scheurich 
> > <jan.scheur...@ericsson.com>
> > Subject: RE: [ovs-dev] [PATCH v2] dpif-netlink: convert packet_type netlink 
> > attribute
> >
> > Hello Yi,
> >
> > I ran make check after applying your change and two tunnel tests did fail.
> >
> > ## -- ##
> > ## openvswitch 2.7.90 test suite. ##
> > ## -- ##
> >
> > 790: tunnel_push_pop_ipv6 - action   FAILED 
> > (tunnel-push-pop-ipv6.at:170)
> > 787: tunnel_push_pop - actionFAILED 
> > (tunnel-push-pop.at:221)
> >
> > The error message from testsuite.log:
> > +2017-07-06T10:06:32.119Z|1|odp_util(revalidator37)|ERR|attribute
> > +eth has length 2 but should have length 12
> >
> > Best regards,
> > Zoltan
> >
> > > -Original Message-
> > > From: Yang, Yi Y [mailto:yi.y.y...@intel.com]
> > > Sent: Thursday, July 06, 2017 11:10 AM
> > > To: Eric Garver <e...@erig.me>; Zoltán Balogh
> > > <zoltan.bal...@ericsson.com>
> > > Cc: 'd...@openvswitch.or

Re: [ovs-dev] [PATCH v2] dpif-netlink: convert packet_type netlink attribute

2017-07-06 Thread Zoltán Balogh
Hello Yi,

I ran make check after applying your change and two tunnel tests did fail.

## -- ##
## openvswitch 2.7.90 test suite. ##
## -- ##

790: tunnel_push_pop_ipv6 - action   FAILED 
(tunnel-push-pop-ipv6.at:170)
787: tunnel_push_pop - actionFAILED 
(tunnel-push-pop.at:221)

The error message from testsuite.log:
+2017-07-06T10:06:32.119Z|1|odp_util(revalidator37)|ERR|attribute eth has 
length 2 but should have length 12

Best regards,
Zoltan

> -Original Message-
> From: Yang, Yi Y [mailto:yi.y.y...@intel.com]
> Sent: Thursday, July 06, 2017 11:10 AM
> To: Eric Garver <e...@erig.me>; Zoltán Balogh <zoltan.bal...@ericsson.com>
> Cc: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: RE: [ovs-dev] [PATCH v2] dpif-netlink: convert packet_type netlink 
> attribute
> 
> Eric, maybe the below patch can fix your issue, please give a try.
> 
> diff --git a/lib/odp-util.c b/lib/odp-util.c
> index 20373ec..c5f714d 100644
> --- a/lib/odp-util.c
> +++ b/lib/odp-util.c
> @@ -4863,6 +4863,9 @@ odp_flow_key_from_flow__(const struct 
> odp_flow_key_parms *parms,
>  goto unencap;
>  }
>  }
> +} else {
> +if (export_mask) {
> +nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, OVS_BE16_MAX);
>  }
> 
>  if (ntohs(flow->dl_type) < ETH_TYPE_MIN) {
> 
> -Original Message-----
> From: Eric Garver [mailto:e...@erig.me]
> Sent: Wednesday, July 5, 2017 11:14 PM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>
> Cc: Yang, Yi Y <yi.y.y...@intel.com>; 'd...@openvswitch.org' 
> <d...@openvswitch.org>
> Subject: Re: [ovs-dev] [PATCH v2] dpif-netlink: convert packet_type netlink 
> attribute
> 
> Hi Zoltan,
> 
> On Tue, Jul 04, 2017 at 09:23:17PM +, Zoltán Balogh wrote:
> > By introducing packet type-aware pipeline, match on ethertype was
> > removed when packet type is not Ethernet. As pointed out by Eric
> > Garver, this could have a side effect on the kernel datapath:
> > https://patchwork.ozlabs.org/patch/782991/
> >
> > This patch does approach the problem from a different perspective.
> > Instead of re-introducing the unconditional match on Ethernet type in
> > all megaflow entries, as suggested by Eric, mapping of packet_type !=
> > PT_ETH to dl_type could be handled in the put_exclude_packet_type() in 
> > dpif-netlink.c.
> >
> > Put_exclude_packet_type() filters the packet_type netlink attribute
> > out, before all attributes are sent from userspace to kernel. This
> > commit modifies the put_exclude_packet_type() function to do a proper
> > conversation and add the missing OVS_KEY_ATTR_ETHERTYPE attribute if it's 
> > needed.
> >
> > Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
> > Reported-by: Eric Garver <e...@erig.me>
> > ---
> >  lib/dpif-netlink.c | 120
> > +++--
> >  1 file changed, 90 insertions(+), 30 deletions(-)
> >
> > diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index
> > 562f613..cf4e98f 100644
> > --- a/lib/dpif-netlink.c
> > +++ b/lib/dpif-netlink.c
> > @@ -3433,34 +3433,101 @@ dpif_netlink_flow_from_ofpbuf(struct
> > dpif_netlink_flow *flow,  }
> >
> >
> > +static bool
> > +put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
> > +const struct nlattr *data, uint16_t data_len,
> > +const struct nlattr *packet_type) {
> > +ovs_assert(NLA_ALIGN(packet_type->nla_len) == NL_A_U32_SIZE);
> > +size_t packet_type_len = NL_A_U32_SIZE;
> > +size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data;
> > +size_t second_chunk_size = data_len - first_chunk_size
> > +   - packet_type_len;
> > +uint8_t *first_attr = NULL;
> > +struct nlattr *next_attr = nl_attr_next(packet_type);
> > +
> > +bool ethernet_present = nl_attr_find__(data, data_len,
> > +   OVS_KEY_ATTR_ETHERNET);
> > +
> > +first_attr = nl_msg_put_unspec_uninit(buf, type,
> > +  data_len - packet_type_len);
> > +memcpy(first_attr, data, first_chunk_size);
> > +memcpy(first_attr + first_chunk_size, next_attr,
> > + second_chunk_size);
> > +
> > +return ethernet_present;
> > +}
> > +
> >  /*
> > - * If PACKET_TYPE attribute is present in 'data', it filters
> > PACKET_TYPE out,
> >

Re: [ovs-dev] [PATCH] dpif-netilnk: convert packet_type netlink attribute

2017-07-04 Thread Zoltán Balogh
Hi Eric and Yi,

I tried to fix the issues. I posted v2 to the list. Could you have a look at it 
and test it, please?
https://patchwork.ozlabs.org/patch/784317/

Best regards,
Zoltan

> -Original Message-
> From: Yang, Yi Y [mailto:yi.y.y...@intel.com]
> Sent: Tuesday, July 04, 2017 2:10 AM
> To: Eric Garver <e...@erig.me>; Zoltán Balogh <zoltan.bal...@ericsson.com>
> Cc: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: RE: [ovs-dev] [PATCH] dpif-netilnk: convert packet_type netlink 
> attribute
> 
> Zoltan, I tested this patch for net-next, it will result in failure by 
> ovs_assert, in addition, we need to handle
> OVS_FLOW_ATTR_MASK and OVS_FLOW_ATTR_KEY differently, to be important, we 
> need to verify it in kernel mode. From my
> test and verification, this patch can't work, instead, it can work without 
> this patch.
> 
> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Eric Garver
> Sent: Tuesday, July 4, 2017 2:52 AM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>
> Cc: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: Re: [ovs-dev] [PATCH] dpif-netilnk: convert packet_type netlink 
> attribute
> 
> On Mon, Jul 03, 2017 at 02:27:18PM +, Zoltán Balogh wrote:
> > By introducing packet type-aware pipeline, match on ethertype was
> > removed when packet type is not Ethernet. As pointed out by Eric
> > Garver, this could have a side effect on the kernel datapath:
> > https://patchwork.ozlabs.org/patch/782991/
> >
> > This patch does approach the problem from a different perspective.
> > Instead of re-introducing the unconditional match on Ethernet type in
> > all megaflow entries, as suggested by Eric, mapping of packet_type !=
> > PT_ETH to dl_type could be handled in the put_exclude_packet_type() in 
> > dpif-netlink.c.
> >
> > Put_exclude_packet_type() filters the packet_type netlink attribute
> > out, before all attributes are sent from userspace to kernel. This
> > commit modifies the put_exclude_packet_type() function to do a proper
> > conversation and add the missing OVS_KEY_ATTR_ETHERTYPE attribute if it's 
> > needed.
> >
> > Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
> > Reported-by: Eric Garver <e...@erig.me>
> > ---
> >  lib/dpif-netlink.c | 34 --
> >  1 file changed, 28 insertions(+), 6 deletions(-)
> >
> > diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index
> > 562f6134c..d8051a09e 100644
> > --- a/lib/dpif-netlink.c
> > +++ b/lib/dpif-netlink.c
> > @@ -3434,11 +3434,11 @@ dpif_netlink_flow_from_ofpbuf(struct
> > dpif_netlink_flow *flow,
> >
> >
> >  /*
> > - * If PACKET_TYPE attribute is present in 'data', it filters
> > PACKET_TYPE out,
> > - * then puts 'data' to 'buf'.
> > + * If PACKET_TYPE attribute is present in 'data', converts it to
> > + ETHERNET and
> > + * ETHERTYPE attributes, then puts 'data' to 'buf'.
> >   */
> >  static void
> > -put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
> > +put_convert_packet_type(struct ofpbuf *buf, uint16_t type,
> >  const struct nlattr *data, uint16_t data_len)
> > {
> >  const struct nlattr *packet_type; @@ -3446,8 +3446,9 @@
> > put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
> >  packet_type = nl_attr_find__(data, data_len,
> > OVS_KEY_ATTR_PACKET_TYPE);
> >
> >  if (packet_type) {
> > -/* exclude PACKET_TYPE Netlink attribute. */
> > +/* Convert PACKET_TYPE Netlink attribute. */
> >  ovs_assert(NLA_ALIGN(packet_type->nla_len) == NL_A_U32_SIZE);
> > +ovs_be32 value = nl_attr_get_be32(packet_type);
> >  size_t packet_type_len = NL_A_U32_SIZE;
> >  size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data;
> >  size_t second_chunk_size = data_len - first_chunk_size @@
> > -3455,10 +3456,31 @@ put_exclude_packet_type(struct ofpbuf *buf, uint16_t 
> > type,
> >  uint8_t *first_attr = NULL;
> >  struct nlattr *next_attr = nl_attr_next(packet_type);
> >
> > +bool ethernet_present = nl_attr_find__(data, data_len,
> > +
> > + OVS_KEY_ATTR_ETHERNET);
> > +
> >  first_attr = nl_msg_put_unspec_uninit(buf, type,
> >data_len - packet_type_len);
> >  memcpy(first_attr, data, first_chunk_size);
> >  memcpy(first_attr + first_chun

[ovs-dev] [PATCH v2] dpif-netlink: convert packet_type netlink attribute

2017-07-04 Thread Zoltán Balogh
By introducing packet type-aware pipeline, match on ethertype was
removed when packet type is not Ethernet. As pointed out by Eric Garver,
this could have a side effect on the kernel datapath:
https://patchwork.ozlabs.org/patch/782991/

This patch does approach the problem from a different perspective.
Instead of re-introducing the unconditional match on Ethernet type in all
megaflow entries, as suggested by Eric, mapping of packet_type != PT_ETH to
dl_type could be handled in the put_exclude_packet_type() in dpif-netlink.c.

Put_exclude_packet_type() filters the packet_type netlink attribute out,
before all attributes are sent from userspace to kernel. This commit modifies
the put_exclude_packet_type() function to do a proper conversation and add the
missing OVS_KEY_ATTR_ETHERTYPE attribute if it's needed.

Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
Reported-by: Eric Garver <e...@erig.me>
---
 lib/dpif-netlink.c | 120 +++--
 1 file changed, 90 insertions(+), 30 deletions(-)

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 562f613..cf4e98f 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -3433,34 +3433,101 @@ dpif_netlink_flow_from_ofpbuf(struct dpif_netlink_flow 
*flow,
 }
 
 
+static bool
+put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
+const struct nlattr *data, uint16_t data_len,
+const struct nlattr *packet_type)
+{
+ovs_assert(NLA_ALIGN(packet_type->nla_len) == NL_A_U32_SIZE);
+size_t packet_type_len = NL_A_U32_SIZE;
+size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data;
+size_t second_chunk_size = data_len - first_chunk_size
+   - packet_type_len;
+uint8_t *first_attr = NULL;
+struct nlattr *next_attr = nl_attr_next(packet_type);
+
+bool ethernet_present = nl_attr_find__(data, data_len,
+   OVS_KEY_ATTR_ETHERNET);
+
+first_attr = nl_msg_put_unspec_uninit(buf, type,
+  data_len - packet_type_len);
+memcpy(first_attr, data, first_chunk_size);
+memcpy(first_attr + first_chunk_size, next_attr, second_chunk_size);
+
+return ethernet_present;
+}
+
 /*
- * If PACKET_TYPE attribute is present in 'data', it filters PACKET_TYPE out,
- * then puts 'data' to 'buf'.
+ * If PACKET_TYPE attribute is present in 'data', converts it to ETHERNET and
+ * ETHERTYPE attributes, then puts 'data' to 'buf'.
  */
 static void
-put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
-const struct nlattr *data, uint16_t data_len)
+put_convert_packet_type(struct ofpbuf *buf,
+const struct dpif_netlink_flow *flow)
 {
 const struct nlattr *packet_type;
+const struct nlattr *data = flow->key;
+uint16_t data_len = flow->key_len;
+const struct nlattr *mask_data = flow->mask;
+uint16_t mask_len = flow->mask_len;
+ovs_be32 value = htonl(PT_ETH);
+bool ethernet_present = false;
+
+/* Verify KEY attributes.  */
+if (data_len) {
+packet_type = nl_attr_find__(data, data_len, OVS_KEY_ATTR_PACKET_TYPE);
+if (packet_type) {
+/* Convert PACKET_TYPE Netlink attribute. */
+value = nl_attr_get_be32(packet_type);
+ethernet_present = put_exclude_packet_type(buf, OVS_FLOW_ATTR_KEY,
+   data, data_len,
+   packet_type);
+/* Put OVS_KEY_ATTR_ETHERTYPE if needed. */
+if (ntohl(value) == PT_ETH) {
+ovs_assert(ethernet_present);
+} else {
+const struct nlattr *eth_type;
+ovs_be16 ns_type = pt_ns_type_be(value);
 
-packet_type = nl_attr_find__(data, data_len, OVS_KEY_ATTR_PACKET_TYPE);
-
-if (packet_type) {
-/* exclude PACKET_TYPE Netlink attribute. */
-ovs_assert(NLA_ALIGN(packet_type->nla_len) == NL_A_U32_SIZE);
-size_t packet_type_len = NL_A_U32_SIZE;
-size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data;
-size_t second_chunk_size = data_len - first_chunk_size
-   - packet_type_len;
-uint8_t *first_attr = NULL;
-struct nlattr *next_attr = nl_attr_next(packet_type);
-
-first_attr = nl_msg_put_unspec_uninit(buf, type,
-  data_len - packet_type_len);
-memcpy(first_attr, data, first_chunk_size);
-memcpy(first_attr + first_chunk_size, next_attr, second_chunk_size);
-} else {
-nl_msg_put_unspec(buf, type, data, data_len);
+ovs_assert(ethernet_present == false);
+
+eth_type = nl_attr_find__(data, data_len,
+  OVS_KEY_ATTR_ETHERTYPE);

Re: [ovs-dev] [PATCH] dpif-netilnk: convert packet_type netlink attribute

2017-07-04 Thread Zoltán Balogh
Thank you for testing!
I'm going to fix it.
/Zoltan

> -Original Message-
> From: Yang, Yi Y [mailto:yi.y.y...@intel.com]
> Sent: Tuesday, July 04, 2017 2:10 AM
> To: Eric Garver <e...@erig.me>; Zoltán Balogh <zoltan.bal...@ericsson.com>
> Cc: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: RE: [ovs-dev] [PATCH] dpif-netilnk: convert packet_type netlink 
> attribute
> 
> Zoltan, I tested this patch for net-next, it will result in failure by 
> ovs_assert, in addition, we need to handle
> OVS_FLOW_ATTR_MASK and OVS_FLOW_ATTR_KEY differently, to be important, we 
> need to verify it in kernel mode. From my
> test and verification, this patch can't work, instead, it can work without 
> this patch.
> 
> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Eric Garver
> Sent: Tuesday, July 4, 2017 2:52 AM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>
> Cc: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: Re: [ovs-dev] [PATCH] dpif-netilnk: convert packet_type netlink 
> attribute
> 
> On Mon, Jul 03, 2017 at 02:27:18PM +, Zoltán Balogh wrote:
> > By introducing packet type-aware pipeline, match on ethertype was
> > removed when packet type is not Ethernet. As pointed out by Eric
> > Garver, this could have a side effect on the kernel datapath:
> > https://patchwork.ozlabs.org/patch/782991/
> >
> > This patch does approach the problem from a different perspective.
> > Instead of re-introducing the unconditional match on Ethernet type in
> > all megaflow entries, as suggested by Eric, mapping of packet_type !=
> > PT_ETH to dl_type could be handled in the put_exclude_packet_type() in 
> > dpif-netlink.c.
> >
> > Put_exclude_packet_type() filters the packet_type netlink attribute
> > out, before all attributes are sent from userspace to kernel. This
> > commit modifies the put_exclude_packet_type() function to do a proper
> > conversation and add the missing OVS_KEY_ATTR_ETHERTYPE attribute if it's 
> > needed.
> >
> > Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
> > Reported-by: Eric Garver <e...@erig.me>
> > ---
> >  lib/dpif-netlink.c | 34 --
> >  1 file changed, 28 insertions(+), 6 deletions(-)
> >
> > diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index
> > 562f6134c..d8051a09e 100644
> > --- a/lib/dpif-netlink.c
> > +++ b/lib/dpif-netlink.c
> > @@ -3434,11 +3434,11 @@ dpif_netlink_flow_from_ofpbuf(struct
> > dpif_netlink_flow *flow,
> >
> >
> >  /*
> > - * If PACKET_TYPE attribute is present in 'data', it filters
> > PACKET_TYPE out,
> > - * then puts 'data' to 'buf'.
> > + * If PACKET_TYPE attribute is present in 'data', converts it to
> > + ETHERNET and
> > + * ETHERTYPE attributes, then puts 'data' to 'buf'.
> >   */
> >  static void
> > -put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
> > +put_convert_packet_type(struct ofpbuf *buf, uint16_t type,
> >  const struct nlattr *data, uint16_t data_len)
> > {
> >  const struct nlattr *packet_type; @@ -3446,8 +3446,9 @@
> > put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
> >  packet_type = nl_attr_find__(data, data_len,
> > OVS_KEY_ATTR_PACKET_TYPE);
> >
> >  if (packet_type) {
> > -/* exclude PACKET_TYPE Netlink attribute. */
> > +/* Convert PACKET_TYPE Netlink attribute. */
> >  ovs_assert(NLA_ALIGN(packet_type->nla_len) == NL_A_U32_SIZE);
> > +ovs_be32 value = nl_attr_get_be32(packet_type);
> >  size_t packet_type_len = NL_A_U32_SIZE;
> >  size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data;
> >  size_t second_chunk_size = data_len - first_chunk_size @@
> > -3455,10 +3456,31 @@ put_exclude_packet_type(struct ofpbuf *buf, uint16_t 
> > type,
> >  uint8_t *first_attr = NULL;
> >  struct nlattr *next_attr = nl_attr_next(packet_type);
> >
> > +bool ethernet_present = nl_attr_find__(data, data_len,
> > +
> > + OVS_KEY_ATTR_ETHERNET);
> > +
> >  first_attr = nl_msg_put_unspec_uninit(buf, type,
> >data_len - packet_type_len);
> >  memcpy(first_attr, data, first_chunk_size);
> >  memcpy(first_attr + first_chunk_size, next_attr,
> > second_chunk_size);
> > +
> > +/* Put OVS_KEY_ATTR_ETHERTYPE if needed. */
> > 

Re: [ovs-dev] [PATCH] dpif-netilnk: convert packet_type netlink attribute

2017-07-04 Thread Zoltán Balogh
Thank you for reviewing!
I'm going to fix it.
/Zoltan

> -Original Message-
> From: Eric Garver [mailto:e...@erig.me]
> Sent: Monday, July 03, 2017 8:52 PM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>
> Cc: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: Re: [ovs-dev] [PATCH] dpif-netilnk: convert packet_type netlink 
> attribute
> 
> On Mon, Jul 03, 2017 at 02:27:18PM +, Zoltán Balogh wrote:
> > By introducing packet type-aware pipeline, match on ethertype was
> > removed when packet type is not Ethernet. As pointed out by Eric Garver,
> > this could have a side effect on the kernel datapath:
> > https://patchwork.ozlabs.org/patch/782991/
> >
> > This patch does approach the problem from a different perspective.
> > Instead of re-introducing the unconditional match on Ethernet type in all
> > megaflow entries, as suggested by Eric, mapping of packet_type != PT_ETH to
> > dl_type could be handled in the put_exclude_packet_type() in dpif-netlink.c.
> >
> > Put_exclude_packet_type() filters the packet_type netlink attribute out,
> > before all attributes are sent from userspace to kernel. This commit 
> > modifies
> > the put_exclude_packet_type() function to do a proper conversation and add 
> > the
> > missing OVS_KEY_ATTR_ETHERTYPE attribute if it's needed.
> >
> > Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
> > Reported-by: Eric Garver <e...@erig.me>
> > ---
> >  lib/dpif-netlink.c | 34 --
> >  1 file changed, 28 insertions(+), 6 deletions(-)
> >
> > diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
> > index 562f6134c..d8051a09e 100644
> > --- a/lib/dpif-netlink.c
> > +++ b/lib/dpif-netlink.c
> > @@ -3434,11 +3434,11 @@ dpif_netlink_flow_from_ofpbuf(struct 
> > dpif_netlink_flow *flow,
> >
> >
> >  /*
> > - * If PACKET_TYPE attribute is present in 'data', it filters PACKET_TYPE 
> > out,
> > - * then puts 'data' to 'buf'.
> > + * If PACKET_TYPE attribute is present in 'data', converts it to ETHERNET 
> > and
> > + * ETHERTYPE attributes, then puts 'data' to 'buf'.
> >   */
> >  static void
> > -put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
> > +put_convert_packet_type(struct ofpbuf *buf, uint16_t type,
> >  const struct nlattr *data, uint16_t data_len)
> >  {
> >  const struct nlattr *packet_type;
> > @@ -3446,8 +3446,9 @@ put_exclude_packet_type(struct ofpbuf *buf, uint16_t 
> > type,
> >  packet_type = nl_attr_find__(data, data_len, OVS_KEY_ATTR_PACKET_TYPE);
> >
> >  if (packet_type) {
> > -/* exclude PACKET_TYPE Netlink attribute. */
> > +/* Convert PACKET_TYPE Netlink attribute. */
> >  ovs_assert(NLA_ALIGN(packet_type->nla_len) == NL_A_U32_SIZE);
> > +ovs_be32 value = nl_attr_get_be32(packet_type);
> >  size_t packet_type_len = NL_A_U32_SIZE;
> >  size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data;
> >  size_t second_chunk_size = data_len - first_chunk_size
> > @@ -3455,10 +3456,31 @@ put_exclude_packet_type(struct ofpbuf *buf, 
> > uint16_t type,
> >  uint8_t *first_attr = NULL;
> >  struct nlattr *next_attr = nl_attr_next(packet_type);
> >
> > +bool ethernet_present = nl_attr_find__(data, data_len,
> > +   OVS_KEY_ATTR_ETHERNET);
> > +
> >  first_attr = nl_msg_put_unspec_uninit(buf, type,
> >data_len - packet_type_len);
> >  memcpy(first_attr, data, first_chunk_size);
> >  memcpy(first_attr + first_chunk_size, next_attr, 
> > second_chunk_size);
> > +
> > +/* Put OVS_KEY_ATTR_ETHERTYPE if needed. */
> > +if (ntohl(value) == PT_ETH) {
> 
> I don't think this works for the mask case. I think value will be
> OVS_BE32_MAX.
> 
> > +ovs_assert(ethernet_present);
> > +} else {
> > +const struct nlattr *eth_type;
> > +ovs_be16 ns_type = pt_ns_type_be(value);
> > +
> > +ovs_assert(ethernet_present == false);
> > +
> > +eth_type = nl_attr_find__(data, data_len, 
> > OVS_KEY_ATTR_ETHERTYPE);
> > +if (eth_type) {
> > +ovs_assert(nl_attr_get_be16(eth_type) == ns_type);
> > +} else {
> > +nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, ns_type);
> 
> This wi

Re: [ovs-dev] [PATCH] packet_type: Force _ETHERTYPE mask in netlink messages

2017-07-03 Thread Zoltán Balogh
Hi Eric,

I sent out the patch mentioned by Jan to the dev list:
https://patchwork.ozlabs.org/patch/783509/

Could you review it, please?

Best regards,
Zoltan

> -Original Message-
> From: Jan Scheurich
> Sent: Monday, July 03, 2017 3:23 PM
> To: Eric Garver <e...@erig.me>; d...@openvswitch.org
> Cc: Zoltán Balogh <zoltan.bal...@ericsson.com>
> Subject: RE: [PATCH] packet_type: Force _ETHERTYPE mask in netlink messages
> 
> Hi Eric,
> 
> Thanks for the catch. We seem to have overlooked this side effect on the 
> kernel datapath when removing the
> conceptually incorrect match on eth_type in the datapath when packet_type != 
> PT_ETH.
> 
> Instead of re-introducing the unconditional match on eth_type in all megaflow 
> entries, we would rather suggest to
> handle this (hopefully temporary) mapping of packet_type != PT_ETH to dl_type 
> for the kernel datapath in the
> function put_exclude_packet_type() in dpif-netlink.c, which already now 
> filters the packet_type attribute out.
> 
> Thus we can keep the ofproto translation logic clean and limit the kernel 
> datapath specialties to a single place in
> the code.
> 
> Zoltan has proposed a similar change earlier and will send a corresponding 
> patch soon.
> 
> BR, Jan
> 
> > -Original Message-
> > From: Eric Garver [mailto:e...@erig.me]
> > Sent: Friday, 30 June, 2017 22:30
> > To: Jan Scheurich <jan.scheur...@ericsson.com>; d...@openvswitch.org
> > Subject: [PATCH] packet_type: Force _ETHERTYPE mask in netlink messages
> >
> > The kernel does not understand packet_type so it's implicitly encoded by
> > the absence of _ETHERNET and presence of _ETHERTYPE. For non-Ethernet we
> > need to force the mask for _ETHERTYPE otherwise the kernel's
> > match_validate() will complain.
> >
> > The mask use to always be set in xlate_wc_init() and xlate_wc_finish(),
> > but that changed for non-Ethernet frames with the commit listed in
> > Fixes.
> >
> > Fixes: 3d4b2e6eb74e ("userspace: Add OXM field MFF_PACKET_TYPE")
> > Signed-off-by: Eric Garver <e...@erig.me>
> > ---
> >  lib/odp-util.c  | 11 ++-
> >  tests/packet-type-aware.at  |  4 ++--
> >  tests/system-userspace-packet-type-aware.at |  8 
> >  3 files changed, 16 insertions(+), 7 deletions(-)
> >
> > diff --git a/lib/odp-util.c b/lib/odp-util.c
> > index f4c0b665068f..956d9608b220 100644
> > --- a/lib/odp-util.c
> > +++ b/lib/odp-util.c
> > @@ -4588,7 +4588,16 @@ odp_flow_key_from_flow__(const struct 
> > odp_flow_key_parms *parms,
> >  goto unencap;
> >  }
> >
> > -nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, data->dl_type);
> > +if (export_mask && flow->packet_type != htonl(PT_ETH)) {
> > +/* The kernel does not yet explicitly support packet_type. 
> > However, it
> > + * implicitly supports it by the absence of _ETHERNET and the 
> > presence
> > + * of _ETHERTYPE. This mean we must force an exact match on the
> > + * _ETHERTYPE.
> > + */
> > +nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, OVS_BE16_MAX);
> > +} else {
> > +nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, data->dl_type);
> > +}
> >
> >  if (eth_type_vlan(flow->dl_type)) {
> >  goto unencap;
> > diff --git a/tests/packet-type-aware.at b/tests/packet-type-aware.at
> > index 110407857786..43756eba3041 100644
> > --- a/tests/packet-type-aware.at
> > +++ b/tests/packet-type-aware.at
> > @@ -407,8 +407,8 @@ AT_CHECK([
> >  recirc_id(0),in_port(br-
> >
> p2),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:01),eth_type(0x0800),ipv4(src=20.0.0.2,dst=20.0.0.1,proto=47,frag=
> no),
> > packets:1, bytes:122, used:0.0s, 
> > actions:set(ipv4(src=10.0.0.2,dst=10.0.0.1)),tnl_pop(gre_sys)
> >  recirc_id(0),in_port(br-
> >
> p3),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:02),eth_type(0x0800),ipv4(src=30.0.0.3,dst=30.0.0.2,proto=47,frag=
> no),
> > packets:1, bytes:122, used:0.0s, 
> > actions:set(ipv4(src=20.0.0.3,dst=20.0.0.2)),tnl_pop(gre_sys)
> >  
> > recirc_id(0),in_port(n3),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(dst=192.168.10.10,tos=0/0x3,frag=no),
> packets:1, bytes:98,
> > used:0.0s,
> >
> actions:pop_eth,tnl_push(tnl_port(gre_sys),header(size=38,type=3,eth(dst=aa:55:00:00:00:02,src=aa:55:00:00:00:03,dl_
> type=0x0800)
> > ,ipv4(src=30.0.0.3,dst=30.0.0.2,proto=47,tos=0,ttl=64,frag=0x4000),gre((flags=0x0,proto=0x800))),out_port(b

[ovs-dev] [PATCH] dpif-netilnk: convert packet_type netlink attribute

2017-07-03 Thread Zoltán Balogh
By introducing packet type-aware pipeline, match on ethertype was
removed when packet type is not Ethernet. As pointed out by Eric Garver,
this could have a side effect on the kernel datapath:
https://patchwork.ozlabs.org/patch/782991/

This patch does approach the problem from a different perspective.
Instead of re-introducing the unconditional match on Ethernet type in all
megaflow entries, as suggested by Eric, mapping of packet_type != PT_ETH to
dl_type could be handled in the put_exclude_packet_type() in dpif-netlink.c.

Put_exclude_packet_type() filters the packet_type netlink attribute out,
before all attributes are sent from userspace to kernel. This commit modifies
the put_exclude_packet_type() function to do a proper conversation and add the
missing OVS_KEY_ATTR_ETHERTYPE attribute if it's needed.

Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
Reported-by: Eric Garver <e...@erig.me>
---
 lib/dpif-netlink.c | 34 --
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 562f6134c..d8051a09e 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -3434,11 +3434,11 @@ dpif_netlink_flow_from_ofpbuf(struct dpif_netlink_flow 
*flow,
 
 
 /*
- * If PACKET_TYPE attribute is present in 'data', it filters PACKET_TYPE out,
- * then puts 'data' to 'buf'.
+ * If PACKET_TYPE attribute is present in 'data', converts it to ETHERNET and
+ * ETHERTYPE attributes, then puts 'data' to 'buf'.
  */
 static void
-put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
+put_convert_packet_type(struct ofpbuf *buf, uint16_t type,
 const struct nlattr *data, uint16_t data_len)
 {
 const struct nlattr *packet_type;
@@ -3446,8 +3446,9 @@ put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
 packet_type = nl_attr_find__(data, data_len, OVS_KEY_ATTR_PACKET_TYPE);
 
 if (packet_type) {
-/* exclude PACKET_TYPE Netlink attribute. */
+/* Convert PACKET_TYPE Netlink attribute. */
 ovs_assert(NLA_ALIGN(packet_type->nla_len) == NL_A_U32_SIZE);
+ovs_be32 value = nl_attr_get_be32(packet_type);
 size_t packet_type_len = NL_A_U32_SIZE;
 size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data;
 size_t second_chunk_size = data_len - first_chunk_size
@@ -3455,10 +3456,31 @@ put_exclude_packet_type(struct ofpbuf *buf, uint16_t 
type,
 uint8_t *first_attr = NULL;
 struct nlattr *next_attr = nl_attr_next(packet_type);
 
+bool ethernet_present = nl_attr_find__(data, data_len,
+   OVS_KEY_ATTR_ETHERNET);
+
 first_attr = nl_msg_put_unspec_uninit(buf, type,
   data_len - packet_type_len);
 memcpy(first_attr, data, first_chunk_size);
 memcpy(first_attr + first_chunk_size, next_attr, second_chunk_size);
+
+/* Put OVS_KEY_ATTR_ETHERTYPE if needed. */
+if (ntohl(value) == PT_ETH) {
+ovs_assert(ethernet_present);
+} else {
+const struct nlattr *eth_type;
+ovs_be16 ns_type = pt_ns_type_be(value);
+
+ovs_assert(ethernet_present == false);
+
+eth_type = nl_attr_find__(data, data_len, OVS_KEY_ATTR_ETHERTYPE);
+if (eth_type) {
+ovs_assert(nl_attr_get_be16(eth_type) == ns_type);
+} else {
+nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, ns_type);
+}
+}
+
 } else {
 nl_msg_put_unspec(buf, type, data, data_len);
 }
@@ -3489,11 +3511,11 @@ dpif_netlink_flow_to_ofpbuf(const struct 
dpif_netlink_flow *flow,
 }
 if (!flow->ufid_terse || !flow->ufid_present) {
 if (flow->key_len) {
-put_exclude_packet_type(buf, OVS_FLOW_ATTR_KEY, flow->key,
+put_convert_packet_type(buf, OVS_FLOW_ATTR_KEY, flow->key,
flow->key_len);
 }
 if (flow->mask_len) {
-put_exclude_packet_type(buf, OVS_FLOW_ATTR_MASK, flow->mask,
+put_convert_packet_type(buf, OVS_FLOW_ATTR_MASK, flow->mask,
flow->mask_len);
 }
 if (flow->actions || flow->actions_len) {
-- 
2.11.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 4/4] netdev: fix crash when interface option is changed to invalid value

2017-06-30 Thread Zoltán Balogh
When trying to modify an interface option (e.g. remote IP of a GRE port) to
an invalid value, the vswitchd does crash. For instance:
 ovs-vsctl add-br br0
 ovs-vsctl add-port br0 gre0 -- set interface gre0 type=gre \
   options:remote_ip=10.0.0.2
 ovs-vsctl set interface gre0 options:remote_ip=9.9.9

The bug is caused by trying to dereference a NULL pointer. It was introduced
by the commit 9fff138ec3a6. Before that, the NULL pointer was handled by the
VLOG_WARN_BUF macro.

Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
CC: Daniele Di Proietto <diproiet...@vmware.com>
Fixes: 9fff138ec3a6 ("netdev: Add 'errp' to set_config().")
---
 lib/netdev.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/netdev.c b/lib/netdev.c
index a7840a8..26e87a2 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -469,7 +469,11 @@ netdev_set_config(struct netdev *netdev, const struct smap 
*args, char **errp)
   "%s: could not set configuration (%s)",
   netdev_get_name(netdev), ovs_strerror(error));
 if (verbose_error) {
-*errp = verbose_error;
+if (errp) {
+*errp = verbose_error;
+} else {
+free(verbose_error);
+}
 }
 }
 return error;
-- 
1.9.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 3/4] ofproto-dpif-xlate: drop L3 packets on L2 legacy port

2017-06-30 Thread Zoltán Balogh
This commit drops packet during xlate if it is a L3 packet and output port
packet_type is legacy_l2. It completes PTAP unit tests with:

  - Send L3 packet over patch port.
  - Output L2/L3 packet to ports with different packet_type properties.
  
Signed-off-by: Zoltán Balogh <zoltan.bal...@ericsson.com>
---
 ofproto/ofproto-dpif-xlate.c |  23 +++-
 tests/packet-type-aware.at   | 304 +++
 2 files changed, 320 insertions(+), 7 deletions(-)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 575c59e..a157fc9 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -3314,6 +3314,14 @@ check_output_prerequisites(struct xlate_ctx *ctx,
 return false;
 }
 }
+
+if (xport->pt_mode == NETDEV_PT_LEGACY_L2 &&
+   flow->packet_type != htonl(PT_ETH)) {
+xlate_report(ctx, OFT_WARN, "Trying to send non-Ethernet packet "
+ "through legacy L2 port. Dropping packet.");
+return false;
+}
+
 return true;
 }
 
@@ -3347,6 +3355,10 @@ compose_output_action__(struct xlate_ctx *ctx, 
ofp_port_t ofp_port,
 odp_port_t out_port, odp_port, odp_tnl_port;
 bool is_native_tunnel = false;
 uint8_t dscp;
+struct eth_addr flow_dl_dst = flow->dl_dst;
+struct eth_addr flow_dl_src = flow->dl_src;
+ovs_be32 flow_packet_type = flow->packet_type;
+ovs_be16 flow_dl_type = flow->dl_type;
 
 /* If 'struct flow' gets additional metadata, we'll need to zero it out
  * before traversing a patch port. */
@@ -3363,13 +3375,6 @@ compose_output_action__(struct xlate_ctx *ctx, 
ofp_port_t ofp_port,
 flow->packet_type = PACKET_TYPE_BE(OFPHTN_ETHERTYPE,
ntohs(flow->dl_type));
 }
-} else {
-/* Add dummy Ethernet header for legacy L2 port. */
-if (xport->pt_mode == NETDEV_PT_LEGACY_L2) {
-flow->packet_type = htonl(PT_ETH);
-flow->dl_dst = eth_addr_zero;
-flow->dl_src = eth_addr_zero;
-}
 }
 
 if (xport->peer) {
@@ -3629,6 +3634,10 @@ compose_output_action__(struct xlate_ctx *ctx, 
ofp_port_t ofp_port,
 /* Restore flow */
 memcpy(flow->vlans, flow_vlans, sizeof flow->vlans);
 flow->nw_tos = flow_nw_tos;
+flow->dl_dst = flow_dl_dst;
+flow->dl_src = flow_dl_src;
+flow->packet_type = flow_packet_type;
+flow->dl_type = flow_dl_type;
 }
 
 static void
diff --git a/tests/packet-type-aware.at b/tests/packet-type-aware.at
index 1104078..a1be7ca 100644
--- a/tests/packet-type-aware.at
+++ b/tests/packet-type-aware.at
@@ -461,3 +461,307 @@ 
aa55aa550003461e7d1a95a108004554f89540004001ac90c0a80a14c0a80a1e0800736f0c1e
 
 OVS_VSWITCHD_STOP(["/The Open vSwitch kernel module is probably not loaded/d"])
 AT_CLEANUP
+
+
+AT_SETUP([ptap - L3 over patch port])
+
+
+# L3 over patch port
+#
+# (192.168.10.10) (192.168.10.30)
+#n0  n1
+# |   |
+#  +--o--+ +--o--+
+#  |   br0   | |   br1   |
+#  +--o--+ +--o---o--+
+#  p0 |p1 |   gre1 (ptap)
+# +---+   10.0.0.1
+#
+# LOCAL
+#  +--o--+
+#  |   br2   |
+#  +--o--+
+# |
+#n2
+# 10.0.0.2
+
+HWADDR_BRP2=aa:55:00:00:00:02
+
+OVS_VSWITCHD_START([dnl
+-- add-br br1 \
+-- set bridge br1 datapath_type=dummy fail-mode=secure \
+-- add-br br2 \
+-- set bridge br2 datapath_type=dummy fail-mode=secure \
+   other_config:hwaddr=\"$HWADDR_BRP2\" \
+-- add-port br0 p0 \
+-- set interface p0 type=patch options:peer=p1 ofport_request=10 \
+-- add-port br1 p1 \
+-- set interface p1 type=patch options:peer=p0 ofport_request=20 \
+-- add-port br0 n0 \
+-- set interface n0 type=dummy ofport_request=30 \
+-- add-port br1 n1 \
+-- set interface n1 type=dummy options:tx_pcap=n1.pcap ofport_request=40 \
+-- add-port br2 n2 \
+-- set interface n2 type=dummy options:tx_pcap=n2.pcap ofport_request=50 \
+-- add-port br1 gre1 \
+-- set interface gre1 type=gre options:remote_ip=10.0.0.2 \
+   options:packet_type=ptap ofport_request=100
+])
+
+### Verify datapath configuration
+AT_CHECK([
+ovs-appctl dpif/show | grep -v hit | sed 's/\t//g' | sed 
's./[[0-9]]\{1,\}..'
+], [0], [dnl
+br0:
+br0 65534: (dummy-internal)
+n0 30: (dummy)
+p0 10/none: (patch: peer=p1)
+br1:
+br1 65534: (dummy-internal)
+gre1 100: (gre: packet_type=ptap, remote_ip=10.0.0.2)
+n1 40: (dummy)
+p1 20/none: (patch: peer=p0)
+br2:
+br2 6553

[ovs-dev] [PATCH 2/4] Translation of generic encap and decap actions

2017-06-30 Thread Zoltán Balogh
From: Jan Scheurich 

This commit implements a skeleton for the translation of generic encap
and decap actions in ofproto-dpif and adds support to encap and decap an
Ethernet header.

In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.

The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.

Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.

Signed-off-by: Jan Scheurich 
Signed-off-by: Yi Yang 
---
 lib/odp-util.c   | 84 +-
 lib/odp-util.h   |  3 +-
 ofproto/ofproto-dpif-xlate.c | 97 +++-
 3 files changed, 153 insertions(+), 31 deletions(-)

diff --git a/lib/odp-util.c b/lib/odp-util.c
index f4c0b66..d9fee4f 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -5862,13 +5862,17 @@ put_ethernet_key(const struct ovs_key_ethernet *eth, 
struct flow *flow)
 }
 
 static void
-commit_set_ether_addr_action(const struct flow *flow, struct flow *base_flow,
- struct ofpbuf *odp_actions,
- struct flow_wildcards *wc,
- bool use_masked)
+commit_set_ether_action(const struct flow *flow, struct flow *base_flow,
+struct ofpbuf *odp_actions,
+struct flow_wildcards *wc,
+bool use_masked)
 {
 struct ovs_key_ethernet key, base, mask;
 
+if (flow->packet_type != htonl(PT_ETH)) {
+return;
+}
+
 get_ethernet_key(flow, );
 get_ethernet_key(base_flow, );
 get_ethernet_key(>masks, );
@@ -5881,29 +5885,6 @@ commit_set_ether_addr_action(const struct flow *flow, 
struct flow *base_flow,
 }
 
 static void
-commit_ether_action(const struct flow *flow, struct flow *base_flow,
-struct ofpbuf *odp_actions, struct flow_wildcards *wc,
-bool use_masked)
-{
-if (flow->packet_type == htonl(PT_ETH)) {
-if (base_flow->packet_type != htonl(PT_ETH)) {
-odp_put_push_eth_action(odp_actions, >dl_src, >dl_dst);
-base_flow->packet_type = flow->packet_type;
-base_flow->dl_src = flow->dl_src;
-base_flow->dl_dst = flow->dl_dst;
-} else {
-commit_set_ether_addr_action(flow, base_flow, odp_actions, wc,
- use_masked);
-}
-} else {
-if (base_flow->packet_type == htonl(PT_ETH)) {
-odp_put_pop_eth_action(odp_actions);
-base_flow->packet_type = flow->packet_type;
-}
-}
-}
-
-static void
 commit_vlan_action(const struct flow* flow, struct flow *base,
struct ofpbuf *odp_actions, struct flow_wildcards *wc)
 {
@@ -6340,6 +6321,50 @@ commit_set_pkt_mark_action(const struct flow *flow, 
struct flow *base_flow,
 }
 }
 
+static void
+commit_packet_type_change(const struct flow *flow,
+  struct flow *base_flow,
+  struct ofpbuf *odp_actions,
+  struct flow_wildcards *wc,
+  bool pending_encap)
+{
+if (flow->packet_type == base_flow->packet_type) {
+return;
+}
+
+if (pending_encap) {
+switch (ntohl(flow->packet_type)) {
+case PT_ETH: {
+/* push_eth */
+odp_put_push_eth_action(odp_actions, >dl_src,
+>dl_dst);
+base_flow->packet_type = flow->packet_type;
+base_flow->dl_src = flow->dl_src;
+base_flow->dl_dst = flow->dl_dst;
+break;
+}
+default:
+/* Only the above protocols are supported for encap. The check
+ * is done at action decoding. */
+OVS_NOT_REACHED();
+}
+} else {
+if (pt_ns(flow->packet_type) == OFPHTN_ETHERTYPE &&
+base_flow->packet_type == htonl(PT_ETH)) {
+/* pop_eth */
+   

[ovs-dev] [PATCH 1/4] Add OF actions for generic encap and decap

2017-06-30 Thread Zoltán Balogh
From: Jan Scheurich 

This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.

CLI syntax for encap action with properties:
  encap(hdr=)
  encap(hdr=,
prop(class=,type=,val=),
prop(class=,type=,val()))

CLI syntax for decap action:
  decap()
  decap(packet_type(ns=,type=))

The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).

Signed-off-by: Jan Scheurich 
Signed-off-by: Yi Yang 
---
 include/openflow/openflow-common.h |   1 +
 include/openvswitch/automake.mk|   1 +
 include/openvswitch/ofp-actions.h  |  31 
 include/openvswitch/ofp-ed-props.h |  69 +++
 include/openvswitch/ofp-errors.h   |   9 +
 lib/automake.mk|   1 +
 lib/ofp-actions.c  | 368 -
 lib/ofp-ed-props.c | 150 +++
 lib/packets.h  |   3 +-
 ofproto/ofproto-dpif-xlate.c   |  11 +-
 10 files changed, 633 insertions(+), 11 deletions(-)
 create mode 100644 include/openvswitch/ofp-ed-props.h
 create mode 100644 lib/ofp-ed-props.c

diff --git a/include/openflow/openflow-common.h 
b/include/openflow/openflow-common.h
index 3a0a575..2776712 100644
--- a/include/openflow/openflow-common.h
+++ b/include/openflow/openflow-common.h
@@ -465,6 +465,7 @@ enum ofp_header_type_namespaces {
 OFPHTN_IP_PROTO = 2,/* ns_type is a IP protocol number. */
 OFPHTN_UDP_TCP_PORT = 3,/* ns_type is a TCP or UDP port. */
 OFPHTN_IPV4_OPTION = 4, /* ns_type is an IPv4 option number. */
+__OFPHTN_MAX
 };
 
 #endif /* openflow/openflow-common.h */
diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk
index 699d9d7..c8e67a2 100644
--- a/include/openvswitch/automake.mk
+++ b/include/openvswitch/automake.mk
@@ -12,6 +12,7 @@ openvswitchinclude_HEADERS = \
include/openvswitch/meta-flow.h \
include/openvswitch/ofpbuf.h \
include/openvswitch/ofp-actions.h \
+   include/openvswitch/ofp-ed-props.h \
include/openvswitch/ofp-errors.h \
include/openvswitch/ofp-msgs.h \
include/openvswitch/ofp-parse.h \
diff --git a/include/openvswitch/ofp-actions.h 
b/include/openvswitch/ofp-actions.h
index 7b4aa92..33021e5 100644
--- a/include/openvswitch/ofp-actions.h
+++ b/include/openvswitch/ofp-actions.h
@@ -25,6 +25,7 @@
 #include "openvswitch/ofp-util.h"
 #include "openvswitch/ofp-errors.h"
 #include "openvswitch/types.h"
+#include "openvswitch/ofp-ed-props.h"
 
 struct vl_mff_map;
 
@@ -89,6 +90,10 @@ struct vl_mff_map;
 OFPACT(PUSH_MPLS,   ofpact_push_mpls,   ofpact, "push_mpls")\
 OFPACT(POP_MPLS,ofpact_pop_mpls,ofpact, "pop_mpls") \
 \
+/* Generic encap & decap */ \
+OFPACT(ENCAP,   ofpact_encap,   props, "encap") \
+OFPACT(DECAP,   ofpact_decap,   ofpact, "decap")\
+\
 /* Metadata. */ \
 OFPACT(SET_TUNNEL,  ofpact_tunnel,  ofpact, "set_tunnel")   \
 OFPACT(SET_QUEUE,   ofpact_queue,   ofpact, "set_queue")\
@@ -969,6 +974,32 @@ struct ofpact_unroll_xlate {
 ovs_be64 rule_cookie; /* OVS_BE64_MAX if none. */
 };
 
+/* OFPACT_ENCAP.
+ *
+ * Used for OFPAT_ENCAP. */
+
+#define OFPACT_ENCAP_MAX_PROP_SIZE 256
+
+struct ofpact_encap {
+struct ofpact ofpact;
+ovs_be32 new_pkt_type;/* Packet type of the header to add. */
+uint16_t hdr_size;/* New header size in bytes. */
+uint16_t n_props; /* Number of encap properties. */
+struct ofpact_ed_prop props[0]; /* Properties in internal format. */
+};
+
+/* OFPACT_DECAP.
+ *
+ * Used for OFPAT_DECAP. */
+struct ofpact_decap {
+struct ofpact ofpact;
+ovs_be32 new_pkt_type; /* New packet type. The special value
+  (0,0xFFFE) "Use next proto" is used to
+  request OvS to automatically set the
+  new packet type based on the decap'ed
+  header's next protocol.*/
+};
+
 /* Converting OpenFlow to ofpacts. */
 enum ofperr ofpacts_pull_openflow_actions(struct ofpbuf *openflow,
   unsigned int actions_len,
diff --git a/include/openvswitch/ofp-ed-props.h 
b/include/openvswitch/ofp-ed-props.h
new file mode 100644
index 000..1db7e56
--- /dev/null
+++ b/include/openvswitch/ofp-ed-props.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017 Intel, Inc.
+ *
+ * Licensed under the Apache License, 

[ovs-dev] [PATCH 0/4] basic encap/decap

2017-06-30 Thread Zoltán Balogh
This series is a continuation of other patch series initiated by Jan Scheurich 
before. These were already applied to the master branch:
 - userspace: Support for L3 tunneling
   https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/87.html
 - Packet type aware pipeline
   https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/334512.html

The main purpose of this series is to add support for the OpenFlow actions 
generic encap and decap (ONF EXT-382) to the OVS control plane. It implements
a skeleton for translation of generic encap and decap actions in ofproto-dpif
and provides support to encap and decap an Ethernet header. Furthermore it 
contains bug fixes.

Jan Scheurich (2)
 Add OF actions for generic encap and decap.
 Translation of generic encap and decap actions.
 
Zoltán Balogh (2)
 ofproto-dpif-xlate: drop L3 packets on L2 legacy port.
 netdev: fix crash when interface option is changed to invalid value.

 include/openflow/openflow-common.h |   1 +
 include/openvswitch/automake.mk|   1 +
 include/openvswitch/ofp-actions.h  |  31 
 include/openvswitch/ofp-ed-props.h |  69 +++
 include/openvswitch/ofp-errors.h   |   9 +
 lib/automake.mk|   1 +
 lib/netdev.c   |   6 +-
 lib/odp-util.c |  84 ++---
 lib/odp-util.h |   3 +-
 lib/ofp-actions.c  | 368 -
 lib/ofp-ed-props.c | 150 +++
 lib/packets.h  |   3 +-
 ofproto/ofproto-dpif-xlate.c   | 129 -
 tests/packet-type-aware.at | 304 ++
 14 files changed, 1109 insertions(+), 50 deletions(-)
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v4 7/7] userspace: Introduce packet_type in OF 1.5 packet-out

2017-06-23 Thread Zoltán Balogh
Introducing packet_type in OF 1.5 packet-out.
Partly based on Jean Tourrilhes's work.

Add test cases for OF1.5 packet-out
Add negative test case for OF1.5 packet-out

Signed-off-by: Jean Tourrilhes 
Signed-off-by: Zoltan Balogh 
Co-authored-by: Jan Scheurich 
Signed-off-by: Ben Pfaff 
---
 lib/flow.c| 36 +--
 lib/ofp-parse.c   | 13 +
 lib/ofp-print.c   |  4 +--
 lib/ofp-util.c|  2 ++
 ofproto/ofproto.c |  3 ++
 tests/ofproto.at  | 81 +++
 utilities/ovs-ofctl.c |  1 +
 7 files changed, 123 insertions(+), 17 deletions(-)

diff --git a/lib/flow.c b/lib/flow.c
index dbca4d03d..75a91cc6a 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -1441,6 +1441,8 @@ void
 flow_wildcards_init_for_packet(struct flow_wildcards *wc,
const struct flow *flow)
 {
+ovs_be16 dl_type = OVS_BE16_MAX;
+
 memset(>masks, 0x0, sizeof wc->masks);
 
 /* Update this function whenever struct flow changes. */
@@ -1493,25 +1495,29 @@ flow_wildcards_init_for_packet(struct flow_wildcards 
*wc,
 /* actset_output wildcarded. */
 
 WC_MASK_FIELD(wc, packet_type);
-WC_MASK_FIELD(wc, dl_dst);
-WC_MASK_FIELD(wc, dl_src);
-WC_MASK_FIELD(wc, dl_type);
-
-/* No need to set mask of inner VLANs that don't exist. */
-for (int i = 0; i < FLOW_MAX_VLAN_HEADERS; i++) {
-/* Always show the first zero VLAN. */
-WC_MASK_FIELD(wc, vlans[i]);
-if (flow->vlans[i].tci == htons(0)) {
-break;
+if (flow->packet_type == htonl(PT_ETH)) {
+WC_MASK_FIELD(wc, dl_dst);
+WC_MASK_FIELD(wc, dl_src);
+WC_MASK_FIELD(wc, dl_type);
+/* No need to set mask of inner VLANs that don't exist. */
+for (int i = 0; i < FLOW_MAX_VLAN_HEADERS; i++) {
+/* Always show the first zero VLAN. */
+WC_MASK_FIELD(wc, vlans[i]);
+if (flow->vlans[i].tci == htons(0)) {
+break;
+}
 }
+dl_type = flow->dl_type;
+} else {
+dl_type = pt_ns_type_be(flow->packet_type);
 }
 
-if (flow->dl_type == htons(ETH_TYPE_IP)) {
+if (dl_type == htons(ETH_TYPE_IP)) {
 WC_MASK_FIELD(wc, nw_src);
 WC_MASK_FIELD(wc, nw_dst);
 WC_MASK_FIELD(wc, ct_nw_src);
 WC_MASK_FIELD(wc, ct_nw_dst);
-} else if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
+} else if (dl_type == htons(ETH_TYPE_IPV6)) {
 WC_MASK_FIELD(wc, ipv6_src);
 WC_MASK_FIELD(wc, ipv6_dst);
 WC_MASK_FIELD(wc, ipv6_label);
@@ -1523,15 +1529,15 @@ flow_wildcards_init_for_packet(struct flow_wildcards 
*wc,
 WC_MASK_FIELD(wc, ct_ipv6_src);
 WC_MASK_FIELD(wc, ct_ipv6_dst);
 }
-} else if (flow->dl_type == htons(ETH_TYPE_ARP) ||
-   flow->dl_type == htons(ETH_TYPE_RARP)) {
+} else if (dl_type == htons(ETH_TYPE_ARP) ||
+   dl_type == htons(ETH_TYPE_RARP)) {
 WC_MASK_FIELD(wc, nw_src);
 WC_MASK_FIELD(wc, nw_dst);
 WC_MASK_FIELD(wc, nw_proto);
 WC_MASK_FIELD(wc, arp_sha);
 WC_MASK_FIELD(wc, arp_tha);
 return;
-} else if (eth_type_mpls(flow->dl_type)) {
+} else if (eth_type_mpls(dl_type)) {
 for (int i = 0; i < FLOW_MAX_MPLS_LABELS; i++) {
 WC_MASK_FIELD(wc, mpls_lse[i]);
 if (flow->mpls_lse[i] & htonl(MPLS_BOS_MASK)) {
diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index 8e2448b20..528b75b4f 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -667,6 +667,19 @@ parse_ofp_packet_out_str__(struct ofputil_packet_out *po, 
char *string,
 goto out;
 }
 match_set_in_port(>flow_metadata, in_port);
+} else if (!strcmp(name, "packet_type")) {
+char *ns = value;
+char *ns_type = strstr(value, ",");
+if (ns_type) {
+ovs_be32 packet_type;
+*ns_type = '\0';
+packet_type = PACKET_TYPE_BE(strtoul(ns, NULL, 0),
+ strtoul(++ns_type, NULL, 0));
+match_set_packet_type(>flow_metadata, packet_type);
+} else {
+error = xasprintf("%s(%s) can't be interpreted", name, value);
+goto out;
+}
 } else if (!strcmp(name, "packet")) {
 const char *error_msg = eth_from_hex(value, );
 if (error_msg) {
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 8a6c54e1d..4370cb522 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -256,9 +256,9 @@ ofp_print_packet_out(struct ds *string, const struct 
ofp_header *oh,
 if (po.buffer_id == UINT32_MAX) {
 ds_put_format(string, " data_len=%"PRIuSIZE, po.packet_len);
 if (verbosity > 0 && po.packet_len > 0) {
-/* 

[ovs-dev] [PATCH v4 5/7] tests: Added unit tests in packet-type-aware.at

2017-06-23 Thread Zoltán Balogh
From: Jan Scheurich 

First and second unit tests perform basic verification.

The third one is a triangular bridge setup test case. It tests dataplane
in non-PTAP and ptap bridges in conjunction with L2 and L3 GRE tunnels.
It uses veth ports, therefore requires root privileges.

A simplified version of the third test is added to system userspace unit tests.

 GRE tunneling test setup for PTAP bridge

 192.168.10.10   192.168.10.20 192.168.10.30
  n1   n2n3
  || |
   +--o--+  +--o--+   +--o--+
   |br-in1   |  |br-in2   |   |br-in3   |
   | |  |   (PTAP)|   | |
   +--o--+  +--o--+   +--o--+
 gre  gre   gre
   10.0.0.1(10.0.0.2)(10.0.0.3)
  (20.0.0.1)20.0.0.2 (20.0.0.3)
  (30.0.0.1) LOCAL (30.0.0.2) LOCAL   30.0.0.3  LOCAL
   +---o-+  +---o-+   +---o-+
   |br-p1|  |br-p2|   |br-p3|
   +--o--+  +--o--+   +--o--+
 p1-0 || p2-0| p3-0
 p0-1 || p0-2| p0-3
   +--oo-o--+
   |  br0   |
   ++

   GRE tunnel ports:
  No Bridge  NamePacket-Type Remote bridge & ports
 ---
  1020   br-in1  gre-12  legacy-l2   br-in2 2010 (ptap)
  1021   br-in1  gre-12_l3   legacy-l3 same
  1030   br-in1  gre-13  legacy-l2   br-in3 3010 (l2)
  2010   br-in2  gre-21  ptapbr-in1 1020 (l2), 1021 (l3)
  2030   br-in2  gre-23  ptapbr-in3 3020 (l2), 3021 (l3)
  3010   br-in1  gre-31  legacy-l2   br-in1 1030 (l2)
  3020   br-in1  gre-32  legacy-l2   br-in2 2010 (ptap)
  3021   br-in1  gre-32_l3   legacy-l3 same

Signed-off-by: Jan Scheurich 
Signed-off-by: Ben Pfaff 
---
 tests/automake.mk   |   6 +-
 tests/packet-type-aware.at  | 463 
 tests/system-userspace-packet-type-aware.at | 418 +
 tests/system-userspace-testsuite.at |   1 +
 tests/testsuite.at  |   1 +
 5 files changed, 887 insertions(+), 2 deletions(-)
 create mode 100644 tests/packet-type-aware.at
 create mode 100644 tests/system-userspace-packet-type-aware.at

diff --git a/tests/automake.mk b/tests/automake.mk
index a13b55e47..3118bbc27 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -98,7 +98,8 @@ TESTSUITE_AT = \
tests/ovn-sbctl.at \
tests/ovn-controller.at \
tests/ovn-controller-vtep.at \
-   tests/mcast-snooping.at
+   tests/mcast-snooping.at \
+   tests/packet-type-aware.at
 
 SYSTEM_KMOD_TESTSUITE_AT = \
tests/system-common-macros.at \
@@ -108,7 +109,8 @@ SYSTEM_KMOD_TESTSUITE_AT = \
 SYSTEM_USERSPACE_TESTSUITE_AT = \
tests/system-userspace-testsuite.at \
tests/system-ovn.at \
-   tests/system-userspace-macros.at
+   tests/system-userspace-macros.at \
+   tests/system-userspace-packet-type-aware.at
 
 SYSTEM_TESTSUITE_AT = \
tests/system-common-macros.at \
diff --git a/tests/packet-type-aware.at b/tests/packet-type-aware.at
new file mode 100644
index 0..110407857
--- /dev/null
+++ b/tests/packet-type-aware.at
@@ -0,0 +1,463 @@
+AT_BANNER([packet-type-aware pipeline])
+
+AT_SETUP([ptap - legal flow entries in ptap bridge])
+
+OVS_VSWITCHD_START
+
+AT_CHECK([
+ovs-ofctl del-flows br0
+ovs-ofctl -Oopenflow13 add-flow br0 
priority=1,dl_src=11:22:33:44:55:66,eth_type=0x1234,actions=drop
+ovs-ofctl -Oopenflow14 add-flow br0 
priority=1,ip,nw_dst=10.11.12.13,actions=drop
+ovs-ofctl -Oopenflow15 add-flow br0 priority=1,ipv6,nw_proto=6,actions=drop
+ovs-ofctl -Oopenflow14 add-flow br0 
priority=2,packet_type=\(0,0x0\),dl_src=11:22:33:44:55:66,dl_type=0x4567,actions=drop
+ovs-ofctl -Oopenflow15 add-flow br0 
priority=2,packet_type=\(0,0x0\),arp,arp_tpa=10.11.12.13,actions=drop
+ovs-ofctl -Oopenflow15 add-flow br0 
priority=3,packet_type=\(1,0x806\),arp_tpa=10.11.12.13,actions=drop
+ovs-ofctl -Oopenflow13 add-flow br0 
priority=3,packet_type=\(1,0x800\),nw_dst=10.11.12.13,actions=drop
+ovs-ofctl -Oopenflow14 add-flow br0 

[ovs-dev] [PATCH v4 6/7] userspace: Complete Packet In handling

2017-06-23 Thread Zoltán Balogh
From: Jan Scheurich 

Send packet_in for non-Ethernet packets.
Include packet_type in Packet In for ptap bridges.

Signed-off-by: Jan Scheurich 
Signed-off-by: Ben Pfaff 
---
 lib/flow.c   | 4 
 lib/ofp-print.c  | 7 +++
 ofproto/ofproto-dpif-xlate.c | 5 -
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/lib/flow.c b/lib/flow.c
index 6be645730..dbca4d03d 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -994,6 +994,10 @@ flow_get_metadata(const struct flow *flow, struct match 
*flow_metadata)
 }
 
 match_set_in_port(flow_metadata, flow->in_port.ofp_port);
+if (flow->packet_type != htonl(PT_ETH)) {
+match_set_packet_type(flow_metadata, flow->packet_type);
+}
+
 if (flow->ct_state != 0) {
 match_set_ct_state(flow_metadata, flow->ct_state);
 if (is_ct_valid(flow, NULL, NULL) && flow->ct_nw_proto != 0) {
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index b1c412ea4..8a6c54e1d 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -218,10 +218,9 @@ ofp_print_packet_in(struct ds *string, const struct 
ofp_header *oh,
 }
 
 if (verbosity > 0) {
-/* Packet In can only carry Ethernet packets. */
-char *packet = ofp_packet_to_string(public->packet,
-public->packet_len,
-htonl(PT_ETH));
+char *packet = ofp_packet_to_string(
+public->packet, public->packet_len,
+public->flow_metadata.flow.packet_type);
 ds_put_cstr(string, packet);
 free(packet);
 }
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index ce364b361..1f4fe1dd6 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -4259,11 +4259,6 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
 return;
 }
 
-if (packet->packet_type != htonl(PT_ETH)) {
-dp_packet_delete(packet);
-return;
-}
-
 /* A packet sent by an action in a table-miss rule is considered an
  * explicit table miss.  OpenFlow before 1.3 doesn't have that concept so
  * it will get translated back to OFPR_ACTION for those versions. */
-- 
2.11.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v4 3/7] userspace: Add OXM field MFF_PACKET_TYPE

2017-06-23 Thread Zoltán Balogh
From: Jan Scheurich 

Allow packet type namespace OFPHTN_ETHERTYPE as alternative pre-requisite
for matching L3 protocols (MPLS, IP, IPv6, ARP etc).

Change the meta-flow definition of packet_type field to use the new
custom format MFS_PACKET_TYPE representing "(NS,NS_TYPE)".

Parsing routine for MFS_PACKET_TYPE added to meta-flow.c. Formatting
routine for field packet_type extracted from match_format() and moved to
flow.c to be used from meta-flow.c for formatting MFS_PACKET_TYPE.

Updated the ovs-fields man page source meta-flow.xml with documentation
for packet-type-aware bridges and added documentation for field packet_type.

Added packet_type to the matching properties in tests/ofproto.at.

If dl_type is unwildcarded due to later packet modification, make sure it
is cleared again if the original packet_type was not PT_ETH.

Signed-off-by: Jan Scheurich 
Signed-off-by: Ben Pfaff 
---
 build-aux/extract-ofp-fields|   3 +-
 include/openvswitch/match.h |   5 +
 include/openvswitch/meta-flow.h |  20 
 lib/flow.c  |  34 +-
 lib/flow.h  |  27 +++--
 lib/learn.c |   1 +
 lib/match.c |  98 +++--
 lib/meta-flow.c |  86 +--
 lib/meta-flow.xml   | 156 +++
 lib/nx-match.c  |  34 +-
 lib/odp-util.c  |  38 +++
 lib/ofp-parse.c |  12 +++
 lib/ofp-util.c  |  67 +---
 ofproto/ofproto-dpif-xlate.c|   6 +-
 ofproto/tunnel.c|   2 -
 tests/dpif-netdev.at|  89 
 tests/odp.at|   1 +
 tests/ofproto-dpif.at   | 230 
 tests/ofproto.at|   1 +
 tests/ovs-ofctl.at  |   2 +-
 tests/pmd.at|   8 +-
 tests/tunnel-push-pop-ipv6.at   |   2 +-
 tests/tunnel-push-pop.at|   2 +-
 tests/tunnel.at |  18 ++--
 24 files changed, 657 insertions(+), 285 deletions(-)

diff --git a/build-aux/extract-ofp-fields b/build-aux/extract-ofp-fields
index d5b8a8202..24dd756ad 100755
--- a/build-aux/extract-ofp-fields
+++ b/build-aux/extract-ofp-fields
@@ -36,7 +36,8 @@ FORMATTING = {"decimal":("MFS_DECIMAL",  1,   
8),
   "OpenFlow 1.1+ port": ("MFS_OFP_PORT_OXM", 4,   4),
   "frag":   ("MFS_FRAG", 1,   1),
   "tunnel flags":   ("MFS_TNL_FLAGS",2,   2),
-  "TCP flags":  ("MFS_TCP_FLAGS",2,   2)}
+  "TCP flags":  ("MFS_TCP_FLAGS",2,   2),
+  "packet type":("MFS_PACKET_TYPE",  4,   4)}
 
 PREREQS = {"none": "MFP_NONE",
"Ethernet": "MFP_ETHERNET",
diff --git a/include/openvswitch/match.h b/include/openvswitch/match.h
index 70da928fe..aca725265 100644
--- a/include/openvswitch/match.h
+++ b/include/openvswitch/match.h
@@ -23,6 +23,7 @@
 
 struct ds;
 struct ofputil_port_map;
+struct mf_field;
 
 /* A flow classification match.
  *
@@ -119,6 +120,10 @@ void match_set_ct_ipv6_dst_masked(struct match *, const 
struct in6_addr *,
   const struct in6_addr *);
 
 void match_set_packet_type(struct match *, ovs_be32 packet_type);
+void match_set_default_packet_type(struct match *);
+bool match_has_default_packet_type(const struct match *);
+void match_add_ethernet_prereq(struct match *, const struct mf_field *);
+
 void match_set_skb_priority(struct match *, uint32_t skb_priority);
 void match_set_dl_type(struct match *, ovs_be16);
 void match_set_dl_src(struct match *, const struct eth_addr );
diff --git a/include/openvswitch/meta-flow.h b/include/openvswitch/meta-flow.h
index cbfd3ba65..fc109501d 100644
--- a/include/openvswitch/meta-flow.h
+++ b/include/openvswitch/meta-flow.h
@@ -133,6 +133,11 @@ struct ofputil_tlv_table_mod;
  *
  *   TCP flags: See the description of tcp_flags in ovs-ofctl(8).
  *
+ *   packet type: A pair of packet type namespace NS and NS_TYPE within
+ *   that namespace "(NS,NS_TYPE)". NS and NS_TYPE are formatted in
+ *   decimal or hexadecimal as and accept decimal and hexadecimal (with
+ *   0x prefix) at parsing.
+ *
  *   Prerequisites:
  *
  * The field's prerequisites.  The values should be straightfoward.
@@ -248,6 +253,20 @@ enum OVS_PACKED_ENUM mf_field_id {
  */
 MFF_RECIRC_ID,
 
+/* "packet_type".
+ *
+ * Define the packet type in OpenFlow 1.5+.
+ *
+ * Type: be32.
+ * Maskable: no.
+ * Formatting: packet type.
+ * Prerequisites: none.
+ * Access: read-only.
+ * NXM: none.
+ * OXM: OXM_OF_PACKET_TYPE(44) since OF1.5 and v2.8.
+ */
+MFF_PACKET_TYPE,
+
 /* "conj_id".
  *
  * ID for "conjunction" actions.  Please refer to ovs-ofctl(8)
@@ -1860,6 

[ovs-dev] [PATCH v4 4/7] userspace: Handling of versatile tunnel ports

2017-06-23 Thread Zoltán Balogh
From: Ben Pfaff 

In netdev_gre_build_header(), GRE protocol and VXLAN next_potocol is set based
on packet_type of flow. If it's about an Ethernet packet, it is set to
ETP_TYPE_TEB. Otherwise, if the name space is OFPHTN_ETHERNET, it is set
according to the name space type.

Signed-off-by: Jan Scheurich 
Signed-off-by: Ben Pfaff 
---
 NEWS  |   6 +--
 lib/meta-flow.xml |  30 ++--
 lib/netdev-bsd.c  |   1 +
 lib/netdev-dpdk.c |   1 +
 lib/netdev-dummy.c|   1 +
 lib/netdev-linux.c|   1 +
 lib/netdev-native-tnl.c   |  23 ++---
 lib/netdev-provider.h |   6 +++
 lib/netdev-vport.c| 106 ++
 lib/netdev-vport.h|   1 -
 lib/netdev.c  |   8 
 lib/netdev.h  |  29 +++-
 ofproto/ofproto-dpif-xlate.c  |  35 --
 ofproto/ofproto-dpif.c|   4 +-
 ofproto/tunnel.c  |  27 ---
 tests/tunnel-push-pop-ipv6.at |   4 +-
 tests/tunnel-push-pop.at  |   4 +-
 vswitchd/vswitch.xml  |  94 ++---
 18 files changed, 279 insertions(+), 102 deletions(-)

diff --git a/NEWS b/NEWS
index 4ea7e628e..0f2604ff5 100644
--- a/NEWS
+++ b/NEWS
@@ -59,11 +59,9 @@ Post-v2.7.0
  * OVN services are no longer restarted automatically after upgrade.
- Add --cleanup option to command 'ovs-appctl exit' (see ovs-vswitchd(8)).
- L3 tunneling:
- * Add "layer3" options for tunnel ports that support non-Ethernet (L3)
-   payload (GRE, VXLAN-GPE).
+ * Use new tunnel port option "packet_type" to configure L2 vs. L3.
  * New vxlan tunnel extension "gpe" to support VXLAN-GPE tunnels.
- * Transparently pop and push Ethernet headers at transmit/reception
-   of packets to/from L3 tunnels.
+ * New support for non-Ethernet (L3) payloads in GRE and VXLAN-GPE.
- The BFD detection multiplier is now user-configurable.
- Add experimental support for hardware offloading
  * HW offloading is disabled by default.
diff --git a/lib/meta-flow.xml b/lib/meta-flow.xml
index 856e1ba8c..634ab69e4 100644
--- a/lib/meta-flow.xml
+++ b/lib/meta-flow.xml
@@ -26,19 +26,27 @@
 networking technology in use are called called root fields.
 Open vSwitch 2.7 and earlier considered Ethernet fields to be root fields,
 and this remains the default mode of operation for Open vSwitch bridges.
-In this mode, when a packet is received from a non-Ethernet interfaces,
-such as a layer-3 LISP or GRE tunnel, Open vSwitch force-fits it to this
+When a packet is received from a non-Ethernet interfaces, such as a layer-3
+LISP tunnel, Open vSwitch 2.7 and earlier force-fit the packet to this
 Ethernet-centric point of view by pretending that an Ethernet header is
 present whose Ethernet type that indicates the packet's actual type (and
 whose source and destination addresses are all-zero).
   
 
   
-Open vSwitch 2.8 and later supports the ``packet type-aware pipeline''
-concept introduced in OpenFlow 1.5.  A bridge configured to be packet
-type-aware can handle packets of multiple networking technologies, such as
-Ethernet, IP, ARP, MPLS, or NSH in parallel.  Such a bridge does not have
-any root fields.
+Open vSwitch 2.8 and later implement the ``packet type-aware pipeline''
+concept introduced in OpenFlow 1.5.  Such a pipeline does not have any root
+fields.  Instead, a new metadata field, ,
+indicates the basic type of the packet, which can be Ethernet, IPv4, IPv6,
+or another type.  For backward compatibility, by default Open vSwitch 2.8
+imitates the behavior of Open vSwitch 2.7 and earlier.  Later versions of
+Open vSwitch may change the default, and in the meantime controllers can
+turn off this legacy behavior, on a port-by-port basis, by setting
+options:packet_type to ptap in the
+Interface table.  This is significant only for ports that can
+handle non-Ethernet packets, which is currently just LISP, VXLAN-GPE, and
+GRE tunnel ports.  See ovs-vwitchd.conf.db(5) for more
+information.
   
 
   
@@ -332,14 +340,6 @@ tcp,tp_src=0x07c0/0xfff0
 mplsm  eth_type=0x8848
   
 
-  
-These shorthand notations continue to work in packet type-aware bridges.
-The absence of a packet_type match implies
-packet_type=ethernet, so that shorthands match on Ethernet
-packets with the implied eth_type. Please note that the shorthand
-ip does not match packets of packet_type (1,0x800) for IPv4.
-  
-
 
   Evolution of OpenFlow Fields
 
diff --git a/lib/netdev-bsd.c b/lib/netdev-bsd.c
index f863a189c..6cc83d347 100644
--- a/lib/netdev-bsd.c
+++ b/lib/netdev-bsd.c
@@ -1517,6 +1517,7 @@ netdev_bsd_update_flags(struct netdev *netdev_, enum 
netdev_flags off,
  

[ovs-dev] [PATCH v4 2/7] nx-match: Add context argument to nxm_put__().

2017-06-23 Thread Zoltán Balogh
From: Ben Pfaff 

An upcoming commit will need to pass an extra piece of data from
nx_put_raw() into all of its direct and indirect calls to nxm_put__().
This commit prepares for that by switching from a "struct ofpbuf *"
parameter to a context structure that, currently, contains just a
struct ofpbuf *.  The upcoming commit will add another member to the
context struct.

This commit has no visible effect on behavior.

Signed-off-by: Ben Pfaff 
---
 lib/nx-match.c | 232 +
 lib/nx-match.h |   6 +-
 lib/tun-metadata.c |   4 +-
 3 files changed, 131 insertions(+), 111 deletions(-)

diff --git a/lib/nx-match.c b/lib/nx-match.c
index 334ecd4a3..6278b7758 100644
--- a/lib/nx-match.c
+++ b/lib/nx-match.c
@@ -772,203 +772,222 @@ oxm_pull_field_array(const void *fields_data, size_t 
fields_len,
  * 'put' functions whose names end in 'm' add a field that might be wildcarded.
  * Other 'put' functions add exact-match fields.
  */
+
+struct nxm_put_ctx {
+struct ofpbuf *output;
+};
+
 void
-nxm_put__(struct ofpbuf *b, enum mf_field_id field, enum ofp_version version,
-  const void *value, const void *mask, size_t n_bytes)
+nxm_put_entry_raw(struct ofpbuf *b,
+  enum mf_field_id field, enum ofp_version version,
+  const void *value, const void *mask, size_t n_bytes)
 {
 nx_put_header_len(b, field, version, !!mask, n_bytes);
 ofpbuf_put(b, value, n_bytes);
 if (mask) {
 ofpbuf_put(b, mask, n_bytes);
 }
+}
 
+static void
+nxm_put__(struct nxm_put_ctx *ctx,
+  enum mf_field_id field, enum ofp_version version,
+  const void *value, const void *mask, size_t n_bytes)
+{
+nxm_put_entry_raw(ctx->output, field, version, value, mask, n_bytes);
 }
 
 static void
-nxm_put(struct ofpbuf *b, enum mf_field_id field, enum ofp_version version,
+nxm_put(struct nxm_put_ctx *ctx,
+enum mf_field_id field, enum ofp_version version,
 const void *value, const void *mask, size_t n_bytes)
 {
 if (!is_all_zeros(mask, n_bytes)) {
 bool masked = !is_all_ones(mask, n_bytes);
-nxm_put__(b, field, version, value, masked ? mask : NULL, n_bytes);
+nxm_put__(ctx, field, version, value, masked ? mask : NULL, n_bytes);
 }
 }
 
 static void
-nxm_put_8m(struct ofpbuf *b, enum mf_field_id field, enum ofp_version version,
+nxm_put_8m(struct nxm_put_ctx *ctx,
+   enum mf_field_id field, enum ofp_version version,
uint8_t value, uint8_t mask)
 {
-nxm_put(b, field, version, , , sizeof value);
+nxm_put(ctx, field, version, , , sizeof value);
 }
 
 static void
-nxm_put_8(struct ofpbuf *b, enum mf_field_id field, enum ofp_version version,
-  uint8_t value)
+nxm_put_8(struct nxm_put_ctx *ctx,
+  enum mf_field_id field, enum ofp_version version, uint8_t value)
 {
-nxm_put__(b, field, version, , NULL, sizeof value);
+nxm_put__(ctx, field, version, , NULL, sizeof value);
 }
 
 static void
-nxm_put_16m(struct ofpbuf *b, enum mf_field_id field, enum ofp_version version,
+nxm_put_16m(struct nxm_put_ctx *ctx,
+enum mf_field_id field, enum ofp_version version,
 ovs_be16 value, ovs_be16 mask)
 {
-nxm_put(b, field, version, , , sizeof value);
+nxm_put(ctx, field, version, , , sizeof value);
 }
 
 static void
-nxm_put_16(struct ofpbuf *b, enum mf_field_id field, enum ofp_version version,
-   ovs_be16 value)
+nxm_put_16(struct nxm_put_ctx *ctx,
+   enum mf_field_id field, enum ofp_version version, ovs_be16 value)
 {
-nxm_put__(b, field, version, , NULL, sizeof value);
+nxm_put__(ctx, field, version, , NULL, sizeof value);
 }
 
 static void
-nxm_put_32m(struct ofpbuf *b, enum mf_field_id field, enum ofp_version version,
+nxm_put_32m(struct nxm_put_ctx *ctx,
+enum mf_field_id field, enum ofp_version version,
 ovs_be32 value, ovs_be32 mask)
 {
-nxm_put(b, field, version, , , sizeof value);
+nxm_put(ctx, field, version, , , sizeof value);
 }
 
 static void
-nxm_put_32(struct ofpbuf *b, enum mf_field_id field, enum ofp_version version,
-   ovs_be32 value)
+nxm_put_32(struct nxm_put_ctx *ctx,
+   enum mf_field_id field, enum ofp_version version, ovs_be32 value)
 {
-nxm_put__(b, field, version, , NULL, sizeof value);
+nxm_put__(ctx, field, version, , NULL, sizeof value);
 }
 
 static void
-nxm_put_64m(struct ofpbuf *b, enum mf_field_id field, enum ofp_version version,
+nxm_put_64m(struct nxm_put_ctx *ctx,
+enum mf_field_id field, enum ofp_version version,
 ovs_be64 value, ovs_be64 mask)
 {
-nxm_put(b, field, version, , , sizeof value);
+nxm_put(ctx, field, version, , , sizeof value);
 }
 
 static void
-nxm_put_128m(struct ofpbuf *b,
+nxm_put_128m(struct nxm_put_ctx *ctx,
  enum mf_field_id field, enum ofp_version version,
  const ovs_be128 value, 

[ovs-dev] [PATCH v4 1/7] ofpbuf: New function ofpbuf_insert().

2017-06-23 Thread Zoltán Balogh
From: Ben Pfaff 

This will receive its first users in an upcoming commit.

Signed-off-by: Ben Pfaff 
---
 include/openvswitch/ofpbuf.h |  1 +
 lib/ofpbuf.c | 18 ++
 2 files changed, 19 insertions(+)

diff --git a/include/openvswitch/ofpbuf.h b/include/openvswitch/ofpbuf.h
index bc25bb8a1..6142f4a58 100644
--- a/include/openvswitch/ofpbuf.h
+++ b/include/openvswitch/ofpbuf.h
@@ -141,6 +141,7 @@ void ofpbuf_reserve(struct ofpbuf *, size_t);
 void *ofpbuf_push_uninit(struct ofpbuf *b, size_t);
 void *ofpbuf_push_zeros(struct ofpbuf *, size_t);
 void *ofpbuf_push(struct ofpbuf *b, const void *, size_t);
+void ofpbuf_insert(struct ofpbuf *b, size_t offset, const void *data, size_t);
 
 static inline size_t ofpbuf_headroom(const struct ofpbuf *);
 static inline size_t ofpbuf_tailroom(const struct ofpbuf *);
diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c
index f4a904064..9c0623688 100644
--- a/lib/ofpbuf.c
+++ b/lib/ofpbuf.c
@@ -461,6 +461,24 @@ ofpbuf_push(struct ofpbuf *b, const void *p, size_t size)
 return dst;
 }
 
+/* Inserts the 'n' bytes of 'data' into 'b' starting at the given 'offset',
+ * moving data forward as necessary to make room.
+ *
+ * 'data' must not point inside 'b'. */
+void
+ofpbuf_insert(struct ofpbuf *b, size_t offset, const void *data, size_t n)
+{
+if (offset < b->size) {
+ofpbuf_put_uninit(b, n);
+memmove((char *) b->data + offset + n, (char *) b->data + offset,
+b->size - offset);
+memcpy((char *) b->data + offset, data, n);
+} else {
+ovs_assert(offset == b->size);
+ofpbuf_put(b, data, n);
+}
+}
+
 /* Returns the data in 'b' as a block of malloc()'d memory and frees the buffer
  * within 'b'.  (If 'b' itself was dynamically allocated, e.g. with
  * ofpbuf_new(), then it should still be freed with, e.g., ofpbuf_delete().) */
-- 
2.11.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v4 0/7] Packet type aware pipeline

2017-06-23 Thread Zoltán Balogh

This series was started by Ben Pfaff, v3 can be found here:
https://patchwork.ozlabs.org/patch/778070/
https://patchwork.ozlabs.org/patch/778071/
https://patchwork.ozlabs.org/patch/778076/
https://patchwork.ozlabs.org/patch/778072/
https://patchwork.ozlabs.org/patch/778074/
https://patchwork.ozlabs.org/patch/778073/
https://patchwork.ozlabs.org/patch/778075/

Ben's series is based on this one:
https://patchwork.ozlabs.org/patch/770490/
https://patchwork.ozlabs.org/patch/770487/
https://patchwork.ozlabs.org/patch/770495/
https://patchwork.ozlabs.org/patch/770498/
https://patchwork.ozlabs.org/patch/770488/
https://patchwork.ozlabs.org/patch/770489/

v1->v2:
  - Squash fixup patches.
  - Apply changes agreed with Jan.
  - Not yet done: Figure out whether to really show packet_type in (some)
match_format() output.
  - New patch at the end unsuccessfully tries to re-enable packet-aware
test.  Either I don't have enough insight yet, or it just reveals a
bug or two.
  - 4 new patches at beginning.  First one is trivial.  Next 3 are intended
to make it easier to debug the packet aware test that is still failing.
Jan, you don't have to feel obligated to review these if you feel they
are off-topic; I will get separate reviews.

v2->v3:
  - Drop first two patches, which have been applied to master.
  - Drop patches 3 and 4, which have been moved to a new series.
  - Drop last patch, which was incomplete.  I'll hope that Jan or Zoltan
can pick it back up.
  - Apply Jan's and Zoltan's comments on a few other patches.

v3->v4:
  - Rebase to recent origin/master (0722f3410).
  - Re-introduce packet-type aware unit tests.
  - Unwildcard dl_type only for packet_type=PT_ETH.
  - Apply comments.

Ben Pfaff (3):
  ofpbuf: New function ofpbuf_insert().
  nx-match: Add context argument to nxm_put__().
  userspace: Handling of versatile tunnel ports

Jan Scheurich (3):
  userspace: Add OXM field MFF_PACKET_TYPE
  tests: Added unit tests in packet-type-aware.at
  userspace: Complete Packet In handling

Zoltán Balogh (1):
  userspace: Introduce packet_type in OF 1.5 packet-out

 NEWS|   6 +-
 build-aux/extract-ofp-fields|   3 +-
 include/openvswitch/match.h |   5 +
 include/openvswitch/meta-flow.h |  20 ++
 include/openvswitch/ofpbuf.h|   1 +
 lib/flow.c  |  74 -
 lib/flow.h  |  27 +-
 lib/learn.c |   1 +
 lib/match.c |  98 --
 lib/meta-flow.c |  86 +-
 lib/meta-flow.xml   | 156 --
 lib/netdev-bsd.c|   1 +
 lib/netdev-dpdk.c   |   1 +
 lib/netdev-dummy.c  |   1 +
 lib/netdev-linux.c  |   1 +
 lib/netdev-native-tnl.c |  23 +-
 lib/netdev-provider.h   |   6 +
 lib/netdev-vport.c  | 106 +--
 lib/netdev-vport.h  |   1 -
 lib/netdev.c|   8 +
 lib/netdev.h|  29 +-
 lib/nx-match.c  | 264 +---
 lib/nx-match.h  |   6 +-
 lib/odp-util.c  |  38 +--
 lib/ofp-parse.c |  25 ++
 lib/ofp-print.c |  11 +-
 lib/ofp-util.c  |  69 -
 lib/ofpbuf.c|  18 ++
 lib/tun-metadata.c  |   4 +-
 ofproto/ofproto-dpif-xlate.c|  46 +--
 ofproto/ofproto-dpif.c  |   4 +-
 ofproto/ofproto.c   |   3 +
 ofproto/tunnel.c|  29 +-
 tests/automake.mk   |   6 +-
 tests/dpif-netdev.at|  89 +++---
 tests/odp.at|   1 +
 tests/ofproto-dpif.at   | 230 +++---
 tests/ofproto.at|  82 +
 tests/ovs-ofctl.at  |   2 +-
 tests/packet-type-aware.at  | 463 
 tests/pmd.at|   8 +-
 tests/system-userspace-packet-type-aware.at | 418 +
 tests/system-userspace-testsuite.at |   1 +
 tests/testsuite.at  |   1 +
 tests/tunnel-push-pop-ipv6.at   |   6 +-
 tests/tunnel-push-pop.at|   6 +-
 tests/tunnel.at |  18 +-
 utilities/ovs-ofctl.c   |   1 +
 vswitchd/vswitch.xml|  94 +-
 49 files changed, 2087 insertions(+), 510 deletions(-)
___
dev maili

Re: [ovs-dev] [PATCH v2 12/12] work on packet aware test

2017-06-20 Thread Zoltán Balogh
s, actions:12
+recirc_id(0),in_port(15),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(dst=192.168.10.30,tos=0/0x3,frag=no),
 packets:2, bytes:196, used:0.0s, 
actions:tnl_push(tnl_port(14),header(size=38,type=3,eth(dst=aa:55:00:00:00:03,src=aa:55:00:00:00:01,dl_type=0x0800),ipv4(src=10.0.0.1,dst=10.0.0.3,proto=47,tos=0,ttl=64,frag=0x4000),gre((flags=0x0,proto=0x6558))),out_port(5))
+recirc_id(0),in_port(17),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(dst=192.168.10.10,tos=0/0x3,frag=no),
 packets:2, bytes:196, used:0.0s, 
actions:pop_eth,tnl_push(tnl_port(14),header(size=38,type=3,eth(dst=aa:55:00:00:00:02,src=aa:55:00:00:00:03,dl_type=0x0800),ipv4(src=30.0.0.3,dst=30.0.0.2,proto=47,tos=0,ttl=64,frag=0x4000),gre((flags=0x0,proto=0x800))),out_port(7))
+recirc_id(0),in_port(5),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), 
packets:2, bytes:272, used:0.0s, actions:8
+recirc_id(0),in_port(6),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), 
packets:2, bytes:244, used:0.0s, actions:9
+recirc_id(0),in_port(7),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), 
packets:2, bytes:244, used:0.0s, actions:10
+recirc_id(0),in_port(8),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:01),eth_type(0x0800),ipv4(src=20.0.0.2,dst=20.0.0.1,proto=47,frag=no),
 packets:2, bytes:244, used:0.0s, 
actions:set(ipv4(src=10.0.0.2,dst=10.0.0.1)),tnl_pop(14)
+recirc_id(0),in_port(9),packet_type(ns=0,id=0),eth(dst=aa:55:00:00:00:02),eth_type(0x0800),ipv4(src=30.0.0.3,dst=30.0.0.2,proto=47,frag=no),
 packets:2, bytes:244, used:0.0s, 
actions:set(ipv4(src=20.0.0.3,dst=20.0.0.2)),tnl_pop(14)
+tunnel(src=10.0.0.2,dst=10.0.0.1,flags(-df-csum)),recirc_id(0),in_port(14),packet_type(ns=1,id=0x800),ipv4(dst=192.168.10.10,frag=no),
 packets:2, bytes:168, used:0.0s, 
actions:push_eth(src=00:00:00:00:00:00,dst=aa:55:aa:55:00:01),15
+tunnel(src=20.0.0.3,dst=20.0.0.2,flags(-df-csum)),recirc_id(0),in_port(14),packet_type(ns=1,id=0x800),ipv4(dst=192.168.10.10,tos=0/0x3,frag=no),
 packets:2, bytes:168, used:0.0s, 
actions:tnl_push(tnl_port(14),header(size=38,type=3,eth(dst=aa:55:00:00:00:01,src=aa:55:00:00:00:02,dl_type=0x0800),ipv4(src=20.0.0.2,dst=20.0.0.1,proto=47,tos=0,ttl=64,frag=0x4000),gre((flags=0x0,proto=0x800))),out_port(6))
 
tunnel(src=30.0.0.1,dst=30.0.0.3,flags(-df-csum)),recirc_id(0),in_port(14),packet_type(ns=0,id=0),eth(dst=aa:55:aa:55:00:03),eth_type(0x0800),ipv4(dst=192.168.10.30,frag=no),
 packets:2, bytes:196, used:0.0s, actions:17
 ])
 
-- 
2.11.0



> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> Sent: Tuesday, June 20, 2017 6:28 PM
> To: Jan Scheurich <jan.scheur...@ericsson.com>; Ben Pfaff <b...@ovn.org>; 
> d...@openvswitch.org
> Subject: Re: [ovs-dev] [PATCH v2 12/12] work on packet aware test
> 
> From: Jan Scheurich <jan.scheur...@ericsson.com>
> 
> Re-introduced packet-type-aware unit tests
> 
> Reverted test with triangular bridge setup to using patch ports to
> avoid dependency on veth ports and root privilidges.
> 
> Adapted to changes in Ben's ptap series. Dependent on patches for
> using port names in datapath flows.
> 
> Signed-off-by: Ben Pfaff <b...@ovn.org>
> Signed-off-by: Jan Scheurich <jan.scheur...@ericsson.com>
> ---
>  tests/packet-type-aware.at | 342 
> -
>  1 file changed, 155 insertions(+), 187 deletions(-)
> 
> diff --git a/tests/packet-type-aware.at b/tests/packet-type-aware.at
> index 0aaeffa..49dcc60 100644
> --- a/tests/packet-type-aware.at
> +++ b/tests/packet-type-aware.at
> @@ -33,10 +33,6 @@ AT_CLEANUP
> 
>  AT_SETUP([ptap - triangle bridge setup with L2 and L3 GRE tunnels])
> 
> -# Always skip this test, for now, until it is revised to use patch
> -# ports in place of veth devices.
> -AT_SKIP_IF([:])
> -
>  
>  # GRE tunneling test setup for PTAP bridge
>  #
> @@ -61,126 +57,108 @@ AT_SKIP_IF([:])
>  #   ++
>  #"
>  #   GRE tunnel ports:
> -#  No Bridge  NameTypeRemote bridge & ports
> +#  No Bridge  NamePacket-type Remote bridge & ports
>  # ---
> -#  1020   br-in1  gre-12  l2  br-in2 2010 (versatile)
> -#  1021   br-in1  gre-12_l3   l3same
> -#  1030   br-in1  gre-13  l2  br-in3 3010 (l2)
> -#  2010   br-in2  gre-21  versatile   br-in1 1020 (l2), 1021 (l3)
> -#  2030   br-in2  gre-13  versatile   br-in3 3020 (l2), 3021 (l3)
> -#  3010   br-in1  gre-31  l2  br-in1 1030 (l2)
> -#  3020   br-in1  gre-32  l2  br-in2 2010 (v

Re: [ovs-dev] [PATCH v2 12/12] work on packet aware test

2017-06-20 Thread Zoltán Balogh
From: Jan Scheurich 

Re-introduced packet-type-aware unit tests

Reverted test with triangular bridge setup to using patch ports to
avoid dependency on veth ports and root privilidges.

Adapted to changes in Ben's ptap series. Dependent on patches for
using port names in datapath flows.

Signed-off-by: Ben Pfaff 
Signed-off-by: Jan Scheurich 
---
 tests/packet-type-aware.at | 342 -
 1 file changed, 155 insertions(+), 187 deletions(-)

diff --git a/tests/packet-type-aware.at b/tests/packet-type-aware.at
index 0aaeffa..49dcc60 100644
--- a/tests/packet-type-aware.at
+++ b/tests/packet-type-aware.at
@@ -33,10 +33,6 @@ AT_CLEANUP
 
 AT_SETUP([ptap - triangle bridge setup with L2 and L3 GRE tunnels])
 
-# Always skip this test, for now, until it is revised to use patch
-# ports in place of veth devices.
-AT_SKIP_IF([:])
-
 
 # GRE tunneling test setup for PTAP bridge
 #
@@ -61,126 +57,108 @@ AT_SKIP_IF([:])
 #   ++
 #"
 #   GRE tunnel ports:
-#  No Bridge  NameTypeRemote bridge & ports
+#  No Bridge  NamePacket-type Remote bridge & ports
 # ---
-#  1020   br-in1  gre-12  l2  br-in2 2010 (versatile)
-#  1021   br-in1  gre-12_l3   l3same
-#  1030   br-in1  gre-13  l2  br-in3 3010 (l2)
-#  2010   br-in2  gre-21  versatile   br-in1 1020 (l2), 1021 (l3)
-#  2030   br-in2  gre-13  versatile   br-in3 3020 (l2), 3021 (l3)
-#  3010   br-in1  gre-31  l2  br-in1 1030 (l2)
-#  3020   br-in1  gre-32  l2  br-in2 2010 (versatile)
-#  3021   br-in1  gre-32_l3   l3same
-
-
-OVS_VSWITCHD_START([])
+#  1020   br-in1  gre-12  legacy-l2   br-in2 2010 (ptap)
+#  1021   br-in1  gre-12_l3   legacy-l3 same
+#  1030   br-in1  gre-13  legacy-l2   br-in3 3010 (l2)
+#  2010   br-in2  gre-21  ptapbr-in1 1020 (l2), 1021 (l3)
+#  2030   br-in2  gre-13  ptapbr-in3 3020 (l2), 3021 (l3)
+#  3010   br-in1  gre-31  legacy-l2   br-in1 1030 (l2)
+#  3020   br-in1  gre-32  legacy-l2   br-in2 2010 (ptap)
+#  3021   br-in1  gre-32_l3   legacy-l3 same
 
 HWADDR_BRP1=aa:55:00:00:00:01
 HWADDR_BRP2=aa:55:00:00:00:02
 HWADDR_BRP3=aa:55:00:00:00:03
 
-dnl Create veth ports to connect br0 with br-p1, br-p2 and br-p3
-AT_CHECK([ip link add p1-0 type veth peer name p0-1])
-AT_CHECK([ip link set p1-0 up])
-AT_CHECK([ip link set p0-1 up])
-AT_CHECK([ip link set dev p1-0 mtu 3300])
-AT_CHECK([ip link set dev p0-1 mtu 3300])
-on_exit 'ip link del p0-1'
-
-AT_CHECK([ip link add p2-0 type veth peer name p0-2])
-AT_CHECK([ip link set p2-0 up])
-AT_CHECK([ip link set p0-2 up])
-AT_CHECK([ip link set dev p2-0 mtu 3300])
-AT_CHECK([ip link set dev p0-2 mtu 3300])
-on_exit 'ip link del p0-2'
-
-AT_CHECK([ip link add p3-0 type veth peer name p0-3])
-AT_CHECK([ip link set p3-0 up])
-AT_CHECK([ip link set p0-3 up])
-AT_CHECK([ip link set dev p3-0 mtu 3300])
-AT_CHECK([ip link set dev p0-3 mtu 3300])
-on_exit 'ip link del p0-3'
+OVS_VSWITCHD_START([dnl
+-- add-br br-in1 \
+-- set bridge br-in1 datapath_type=dummy fail-mode=secure \
+-- add-br br-in2 \
+-- set bridge br-in2 datapath_type=dummy fail-mode=secure \
+-- add-br br-in3 \
+-- set bridge br-in3 datapath_type=dummy fail-mode=secure \
+-- add-br br-p1 -- \
+-- set bridge br-p1 datapath_type=dummy fail-mode=secure 
other-config:hwaddr=\"$HWADDR_BRP1\" \
+-- add-br br-p2 -- \
+-- set bridge br-p2 datapath_type=dummy fail-mode=secure 
other-config:hwaddr=\"$HWADDR_BRP2\" \
+-- add-br br-p3 -- \
+-- set bridge br-p3 datapath_type=dummy fail-mode=secure 
other-config:hwaddr=\"$HWADDR_BRP3\" \
+-- add-port br-p1 p1-0 \
+-- set interface p1-0 type=patch options:peer=p0-1 ofport_request=2 \
+-- add-port br-p2 p2-0 \
+-- set interface p2-0 type=patch options:peer=p0-2 ofport_request=2 \
+-- add-port br-p3 p3-0 \
+-- set interface p3-0 type=patch options:peer=p0-3 ofport_request=2 \
+-- add-port br0 p0-1 \
+-- set interface p0-1 type=patch options:peer=p1-0 ofport_request=10 \
+-- add-port br0 p0-2 \
+-- set interface p0-2 type=patch options:peer=p2-0 ofport_request=20 \
+-- add-port br0 p0-3 \
+-- set interface p0-3 type=patch options:peer=p3-0 ofport_request=30 \
+-- add-port br-in1 gre12 \
+-- set interface gre12 type=gre options:remote_ip=10.0.0.2 \
+   ofport_request=1020 \
+-- add-port br-in1 gre12_l3 \
+-- set interface gre12_l3 type=gre options:remote_ip=10.0.0.2 \
+   

Re: [ovs-dev] [PATCH v3 7/7] userspace: Introduce packet_type in OF 1.5 packet-out

2017-06-20 Thread Zoltán Balogh
Hi Ben,

Setting "other-config:legacy-l3-pipeline=true" can be removed from the 
tests/system-userspace-packet-type-aware.at file as well. Sorry, for not 
indicating this in my previous e-mail.

Best regards,
Zoltan

> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Tuesday, June 20, 2017 4:23 AM
> To: d...@openvswitch.org
> Cc: Ben Pfaff <b...@ovn.org>; Zoltán Balogh <zoltan.bal...@ericsson.com>; 
> Jean Tourrilhes <j...@labs.hpe.com>; Jan
> Scheurich <jan.scheur...@ericsson.com>
> Subject: [PATCH v3 7/7] userspace: Introduce packet_type in OF 1.5 packet-out
> 
> From: Zoltán Balogh <zoltan.bal...@ericsson.com>
> 
> Introducing packet_type in OF 1.5 packet-out.
> Partly based on Jean Tourrilhes's work.
> 
> Add test cases for OF1.5 packet-out
> Add negative test case for OF1.5 packet-out
> Modify wildcarding and packet-out test printout.
> 
> Signed-off-by: Jean Tourrilhes <j...@labs.hpe.com>
> Signed-off-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> Co-authored-by: Jan Scheurich <jan.scheur...@ericsson.com>
> Signed-off-by: Ben Pfaff <b...@ovn.org>
> ---
>  lib/flow.c  | 36 +++--
>  lib/ofp-parse.c | 13 +
>  lib/ofp-print.c |  4 +-
>  lib/ofp-util.c  |  2 +
>  ofproto/ofproto.c   |  3 ++
>  tests/ofproto.at| 81 
> +
>  tests/system-userspace-packet-type-aware.at |  2 +-
>  utilities/ovs-ofctl.c   |  1 +
>  8 files changed, 124 insertions(+), 18 deletions(-)
> 
> diff --git a/lib/flow.c b/lib/flow.c
> index dbca4d03da3d..75a91cc6a2f3 100644
> --- a/lib/flow.c
> +++ b/lib/flow.c
> @@ -1441,6 +1441,8 @@ void
>  flow_wildcards_init_for_packet(struct flow_wildcards *wc,
> const struct flow *flow)
>  {
> +ovs_be16 dl_type = OVS_BE16_MAX;
> +
>  memset(>masks, 0x0, sizeof wc->masks);
> 
>  /* Update this function whenever struct flow changes. */
> @@ -1493,25 +1495,29 @@ flow_wildcards_init_for_packet(struct flow_wildcards 
> *wc,
>  /* actset_output wildcarded. */
> 
>  WC_MASK_FIELD(wc, packet_type);
> -WC_MASK_FIELD(wc, dl_dst);
> -WC_MASK_FIELD(wc, dl_src);
> -WC_MASK_FIELD(wc, dl_type);
> -
> -/* No need to set mask of inner VLANs that don't exist. */
> -for (int i = 0; i < FLOW_MAX_VLAN_HEADERS; i++) {
> -/* Always show the first zero VLAN. */
> -WC_MASK_FIELD(wc, vlans[i]);
> -if (flow->vlans[i].tci == htons(0)) {
> -break;
> +if (flow->packet_type == htonl(PT_ETH)) {
> +WC_MASK_FIELD(wc, dl_dst);
> +WC_MASK_FIELD(wc, dl_src);
> +WC_MASK_FIELD(wc, dl_type);
> +/* No need to set mask of inner VLANs that don't exist. */
> +for (int i = 0; i < FLOW_MAX_VLAN_HEADERS; i++) {
> +/* Always show the first zero VLAN. */
> +WC_MASK_FIELD(wc, vlans[i]);
> +if (flow->vlans[i].tci == htons(0)) {
> +break;
> +}
>  }
> +dl_type = flow->dl_type;
> +} else {
> +dl_type = pt_ns_type_be(flow->packet_type);
>  }
> 
> -if (flow->dl_type == htons(ETH_TYPE_IP)) {
> +if (dl_type == htons(ETH_TYPE_IP)) {
>  WC_MASK_FIELD(wc, nw_src);
>  WC_MASK_FIELD(wc, nw_dst);
>  WC_MASK_FIELD(wc, ct_nw_src);
>  WC_MASK_FIELD(wc, ct_nw_dst);
> -} else if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
> +} else if (dl_type == htons(ETH_TYPE_IPV6)) {
>  WC_MASK_FIELD(wc, ipv6_src);
>  WC_MASK_FIELD(wc, ipv6_dst);
>  WC_MASK_FIELD(wc, ipv6_label);
> @@ -1523,15 +1529,15 @@ flow_wildcards_init_for_packet(struct flow_wildcards 
> *wc,
>  WC_MASK_FIELD(wc, ct_ipv6_src);
>  WC_MASK_FIELD(wc, ct_ipv6_dst);
>  }
> -} else if (flow->dl_type == htons(ETH_TYPE_ARP) ||
> -   flow->dl_type == htons(ETH_TYPE_RARP)) {
> +} else if (dl_type == htons(ETH_TYPE_ARP) ||
> +   dl_type == htons(ETH_TYPE_RARP)) {
>  WC_MASK_FIELD(wc, nw_src);
>  WC_MASK_FIELD(wc, nw_dst);
>  WC_MASK_FIELD(wc, nw_proto);
>  WC_MASK_FIELD(wc, arp_sha);
>  WC_MASK_FIELD(wc, arp_tha);
>  return;
> -} else if (eth_type_mpls(flow->dl_type)) {
> +} else if (eth_type_mpls(dl_type)) {
>  for (int i = 0; i < FLOW_MAX_MPLS_LABELS; i++) {
>  WC_MASK_FIELD(wc, 

Re: [ovs-dev] [PATCH v2 00/12] Packet type aware pipeline

2017-06-20 Thread Zoltán Balogh
> > OVS_KEY_ATTR_PACKET_TYPE is represented with OVS_KEY_ATTR_ETHERNET and 
> > OVS_KEY_ATTR_ETHERTYPE in the kernel.
> > From Google doc:
> > "The presence of netlink key attribute OVS_KEY_ATTR_ETHERNET is used to 
> > indicate if it's about L2 or L3 packet on
> the netlink interface. The "L3" packet type is encoded in the 
> OVS_KEY_ATTR_ETHERTYPE netlink attribute."
> 
> Oh, OK.  The header file is confusing.  I think that
> OVS_KEY_ATTR_PACKET_TYPE should be inside #ifndef __KERNEL__, to
> clarify.  I sent a patch:
> https://patchwork.ozlabs.org/patch/778029/

Hi Ben,

I agree, OVS_KEY_ATTR_PACKET_TYPE should be inside #ifndef __KERNEL__.
Thank you for fixing this!

Best regards,
Zoltan
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v2 08/12] userspace: Handling of versatile tunnel ports

2017-06-20 Thread Zoltán Balogh

Hi Ben,

I guess you meant "options:packet_type" instead of "other-config:packet_type", 
since it's about an interface not a bridge property.

Best regards,
Zoltan

> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Tuesday, June 20, 2017 4:20 AM
> To: Zoltán Balogh <zoltan.bal...@ericsson.com>
> Cc: d...@openvswitch.org
> Subject: Re: [ovs-dev] [PATCH v2 08/12] userspace: Handling of versatile 
> tunnel ports
> 
> Thanks for reporting that.  I changed this paragraph to:
> 
>   
> Open vSwitch 2.8 and later implement the ``packet type-aware pipeline''
> concept introduced in OpenFlow 1.5.  Such a pipeline does not have any 
> root
> fields.  Instead, a new metadata field, ,
> indicates the basic type of the packet, which can be Ethernet, IPv4, IPv6,
> or another type.  For backward compatibility, by default Open vSwitch 2.8
> imitates the behavior of Open vSwitch 2.7 and earlier.  Later versions of
> Open vSwitch may change the default, and in the meantime controllers can
> turn off this legacy behavior, on a port-by-port basis, by setting
> other_config:packet_type to ptap in the
> Interface table.  This is significant only for ports that can
> handle non-Ethernet packets, which is currently just LISP, VXLAN-GPE, and
> GRE tunnel ports.  See ovs-vwitchd.conf.db(5) for more
> information.
>   
> 
> 
> On Mon, Jun 19, 2017 at 03:33:33PM +, Zoltán Balogh wrote:
> > Hi Ben,
> >
> > In the lib/meta-flow.xml, you introduced the 'packet type-aware pipeline' 
> > concept.
> > You mentioned, controllers can turn off legacy behavior by setting 
> > 'other-config:packet-type' bridge property to
> 'ptap'.
> > As far as I know, you discussed on Friday, there will be only one property 
> > for the tunnel ports and no bridge
> property.
> >
> > Best regards,
> > Zoltan
> >
> >
> > > -Original Message-
> > > From: ovs-dev-boun...@openvswitch.org 
> > > [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Ben Pfaff
> > > Sent: Monday, June 19, 2017 1:30 AM
> > > To: d...@openvswitch.org
> > > Cc: Ben Pfaff <b...@ovn.org>
> > > Subject: [ovs-dev] [PATCH v2 08/12] userspace: Handling of versatile 
> > > tunnel ports
> > >
> > > In netdev_gre_build_header(), GRE protocol and VXLAN next_potocol is set 
> > > based
> > > on packet_type of flow. If it's about an Ethernet packet, it is set to
> > > ETP_TYPE_TEB. Otherwise, if the name space is OFPHTN_ETHERNET, it is set
> > > according to the name space type.
> > >
> > > Signed-off-by: Jan Scheurich <jan.scheur...@ericsson.com>
> > > Signed-off-by: Ben Pfaff <b...@ovn.org>
> > > ---
> > >  NEWS  |   6 +--
> > >  lib/meta-flow.xml |  28 ++-
> > >  lib/netdev-bsd.c  |   1 +
> > >  lib/netdev-dpdk.c |   1 +
> > >  lib/netdev-dummy.c|   1 +
> > >  lib/netdev-linux.c|   1 +
> > >  lib/netdev-native-tnl.c   |  23 ++---
> > >  lib/netdev-provider.h |   6 +++
> > >  lib/netdev-vport.c| 106 
> > > ++
> > >  lib/netdev-vport.h|   1 -
> > >  lib/netdev.c  |   8 
> > >  lib/netdev.h  |  29 +++-
> > >  ofproto/ofproto-dpif-xlate.c  |  35 --
> > >  ofproto/ofproto-dpif.c|   4 +-
> > >  ofproto/tunnel.c  |  27 ---
> > >  tests/tunnel-push-pop-ipv6.at |   4 +-
> > >  tests/tunnel-push-pop.at  |   4 +-
> > >  vswitchd/vswitch.xml  |  94 ++---
> > >  18 files changed, 277 insertions(+), 102 deletions(-)
> > >
> > > diff --git a/NEWS b/NEWS
> > > index a2f5a6dc8e54..8b0ad6191325 100644
> > > --- a/NEWS
> > > +++ b/NEWS
> > > @@ -59,11 +59,9 @@ Post-v2.7.0
> > >   * OVN services are no longer restarted automatically after upgrade.
> > > - Add --cleanup option to command 'ovs-appctl exit' (see 
> > > ovs-vswitchd(8)).
> > > - L3 tunneling:
> > > - * Add "layer3" options for tunnel ports that support non-Ethernet 
> > > (L3)
> > > -   payload (GRE, VXLAN-GPE).
> > > + * Use new tunnel port option "packet_type" to configure L2 vs. L3.
> > >   * New vxlan tunnel extension "gpe"

Re: [ovs-dev] [PATCH v2 07/12] userspace: Add OXM field MFF_PACKET_TYPE

2017-06-19 Thread Zoltán Balogh
Hi Ben,

I've been testing L2/L3 tunneling and ptap ports receiving/transmitting L2 and 
L3 packets. 
I observed, that 'ovs-appctl dpctl/dump-flows' prints out packet_type 'id' in 
decimal format.
For instance, in case of receiving a L3 MPLS packet on a ptap port results in:

tunnel(src=20.0.0.1,dst=20.0.0.2,flags(-df-csum)),recirc_id(0),in_port(7),packet_type(ns=1,id=34887),eth_type(0x8847),
 packets:24, bytes:2112, used:0.064s, actions:drop

Would not it be more readable, to use hex format if the 'id' is not zero?

By applying this diff:

diff --git a/lib/odp-util.c b/lib/odp-util.c
index ef8651247..72f4f2324 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -2992,7 +2992,10 @@ format_odp_key_attr(const struct nlattr *a, const struct 
nlattr *ma,
 
 ovs_be16 ns_type = pt_ns_type_be(value);
 ovs_be16 ns_type_mask = pt_ns_type_be(mask);
-format_be16(ds, "id", ns_type, _type_mask, verbose);
+if (ns_type)
+format_be16x(ds, "id", ns_type, _type_mask, verbose);
+else
+format_be16(ds, "id", ns_type, _type_mask, verbose);
 
 ds_chomp(ds, ',');
 break;

... we can get printouts like this:

recirc_id(0),in_port(4),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), 
packets:0, bytes:0, used:never, actions:9
tunnel(src=20.0.0.1,dst=20.0.0.2,flags(-df-csum)),recirc_id(0),in_port(7),packet_type(ns=1,id=0x8847),eth_type(0x8847),
 packets:0, bytes:0, used:never, actions:drop

Best regards,
Zoltan

> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Ben Pfaff
> Sent: Monday, June 19, 2017 1:30 AM
> To: d...@openvswitch.org
> Cc: Ben Pfaff 
> Subject: [ovs-dev] [PATCH v2 07/12] userspace: Add OXM field MFF_PACKET_TYPE
> 
> From: Jan Scheurich 
> 
> Allow packet type namespace OFPHTN_ETHERTYPE as alternative pre-requisite
> for matching L3 protocols (MPLS, IP, IPv6, ARP etc).
> 
> Change the meta-flow definition of packet_type field to use the new
> custom format MFS_PACKET_TYPE representing "(NS,NS_TYPE)".
> 
> Parsing routine for MFS_PACKET_TYPE added to meta-flow.c. Formatting
> routine for field packet_type extracted from match_format() and moved to
> flow.c to be used from meta-flow.c for formatting MFS_PACKET_TYPE.
> 
> Updated the ovs-fields man page source meta-flow.xml with documentation
> for packet-type-aware bridges and added documentation for field packet_type.
> 
> Added packet_type to the matching properties in tests/ofproto.at. Should be
> removed later, when packet_type_aware bridge attribute will be introduced.
> 
> Signed-off-by: Jan Scheurich 
> Signed-off-by: Ben Pfaff 
> ---
>  build-aux/extract-ofp-fields|   3 +-
>  include/openvswitch/match.h |   5 +
>  include/openvswitch/meta-flow.h |  20 
>  lib/flow.c  |  34 +-
>  lib/flow.h  |  27 +++--
>  lib/learn.c |   1 +
>  lib/match.c |  98 +++--
>  lib/meta-flow.c |  86 +--
>  lib/meta-flow.xml   | 156 +++
>  lib/nx-match.c  |  34 +-
>  lib/odp-util.c  |  38 +++
>  lib/ofp-parse.c |  12 +++
>  lib/ofp-util.c  |  67 +---
>  ofproto/ofproto-dpif-xlate.c|   1 +
>  ofproto/tunnel.c|   2 -
>  tests/dpif-netdev.at|  89 
>  tests/odp.at|   1 +
>  tests/ofproto-dpif.at   | 230 
> 
>  tests/ofproto.at|   1 +
>  tests/ovs-ofctl.at  |   2 +-
>  tests/pmd.at|   8 +-
>  tests/tunnel-push-pop-ipv6.at   |   2 +-
>  tests/tunnel-push-pop.at|   2 +-
>  tests/tunnel.at |  18 ++--
>  24 files changed, 653 insertions(+), 284 deletions(-)
> 
> diff --git a/build-aux/extract-ofp-fields b/build-aux/extract-ofp-fields
> index d5b8a820251e..24dd756ad7d5 100755
> --- a/build-aux/extract-ofp-fields
> +++ b/build-aux/extract-ofp-fields
> @@ -36,7 +36,8 @@ FORMATTING = {"decimal":("MFS_DECIMAL",  1, 
>   8),
>"OpenFlow 1.1+ port": ("MFS_OFP_PORT_OXM", 4,   4),
>"frag":   ("MFS_FRAG", 1,   1),
>"tunnel flags":   ("MFS_TNL_FLAGS",2,   2),
> -  "TCP flags":  ("MFS_TCP_FLAGS",2,   2)}
> +  "TCP flags":  ("MFS_TCP_FLAGS",2,   2),
> +  "packet type":("MFS_PACKET_TYPE",  4,   4)}
> 
>  PREREQS = {"none": "MFP_NONE",
> "Ethernet": "MFP_ETHERNET",
> diff --git a/include/openvswitch/match.h b/include/openvswitch/match.h
> index 70da928fe47d..aca725265c79 100644
> --- a/include/openvswitch/match.h
> +++ b/include/openvswitch/match.h
> @@ -23,6 +23,7 @@

Re: [ovs-dev] [PATCH v2 11/12] userspace: Introduce packet_type in OF 1.5 packet-out

2017-06-19 Thread Zoltán Balogh
Hi Ben,

The bridge property 'other-config:legacy-l3-pipeline' is obsolete, so the 3 
lines starting at line 4197 in ofproto.at can be removed.

> +AT_CHECK([
> +ovs-vsctl set bridge br0 other-config:legacy-l3-pipeline=false
> +], [0])


Best regards,
Zoltan

> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Monday, June 19, 2017 1:30 AM
> To: d...@openvswitch.org
> Cc: Ben Pfaff <b...@ovn.org>; Zoltán Balogh <zoltan.bal...@ericsson.com>; 
> Jean Tourrilhes <j...@labs.hpe.com>; Jan
> Scheurich <jan.scheur...@ericsson.com>
> Subject: [PATCH v2 11/12] userspace: Introduce packet_type in OF 1.5 
> packet-out
> 
> From: Zoltán Balogh <zoltan.bal...@ericsson.com>
> 
> Introducing packet_type in OF 1.5 packet-out.
> Partly based on Jean Tourrilhes's work.
> 
> Add test cases for OF1.5 packet-out
> Add negative test case for OF1.5 packet-out
> Modify wildcarding and packet-out test printout.
> 
> Signed-off-by: Jean Tourrilhes <j...@labs.hpe.com>
> Signed-off-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> Co-authored-by: Jan Scheurich <jan.scheur...@ericsson.com>
> Signed-off-by: Ben Pfaff <b...@ovn.org>
> ---
>  lib/flow.c  | 36 +++-
>  lib/ofp-parse.c | 13 +
>  lib/ofp-print.c |  4 +-
>  lib/ofp-util.c  |  2 +
>  ofproto/ofproto.c   |  3 +
>  tests/ofproto.at| 85 
> +
>  tests/system-userspace-packet-type-aware.at |  2 +-
>  utilities/ovs-ofctl.c   |  1 +
>  8 files changed, 128 insertions(+), 18 deletions(-)
> 
> diff --git a/lib/flow.c b/lib/flow.c
> index dbca4d03da3d..75a91cc6a2f3 100644
> --- a/lib/flow.c
> +++ b/lib/flow.c
> @@ -1441,6 +1441,8 @@ void
>  flow_wildcards_init_for_packet(struct flow_wildcards *wc,
> const struct flow *flow)
>  {
> +ovs_be16 dl_type = OVS_BE16_MAX;
> +
>  memset(>masks, 0x0, sizeof wc->masks);
> 
>  /* Update this function whenever struct flow changes. */
> @@ -1493,25 +1495,29 @@ flow_wildcards_init_for_packet(struct flow_wildcards 
> *wc,
>  /* actset_output wildcarded. */
> 
>  WC_MASK_FIELD(wc, packet_type);
> -WC_MASK_FIELD(wc, dl_dst);
> -WC_MASK_FIELD(wc, dl_src);
> -WC_MASK_FIELD(wc, dl_type);
> -
> -/* No need to set mask of inner VLANs that don't exist. */
> -for (int i = 0; i < FLOW_MAX_VLAN_HEADERS; i++) {
> -/* Always show the first zero VLAN. */
> -WC_MASK_FIELD(wc, vlans[i]);
> -if (flow->vlans[i].tci == htons(0)) {
> -break;
> +if (flow->packet_type == htonl(PT_ETH)) {
> +WC_MASK_FIELD(wc, dl_dst);
> +WC_MASK_FIELD(wc, dl_src);
> +WC_MASK_FIELD(wc, dl_type);
> +/* No need to set mask of inner VLANs that don't exist. */
> +for (int i = 0; i < FLOW_MAX_VLAN_HEADERS; i++) {
> +/* Always show the first zero VLAN. */
> +WC_MASK_FIELD(wc, vlans[i]);
> +if (flow->vlans[i].tci == htons(0)) {
> +break;
> +}
>  }
> +dl_type = flow->dl_type;
> +} else {
> +dl_type = pt_ns_type_be(flow->packet_type);
>  }
> 
> -if (flow->dl_type == htons(ETH_TYPE_IP)) {
> +if (dl_type == htons(ETH_TYPE_IP)) {
>  WC_MASK_FIELD(wc, nw_src);
>  WC_MASK_FIELD(wc, nw_dst);
>  WC_MASK_FIELD(wc, ct_nw_src);
>  WC_MASK_FIELD(wc, ct_nw_dst);
> -} else if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
> +} else if (dl_type == htons(ETH_TYPE_IPV6)) {
>  WC_MASK_FIELD(wc, ipv6_src);
>  WC_MASK_FIELD(wc, ipv6_dst);
>  WC_MASK_FIELD(wc, ipv6_label);
> @@ -1523,15 +1529,15 @@ flow_wildcards_init_for_packet(struct flow_wildcards 
> *wc,
>  WC_MASK_FIELD(wc, ct_ipv6_src);
>  WC_MASK_FIELD(wc, ct_ipv6_dst);
>  }
> -} else if (flow->dl_type == htons(ETH_TYPE_ARP) ||
> -   flow->dl_type == htons(ETH_TYPE_RARP)) {
> +} else if (dl_type == htons(ETH_TYPE_ARP) ||
> +   dl_type == htons(ETH_TYPE_RARP)) {
>  WC_MASK_FIELD(wc, nw_src);
>  WC_MASK_FIELD(wc, nw_dst);
>  WC_MASK_FIELD(wc, nw_proto);
>  WC_MASK_FIELD(wc, arp_sha);
>  WC_MASK_FIELD(wc, arp_tha);
>  return;
> -} else if (eth_type_mpls(flow->dl_type)) {
> +} else if (eth_type_mpls(dl_type)) {
>  for (int i = 0; i < FLOW_MAX_MPLS_LABEL

Re: [ovs-dev] [PATCH v2 08/12] userspace: Handling of versatile tunnel ports

2017-06-19 Thread Zoltán Balogh
Hi Ben,

In the lib/meta-flow.xml, you introduced the 'packet type-aware pipeline' 
concept. 
You mentioned, controllers can turn off legacy behavior by setting 
'other-config:packet-type' bridge property to 'ptap'.
As far as I know, you discussed on Friday, there will be only one property for 
the tunnel ports and no bridge property.

Best regards,
Zoltan


> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Ben Pfaff
> Sent: Monday, June 19, 2017 1:30 AM
> To: d...@openvswitch.org
> Cc: Ben Pfaff 
> Subject: [ovs-dev] [PATCH v2 08/12] userspace: Handling of versatile tunnel 
> ports
> 
> In netdev_gre_build_header(), GRE protocol and VXLAN next_potocol is set based
> on packet_type of flow. If it's about an Ethernet packet, it is set to
> ETP_TYPE_TEB. Otherwise, if the name space is OFPHTN_ETHERNET, it is set
> according to the name space type.
> 
> Signed-off-by: Jan Scheurich 
> Signed-off-by: Ben Pfaff 
> ---
>  NEWS  |   6 +--
>  lib/meta-flow.xml |  28 ++-
>  lib/netdev-bsd.c  |   1 +
>  lib/netdev-dpdk.c |   1 +
>  lib/netdev-dummy.c|   1 +
>  lib/netdev-linux.c|   1 +
>  lib/netdev-native-tnl.c   |  23 ++---
>  lib/netdev-provider.h |   6 +++
>  lib/netdev-vport.c| 106 
> ++
>  lib/netdev-vport.h|   1 -
>  lib/netdev.c  |   8 
>  lib/netdev.h  |  29 +++-
>  ofproto/ofproto-dpif-xlate.c  |  35 --
>  ofproto/ofproto-dpif.c|   4 +-
>  ofproto/tunnel.c  |  27 ---
>  tests/tunnel-push-pop-ipv6.at |   4 +-
>  tests/tunnel-push-pop.at  |   4 +-
>  vswitchd/vswitch.xml  |  94 ++---
>  18 files changed, 277 insertions(+), 102 deletions(-)
> 
> diff --git a/NEWS b/NEWS
> index a2f5a6dc8e54..8b0ad6191325 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -59,11 +59,9 @@ Post-v2.7.0
>   * OVN services are no longer restarted automatically after upgrade.
> - Add --cleanup option to command 'ovs-appctl exit' (see ovs-vswitchd(8)).
> - L3 tunneling:
> - * Add "layer3" options for tunnel ports that support non-Ethernet (L3)
> -   payload (GRE, VXLAN-GPE).
> + * Use new tunnel port option "packet_type" to configure L2 vs. L3.
>   * New vxlan tunnel extension "gpe" to support VXLAN-GPE tunnels.
> - * Transparently pop and push Ethernet headers at transmit/reception
> -   of packets to/from L3 tunnels.
> + * New support for non-Ethernet (L3) payloads in GRE and VXLAN-GPE.
> - The BFD detection multiplier is now user-configurable.
> - New support for HW offloading
>   * HW offloading is disabled by default.
> diff --git a/lib/meta-flow.xml b/lib/meta-flow.xml
> index 856e1ba8cf7b..dc2731e2a260 100644
> --- a/lib/meta-flow.xml
> +++ b/lib/meta-flow.xml
> @@ -26,19 +26,25 @@
>  networking technology in use are called called root fields.
>  Open vSwitch 2.7 and earlier considered Ethernet fields to be root 
> fields,
>  and this remains the default mode of operation for Open vSwitch bridges.
> -In this mode, when a packet is received from a non-Ethernet interfaces,
> -such as a layer-3 LISP or GRE tunnel, Open vSwitch force-fits it to this
> +When a packet is received from a non-Ethernet interfaces, such as a 
> layer-3
> +LISP tunnel, Open vSwitch 2.7 and earlier force-fit the packet to this
>  Ethernet-centric point of view by pretending that an Ethernet header is
>  present whose Ethernet type that indicates the packet's actual type (and
>  whose source and destination addresses are all-zero).
>
> 
>
> -Open vSwitch 2.8 and later supports the ``packet type-aware pipeline''
> -concept introduced in OpenFlow 1.5.  A bridge configured to be packet
> -type-aware can handle packets of multiple networking technologies, such 
> as
> -Ethernet, IP, ARP, MPLS, or NSH in parallel.  Such a bridge does not have
> -any root fields.
> +Open vSwitch 2.8 and later implement the ``packet type-aware pipeline''
> +concept introduced in OpenFlow 1.5.  Such a pipeline does not have any 
> root
> +fields.  Instead, a new metadata field, ,
> +indicates the basic type of the packet, which can be Ethernet, IPv4, 
> IPv6,
> +or another type.  For backward compatibility, by default Open vSwitch 2.8
> +imitates the behavior of Open vSwitch 2.7 and earlier.  Later versions of
> +Open vSwitch may change the default, and in the meantime controllers can
> +turn off this legacy behavior by setting
> +other-config:packet-type to ptap in the
> +Bridge table.  (See ovs-vwitchd.conf.db(5) for
> +more information.)
>
> 
>
> @@ -332,14 +338,6 @@ tcp,tp_src=0x07c0/0xfff0
> 

Re: [ovs-dev] [PATCH v2 00/12] Packet type aware pipeline

2017-06-19 Thread Zoltán Balogh
> 
> A new concern came up while thinking about this series.  The
> OVS_ATTR_PACKET_TYPE does not appear to be implemented in the kernel
> module, and what's more, because of #ifdefs, OVS_ATTR_PACKET_TYPE will
> actually have a different value in the kernel module than in userspace.
> What's the plan here?

Hi Ben, 

OVS_KEY_ATTR_PACKET_TYPE is represented with OVS_KEY_ATTR_ETHERNET and 
OVS_KEY_ATTR_ETHERTYPE in the kernel.
>From Google doc:
"The presence of netlink key attribute OVS_KEY_ATTR_ETHERNET is used to 
indicate if it's about L2 or L3 packet on the netlink interface. The "L3" 
packet type is encoded in the OVS_KEY_ATTR_ETHERTYPE netlink attribute."

The plan was to do a conversion between OVS_KEY_ATTR_PACKET_TYPE and the pair 
of OVS_KEY_ATTR_ETHERNET + OVS_KEY_ATTR_ETHERTYPE attributes before/after 
transmission over netlink. Currently the PACKET_TYPE attribute is filtered out 
in the put_exclude_packet_type() function in lib/dpif-netlink.c.

put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
const struct nlattr *data, uint16_t data_len)
{
const struct nlattr *packet_type;

packet_type = nl_attr_find__(data, data_len, OVS_KEY_ATTR_PACKET_TYPE);

if (packet_type) {
/* exclude PACKET_TYPE Netlink attribute. */
ovs_assert(NLA_ALIGN(packet_type->nla_len) == NL_A_U32_SIZE);
size_t packet_type_len = NL_A_U32_SIZE;
size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data;
size_t second_chunk_size = data_len - first_chunk_size
   - packet_type_len;
uint8_t *first_attr = NULL;
struct nlattr *next_attr = nl_attr_next(packet_type);

first_attr = nl_msg_put_unspec_uninit(buf, type,
  data_len - packet_type_len);
memcpy(first_attr, data, first_chunk_size);
memcpy(first_attr + first_chunk_size, next_attr, second_chunk_size);
} else {
nl_msg_put_unspec(buf, type, data, data_len);
}
}

This could be modified to do more verification and put OVS_KEY_ATTR_ETHERTYPE 
if needed:

---

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 562f6134c..bdcc76c7b 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -3434,11 +3434,11 @@ dpif_netlink_flow_from_ofpbuf(struct dpif_netlink_flow 
*flow,
 
 
 /*
- * If PACKET_TYPE attribute is present in 'data', it filters PACKET_TYPE out,
- * then puts 'data' to 'buf'.
+ * If PACKET_TYPE attribute is present in 'data', converts it to ETHERNET and
+ * ETHERTYPE attributes, then puts 'data' to 'buf'.
  */
 static void
-put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
+put_convert_packet_type(struct ofpbuf *buf, uint16_t type,
 const struct nlattr *data, uint16_t data_len)
 {
 const struct nlattr *packet_type;
@@ -3446,8 +3446,9 @@ put_exclude_packet_type(struct ofpbuf *buf, uint16_t type,
 packet_type = nl_attr_find__(data, data_len, OVS_KEY_ATTR_PACKET_TYPE);
 
 if (packet_type) {
-/* exclude PACKET_TYPE Netlink attribute. */
+/* convert PACKET_TYPE Netlink attribute. */
 ovs_assert(NLA_ALIGN(packet_type->nla_len) == NL_A_U32_SIZE);
+ovs_be32 value = nl_attr_get_be32(packet_type);
 size_t packet_type_len = NL_A_U32_SIZE;
 size_t first_chunk_size = (uint8_t *)packet_type - (uint8_t *)data;
 size_t second_chunk_size = data_len - first_chunk_size
@@ -3455,10 +3456,31 @@ put_exclude_packet_type(struct ofpbuf *buf, uint16_t 
type,
 uint8_t *first_attr = NULL;
 struct nlattr *next_attr = nl_attr_next(packet_type);
 
+bool ethernet_present = nl_attr_find__(data, data_len,
+   OVS_KEY_ATTR_ETHERNET);
+
 first_attr = nl_msg_put_unspec_uninit(buf, type,
   data_len - packet_type_len);
 memcpy(first_attr, data, first_chunk_size);
 memcpy(first_attr + first_chunk_size, next_attr, second_chunk_size);
+
+/* Put OVS_KEY_ATTR_ETHERTYPE if needed. */
+if (ntohl(value) == PT_ETH) {
+ovs_assert(ethernet_present);
+} else {
+const struct nlattr *eth_type;
+ovs_be16 ns_type = pt_ns_type_be(value);
+
+ovs_assert(ethernet_present == false);
+
+eth_type = nl_attr_find__(data, data_len, OVS_KEY_ATTR_ETHERTYPE);
+if (eth_type) {
+ovs_assert(nl_attr_get_be16(eth_type) == ns_type);
+} else {
+nl_msg_put_be16(buf, OVS_KEY_ATTR_ETHERTYPE, ns_type);
+}
+}
+
 } else {
 nl_msg_put_unspec(buf, type, data, data_len);
 }
@@ -3489,11 +3511,11 @@ dpif_netlink_flow_to_ofpbuf(const struct 
dpif_netlink_flow *flow,
 }
 if (!flow->ufid_terse || !flow->ufid_present) {
 if (flow->key_len) {
-put_exclude_packet_type(buf, OVS_FLOW_ATTR_KEY, flow->key,
+  

Re: [ovs-dev] [PATCH v8 3/3] userspace: add vxlan gpe support to vport

2017-06-02 Thread Zoltán Balogh
Hi, 

V9 was sent to the mailing list, please review that one:
https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/89.html

/Zoltan

> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> Sent: Friday, May 26, 2017 9:26 AM
> To: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: [ovs-dev] [PATCH v8 3/3] userspace: add vxlan gpe support to vport
> 
> From: Georg Schmuecking <georg.schmueck...@ericsson.com>
> 
> This patch is based on the "datapath: enable vxlangpe creation in compat mode"
> from Yi Yang. It introduces an extension option "gpe" to the vxlan port in the
> netdev-dpdk datapath. Description of vxlan gpe protocoll was added to header
> file lib/packets.h. In the vxlan specific methods the different packet are
> introduced and handled.
> 
> Added VXLAN GPE tunnel push test.
> 
> Signed-off-by: Yi Yang 
> Signed-off-by: Georg Schmuecking <georg.schmueck...@ericsson.com>
> ---
>  datapath/linux/compat/include/linux/openvswitch.h |  1 +
>  include/openvswitch/automake.mk   |  1 -
>  lib/netdev-native-tnl.c   | 59 
> +--
>  lib/netdev-vport.c| 22 +++--
>  lib/packets.h | 54 -
>  tests/tunnel-push-pop.at  | 10 
>  6 files changed, 135 insertions(+), 12 deletions(-)
> 
> diff --git a/datapath/linux/compat/include/linux/openvswitch.h 
> b/datapath/linux/compat/include/linux/openvswitch.h
> index 7990638..2ae1797 100644
> --- a/datapath/linux/compat/include/linux/openvswitch.h
> +++ b/datapath/linux/compat/include/linux/openvswitch.h
> @@ -291,6 +291,7 @@ enum ovs_vport_attr {
>  enum {
>   OVS_VXLAN_EXT_UNSPEC,
>   OVS_VXLAN_EXT_GBP,  /* Flag or __u32 */
> + OVS_VXLAN_EXT_GPE = 8,  /* Flag or __u32 */
>   __OVS_VXLAN_EXT_MAX,
>  };
> 
> diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk
> index c0e276f..699d9d7 100644
> --- a/include/openvswitch/automake.mk
> +++ b/include/openvswitch/automake.mk
> @@ -30,4 +30,3 @@ openvswitchinclude_HEADERS = \
>   include/openvswitch/version.h \
>   include/openvswitch/vconn.h \
>   include/openvswitch/vlog.h
> -
> diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
> index 0651322..c7a2993 100644
> --- a/lib/netdev-native-tnl.c
> +++ b/lib/netdev-native-tnl.c
> @@ -499,6 +499,8 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
>  struct flow_tnl *tnl = >tunnel;
>  struct vxlanhdr *vxh;
>  unsigned int hlen;
> +ovs_be32 vx_flags;
> +enum packet_type next_pt = PT_ETH;
> 
>  pkt_metadata_init_tnl(md);
>  if (VXLAN_HLEN > dp_packet_l4_size(packet)) {
> @@ -510,18 +512,43 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
>  goto err;
>  }
> 
> -if (get_16aligned_be32(>vx_flags) != htonl(VXLAN_FLAGS) ||
> +vx_flags = get_16aligned_be32(>vx_flags);
> +if (vx_flags & htonl(VXLAN_HF_GPE)) {
> +vx_flags &= htonl(~VXLAN_GPE_USED_BITS);
> +/* Drop the OAM packets */
> +if (vxh->vx_gpe.flags & VXLAN_GPE_FLAGS_O) {
> +goto err;
> +}
> +switch (vxh->vx_gpe.next_protocol) {
> +case VXLAN_GPE_NP_IPV4:
> +next_pt = PT_IPV4;
> +break;
> +case VXLAN_GPE_NP_IPV6:
> +next_pt = PT_IPV6;
> +break;
> +case VXLAN_GPE_NP_ETHERNET:
> +next_pt = PT_ETH;
> +break;
> +default:
> +goto err;
> +}
> +}
> +
> +if (vx_flags != htonl(VXLAN_FLAGS) ||
> (get_16aligned_be32(>vx_vni) & htonl(0xff))) {
>  VLOG_WARN_RL(_rl, "invalid vxlan flags=%#x vni=%#x\n",
> - ntohl(get_16aligned_be32(>vx_flags)),
> + ntohl(vx_flags),
>   ntohl(get_16aligned_be32(>vx_vni)));
>  goto err;
>  }
>  tnl->tun_id = htonll(ntohl(get_16aligned_be32(>vx_vni)) >> 8);
>  tnl->flags |= FLOW_TNL_F_KEY;
> 
> -packet->packet_type = htonl(PT_ETH);
> +packet->packet_type = htonl(next_pt);
>  dp_packet_reset_packet(packet, hlen + VXLAN_HLEN);
> +if (next_pt != PT_ETH) {
> +packet->l3_ofs = 0;
> +}
> 
>  return packet;
>  err:
> @@ -544,8 +571,30 @@ netdev_vxlan_build_header(const struct netdev *netdev,
> 
>  vxh = udp_build_header(tnl_cfg, data, params);
> 
> -pu

Re: [ovs-dev] [PATCH v8 2/3] userspace: L3 tunnel support for GRE and LISP

2017-06-02 Thread Zoltán Balogh
Hi, 

V9 was sent to the mailing list, please review that one:
https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/88.html

/Zoltan

> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> Sent: Friday, May 26, 2017 9:26 AM
> To: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: [ovs-dev] [PATCH v8 2/3] userspace: L3 tunnel support for GRE and 
> LISP
> 
> From: Jan Scheurich <jan.scheur...@ericsson.com>
> 
> Add a boolean "layer3" configuration option for tunnel vports.
> The layer3 option defaults to false for all ports except LISP.
> GRE ports accept both true and false for "layer3".
> 
> A tunnel vport configured with layer3=true receives L3 packets.
> which are then converted to Ethernet packets by pushing a dummy
> Ethernet heder at the ingress of the OpenFlow pipeline. The
> Ethernet header of a packet is stripped before sending to a
> layer3 tunnel vport.
> 
> Presently a single GRE vport cannot carry both L2 and L3 packets.
> But it is possible to create two GRE vports representing the same
> GRE tunel, one with layer3=false, the other with layer3=true.
> L2 packet from the tunnel are received on the first vport, L3
> packets on the second. The controller must send packets to the
> layer3 GRE vport to tunnel them without their Ethernet header.
> 
> Units tests have been added to check the L3 tunnel handling.
> 
> LISP tunnels are not yet supported by the netdev userspace datapath.
> 
> Signed-off-by: Simon Horman <simon.hor...@netronome.com>
> Signed-off-by: Jiri Benc <jb...@redhat.com>
> Signed-off-by: Yi Yang <yi.y.y...@intel.com>
> Signed-off-by: Jan Scheurich <jan.scheur...@ericsson.com>
> Co-authored-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> ---
>  NEWS  |  6 ++
>  lib/netdev-native-tnl.c   | 28 +++-
>  lib/netdev-vport.c| 14 --
>  ofproto/tunnel.c  | 14 +++---
>  tests/tunnel-push-pop-ipv6.at | 16 +++-
>  tests/tunnel-push-pop.at  | 33 -
>  vswitchd/vswitch.xml  | 13 +
>  7 files changed, 104 insertions(+), 20 deletions(-)
> 
> diff --git a/NEWS b/NEWS
> index 25eb477..bbed787 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -45,6 +45,12 @@ Post-v2.7.0
> - Fedora Packaging:
>   * OVN services are no longer restarted automatically after upgrade.
> - Add --cleanup option to command 'ovs-appctl exit' (see ovs-vswitchd(8)).
> +   - L3 tunneling:
> + * Add "layer3" options for tunnel ports that support non-Ethernet (L3)
> +   payload (GRE, VXLAN-GPE).
> + * New vxlan tunnel extension "gpe" to support VXLAN-GPE tunnels.
> + * Transparently pop and push Ethernet headers at transmit/reception
> +   of packets to/from L3 tunnels.
> 
>  v2.7.0 - 21 Feb 2017
>  -
> diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
> index 2798324..0651322 100644
> --- a/lib/netdev-native-tnl.c
> +++ b/lib/netdev-native-tnl.c
> @@ -154,6 +154,10 @@ netdev_tnl_push_ip_header(struct dp_packet *packet,
>  *ip_tot_size = dp_packet_size(packet) - sizeof (struct eth_header);
> 
>  memcpy(eth, header, size);
> +/* The encapsulated packet has type Ethernet. Adjust dp_packet. */
> +packet->packet_type = htonl(PT_ETH);
> +dp_packet_reset_offsets(packet);
> +packet->l3_ofs = sizeof (struct eth_header);
> 
>  if (netdev_tnl_is_header_ipv6(header)) {
>  ip6 = netdev_tnl_ipv6_hdr(eth);
> @@ -345,6 +349,7 @@ parse_gre_header(struct dp_packet *packet,
>  ovs_16aligned_be32 *options;
>  int hlen;
>  unsigned int ulen;
> +uint16_t greh_protocol;
> 
>  greh = netdev_tnl_ip_extract_tnl_md(packet, tnl, );
>  if (!greh) {
> @@ -355,10 +360,6 @@ parse_gre_header(struct dp_packet *packet,
>  return -EINVAL;
>  }
> 
> -if (greh->protocol != htons(ETH_TYPE_TEB)) {
> -return -EINVAL;
> -}
> -
>  hlen = ulen + gre_header_len(greh->flags);
>  if (hlen > dp_packet_size(packet)) {
>  return -EINVAL;
> @@ -388,6 +389,17 @@ parse_gre_header(struct dp_packet *packet,
>  options++;
>  }
> 
> +/* Set the new packet type depending on the GRE protocol field. */
> +greh_protocol = ntohs(greh->protocol);
> +if (greh_protocol == ETH_TYPE_TEB) {
> +packet->packet_type = htonl(PT_ETH);
> +} else if (greh_protocol >= ETH_TYPE_MIN) {
> +/* Allow all GRE protocol valu

Re: [ovs-dev] [PATCH v8 1/3] userspace: Switching of L3 packets in L2 pipeline

2017-06-02 Thread Zoltán Balogh
Hi, 

V9 was sent to the mailing list, please review that one:
https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/86.html

/Zoltan

> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> Sent: Friday, May 26, 2017 9:26 AM
> To: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: [ovs-dev] [PATCH v8 1/3] userspace: Switching of L3 packets in L2 
> pipeline
> 
> From: Jan Scheurich <jan.scheur...@ericsson.com>
> 
> Ports have a new layer3 attribute if they send/receive L3 packets.
> 
> The packet_type included in structs dp_packet and flow is considered in
> ofproto-dpif. The classical L2 match fields (dl_src, dl_dst, dl_type, and
> vlan_tci, vlan_vid, vlan_pcp) now have Ethernet as pre-requisite.
> 
> A dummy ethernet header is pushed to L3 packets received from L3 ports
> before the the pipeline processing starts. The ethernet header is popped
> before sending a packet to a L3 port.
> 
> For datapath ports that can receive L2 or L3 packets, the packet_type
> becomes part of the flow key for datapath flows and is handled
> appropriately in dpif-netdev.
> 
> In the 'else' branch in flow_put_on_pmd() function, the additional check
> flow_equal(, _flow->flow) was removed, as a) the dpcls
> lookup is sufficient to uniquely identify a flow and b) it caused false
> negatives because the flow in netdev->flow may not properly masked.
> 
> In dpif_netdev_flow_put() we now use the same method for constructing the
> netdev_flow_key as the one used when adding the flow to the dplcs to make sure
> these always match. The function netdev_flow_key_from_flow() used so far was
> not only inefficient but sometimes caused mismatches and subsequent flow
> update failures.
> 
> The kernel datapath does not support the packet_type match field.
> Instead it encodes the packet type implictly by the presence or absence of
> the Ethernet attribute in the flow key and mask.
> This patch filters the PACKET_TYPE attribute out of netlink flow key and
> mask to be sent to the kernel datapath.
> 
> Signed-off-by: Lorand Jakab <loja...@cisco.com>
> Signed-off-by: Simon Horman <simon.hor...@netronome.com>
> Signed-off-by: Jiri Benc <jb...@redhat.com>
> Signed-off-by: Yi Yang <yi.y.y...@intel.com>
> Signed-off-by: Jan Scheurich <jan.scheur...@ericsson.com>
> Co-authored-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> ---
>  build-aux/extract-ofp-fields  |   1 +
>  datapath/linux/compat/include/linux/openvswitch.h |   2 +
>  include/openvswitch/match.h   |   1 +
>  include/openvswitch/meta-flow.h   |  15 +-
>  lib/dpif-netdev.c |  45 +++---
>  lib/dpif-netlink.c|  43 -
>  lib/dpif.c|   2 +-
>  lib/match.c   |  25 +++
>  lib/meta-flow.c   |   2 +
>  lib/netdev-vport.c|   8 +-
>  lib/netdev.h  |   1 +
>  lib/odp-execute.c |   2 +
>  lib/odp-util.c| 182 
> +-
>  lib/odp-util.h|   6 +-
>  lib/packets.h |   1 -
>  ofproto/ofproto-dpif-sflow.c  |   1 +
>  ofproto/ofproto-dpif-upcall.c |   4 +-
>  ofproto/ofproto-dpif-xlate.c  |  54 ++-
>  ofproto/ofproto-dpif.c|   6 +-
>  ofproto/tunnel.c  |   3 +
>  tests/tunnel-push-pop-ipv6.at |  10 +-
>  tests/tunnel-push-pop.at  |  14 +-
>  tests/tunnel.at   |  28 ++--
>  23 files changed, 337 insertions(+), 119 deletions(-)
> 
> diff --git a/build-aux/extract-ofp-fields b/build-aux/extract-ofp-fields
> index af7c69b..d5b8a82 100755
> --- a/build-aux/extract-ofp-fields
> +++ b/build-aux/extract-ofp-fields
> @@ -39,6 +39,7 @@ FORMATTING = {"decimal":("MFS_DECIMAL",  1, 
>   8),
>"TCP flags":  ("MFS_TCP_FLAGS",2,   2)}
> 
>  PREREQS = {"none": "MFP_NONE",
> +   "Ethernet": "MFP_ETHERNET",
> "ARP": "MFP_ARP",
> "VLAN VID": "MFP_VLAN_VID",
> "IPv4": "MFP_IPV4",
> diff --git a/datapath/linux/compat/include/linux/openvswitch.

[ovs-dev] [PATCH v3 3/6] userspace: Handling of versatile tunnel ports

2017-06-02 Thread Zoltán Balogh
From: Jan Scheurich 

In netdev_gre_build_header(), GRE protocol and VXLAN next_potocol is set based
on packet_type of flow. If it's about an Ethernet packet, it is set to
ETP_TYPE_TEB. Otherwise, if the name space is OFPHTN_ETHERNET, it is set
according to the name space type.

Signed-off-by: Jan Scheurich 
---
 lib/netdev-native-tnl.c  | 20 ++--
 ofproto/ofproto-dpif-xlate.c |  2 +-
 ofproto/tunnel.c | 24 
 ofproto/tunnel.h |  2 +-
 4 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index c7a299345..658c87101 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -463,10 +463,12 @@ netdev_gre_build_header(const struct netdev *netdev,
 
 greh = netdev_tnl_ip_build_header(data, params, IPPROTO_GRE);
 
-if (tnl_cfg->is_layer3) {
-greh->protocol = params->flow->dl_type;
-} else {
+if (params->flow->packet_type == htonl(PT_ETH)) {
 greh->protocol = htons(ETH_TYPE_TEB);
+} else if (pt_ns(params->flow->packet_type) == OFPHTN_ETHERTYPE) {
+greh->protocol = pt_ns_type_be(params->flow->packet_type);
+} else {
+return 1;
 }
 greh->flags = 0;
 
@@ -575,8 +577,10 @@ netdev_vxlan_build_header(const struct netdev *netdev,
 put_16aligned_be32(>vx_flags, htonl(VXLAN_FLAGS | VXLAN_HF_GPE));
 put_16aligned_be32(>vx_vni,
htonl(ntohll(params->flow->tunnel.tun_id) << 8));
-if (tnl_cfg->is_layer3) {
-switch (ntohs(params->flow->dl_type)) {
+if (params->flow->packet_type == htonl(PT_ETH)) {
+vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_ETHERNET;
+} else if (pt_ns(params->flow->packet_type) == OFPHTN_ETHERTYPE){
+switch (pt_ns_type(params->flow->packet_type)) {
 case ETH_TYPE_IP:
 vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_IPV4;
 break;
@@ -586,9 +590,13 @@ netdev_vxlan_build_header(const struct netdev *netdev,
 case ETH_TYPE_TEB:
 vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_ETHERNET;
 break;
+default:
+/* Drop packet. */
+return 1;
+break;
 }
 } else {
-vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_ETHERNET;
+return 1;
 }
 } else {
 put_16aligned_be32(>vx_flags, htonl(VXLAN_FLAGS));
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 63b9d5c1c..c22647289 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -6152,7 +6152,7 @@ xlate_wc_init(struct xlate_ctx *ctx)
 netflow_mask_wc(>xin->flow, ctx->wc);
 }
 
-tnl_wc_init(>xin->flow, ctx->wc);
+tnl_wc_init(>xin->flow, ctx->wc, ctx->xbridge->packet_type_aware);
 }
 
 static void
diff --git a/ofproto/tunnel.c b/ofproto/tunnel.c
index e27a9fb75..caf01be5f 100644
--- a/ofproto/tunnel.c
+++ b/ofproto/tunnel.c
@@ -361,7 +361,8 @@ tnl_process_ecn(struct flow *flow)
 }
 
 void
-tnl_wc_init(struct flow *flow, struct flow_wildcards *wc)
+tnl_wc_init(struct flow *flow, struct flow_wildcards *wc,
+bool packet_type_aware)
 {
 if (tnl_port_should_receive(flow)) {
 wc->masks.tunnel.tun_id = OVS_BE64_MAX;
@@ -386,8 +387,10 @@ tnl_wc_init(struct flow *flow, struct flow_wildcards *wc)
 && IP_ECN_is_ce(flow->tunnel.ip_tos)) {
 wc->masks.nw_tos |= IP_ECN_MASK;
 }
-/* Match on packet_type for tunneled packets.*/
-wc->masks.packet_type = OVS_BE32_MAX;
+if (!packet_type_aware) {
+/* Match on packet_type for tunneled packets.*/
+wc->masks.packet_type = OVS_BE32_MAX;
+}
 }
 }
 
@@ -566,8 +569,21 @@ tnl_find(const struct flow *flow) OVS_REQ_RDLOCK(rwlock)
 match.in_key_flow = in_key_flow;
 match.ip_dst_flow = ip_dst_flow;
 match.ip_src_flow = ip_src == IP_SRC_FLOW;
-match.is_layer3 = flow->packet_type != htonl(PT_ETH);
 
+/* If it's about a Non-ethernet packet then we look for a
+ * layer3 tunnel port first, as it would be attached to a
+ * non-PTAP bridge. Then for a versatile tunnel port as it
+ * would be attached to a PTAP bridge. */
+if (pt_ns(flow->packet_type) == OFPHTN_ETHERTYPE) {
+/* Try to find a layer3 port first. */
+match.is_layer3 = true;
+tnl_port = tnl_find_exact(, map);
+if (tnl_port) {
+return tnl_port;
+}
+}
+/* Check for a non-layer3 or versatile tunnel port. */
+   

[ovs-dev] [PATCH v3 1/6] userspace: Add OXM field MFF_PACKET_TYPE

2017-06-02 Thread Zoltán Balogh
From: Jan Scheurich 

Allow packet type namespace OFPHTN_ETHERTYPE as alternative pre-requisite
for matching L3 protocols (MPLS, IP, IPv6, ARP etc).

Change the meta-flow definition of packet_type field to use the new
custom format MFS_PACKET_TYPE representing "(NS,NS_TYPE)".

Parsing routine for MFS_PACKET_TYPE added to meta-flow.c. Formatting
routine for field packet_type extracted from match_format() and moved to
flow.c to be used from meta-flow.c for formatting MFS_PACKET_TYPE.

Updated the ovs-fields man page source meta-flow.xml with documentation
for packet-type-aware bridges and added documentation for field packet_type.

Added packet_type to the matching properties in tests/ofproto.at. Should be
removed later, when packet_type_aware bridge attribute will be introduced.

Signed-off-by: Jan Scheurich 
---
 build-aux/extract-ofp-fields|   3 +-
 include/openvswitch/meta-flow.h |  20 
 lib/flow.c  |  18 +++
 lib/flow.h  |  28 ---
 lib/match.c |  52 +---
 lib/meta-flow.c |  86 +---
 lib/meta-flow.xml   | 106 +++-
 lib/nx-match.c  |  16 --
 lib/odp-util.c  |  48 --
 lib/ofp-parse.c |   6 +++
 lib/ofp-util.c  |  42 +++-
 tests/dpif-netdev.at|  14 +++---
 tests/odp.at|   1 +
 tests/ofproto-dpif.at   |  20 
 tests/ofproto.at|   1 +
 tests/pmd.at|   2 +-
 tests/tunnel-push-pop-ipv6.at   |   2 +-
 tests/tunnel-push-pop.at|   2 +-
 18 files changed, 362 insertions(+), 105 deletions(-)

diff --git a/build-aux/extract-ofp-fields b/build-aux/extract-ofp-fields
index d5b8a8202..24dd756ad 100755
--- a/build-aux/extract-ofp-fields
+++ b/build-aux/extract-ofp-fields
@@ -36,7 +36,8 @@ FORMATTING = {"decimal":("MFS_DECIMAL",  1,   
8),
   "OpenFlow 1.1+ port": ("MFS_OFP_PORT_OXM", 4,   4),
   "frag":   ("MFS_FRAG", 1,   1),
   "tunnel flags":   ("MFS_TNL_FLAGS",2,   2),
-  "TCP flags":  ("MFS_TCP_FLAGS",2,   2)}
+  "TCP flags":  ("MFS_TCP_FLAGS",2,   2),
+  "packet type":("MFS_PACKET_TYPE",  4,   4)}
 
 PREREQS = {"none": "MFP_NONE",
"Ethernet": "MFP_ETHERNET",
diff --git a/include/openvswitch/meta-flow.h b/include/openvswitch/meta-flow.h
index cbfd3ba65..3a17d7b06 100644
--- a/include/openvswitch/meta-flow.h
+++ b/include/openvswitch/meta-flow.h
@@ -133,6 +133,11 @@ struct ofputil_tlv_table_mod;
  *
  *   TCP flags: See the description of tcp_flags in ovs-ofctl(8).
  *
+ *   packet type: A pair of packet type namespace NS and NS_TYPE within
+ *   that namespace "(NS,NS_TYPE)". NS and NS_TYPE are formatted in
+ *   decimal or hexadecimal as and accept decimal and hexadecimal (with
+ *   0x prefix) at parsing.
+ *
  *   Prerequisites:
  *
  * The field's prerequisites.  The values should be straightfoward.
@@ -248,6 +253,20 @@ enum OVS_PACKED_ENUM mf_field_id {
  */
 MFF_RECIRC_ID,
 
+/* "packet_type".
+ *
+ * Define the packet type in OpenFlow 1.3+.
+ *
+ * Type: be32.
+ * Maskable: no.
+ * Formatting: packet type.
+ * Prerequisites: none.
+ * Access: read-only.
+ * NXM: none.
+ * OXM: OXM_OF_PACKET_TYPE(44) since OF1.3 and v2.8.
+ */
+MFF_PACKET_TYPE,
+
 /* "conj_id".
  *
  * ID for "conjunction" actions.  Please refer to ovs-ofctl(8)
@@ -1860,6 +1879,7 @@ enum OVS_PACKED_ENUM mf_string {
 MFS_FRAG,   /* no, yes, first, later, not_later */
 MFS_TNL_FLAGS,  /* FLOW_TNL_F_* flags */
 MFS_TCP_FLAGS,  /* TCP_* flags */
+MFS_PACKET_TYPE,/* "(NS,NS_TYPE)" */
 };
 
 struct mf_field {
diff --git a/lib/flow.c b/lib/flow.c
index 779bb54d5..306874363 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -1150,6 +1150,24 @@ format_flags_masked(struct ds *ds, const char *name,
 }
 }
 
+void
+format_packet_type_masked(struct ds *s, const ovs_be32 value, const ovs_be32 
mask)
+{
+if (pt_ns_type_be(mask) == 0) {
+ds_put_format(s, "packet_type=(%u,*),",
+  pt_ns(value));
+} else if (pt_ns_type_be(mask) == OVS_BE16_MAX) {
+ds_put_format(s, "packet_type=(%u,%#"PRIx16"),",
+  pt_ns(value),
+  pt_ns_type(value));
+} else{
+ds_put_format(s, "packet_type=(%u,%#"PRIx16"/%#"PRIx16"),",
+  pt_ns(value),
+  pt_ns_type(value),
+  pt_ns_type(mask));
+}
+}
+
 /* Scans a string 's' of flags to determine their numerical value and
  * returns the number 

[ovs-dev] [PATCH v3 2/6] userspace: Add bridge property 'packet-type-aware'

2017-06-02 Thread Zoltán Balogh
From: Jan Scheurich 

New boolean parameter "other-config:packet-type-aware' in bridge table.
Pass non-Ethernet packets unchanged into packet-type-aware bridges.
Do not convert packet type when sending packet from packet-type-aware
bridge to a port.

Only include field MFF_PACKET_TYPE in matchabale and maskable fields
if the ofproto bridge is packet-type-aware.

Add default match on packet_type Ethernet in case of packet-type-aware bridge.
Reject packet_type match in case of non-ptap bridge.

Removed packet_type from list of matching properties in tests/ofproto.at.

Signed-off-by: Jan Scheurich 
---
 lib/nx-match.c   | 10 --
 lib/nx-match.h   |  4 ++--
 ofproto/ofproto-dpif-xlate.c | 36 +++-
 ofproto/ofproto-dpif-xlate.h |  1 +
 ofproto/ofproto-dpif.c   |  1 +
 ofproto/ofproto-provider.h   |  1 +
 ofproto/ofproto.c| 26 +++---
 ofproto/ofproto.h|  1 +
 tests/ofproto.at |  1 -
 vswitchd/bridge.c|  9 +
 vswitchd/vswitch.xml |  9 +
 11 files changed, 78 insertions(+), 21 deletions(-)

diff --git a/lib/nx-match.c b/lib/nx-match.c
index 9657dc01f..0cde69981 100644
--- a/lib/nx-match.c
+++ b/lib/nx-match.c
@@ -2083,12 +2083,15 @@ oxm_writable_fields(void)
 /* Returns a bitmap of fields that can be encoded in OXM and that can be
  * matched in a flow table.  */
 struct mf_bitmap
-oxm_matchable_fields(void)
+oxm_matchable_fields(bool packet_type_aware)
 {
 struct mf_bitmap b = MF_BITMAP_INITIALIZER;
 int i;
 
 for (i = 0; i < MFF_N_IDS; i++) {
+if (i == MFF_PACKET_TYPE && !packet_type_aware) {
+continue;
+}
 if (mf_oxm_header(i, 0)) {
 bitmap_set1(b.bm, i);
 }
@@ -2099,12 +2102,15 @@ oxm_matchable_fields(void)
 /* Returns a bitmap of fields that can be encoded in OXM and that can be
  * matched in a flow table with an arbitrary bitmask.  */
 struct mf_bitmap
-oxm_maskable_fields(void)
+oxm_maskable_fields(bool packet_type_aware)
 {
 struct mf_bitmap b = MF_BITMAP_INITIALIZER;
 int i;
 
 for (i = 0; i < MFF_N_IDS; i++) {
+if (i == MFF_PACKET_TYPE && !packet_type_aware) {
+continue;
+}
 if (mf_oxm_header(i, 0) && mf_from_id(i)->maskable == MFM_FULLY) {
 bitmap_set1(b.bm, i);
 }
diff --git a/lib/nx-match.h b/lib/nx-match.h
index 90cb6f8fd..fa995a167 100644
--- a/lib/nx-match.h
+++ b/lib/nx-match.h
@@ -149,8 +149,8 @@ ovs_be64 oxm_bitmap_from_mf_bitmap(const struct mf_bitmap 
*, enum ofp_version);
 struct mf_bitmap oxm_bitmap_to_mf_bitmap(ovs_be64 oxm_bitmap,
  enum ofp_version);
 struct mf_bitmap oxm_writable_fields(void);
-struct mf_bitmap oxm_matchable_fields(void);
-struct mf_bitmap oxm_maskable_fields(void);
+struct mf_bitmap oxm_matchable_fields(bool packet_type_aware);
+struct mf_bitmap oxm_maskable_fields(bool packet_type_aware);
 
 /* Dealing with the 'ofs_nbits' members in several Nicira extensions. */
 
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index e682e2f6f..63b9d5c1c 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -108,6 +108,7 @@ struct xbridge {
 
 bool has_in_band; /* Bridge has in band control? */
 bool forward_bpdu;/* Bridge forwards STP BPDUs? */
+bool packet_type_aware;   /* Bridge is packet-type-aware? */
 
 /* Datapath feature support. */
 struct dpif_backer_support support;
@@ -555,6 +556,7 @@ static void xlate_xbridge_set(struct xbridge *, struct dpif 
*,
   const struct dpif_ipfix *,
   const struct netflow *,
   bool forward_bpdu, bool has_in_band,
+  bool packet_type_aware,
   const struct dpif_backer_support *);
 static void xlate_xbundle_set(struct xbundle *xbundle,
   enum port_vlan_mode vlan_mode,
@@ -815,6 +817,7 @@ xlate_xbridge_set(struct xbridge *xbridge,
   const struct dpif_ipfix *ipfix,
   const struct netflow *netflow,
   bool forward_bpdu, bool has_in_band,
+  bool packet_type_aware,
   const struct dpif_backer_support *support)
 {
 if (xbridge->ml != ml) {
@@ -860,6 +863,7 @@ xlate_xbridge_set(struct xbridge *xbridge,
 xbridge->dpif = dpif;
 xbridge->forward_bpdu = forward_bpdu;
 xbridge->has_in_band = has_in_band;
+xbridge->packet_type_aware = packet_type_aware;
 xbridge->support = *support;
 }
 
@@ -950,7 +954,7 @@ xlate_xbridge_copy(struct xbridge *xbridge)
   xbridge->rstp, xbridge->ms, xbridge->mbridge,
   xbridge->sflow, xbridge->ipfix, xbridge->netflow,
 

[ovs-dev] [PATCH v9 3/3] userspace: add vxlan gpe support to vport

2017-06-02 Thread Zoltán Balogh
From: Georg Schmuecking 

This patch is based on the "datapath: enable vxlangpe creation in compat mode"
from Yi Yang. It introduces an extension option "gpe" to the vxlan port in the
netdev-dpdk datapath. Description of vxlan gpe protocoll was added to header
file lib/packets.h. In the vxlan specific methods the different packet are
introduced and handled.

Added VXLAN GPE tunnel push test.

Signed-off-by: Yi Yang 
Signed-off-by: Georg Schmuecking 
---
 datapath/linux/compat/include/linux/openvswitch.h |  1 +
 include/openvswitch/automake.mk   |  1 -
 lib/netdev-native-tnl.c   | 59 +--
 lib/netdev-vport.c| 22 +++--
 lib/packets.h | 54 -
 tests/tunnel-push-pop.at  | 10 
 vswitchd/vswitch.xml  |  5 ++
 7 files changed, 140 insertions(+), 12 deletions(-)

diff --git a/datapath/linux/compat/include/linux/openvswitch.h 
b/datapath/linux/compat/include/linux/openvswitch.h
index d29e61e97..4c88de1d6 100644
--- a/datapath/linux/compat/include/linux/openvswitch.h
+++ b/datapath/linux/compat/include/linux/openvswitch.h
@@ -291,6 +291,7 @@ enum ovs_vport_attr {
 enum {
OVS_VXLAN_EXT_UNSPEC,
OVS_VXLAN_EXT_GBP,  /* Flag or __u32 */
+   OVS_VXLAN_EXT_GPE = 8,  /* Flag or __u32 */
__OVS_VXLAN_EXT_MAX,
 };
 
diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk
index c0e276f9d..699d9d74e 100644
--- a/include/openvswitch/automake.mk
+++ b/include/openvswitch/automake.mk
@@ -30,4 +30,3 @@ openvswitchinclude_HEADERS = \
include/openvswitch/version.h \
include/openvswitch/vconn.h \
include/openvswitch/vlog.h
-
diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index 0651322ec..c7a299345 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -499,6 +499,8 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
 struct flow_tnl *tnl = >tunnel;
 struct vxlanhdr *vxh;
 unsigned int hlen;
+ovs_be32 vx_flags;
+enum packet_type next_pt = PT_ETH;
 
 pkt_metadata_init_tnl(md);
 if (VXLAN_HLEN > dp_packet_l4_size(packet)) {
@@ -510,18 +512,43 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
 goto err;
 }
 
-if (get_16aligned_be32(>vx_flags) != htonl(VXLAN_FLAGS) ||
+vx_flags = get_16aligned_be32(>vx_flags);
+if (vx_flags & htonl(VXLAN_HF_GPE)) {
+vx_flags &= htonl(~VXLAN_GPE_USED_BITS);
+/* Drop the OAM packets */
+if (vxh->vx_gpe.flags & VXLAN_GPE_FLAGS_O) {
+goto err;
+}
+switch (vxh->vx_gpe.next_protocol) {
+case VXLAN_GPE_NP_IPV4:
+next_pt = PT_IPV4;
+break;
+case VXLAN_GPE_NP_IPV6:
+next_pt = PT_IPV6;
+break;
+case VXLAN_GPE_NP_ETHERNET:
+next_pt = PT_ETH;
+break;
+default:
+goto err;
+}
+}
+
+if (vx_flags != htonl(VXLAN_FLAGS) ||
(get_16aligned_be32(>vx_vni) & htonl(0xff))) {
 VLOG_WARN_RL(_rl, "invalid vxlan flags=%#x vni=%#x\n",
- ntohl(get_16aligned_be32(>vx_flags)),
+ ntohl(vx_flags),
  ntohl(get_16aligned_be32(>vx_vni)));
 goto err;
 }
 tnl->tun_id = htonll(ntohl(get_16aligned_be32(>vx_vni)) >> 8);
 tnl->flags |= FLOW_TNL_F_KEY;
 
-packet->packet_type = htonl(PT_ETH);
+packet->packet_type = htonl(next_pt);
 dp_packet_reset_packet(packet, hlen + VXLAN_HLEN);
+if (next_pt != PT_ETH) {
+packet->l3_ofs = 0;
+}
 
 return packet;
 err:
@@ -544,8 +571,30 @@ netdev_vxlan_build_header(const struct netdev *netdev,
 
 vxh = udp_build_header(tnl_cfg, data, params);
 
-put_16aligned_be32(>vx_flags, htonl(VXLAN_FLAGS));
-put_16aligned_be32(>vx_vni, htonl(ntohll(params->flow->tunnel.tun_id) 
<< 8));
+if (tnl_cfg->exts & (1 << OVS_VXLAN_EXT_GPE)) {
+put_16aligned_be32(>vx_flags, htonl(VXLAN_FLAGS | VXLAN_HF_GPE));
+put_16aligned_be32(>vx_vni,
+   htonl(ntohll(params->flow->tunnel.tun_id) << 8));
+if (tnl_cfg->is_layer3) {
+switch (ntohs(params->flow->dl_type)) {
+case ETH_TYPE_IP:
+vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_IPV4;
+break;
+case ETH_TYPE_IPV6:
+vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_IPV6;
+break;
+case ETH_TYPE_TEB:
+vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_ETHERNET;
+break;
+}
+} else {
+vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_ETHERNET;
+}
+} else {
+put_16aligned_be32(>vx_flags, htonl(VXLAN_FLAGS));
+put_16aligned_be32(>vx_vni,

[ovs-dev] [PATCH v9 0/3] userspace: Support for L3 tunneling

2017-06-02 Thread Zoltán Balogh
From: Jan Scheurich 

This patch set is part of an initiative to deal with non-Ethernet packets in 
OVS for advanced use cases like L3 tunneling or NSH. The initiative is 
centering on the new OpenFlow concepts of "Packet type-aware pipeline" (PTAP) 
and "Generic encap/decap actions" (EXT-382). The overall design is documented 
in 
https://docs.google.com/document/d/1oWMYUH8sjZJzWa72o2q9kU0N6pNE-rwZcLH3-kbbDR8

The patches implement the user-space parts of the support for L3 tunnels 
connected to the legacy Ethernet-only pipeline in OVS. In large parts it is an 
adaptation of the earlier work on L3 tunneling by Lorand Jakab, Simon Horman, 
Jiri Benc and Yi Yang, adapted to the new design for packet type aware 
pipelines as prototyped by Jean Tourrilhes. 

Key changes compared to earlier patch series are the introduction of explicit 
packet_type members in the structs dp_packet and flow, as well as a simpler 
handling of L3 tunnels limited to the ofproto layer.

The present series v9 supersedes v8 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332895.html), v9 is 
rebased to recent origin/master (5978c2e31).
The present series v8 supersedes v7 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332837.html), v8 fixes 
a typo and adds BUILD_ASSERC_DELC for struct vxlanhdr.
The present series v7 supersedes v6 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332367.html). Header 
file vxlangpe.h was removed, its content was moved into VXLAN section of 
lib/packets.h. Two patches were merged into a single one and fixes were done 
based on review comments.
The present series v6 supersedes v5 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332151.html). The 
reason of creating v6 is that tunnel handling has been changed on master 
branch, so rebasing was necessary.
The present series v5 supersedes v4 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/331424.html), v4 
fixes struct ovs_action_push_eth, so kernel and userspace use same data 
structure and removes a patch from the series which was applied to master.
The series v4 supersedes v3 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/330488.html), v4 
fixes sparse warnings coding style and removes a patch from the series.
The series v3 superseded v2 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/330444.html) which 
added support for vxlan-gpe tunnels in the netdev-dpdk datapath based on 
earlier patches 14-16 out of a patch set by Yi Yang 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-February/328498.html). 

   userspace: Switching of L3 packets in L2 pipeline 
   userspace: L3 tunnel support for GRE and LISP 
   userspace: add vxlan gpe support to vport

For native L3 tunneling with the userspace datapath these patches are complete 
and could be merged.

The necessary kernel module changes for L3 tunneling have already been 
upstreamed to the net-next kernel and back-ported to OVS. To apply L3 tunneling 
to the kernel datapath, one will need the following additional contributions:

* [PATCH v2 0/7] create tunnel devices using rtnetlink interface
   https://mail.openvswitch.org/pipermail/ovs-dev/2017-March/329893.html 
* An additional user-space patch based on the above to configure the layer3 
tunnel option in the kernel datapath

Changes v1 -> v2:
* Rebased to master (f40c558 ovn: Gratuitous ARP for distributed NAT rules)
* Moved new packet_type member to fill a 4-byte padding in struct flow
* Define the packet_type constants to be in host byte order
* Update the display format of packet_type in match and flow key printouts to a 
pair format "(ns, type)"
* Renamed dp_packet_l2() to dp_packet_eth()
* Removed unnecessary wrappers dp_packet_packet_type() and 
dp_packet_set_packet_type()
* Fixed "sparse" warnings
* Removed misleading or unnecessary comments
* Added support for vxlan-gpe tunnel vports for Ethernet, IPv4, IPv6 and NSH 
payload

Changes v2 -> v3:
* Removed unused function dp_packet_is_l3()
* Using VLOG_DROP_DBG and VLOG_DBG instead of VLOG_DBG_RL in 
dp_netdev_flow_add()
* Moved changes related comment from flow_put_on_md() into commit message
* PT_NS* macros were replaced with inline functions
* Unnecessary if statements removed from match_format()
* Using assignment operator instead of memset where it's possible
* Improved some commit messages

Changes v3 -> v4:
* Fixed "sparse" warnings
* Fixed coding style
* Removed patch "ofproto-dpif-upcall: Intialize dump-seq of new flow to zero"
* Rebased to origin/master (9a84f46)

Changes v4 -> v5:
* Eth_type member removed from struct ovs_action_push_eth.
* Patch "userspace: Add packet_type in dp_packet and flow" exluded.

Changes v5 -> v6:
* Rebased to origin/master (f5f6455)
* Patch "userspace: Support for push_eth and pop_eth actions" exluded.

Changes v6 -> v7:
* Rebased to origin/master (b50fcaa)
* Patch "dpif-netlink: Don't send PACKET_TYPE to kernel" merged into patch 
"userspace: Switching 

[ovs-dev] [PATCH v9 1/3] userspace: Switching of L3 packets in L2 pipeline

2017-06-02 Thread Zoltán Balogh
From: Jan Scheurich 

Ports have a new layer3 attribute if they send/receive L3 packets.

The packet_type included in structs dp_packet and flow is considered in
ofproto-dpif. The classical L2 match fields (dl_src, dl_dst, dl_type, and
vlan_tci, vlan_vid, vlan_pcp) now have Ethernet as pre-requisite.

A dummy ethernet header is pushed to L3 packets received from L3 ports
before the the pipeline processing starts. The ethernet header is popped
before sending a packet to a L3 port.

For datapath ports that can receive L2 or L3 packets, the packet_type
becomes part of the flow key for datapath flows and is handled
appropriately in dpif-netdev.

In the 'else' branch in flow_put_on_pmd() function, the additional check
flow_equal(, _flow->flow) was removed, as a) the dpcls
lookup is sufficient to uniquely identify a flow and b) it caused false
negatives because the flow in netdev->flow may not properly masked.

In dpif_netdev_flow_put() we now use the same method for constructing the
netdev_flow_key as the one used when adding the flow to the dplcs to make sure
these always match. The function netdev_flow_key_from_flow() used so far was
not only inefficient but sometimes caused mismatches and subsequent flow
update failures.

The kernel datapath does not support the packet_type match field.
Instead it encodes the packet type implictly by the presence or absence of
the Ethernet attribute in the flow key and mask.
This patch filters the PACKET_TYPE attribute out of netlink flow key and
mask to be sent to the kernel datapath.

Signed-off-by: Lorand Jakab 
Signed-off-by: Simon Horman 
Signed-off-by: Jiri Benc 
Signed-off-by: Yi Yang 
Signed-off-by: Jan Scheurich 
Co-authored-by: Zoltan Balogh 
---
 build-aux/extract-ofp-fields  |   1 +
 datapath/linux/compat/include/linux/openvswitch.h |   2 +
 include/openvswitch/match.h   |   1 +
 include/openvswitch/meta-flow.h   |  15 +-
 lib/dpif-netdev.c |  45 +++---
 lib/dpif-netlink.c|  43 -
 lib/dpif.c|   2 +-
 lib/match.c   |  25 +++
 lib/meta-flow.c   |   2 +
 lib/netdev-vport.c|   8 +-
 lib/netdev.h  |   1 +
 lib/odp-execute.c |   2 +
 lib/odp-util.c| 182 +-
 lib/odp-util.h|   6 +-
 lib/packets.h |   1 -
 ofproto/ofproto-dpif-sflow.c  |   1 +
 ofproto/ofproto-dpif-upcall.c |   4 +-
 ofproto/ofproto-dpif-xlate.c  |  54 ++-
 ofproto/ofproto-dpif.c|   6 +-
 ofproto/tunnel.c  |   3 +
 tests/tunnel-push-pop-ipv6.at |  10 +-
 tests/tunnel-push-pop.at  |  14 +-
 tests/tunnel.at   |  28 ++--
 23 files changed, 337 insertions(+), 119 deletions(-)

diff --git a/build-aux/extract-ofp-fields b/build-aux/extract-ofp-fields
index af7c69b22..d5b8a8202 100755
--- a/build-aux/extract-ofp-fields
+++ b/build-aux/extract-ofp-fields
@@ -39,6 +39,7 @@ FORMATTING = {"decimal":("MFS_DECIMAL",  1,   
8),
   "TCP flags":  ("MFS_TCP_FLAGS",2,   2)}
 
 PREREQS = {"none": "MFP_NONE",
+   "Ethernet": "MFP_ETHERNET",
"ARP": "MFP_ARP",
"VLAN VID": "MFP_VLAN_VID",
"IPv4": "MFP_IPV4",
diff --git a/datapath/linux/compat/include/linux/openvswitch.h 
b/datapath/linux/compat/include/linux/openvswitch.h
index 55ec6c13f..d29e61e97 100644
--- a/datapath/linux/compat/include/linux/openvswitch.h
+++ b/datapath/linux/compat/include/linux/openvswitch.h
@@ -363,6 +363,8 @@ enum ovs_key_attr {
/* Only used within kernel data path. */
OVS_KEY_ATTR_TUNNEL_INFO,  /* struct ovs_tunnel_info */
 #endif
+
+   OVS_KEY_ATTR_PACKET_TYPE,  /* be32 packet type */
__OVS_KEY_ATTR_MAX
 };
 
diff --git a/include/openvswitch/match.h b/include/openvswitch/match.h
index ca1dc7df9..9e15da24d 100644
--- a/include/openvswitch/match.h
+++ b/include/openvswitch/match.h
@@ -116,6 +116,7 @@ void match_set_ct_ipv6_dst(struct match *, const struct 
in6_addr *);
 void match_set_ct_ipv6_dst_masked(struct match *, const struct in6_addr *,
   const struct in6_addr *);
 
+void match_set_packet_type(struct match *, ovs_be32 packet_type);
 void match_set_skb_priority(struct match *, uint32_t skb_priority);
 void match_set_dl_type(struct match *, ovs_be16);
 void match_set_dl_src(struct match *, 

[ovs-dev] [PATCH v2 ] bfd: Detect Multiplier configuration

2017-06-02 Thread Zoltán Balogh
From: Gábor Szűcs 

Hi,
hereby I'm sending an implementation of configurable BFD Detect Multiplier.

Mult value (bfd.DetectMult in RFC5880) is hard-coded and equal to 3 in
current openvswitch. As a consequence remote and local mult is the same.

In this commit the mult (Detect Multiplier/bfd.DetectMult/Detect Mult)
can be set on each interface setting the mult= in bfd Column
in Interface table of ovsdb database.
Example:
ovs-vsctl set Interface p1 bfd:mult=4
sets mult=4 on p1 interface

The modification based on RFC5880 June 2010.
The relevant paragraphs are:
4.1. Generic BFD Control Packet Format
6.8.4. Calculating the Detection Time
6.8.7. Transmitting BFD Control Packets
6.8.12. Detect Multiplier Change

The mult value is set to default 3 if it is not set in ovsdb. This
provides backward compatibility to previous openvswitch behaviour.
The RFC5880 says in 6.8.1 that DetectMult shall be a non-zero integer.
In RFC5880 4.1. "Detect Mult" has 8 bit length and is declared
as a 8 bit unsigned integer in bfd.c.
Consequently mult value shall be greater than 0 and less then 256.
In case of incorrect mult value is given in ovsdb the default value (3)
will be set and a message is logged into ovs-vswitchd.log on that.
Local or remote mult value change is also logged into ovs-vswitchd.log.

Since remote and local mult is not the same calculation of detect time
has been changed. Due to RFC5880 6.8.4 Detection Time is calculated using
mult value of the remote system.
Detection time is recalculated due to remote mult change.

The BFD packet transmission jitter is different in case of mult=1
due to RFC5880 6.8.7. The maximum interval of the transmitted bfd packet
is 90% of the transmission interval.

The value of remote mult is printed in the last line of the output of
ovs-appctl bfd/show command with label: Remote Detect Mult.

There is a feature in openvswitch connected with forwarding_if_rx that
is not the part of RFC5880. This feature also uses mult value but it is
not specified if local or remote since it was the
same in original code. The relevant description in code:
   /* When 'bfd->forwarding_if_rx' is set, at least one bfd control packet
 * is required to be received every 100 * bfd->cfg_min_rx.  If bfd
 * control packet is not received within this interval, even if data
 * packets are received, the bfd->forwarding will still be false. */

Due to lack of specification local mult value is used for calculation of
forwarding_if_rx_detect_time. This detect time is recalculated at mult
change if forwarding_if_rx is true and bfd is in UP state.

A new unit test has been added: "bfd - Edit the Detect Mult values"
The following cases are tested:
- Without setting mult the mult will be the default value (3).
- The setting of the lowest (1) and highest (255) valid mult value
  and the detection of remote mult value.
- The setting of out of range mult value (0, 256) in ovsdb results
  sets default value in ovs-vswitchd
- Clearing non default mult value from ovsdb results sets default
  value in ovs-vswitchd.

Signed-off-by: Gábor Szűcs 
---
diff --git a/lib/bfd.c b/lib/bfd.c
index 383be20..cc3adc7 100644
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -146,6 +146,8 @@ BUILD_ASSERT_DECL(BFD_PACKET_LEN == sizeof(structmsg));
 #define VERS_SHIFT 5
 #define STATE_MASK 0xC0
 #define FLAGS_MASK 0x3f
+#define DEFAULT_MULT 3
+

 struct bfd {
 struct hmap_node node;/* In 'all_bfds'. */
@@ -155,6 +157,7 @@ struct bfd {

 bool cpath_down;  /* Concatenated Path Down. */
 uint8_t mult; /* bfd.DetectMult. */
+uint8_t rmt_mult; /* Remote bfd.DetectMult. */

 struct netdev *netdev;
 uint64_t rx_packets;  /* Packets received by 'netdev'. */
@@ -354,6 +357,8 @@ bfd_configure(struct bfd *bfd, const char *name, const 
struct smap *cfg,
 bool need_poll = false;
 bool cfg_min_rx_changed = false;
 bool cpath_down, forwarding_if_rx;
+int new_mult;
+int old_mult;

 if (!cfg || !smap_get_bool(cfg, "enable", false)) {
 bfd_unref(bfd);
@@ -370,7 +375,8 @@ bfd_configure(struct bfd *bfd, const char *name, const 
struct smap *cfg,

 bfd->diag = DIAG_NONE;
 bfd->min_tx = 1000;
-bfd->mult = 3;
+bfd->rmt_mult = 0;
+bfd->mult = DEFAULT_MULT;
 ovs_refcount_init(>ref_cnt);
 bfd->netdev = netdev_ref(netdev);
 bfd->rx_packets = bfd_rx_packets(bfd);
@@ -389,6 +395,21 @@ bfd_configure(struct bfd *bfd, const char *name, const 
struct smap *cfg,
 bfd_status_changed(bfd);
 }

+old_mult = bfd->mult;
+
+new_mult = smap_get_int(cfg, "mult", DEFAULT_MULT);
+if (new_mult < 1 || new_mult > 255) {
+VLOG_INFO("Interface %s mult value %d out of range 1-255 changedto %d",
+   name, new_mult, DEFAULT_MULT);
+new_mult = DEFAULT_MULT;
+}
+
+bfd->mult = (uint8_t) new_mult;
+if (new_mult 

Re: [ovs-dev] [PATCH v5] tunneling: Avoid recirculation on datapath by computing the recirculate actions at translate time.

2017-05-26 Thread Zoltán Balogh

Hi Joe,

> Backing up a bit for context, the stats attribution goes roughly like this:
> * First upcall, handler thread calls through the translate code with a
> packet. The resubmit_stats are derived from that packet. This goes
> through xlate_actions().
> * First dump of flow from revalidator thread fetches the flow and runs
> the same xlate_actions() with whatever stats it has (may be zero).
> This time, whenever stats attribution or side effects occur, an
> xlate_cache entry is generated.
> * Second and subsequent dumps of flows fetches the flow and shortcuts
> the xlate_actions() by using the xlate_cache instead - ie a call to
> xlate_push_stats().
> 
> So, in the same place where the resubmit_stats is manipulated, you
> would also need to generate a new XC entry which would manipulate the
> stats - this would be a 'side-effect'. I'd imagine that prior to the
> full output translation there would be a XC_TRUNCATE(truncated_size)
> then afterwards there would be an XC_TRUNCATE_RESET(). Or it could be
> just XC_SET_SIZE(...) where 0 is reset and non-zero is a truncate
> size. In the implementation/execution in xlate_push_stats() when
> performing XC_TRUNCATE you would need to store the original push_stats
> size somewhere, then calculate a new 'n_bytes' based on the number of
> packets and existing bytes*. For XC_TRUNCATE_RESET(), it would restore
> the original push_stats size.

 Thank you for the explanation.
 
> * Hmm, I'm not sure the calculation will be 100% here. Let's say there
> were 3 packets hit the flow, 50B, 200B, 300B. If output(max_len=100)
> was executed, then we don't know how many of the packets were
> truncated. The maximum number of bytes that could be transmitted is
> 300, but the actual number was 250. We could divide the n_bytes by
> n_packets, subtract the max_len and then multiply back up by the
> number of packets, which works for this case assuming floating point
> arithmetic but is slightly off if using integer math..

I don't think, that would be the proper way of calculating n_bytes. Let's 
say we have 3 packets with 50B, 200B, 200B and max_len=100. The output 
should be 50 + 100 + 100 = 250B.
Following the instructions above we will get 
[(50 + 200 + 200) / 3 - 100 ] * 3 = [450 / 3 - 100 ] * 3 = 50 * 3 = 150B

Any other idea how to calculate the truncated size with xlate cache? 
Or maybe I did not understand your calculation.

There is one more thing to be taken into consideration. By adding a tunnel 
header, the size of packets increases as well. But that's a constant value
for each packet, easier to calculate with it.

Best regards,
Zoltan

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v7 3/3] userspace: add vxlan gpe support to vport

2017-05-26 Thread Zoltán Balogh
Hi,

Please have a look at v8:
https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332898.html

Best regards,
Zoltan


> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> Sent: Thursday, May 25, 2017 5:38 PM
> To: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: [ovs-dev] [PATCH v7 3/3] userspace: add vxlan gpe support to vport
> 
> From: Georg Schmuecking <georg.schmueck...@ericsson.com>
> 
> This patch is based on the "datapath: enable vxlangpe creation in compat mode"
> from Yi Yang. It introduces an extension option "gpe" to the vxlan port in the
> netdev-dpdk datapath. Description of vxlan gpe protocoll was added to header
> file lib/packets.h. In the vxlan specific methods the different packet are
> introduced and handled.
> 
> Added VXLAN GPE tunnel push test.
> 
> Signed-off-by: Yi Yang 
> Signed-off-by: Georg Schmuecking <georg.schmueck...@ericsson.com>
> ---
>  datapath/linux/compat/include/linux/openvswitch.h |  1 +
>  include/openvswitch/automake.mk   |  1 -
>  lib/netdev-native-tnl.c   | 59 
> +--
>  lib/netdev-vport.c| 22 +++--
>  lib/packets.h | 54 -
>  tests/tunnel-push-pop.at  | 10 
>  6 files changed, 135 insertions(+), 12 deletions(-)
> 
> diff --git a/datapath/linux/compat/include/linux/openvswitch.h 
> b/datapath/linux/compat/include/linux/openvswitch.h
> index 7990638..2ae1797 100644
> --- a/datapath/linux/compat/include/linux/openvswitch.h
> +++ b/datapath/linux/compat/include/linux/openvswitch.h
> @@ -291,6 +291,7 @@ enum ovs_vport_attr {
>  enum {
>   OVS_VXLAN_EXT_UNSPEC,
>   OVS_VXLAN_EXT_GBP,  /* Flag or __u32 */
> + OVS_VXLAN_EXT_GPE = 8,  /* Flag or __u32 */
>   __OVS_VXLAN_EXT_MAX,
>  };
> 
> diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk
> index c0e276f..699d9d7 100644
> --- a/include/openvswitch/automake.mk
> +++ b/include/openvswitch/automake.mk
> @@ -30,4 +30,3 @@ openvswitchinclude_HEADERS = \
>   include/openvswitch/version.h \
>   include/openvswitch/vconn.h \
>   include/openvswitch/vlog.h
> -
> diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
> index 0651322..8ae8893 100644
> --- a/lib/netdev-native-tnl.c
> +++ b/lib/netdev-native-tnl.c
> @@ -499,6 +499,8 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
>  struct flow_tnl *tnl = >tunnel;
>  struct vxlanhdr *vxh;
>  unsigned int hlen;
> +ovs_be32 vx_flags;
> +enum packet_type next_pt = PT_ETH;
> 
>  pkt_metadata_init_tnl(md);
>  if (VXLAN_HLEN > dp_packet_l4_size(packet)) {
> @@ -510,18 +512,43 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
>  goto err;
>  }
> 
> -if (get_16aligned_be32(>vx_flags) != htonl(VXLAN_FLAGS) ||
> +vx_flags = get_16aligned_be32(>vx_flags);
> +if (vx_flags & htonl(VXLAN_HF_GPE)) {
> +vx_flags &= htonl(~VXLAN_GPE_USED_BITS);
> +/* Drop the OAM packets */
> +if (vxh->vx_pge.flags & VXLAN_GPE_FLAGS_O) {
> +goto err;
> +}
> +switch (vxh->vx_pge.next_protocol) {
> +case VXLAN_GPE_NP_IPV4:
> +next_pt = PT_IPV4;
> +break;
> +case VXLAN_GPE_NP_IPV6:
> +next_pt = PT_IPV6;
> +break;
> +case VXLAN_GPE_NP_ETHERNET:
> +next_pt = PT_ETH;
> +break;
> +default:
> +goto err;
> +}
> +}
> +
> +if (vx_flags != htonl(VXLAN_FLAGS) ||
> (get_16aligned_be32(>vx_vni) & htonl(0xff))) {
>  VLOG_WARN_RL(_rl, "invalid vxlan flags=%#x vni=%#x\n",
> - ntohl(get_16aligned_be32(>vx_flags)),
> + ntohl(vx_flags),
>   ntohl(get_16aligned_be32(>vx_vni)));
>  goto err;
>  }
>  tnl->tun_id = htonll(ntohl(get_16aligned_be32(>vx_vni)) >> 8);
>  tnl->flags |= FLOW_TNL_F_KEY;
> 
> -packet->packet_type = htonl(PT_ETH);
> +packet->packet_type = htonl(next_pt);
>  dp_packet_reset_packet(packet, hlen + VXLAN_HLEN);
> +if (next_pt != PT_ETH) {
> +packet->l3_ofs = 0;
> +}
> 
>  return packet;
>  err:
> @@ -544,8 +571,30 @@ netdev_vxlan_build_header(const struct netdev *netdev,
> 
>  vxh = udp_build_header(tnl_cfg, data, params);
> 
> -put_16aligned_be3

Re: [ovs-dev] [PATCH v7 2/3] userspace: L3 tunnel support for GRE and LISP

2017-05-26 Thread Zoltán Balogh
Hi,

Please have a look at v8:
https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332897.html

Best regards,
Zoltan

> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> Sent: Thursday, May 25, 2017 5:38 PM
> To: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: [ovs-dev] [PATCH v7 2/3] userspace: L3 tunnel support for GRE and 
> LISP
> 
> From: Jan Scheurich <jan.scheur...@ericsson.com>
> 
> Add a boolean "layer3" configuration option for tunnel vports.
> The layer3 option defaults to false for all ports except LISP.
> GRE ports accept both true and false for "layer3".
> 
> A tunnel vport configured with layer3=true receives L3 packets.
> which are then converted to Ethernet packets by pushing a dummy
> Ethernet heder at the ingress of the OpenFlow pipeline. The
> Ethernet header of a packet is stripped before sending to a
> layer3 tunnel vport.
> 
> Presently a single GRE vport cannot carry both L2 and L3 packets.
> But it is possible to create two GRE vports representing the same
> GRE tunel, one with layer3=false, the other with layer3=true.
> L2 packet from the tunnel are received on the first vport, L3
> packets on the second. The controller must send packets to the
> layer3 GRE vport to tunnel them without their Ethernet header.
> 
> Units tests have been added to check the L3 tunnel handling.
> 
> LISP tunnels are not yet supported by the netdev userspace datapath.
> 
> Signed-off-by: Simon Horman <simon.hor...@netronome.com>
> Signed-off-by: Jiri Benc <jb...@redhat.com>
> Signed-off-by: Yi Yang <yi.y.y...@intel.com>
> Signed-off-by: Jan Scheurich <jan.scheur...@ericsson.com>
> Co-authored-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> ---
>  NEWS  |  6 ++
>  lib/netdev-native-tnl.c   | 28 +++-
>  lib/netdev-vport.c| 14 --
>  ofproto/tunnel.c  | 14 +++---
>  tests/tunnel-push-pop-ipv6.at | 16 +++-
>  tests/tunnel-push-pop.at  | 33 -
>  vswitchd/vswitch.xml  | 13 +
>  7 files changed, 104 insertions(+), 20 deletions(-)
> 
> diff --git a/NEWS b/NEWS
> index 25eb477..bbed787 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -45,6 +45,12 @@ Post-v2.7.0
> - Fedora Packaging:
>   * OVN services are no longer restarted automatically after upgrade.
> - Add --cleanup option to command 'ovs-appctl exit' (see ovs-vswitchd(8)).
> +   - L3 tunneling:
> + * Add "layer3" options for tunnel ports that support non-Ethernet (L3)
> +   payload (GRE, VXLAN-GPE).
> + * New vxlan tunnel extension "gpe" to support VXLAN-GPE tunnels.
> + * Transparently pop and push Ethernet headers at transmit/reception
> +   of packets to/from L3 tunnels.
> 
>  v2.7.0 - 21 Feb 2017
>  -
> diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
> index 2798324..0651322 100644
> --- a/lib/netdev-native-tnl.c
> +++ b/lib/netdev-native-tnl.c
> @@ -154,6 +154,10 @@ netdev_tnl_push_ip_header(struct dp_packet *packet,
>  *ip_tot_size = dp_packet_size(packet) - sizeof (struct eth_header);
> 
>  memcpy(eth, header, size);
> +/* The encapsulated packet has type Ethernet. Adjust dp_packet. */
> +packet->packet_type = htonl(PT_ETH);
> +dp_packet_reset_offsets(packet);
> +packet->l3_ofs = sizeof (struct eth_header);
> 
>  if (netdev_tnl_is_header_ipv6(header)) {
>  ip6 = netdev_tnl_ipv6_hdr(eth);
> @@ -345,6 +349,7 @@ parse_gre_header(struct dp_packet *packet,
>  ovs_16aligned_be32 *options;
>  int hlen;
>  unsigned int ulen;
> +uint16_t greh_protocol;
> 
>  greh = netdev_tnl_ip_extract_tnl_md(packet, tnl, );
>  if (!greh) {
> @@ -355,10 +360,6 @@ parse_gre_header(struct dp_packet *packet,
>  return -EINVAL;
>  }
> 
> -if (greh->protocol != htons(ETH_TYPE_TEB)) {
> -return -EINVAL;
> -}
> -
>  hlen = ulen + gre_header_len(greh->flags);
>  if (hlen > dp_packet_size(packet)) {
>  return -EINVAL;
> @@ -388,6 +389,17 @@ parse_gre_header(struct dp_packet *packet,
>  options++;
>  }
> 
> +/* Set the new packet type depending on the GRE protocol field. */
> +greh_protocol = ntohs(greh->protocol);
> +if (greh_protocol == ETH_TYPE_TEB) {
> +packet->packet_type = htonl(PT_ETH);
> +} else if (greh_protocol >= ETH_TYPE_MIN) {
> +/* Allow all GRE protocol values above 0x5ff as E

Re: [ovs-dev] [PATCH v7 1/3] userspace: Switching of L3 packets in L2 pipeline

2017-05-26 Thread Zoltán Balogh
Hi,

Please have a look at v8:
https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332896.html

Best regards,
Zoltan

> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> Sent: Thursday, May 25, 2017 5:38 PM
> To: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: [ovs-dev] [PATCH v7 1/3] userspace: Switching of L3 packets in L2 
> pipeline
> 
> From: Jan Scheurich <jan.scheur...@ericsson.com>
> 
> Ports have a new layer3 attribute if they send/receive L3 packets.
> 
> The packet_type included in structs dp_packet and flow is considered in
> ofproto-dpif. The classical L2 match fields (dl_src, dl_dst, dl_type, and
> vlan_tci, vlan_vid, vlan_pcp) now have Ethernet as pre-requisite.
> 
> A dummy ethernet header is pushed to L3 packets received from L3 ports
> before the the pipeline processing starts. The ethernet header is popped
> before sending a packet to a L3 port.
> 
> For datapath ports that can receive L2 or L3 packets, the packet_type
> becomes part of the flow key for datapath flows and is handled
> appropriately in dpif-netdev.
> 
> In the 'else' branch in flow_put_on_pmd() function, the additional check
> flow_equal(, _flow->flow) was removed, as a) the dpcls
> lookup is sufficient to uniquely identify a flow and b) it caused false
> negatives because the flow in netdev->flow may not properly masked.
> 
> In dpif_netdev_flow_put() we now use the same method for constructing the
> netdev_flow_key as the one used when adding the flow to the dplcs to make sure
> these always match. The function netdev_flow_key_from_flow() used so far was
> not only inefficient but sometimes caused mismatches and subsequent flow
> update failures.
> 
> The kernel datapath does not support the packet_type match field.
> Instead it encodes the packet type implictly by the presence or absence of
> the Ethernet attribute in the flow key and mask.
> This patch filters the PACKET_TYPE attribute out of netlink flow key and
> mask to be sent to the kernel datapath.
> 
> Signed-off-by: Lorand Jakab <loja...@cisco.com>
> Signed-off-by: Simon Horman <simon.hor...@netronome.com>
> Signed-off-by: Jiri Benc <jb...@redhat.com>
> Signed-off-by: Yi Yang <yi.y.y...@intel.com>
> Signed-off-by: Jan Scheurich <jan.scheur...@ericsson.com>
> Co-authored-by: Zoltan Balogh <zoltan.bal...@ericsson.com>
> ---
>  build-aux/extract-ofp-fields  |   1 +
>  datapath/linux/compat/include/linux/openvswitch.h |   2 +
>  include/openvswitch/match.h   |   1 +
>  include/openvswitch/meta-flow.h   |  15 +-
>  lib/dpif-netdev.c |  45 +++---
>  lib/dpif-netlink.c|  43 -
>  lib/dpif.c|   2 +-
>  lib/match.c   |  25 +++
>  lib/meta-flow.c   |   2 +
>  lib/netdev-vport.c|   8 +-
>  lib/netdev.h  |   1 +
>  lib/odp-execute.c |   2 +
>  lib/odp-util.c| 182 
> +-
>  lib/odp-util.h|   6 +-
>  lib/packets.h |   1 -
>  ofproto/ofproto-dpif-sflow.c  |   1 +
>  ofproto/ofproto-dpif-upcall.c |   4 +-
>  ofproto/ofproto-dpif-xlate.c  |  54 ++-
>  ofproto/ofproto-dpif.c|   6 +-
>  ofproto/tunnel.c  |   3 +
>  tests/tunnel-push-pop-ipv6.at |  10 +-
>  tests/tunnel-push-pop.at  |  14 +-
>  tests/tunnel.at   |  28 ++--
>  23 files changed, 337 insertions(+), 119 deletions(-)
> 
> diff --git a/build-aux/extract-ofp-fields b/build-aux/extract-ofp-fields
> index af7c69b..d5b8a82 100755
> --- a/build-aux/extract-ofp-fields
> +++ b/build-aux/extract-ofp-fields
> @@ -39,6 +39,7 @@ FORMATTING = {"decimal":("MFS_DECIMAL",  1, 
>   8),
>"TCP flags":  ("MFS_TCP_FLAGS",2,   2)}
> 
>  PREREQS = {"none": "MFP_NONE",
> +   "Ethernet": "MFP_ETHERNET",
> "ARP": "MFP_ARP",
> "VLAN VID": "MFP_VLAN_VID",
> "IPv4": "MFP_IPV4",
> diff --git a/datapath/linux/compat/include/linux/openvswitch.h 
> b/datapath/lin

Re: [ovs-dev] [PATCH v7 0/3] userspace: Support for L3 tunneling

2017-05-26 Thread Zoltán Balogh
Hi,

I sent out v8, that fixes a typo and adds BUILD_ASSERT_DECL for struct vxlanhdr.

https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332895.html
https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332896.html
https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332897.html
https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332898.html

Best regards,
Zoltan

> -Original Message-
> From: ovs-dev-boun...@openvswitch.org 
> [mailto:ovs-dev-boun...@openvswitch.org] On Behalf Of Zoltán Balogh
> Sent: Thursday, May 25, 2017 5:37 PM
> To: 'd...@openvswitch.org' <d...@openvswitch.org>
> Subject: [ovs-dev] [PATCH v7 0/3] userspace: Support for L3 tunneling
> 
> From: Jan Scheurich <jan.scheur...@ericssom.com>
> 
> This patch set is part of an initiative to deal with non-Ethernet packets in 
> OVS for advanced use cases like L3
> tunneling or NSH. The initiative is centering on the new OpenFlow concepts of 
> "Packet type-aware pipeline" (PTAP)
> and "Generic encap/decap actions" (EXT-382). The overall design is documented 
> in
> https://docs.google.com/document/d/1oWMYUH8sjZJzWa72o2q9kU0N6pNE-rwZcLH3-kbbDR8
> 
> The patches implement the user-space parts of the support for L3 tunnels 
> connected to the legacy Ethernet-only
> pipeline in OVS. In large parts it is an adaptation of the earlier work on L3 
> tunneling by Lorand Jakab, Simon
> Horman, Jiri Benc and Yi Yang, adapted to the new design for packet type 
> aware pipelines as prototyped by Jean
> Tourrilhes.
> 
> Key changes compared to earlier patch series are the introduction of explicit 
> packet_type members in the structs
> dp_packet and flow, as well as a simpler handling of L3 tunnels limited to 
> the ofproto layer.
> 
> The present series v7 supersedes v6 
> (https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332367.html). Header
> file vxlangpe.h was removed, its content was moved into VXLAN section of 
> lib/packets.h. Two patches were merged into
> a single one and fixes were done based on review comments.
> The present series v6 supersedes v5 
> (https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332151.html). The
> reason of creating v6 is that tunnel handling has been changed on master 
> branch, so rebasing was necessary.
> The present series v5 supersedes v4 
> (https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/331424.html), v4
> fixes struct ovs_action_push_eth, so kernel and userspace use same data 
> structure and removes a patch from the
> series which was applied to master.
> The series v4 supersedes v3 
> (https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/330488.html), v4 
> fixes sparse
> warnings coding style and removes a patch from the series.
> The series v3 superseded v2 
> (https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/330444.html) which 
> added
> support for vxlan-gpe tunnels in the netdev-dpdk datapath based on earlier 
> patches 14-16 out of a patch set by Yi
> Yang 
> (https://mail.openvswitch.org/pipermail/ovs-dev/2017-February/328498.html).
> 
>userspace: Switching of L3 packets in L2 pipeline
>userspace: L3 tunnel support for GRE and LISP
>userspace: add vxlan gpe support to vport
> 
> For native L3 tunneling with the userspace datapath these patches are 
> complete and could be merged.
> 
> The necessary kernel module changes for L3 tunneling have already been 
> upstreamed to the net-next kernel and back-
> ported to OVS. To apply L3 tunneling to the kernel datapath, one will need 
> the following additional contributions:
> 
> * [PATCH v2 0/7] create tunnel devices using rtnetlink interface
>https://mail.openvswitch.org/pipermail/ovs-dev/2017-March/329893.html
> * An additional user-space patch based on the above to configure the layer3 
> tunnel option in the kernel datapath
> 
> Changes v1 -> v2:
> * Rebased to master (f40c558 ovn: Gratuitous ARP for distributed NAT rules)
> * Moved new packet_type member to fill a 4-byte padding in struct flow
> * Define the packet_type constants to be in host byte order
> * Update the display format of packet_type in match and flow key printouts to 
> a pair format "(ns, type)"
> * Renamed dp_packet_l2() to dp_packet_eth()
> * Removed unnecessary wrappers dp_packet_packet_type() and 
> dp_packet_set_packet_type()
> * Fixed "sparse" warnings
> * Removed misleading or unnecessary comments
> * Added support for vxlan-gpe tunnel vports for Ethernet, IPv4, IPv6 and NSH 
> payload
> 
> Changes v2 -> v3:
> * Removed unused function dp_packet_is_l3()
> * Using VLOG_DROP_DBG and VLOG_DBG instead of VLOG_DBG_RL in 
> dp_netdev_flow_add()
> * Moved changes related comment from fl

[ovs-dev] [PATCH v8 3/3] userspace: add vxlan gpe support to vport

2017-05-26 Thread Zoltán Balogh
From: Georg Schmuecking 

This patch is based on the "datapath: enable vxlangpe creation in compat mode"
from Yi Yang. It introduces an extension option "gpe" to the vxlan port in the
netdev-dpdk datapath. Description of vxlan gpe protocoll was added to header
file lib/packets.h. In the vxlan specific methods the different packet are
introduced and handled.

Added VXLAN GPE tunnel push test.

Signed-off-by: Yi Yang 
Signed-off-by: Georg Schmuecking 
---
 datapath/linux/compat/include/linux/openvswitch.h |  1 +
 include/openvswitch/automake.mk   |  1 -
 lib/netdev-native-tnl.c   | 59 +--
 lib/netdev-vport.c| 22 +++--
 lib/packets.h | 54 -
 tests/tunnel-push-pop.at  | 10 
 6 files changed, 135 insertions(+), 12 deletions(-)

diff --git a/datapath/linux/compat/include/linux/openvswitch.h 
b/datapath/linux/compat/include/linux/openvswitch.h
index 7990638..2ae1797 100644
--- a/datapath/linux/compat/include/linux/openvswitch.h
+++ b/datapath/linux/compat/include/linux/openvswitch.h
@@ -291,6 +291,7 @@ enum ovs_vport_attr {
 enum {
OVS_VXLAN_EXT_UNSPEC,
OVS_VXLAN_EXT_GBP,  /* Flag or __u32 */
+   OVS_VXLAN_EXT_GPE = 8,  /* Flag or __u32 */
__OVS_VXLAN_EXT_MAX,
 };
 
diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk
index c0e276f..699d9d7 100644
--- a/include/openvswitch/automake.mk
+++ b/include/openvswitch/automake.mk
@@ -30,4 +30,3 @@ openvswitchinclude_HEADERS = \
include/openvswitch/version.h \
include/openvswitch/vconn.h \
include/openvswitch/vlog.h
-
diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index 0651322..c7a2993 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -499,6 +499,8 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
 struct flow_tnl *tnl = >tunnel;
 struct vxlanhdr *vxh;
 unsigned int hlen;
+ovs_be32 vx_flags;
+enum packet_type next_pt = PT_ETH;
 
 pkt_metadata_init_tnl(md);
 if (VXLAN_HLEN > dp_packet_l4_size(packet)) {
@@ -510,18 +512,43 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
 goto err;
 }
 
-if (get_16aligned_be32(>vx_flags) != htonl(VXLAN_FLAGS) ||
+vx_flags = get_16aligned_be32(>vx_flags);
+if (vx_flags & htonl(VXLAN_HF_GPE)) {
+vx_flags &= htonl(~VXLAN_GPE_USED_BITS);
+/* Drop the OAM packets */
+if (vxh->vx_gpe.flags & VXLAN_GPE_FLAGS_O) {
+goto err;
+}
+switch (vxh->vx_gpe.next_protocol) {
+case VXLAN_GPE_NP_IPV4:
+next_pt = PT_IPV4;
+break;
+case VXLAN_GPE_NP_IPV6:
+next_pt = PT_IPV6;
+break;
+case VXLAN_GPE_NP_ETHERNET:
+next_pt = PT_ETH;
+break;
+default:
+goto err;
+}
+}
+
+if (vx_flags != htonl(VXLAN_FLAGS) ||
(get_16aligned_be32(>vx_vni) & htonl(0xff))) {
 VLOG_WARN_RL(_rl, "invalid vxlan flags=%#x vni=%#x\n",
- ntohl(get_16aligned_be32(>vx_flags)),
+ ntohl(vx_flags),
  ntohl(get_16aligned_be32(>vx_vni)));
 goto err;
 }
 tnl->tun_id = htonll(ntohl(get_16aligned_be32(>vx_vni)) >> 8);
 tnl->flags |= FLOW_TNL_F_KEY;
 
-packet->packet_type = htonl(PT_ETH);
+packet->packet_type = htonl(next_pt);
 dp_packet_reset_packet(packet, hlen + VXLAN_HLEN);
+if (next_pt != PT_ETH) {
+packet->l3_ofs = 0;
+}
 
 return packet;
 err:
@@ -544,8 +571,30 @@ netdev_vxlan_build_header(const struct netdev *netdev,
 
 vxh = udp_build_header(tnl_cfg, data, params);
 
-put_16aligned_be32(>vx_flags, htonl(VXLAN_FLAGS));
-put_16aligned_be32(>vx_vni, htonl(ntohll(params->flow->tunnel.tun_id) 
<< 8));
+if (tnl_cfg->exts & (1 << OVS_VXLAN_EXT_GPE)) {
+put_16aligned_be32(>vx_flags, htonl(VXLAN_FLAGS | VXLAN_HF_GPE));
+put_16aligned_be32(>vx_vni,
+   htonl(ntohll(params->flow->tunnel.tun_id) << 8));
+if (tnl_cfg->is_layer3) {
+switch (ntohs(params->flow->dl_type)) {
+case ETH_TYPE_IP:
+vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_IPV4;
+break;
+case ETH_TYPE_IPV6:
+vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_IPV6;
+break;
+case ETH_TYPE_TEB:
+vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_ETHERNET;
+break;
+}
+} else {
+vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_ETHERNET;
+}
+} else {
+put_16aligned_be32(>vx_flags, htonl(VXLAN_FLAGS));
+put_16aligned_be32(>vx_vni,
+   htonl(ntohll(params->flow->tunnel.tun_id) 

[ovs-dev] [PATCH v8 2/3] userspace: L3 tunnel support for GRE and LISP

2017-05-26 Thread Zoltán Balogh
From: Jan Scheurich 

Add a boolean "layer3" configuration option for tunnel vports.
The layer3 option defaults to false for all ports except LISP.
GRE ports accept both true and false for "layer3".

A tunnel vport configured with layer3=true receives L3 packets.
which are then converted to Ethernet packets by pushing a dummy
Ethernet heder at the ingress of the OpenFlow pipeline. The
Ethernet header of a packet is stripped before sending to a
layer3 tunnel vport.

Presently a single GRE vport cannot carry both L2 and L3 packets.
But it is possible to create two GRE vports representing the same
GRE tunel, one with layer3=false, the other with layer3=true.
L2 packet from the tunnel are received on the first vport, L3
packets on the second. The controller must send packets to the
layer3 GRE vport to tunnel them without their Ethernet header.

Units tests have been added to check the L3 tunnel handling.

LISP tunnels are not yet supported by the netdev userspace datapath.

Signed-off-by: Simon Horman 
Signed-off-by: Jiri Benc 
Signed-off-by: Yi Yang 
Signed-off-by: Jan Scheurich 
Co-authored-by: Zoltan Balogh 
---
 NEWS  |  6 ++
 lib/netdev-native-tnl.c   | 28 +++-
 lib/netdev-vport.c| 14 --
 ofproto/tunnel.c  | 14 +++---
 tests/tunnel-push-pop-ipv6.at | 16 +++-
 tests/tunnel-push-pop.at  | 33 -
 vswitchd/vswitch.xml  | 13 +
 7 files changed, 104 insertions(+), 20 deletions(-)

diff --git a/NEWS b/NEWS
index 25eb477..bbed787 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,12 @@ Post-v2.7.0
- Fedora Packaging:
  * OVN services are no longer restarted automatically after upgrade.
- Add --cleanup option to command 'ovs-appctl exit' (see ovs-vswitchd(8)).
+   - L3 tunneling:
+ * Add "layer3" options for tunnel ports that support non-Ethernet (L3)
+   payload (GRE, VXLAN-GPE).
+ * New vxlan tunnel extension "gpe" to support VXLAN-GPE tunnels.
+ * Transparently pop and push Ethernet headers at transmit/reception
+   of packets to/from L3 tunnels.
 
 v2.7.0 - 21 Feb 2017
 -
diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index 2798324..0651322 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -154,6 +154,10 @@ netdev_tnl_push_ip_header(struct dp_packet *packet,
 *ip_tot_size = dp_packet_size(packet) - sizeof (struct eth_header);
 
 memcpy(eth, header, size);
+/* The encapsulated packet has type Ethernet. Adjust dp_packet. */
+packet->packet_type = htonl(PT_ETH);
+dp_packet_reset_offsets(packet);
+packet->l3_ofs = sizeof (struct eth_header);
 
 if (netdev_tnl_is_header_ipv6(header)) {
 ip6 = netdev_tnl_ipv6_hdr(eth);
@@ -345,6 +349,7 @@ parse_gre_header(struct dp_packet *packet,
 ovs_16aligned_be32 *options;
 int hlen;
 unsigned int ulen;
+uint16_t greh_protocol;
 
 greh = netdev_tnl_ip_extract_tnl_md(packet, tnl, );
 if (!greh) {
@@ -355,10 +360,6 @@ parse_gre_header(struct dp_packet *packet,
 return -EINVAL;
 }
 
-if (greh->protocol != htons(ETH_TYPE_TEB)) {
-return -EINVAL;
-}
-
 hlen = ulen + gre_header_len(greh->flags);
 if (hlen > dp_packet_size(packet)) {
 return -EINVAL;
@@ -388,6 +389,17 @@ parse_gre_header(struct dp_packet *packet,
 options++;
 }
 
+/* Set the new packet type depending on the GRE protocol field. */
+greh_protocol = ntohs(greh->protocol);
+if (greh_protocol == ETH_TYPE_TEB) {
+packet->packet_type = htonl(PT_ETH);
+} else if (greh_protocol >= ETH_TYPE_MIN) {
+/* Allow all GRE protocol values above 0x5ff as Ethertypes. */
+packet->packet_type = PACKET_TYPE_BE(OFPHTN_ETHERTYPE, greh_protocol);
+} else {
+return -EINVAL;
+}
+
 return hlen;
 }
 
@@ -451,7 +463,11 @@ netdev_gre_build_header(const struct netdev *netdev,
 
 greh = netdev_tnl_ip_build_header(data, params, IPPROTO_GRE);
 
-greh->protocol = htons(ETH_TYPE_TEB);
+if (tnl_cfg->is_layer3) {
+greh->protocol = params->flow->dl_type;
+} else {
+greh->protocol = htons(ETH_TYPE_TEB);
+}
 greh->flags = 0;
 
 options = (ovs_16aligned_be32 *) (greh + 1);
@@ -504,6 +520,7 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
 tnl->tun_id = htonll(ntohl(get_16aligned_be32(>vx_vni)) >> 8);
 tnl->flags |= FLOW_TNL_F_KEY;
 
+packet->packet_type = htonl(PT_ETH);
 dp_packet_reset_packet(packet, hlen + VXLAN_HLEN);
 
 return packet;
@@ -583,6 +600,7 @@ netdev_geneve_pop_header(struct dp_packet *packet)
 tnl->metadata.present.len = opts_len;
 tnl->flags |= FLOW_TNL_F_UDPIF;
 
+packet->packet_type = htonl(PT_ETH);
   

[ovs-dev] [PATCH v8 1/3] userspace: Switching of L3 packets in L2 pipeline

2017-05-26 Thread Zoltán Balogh
From: Jan Scheurich 

Ports have a new layer3 attribute if they send/receive L3 packets.

The packet_type included in structs dp_packet and flow is considered in
ofproto-dpif. The classical L2 match fields (dl_src, dl_dst, dl_type, and
vlan_tci, vlan_vid, vlan_pcp) now have Ethernet as pre-requisite.

A dummy ethernet header is pushed to L3 packets received from L3 ports
before the the pipeline processing starts. The ethernet header is popped
before sending a packet to a L3 port.

For datapath ports that can receive L2 or L3 packets, the packet_type
becomes part of the flow key for datapath flows and is handled
appropriately in dpif-netdev.

In the 'else' branch in flow_put_on_pmd() function, the additional check
flow_equal(, _flow->flow) was removed, as a) the dpcls
lookup is sufficient to uniquely identify a flow and b) it caused false
negatives because the flow in netdev->flow may not properly masked.

In dpif_netdev_flow_put() we now use the same method for constructing the
netdev_flow_key as the one used when adding the flow to the dplcs to make sure
these always match. The function netdev_flow_key_from_flow() used so far was
not only inefficient but sometimes caused mismatches and subsequent flow
update failures.

The kernel datapath does not support the packet_type match field.
Instead it encodes the packet type implictly by the presence or absence of
the Ethernet attribute in the flow key and mask.
This patch filters the PACKET_TYPE attribute out of netlink flow key and
mask to be sent to the kernel datapath.

Signed-off-by: Lorand Jakab 
Signed-off-by: Simon Horman 
Signed-off-by: Jiri Benc 
Signed-off-by: Yi Yang 
Signed-off-by: Jan Scheurich 
Co-authored-by: Zoltan Balogh 
---
 build-aux/extract-ofp-fields  |   1 +
 datapath/linux/compat/include/linux/openvswitch.h |   2 +
 include/openvswitch/match.h   |   1 +
 include/openvswitch/meta-flow.h   |  15 +-
 lib/dpif-netdev.c |  45 +++---
 lib/dpif-netlink.c|  43 -
 lib/dpif.c|   2 +-
 lib/match.c   |  25 +++
 lib/meta-flow.c   |   2 +
 lib/netdev-vport.c|   8 +-
 lib/netdev.h  |   1 +
 lib/odp-execute.c |   2 +
 lib/odp-util.c| 182 +-
 lib/odp-util.h|   6 +-
 lib/packets.h |   1 -
 ofproto/ofproto-dpif-sflow.c  |   1 +
 ofproto/ofproto-dpif-upcall.c |   4 +-
 ofproto/ofproto-dpif-xlate.c  |  54 ++-
 ofproto/ofproto-dpif.c|   6 +-
 ofproto/tunnel.c  |   3 +
 tests/tunnel-push-pop-ipv6.at |  10 +-
 tests/tunnel-push-pop.at  |  14 +-
 tests/tunnel.at   |  28 ++--
 23 files changed, 337 insertions(+), 119 deletions(-)

diff --git a/build-aux/extract-ofp-fields b/build-aux/extract-ofp-fields
index af7c69b..d5b8a82 100755
--- a/build-aux/extract-ofp-fields
+++ b/build-aux/extract-ofp-fields
@@ -39,6 +39,7 @@ FORMATTING = {"decimal":("MFS_DECIMAL",  1,   
8),
   "TCP flags":  ("MFS_TCP_FLAGS",2,   2)}
 
 PREREQS = {"none": "MFP_NONE",
+   "Ethernet": "MFP_ETHERNET",
"ARP": "MFP_ARP",
"VLAN VID": "MFP_VLAN_VID",
"IPv4": "MFP_IPV4",
diff --git a/datapath/linux/compat/include/linux/openvswitch.h 
b/datapath/linux/compat/include/linux/openvswitch.h
index d22102e..7990638 100644
--- a/datapath/linux/compat/include/linux/openvswitch.h
+++ b/datapath/linux/compat/include/linux/openvswitch.h
@@ -363,6 +363,8 @@ enum ovs_key_attr {
/* Only used within kernel data path. */
OVS_KEY_ATTR_TUNNEL_INFO,  /* struct ovs_tunnel_info */
 #endif
+
+   OVS_KEY_ATTR_PACKET_TYPE,  /* be32 packet type */
__OVS_KEY_ATTR_MAX
 };
 
diff --git a/include/openvswitch/match.h b/include/openvswitch/match.h
index 06fa04c..ce06919 100644
--- a/include/openvswitch/match.h
+++ b/include/openvswitch/match.h
@@ -115,6 +115,7 @@ void match_set_ct_ipv6_dst(struct match *, const struct 
in6_addr *);
 void match_set_ct_ipv6_dst_masked(struct match *, const struct in6_addr *,
   const struct in6_addr *);
 
+void match_set_packet_type(struct match *, ovs_be32 packet_type);
 void match_set_skb_priority(struct match *, uint32_t skb_priority);
 void match_set_dl_type(struct match *, ovs_be16);
 void match_set_dl_src(struct match *, const struct 

[ovs-dev] [PATCH v8 0/3] userspace: Support for L3 tunneling

2017-05-26 Thread Zoltán Balogh
From: Jan Scheurich 

This patch set is part of an initiative to deal with non-Ethernet packets in 
OVS for advanced use cases like L3 tunneling or NSH. The initiative is 
centering on the new OpenFlow concepts of "Packet type-aware pipeline" (PTAP) 
and "Generic encap/decap actions" (EXT-382). The overall design is documented 
in 
https://docs.google.com/document/d/1oWMYUH8sjZJzWa72o2q9kU0N6pNE-rwZcLH3-kbbDR8

The patches implement the user-space parts of the support for L3 tunnels 
connected to the legacy Ethernet-only pipeline in OVS. In large parts it is an 
adaptation of the earlier work on L3 tunneling by Lorand Jakab, Simon Horman, 
Jiri Benc and Yi Yang, adapted to the new design for packet type aware 
pipelines as prototyped by Jean Tourrilhes. 

Key changes compared to earlier patch series are the introduction of explicit 
packet_type members in the structs dp_packet and flow, as well as a simpler 
handling of L3 tunnels limited to the ofproto layer.

The present series v8 supersedes v7 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332837.html), v8 fixes 
a typo and adds BUILD_ASSERC_DELC for struct vxlanhdr.
The present series v7 supersedes v6 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332367.html). Header 
file vxlangpe.h was removed, its content was moved into VXLAN section of 
lib/packets.h. Two patches were merged into a single one and fixes were done 
based on review comments.
The present series v6 supersedes v5 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332151.html). The 
reason of creating v6 is that tunnel handling has been changed on master 
branch, so rebasing was necessary.
The present series v5 supersedes v4 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/331424.html), v4 
fixes struct ovs_action_push_eth, so kernel and userspace use same data 
structure and removes a patch from the series which was applied to master.
The series v4 supersedes v3 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/330488.html), v4 
fixes sparse warnings coding style and removes a patch from the series.
The series v3 superseded v2 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/330444.html) which 
added support for vxlan-gpe tunnels in the netdev-dpdk datapath based on 
earlier patches 14-16 out of a patch set by Yi Yang 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-February/328498.html). 

   userspace: Switching of L3 packets in L2 pipeline 
   userspace: L3 tunnel support for GRE and LISP 
   userspace: add vxlan gpe support to vport

For native L3 tunneling with the userspace datapath these patches are complete 
and could be merged.

The necessary kernel module changes for L3 tunneling have already been 
upstreamed to the net-next kernel and back-ported to OVS. To apply L3 tunneling 
to the kernel datapath, one will need the following additional contributions:

* [PATCH v2 0/7] create tunnel devices using rtnetlink interface
   https://mail.openvswitch.org/pipermail/ovs-dev/2017-March/329893.html 
* An additional user-space patch based on the above to configure the layer3 
tunnel option in the kernel datapath

Changes v1 -> v2:
* Rebased to master (f40c558 ovn: Gratuitous ARP for distributed NAT rules)
* Moved new packet_type member to fill a 4-byte padding in struct flow
* Define the packet_type constants to be in host byte order
* Update the display format of packet_type in match and flow key printouts to a 
pair format "(ns, type)"
* Renamed dp_packet_l2() to dp_packet_eth()
* Removed unnecessary wrappers dp_packet_packet_type() and 
dp_packet_set_packet_type()
* Fixed "sparse" warnings
* Removed misleading or unnecessary comments
* Added support for vxlan-gpe tunnel vports for Ethernet, IPv4, IPv6 and NSH 
payload

Changes v2 -> v3:
* Removed unused function dp_packet_is_l3()
* Using VLOG_DROP_DBG and VLOG_DBG instead of VLOG_DBG_RL in 
dp_netdev_flow_add()
* Moved changes related comment from flow_put_on_md() into commit message
* PT_NS* macros were replaced with inline functions
* Unnecessary if statements removed from match_format()
* Using assignment operator instead of memset where it's possible
* Improved some commit messages

Changes v3 -> v4:
* Fixed "sparse" warnings
* Fixed coding style
* Removed patch "ofproto-dpif-upcall: Intialize dump-seq of new flow to zero"
* Rebased to origin/master (9a84f46)

Changes v4 -> v5:
* Eth_type member removed from struct ovs_action_push_eth.
* Patch "userspace: Add packet_type in dp_packet and flow" exluded.

Changes v5 -> v6:
* Rebased to origin/master (f5f6455)
* Patch "userspace: Support for push_eth and pop_eth actions" exluded.

Changes v6 -> v7:
* Rebased to origin/master (b50fcaa)
* Patch "dpif-netlink: Don't send PACKET_TYPE to kernel" merged into patch 
"userspace: Switching of L3 packets in L2 pipeline".
* Patch "ofproto-dpif-xlate: refactor compose_output_action__" excluded.
* Fixed coding style. 
* Printout format 

[ovs-dev] [PATCH v7 3/3] userspace: add vxlan gpe support to vport

2017-05-25 Thread Zoltán Balogh
From: Georg Schmuecking 

This patch is based on the "datapath: enable vxlangpe creation in compat mode"
from Yi Yang. It introduces an extension option "gpe" to the vxlan port in the
netdev-dpdk datapath. Description of vxlan gpe protocoll was added to header
file lib/packets.h. In the vxlan specific methods the different packet are
introduced and handled.

Added VXLAN GPE tunnel push test.

Signed-off-by: Yi Yang 
Signed-off-by: Georg Schmuecking 
---
 datapath/linux/compat/include/linux/openvswitch.h |  1 +
 include/openvswitch/automake.mk   |  1 -
 lib/netdev-native-tnl.c   | 59 +--
 lib/netdev-vport.c| 22 +++--
 lib/packets.h | 54 -
 tests/tunnel-push-pop.at  | 10 
 6 files changed, 135 insertions(+), 12 deletions(-)

diff --git a/datapath/linux/compat/include/linux/openvswitch.h 
b/datapath/linux/compat/include/linux/openvswitch.h
index 7990638..2ae1797 100644
--- a/datapath/linux/compat/include/linux/openvswitch.h
+++ b/datapath/linux/compat/include/linux/openvswitch.h
@@ -291,6 +291,7 @@ enum ovs_vport_attr {
 enum {
OVS_VXLAN_EXT_UNSPEC,
OVS_VXLAN_EXT_GBP,  /* Flag or __u32 */
+   OVS_VXLAN_EXT_GPE = 8,  /* Flag or __u32 */
__OVS_VXLAN_EXT_MAX,
 };
 
diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk
index c0e276f..699d9d7 100644
--- a/include/openvswitch/automake.mk
+++ b/include/openvswitch/automake.mk
@@ -30,4 +30,3 @@ openvswitchinclude_HEADERS = \
include/openvswitch/version.h \
include/openvswitch/vconn.h \
include/openvswitch/vlog.h
-
diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index 0651322..8ae8893 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -499,6 +499,8 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
 struct flow_tnl *tnl = >tunnel;
 struct vxlanhdr *vxh;
 unsigned int hlen;
+ovs_be32 vx_flags;
+enum packet_type next_pt = PT_ETH;
 
 pkt_metadata_init_tnl(md);
 if (VXLAN_HLEN > dp_packet_l4_size(packet)) {
@@ -510,18 +512,43 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
 goto err;
 }
 
-if (get_16aligned_be32(>vx_flags) != htonl(VXLAN_FLAGS) ||
+vx_flags = get_16aligned_be32(>vx_flags);
+if (vx_flags & htonl(VXLAN_HF_GPE)) {
+vx_flags &= htonl(~VXLAN_GPE_USED_BITS);
+/* Drop the OAM packets */
+if (vxh->vx_pge.flags & VXLAN_GPE_FLAGS_O) {
+goto err;
+}
+switch (vxh->vx_pge.next_protocol) {
+case VXLAN_GPE_NP_IPV4:
+next_pt = PT_IPV4;
+break;
+case VXLAN_GPE_NP_IPV6:
+next_pt = PT_IPV6;
+break;
+case VXLAN_GPE_NP_ETHERNET:
+next_pt = PT_ETH;
+break;
+default:
+goto err;
+}
+}
+
+if (vx_flags != htonl(VXLAN_FLAGS) ||
(get_16aligned_be32(>vx_vni) & htonl(0xff))) {
 VLOG_WARN_RL(_rl, "invalid vxlan flags=%#x vni=%#x\n",
- ntohl(get_16aligned_be32(>vx_flags)),
+ ntohl(vx_flags),
  ntohl(get_16aligned_be32(>vx_vni)));
 goto err;
 }
 tnl->tun_id = htonll(ntohl(get_16aligned_be32(>vx_vni)) >> 8);
 tnl->flags |= FLOW_TNL_F_KEY;
 
-packet->packet_type = htonl(PT_ETH);
+packet->packet_type = htonl(next_pt);
 dp_packet_reset_packet(packet, hlen + VXLAN_HLEN);
+if (next_pt != PT_ETH) {
+packet->l3_ofs = 0;
+}
 
 return packet;
 err:
@@ -544,8 +571,30 @@ netdev_vxlan_build_header(const struct netdev *netdev,
 
 vxh = udp_build_header(tnl_cfg, data, params);
 
-put_16aligned_be32(>vx_flags, htonl(VXLAN_FLAGS));
-put_16aligned_be32(>vx_vni, htonl(ntohll(params->flow->tunnel.tun_id) 
<< 8));
+if (tnl_cfg->exts & (1 << OVS_VXLAN_EXT_GPE)) {
+put_16aligned_be32(>vx_flags, htonl(VXLAN_FLAGS | VXLAN_HF_GPE));
+put_16aligned_be32(>vx_vni,
+   htonl(ntohll(params->flow->tunnel.tun_id) << 8));
+if (tnl_cfg->is_layer3) {
+switch (ntohs(params->flow->dl_type)) {
+case ETH_TYPE_IP:
+vxh->vx_pge.next_protocol = VXLAN_GPE_NP_IPV4;
+break;
+case ETH_TYPE_IPV6:
+vxh->vx_pge.next_protocol = VXLAN_GPE_NP_IPV6;
+break;
+case ETH_TYPE_TEB:
+vxh->vx_pge.next_protocol = VXLAN_GPE_NP_ETHERNET;
+break;
+}
+} else {
+vxh->vx_pge.next_protocol = VXLAN_GPE_NP_ETHERNET;
+}
+} else {
+put_16aligned_be32(>vx_flags, htonl(VXLAN_FLAGS));
+put_16aligned_be32(>vx_vni,
+   htonl(ntohll(params->flow->tunnel.tun_id) 

[ovs-dev] [PATCH v7 2/3] userspace: L3 tunnel support for GRE and LISP

2017-05-25 Thread Zoltán Balogh
From: Jan Scheurich 

Add a boolean "layer3" configuration option for tunnel vports.
The layer3 option defaults to false for all ports except LISP.
GRE ports accept both true and false for "layer3".

A tunnel vport configured with layer3=true receives L3 packets.
which are then converted to Ethernet packets by pushing a dummy
Ethernet heder at the ingress of the OpenFlow pipeline. The
Ethernet header of a packet is stripped before sending to a
layer3 tunnel vport.

Presently a single GRE vport cannot carry both L2 and L3 packets.
But it is possible to create two GRE vports representing the same
GRE tunel, one with layer3=false, the other with layer3=true.
L2 packet from the tunnel are received on the first vport, L3
packets on the second. The controller must send packets to the
layer3 GRE vport to tunnel them without their Ethernet header.

Units tests have been added to check the L3 tunnel handling.

LISP tunnels are not yet supported by the netdev userspace datapath.

Signed-off-by: Simon Horman 
Signed-off-by: Jiri Benc 
Signed-off-by: Yi Yang 
Signed-off-by: Jan Scheurich 
Co-authored-by: Zoltan Balogh 
---
 NEWS  |  6 ++
 lib/netdev-native-tnl.c   | 28 +++-
 lib/netdev-vport.c| 14 --
 ofproto/tunnel.c  | 14 +++---
 tests/tunnel-push-pop-ipv6.at | 16 +++-
 tests/tunnel-push-pop.at  | 33 -
 vswitchd/vswitch.xml  | 13 +
 7 files changed, 104 insertions(+), 20 deletions(-)

diff --git a/NEWS b/NEWS
index 25eb477..bbed787 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,12 @@ Post-v2.7.0
- Fedora Packaging:
  * OVN services are no longer restarted automatically after upgrade.
- Add --cleanup option to command 'ovs-appctl exit' (see ovs-vswitchd(8)).
+   - L3 tunneling:
+ * Add "layer3" options for tunnel ports that support non-Ethernet (L3)
+   payload (GRE, VXLAN-GPE).
+ * New vxlan tunnel extension "gpe" to support VXLAN-GPE tunnels.
+ * Transparently pop and push Ethernet headers at transmit/reception
+   of packets to/from L3 tunnels.
 
 v2.7.0 - 21 Feb 2017
 -
diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index 2798324..0651322 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -154,6 +154,10 @@ netdev_tnl_push_ip_header(struct dp_packet *packet,
 *ip_tot_size = dp_packet_size(packet) - sizeof (struct eth_header);
 
 memcpy(eth, header, size);
+/* The encapsulated packet has type Ethernet. Adjust dp_packet. */
+packet->packet_type = htonl(PT_ETH);
+dp_packet_reset_offsets(packet);
+packet->l3_ofs = sizeof (struct eth_header);
 
 if (netdev_tnl_is_header_ipv6(header)) {
 ip6 = netdev_tnl_ipv6_hdr(eth);
@@ -345,6 +349,7 @@ parse_gre_header(struct dp_packet *packet,
 ovs_16aligned_be32 *options;
 int hlen;
 unsigned int ulen;
+uint16_t greh_protocol;
 
 greh = netdev_tnl_ip_extract_tnl_md(packet, tnl, );
 if (!greh) {
@@ -355,10 +360,6 @@ parse_gre_header(struct dp_packet *packet,
 return -EINVAL;
 }
 
-if (greh->protocol != htons(ETH_TYPE_TEB)) {
-return -EINVAL;
-}
-
 hlen = ulen + gre_header_len(greh->flags);
 if (hlen > dp_packet_size(packet)) {
 return -EINVAL;
@@ -388,6 +389,17 @@ parse_gre_header(struct dp_packet *packet,
 options++;
 }
 
+/* Set the new packet type depending on the GRE protocol field. */
+greh_protocol = ntohs(greh->protocol);
+if (greh_protocol == ETH_TYPE_TEB) {
+packet->packet_type = htonl(PT_ETH);
+} else if (greh_protocol >= ETH_TYPE_MIN) {
+/* Allow all GRE protocol values above 0x5ff as Ethertypes. */
+packet->packet_type = PACKET_TYPE_BE(OFPHTN_ETHERTYPE, greh_protocol);
+} else {
+return -EINVAL;
+}
+
 return hlen;
 }
 
@@ -451,7 +463,11 @@ netdev_gre_build_header(const struct netdev *netdev,
 
 greh = netdev_tnl_ip_build_header(data, params, IPPROTO_GRE);
 
-greh->protocol = htons(ETH_TYPE_TEB);
+if (tnl_cfg->is_layer3) {
+greh->protocol = params->flow->dl_type;
+} else {
+greh->protocol = htons(ETH_TYPE_TEB);
+}
 greh->flags = 0;
 
 options = (ovs_16aligned_be32 *) (greh + 1);
@@ -504,6 +520,7 @@ netdev_vxlan_pop_header(struct dp_packet *packet)
 tnl->tun_id = htonll(ntohl(get_16aligned_be32(>vx_vni)) >> 8);
 tnl->flags |= FLOW_TNL_F_KEY;
 
+packet->packet_type = htonl(PT_ETH);
 dp_packet_reset_packet(packet, hlen + VXLAN_HLEN);
 
 return packet;
@@ -583,6 +600,7 @@ netdev_geneve_pop_header(struct dp_packet *packet)
 tnl->metadata.present.len = opts_len;
 tnl->flags |= FLOW_TNL_F_UDPIF;
 
+packet->packet_type = htonl(PT_ETH);
   

[ovs-dev] [PATCH v7 1/3] userspace: Switching of L3 packets in L2 pipeline

2017-05-25 Thread Zoltán Balogh
From: Jan Scheurich 

Ports have a new layer3 attribute if they send/receive L3 packets.

The packet_type included in structs dp_packet and flow is considered in
ofproto-dpif. The classical L2 match fields (dl_src, dl_dst, dl_type, and
vlan_tci, vlan_vid, vlan_pcp) now have Ethernet as pre-requisite.

A dummy ethernet header is pushed to L3 packets received from L3 ports
before the the pipeline processing starts. The ethernet header is popped
before sending a packet to a L3 port.

For datapath ports that can receive L2 or L3 packets, the packet_type
becomes part of the flow key for datapath flows and is handled
appropriately in dpif-netdev.

In the 'else' branch in flow_put_on_pmd() function, the additional check
flow_equal(, _flow->flow) was removed, as a) the dpcls
lookup is sufficient to uniquely identify a flow and b) it caused false
negatives because the flow in netdev->flow may not properly masked.

In dpif_netdev_flow_put() we now use the same method for constructing the
netdev_flow_key as the one used when adding the flow to the dplcs to make sure
these always match. The function netdev_flow_key_from_flow() used so far was
not only inefficient but sometimes caused mismatches and subsequent flow
update failures.

The kernel datapath does not support the packet_type match field.
Instead it encodes the packet type implictly by the presence or absence of
the Ethernet attribute in the flow key and mask.
This patch filters the PACKET_TYPE attribute out of netlink flow key and
mask to be sent to the kernel datapath.

Signed-off-by: Lorand Jakab 
Signed-off-by: Simon Horman 
Signed-off-by: Jiri Benc 
Signed-off-by: Yi Yang 
Signed-off-by: Jan Scheurich 
Co-authored-by: Zoltan Balogh 
---
 build-aux/extract-ofp-fields  |   1 +
 datapath/linux/compat/include/linux/openvswitch.h |   2 +
 include/openvswitch/match.h   |   1 +
 include/openvswitch/meta-flow.h   |  15 +-
 lib/dpif-netdev.c |  45 +++---
 lib/dpif-netlink.c|  43 -
 lib/dpif.c|   2 +-
 lib/match.c   |  25 +++
 lib/meta-flow.c   |   2 +
 lib/netdev-vport.c|   8 +-
 lib/netdev.h  |   1 +
 lib/odp-execute.c |   2 +
 lib/odp-util.c| 182 +-
 lib/odp-util.h|   6 +-
 lib/packets.h |   1 -
 ofproto/ofproto-dpif-sflow.c  |   1 +
 ofproto/ofproto-dpif-upcall.c |   4 +-
 ofproto/ofproto-dpif-xlate.c  |  54 ++-
 ofproto/ofproto-dpif.c|   6 +-
 ofproto/tunnel.c  |   3 +
 tests/tunnel-push-pop-ipv6.at |  10 +-
 tests/tunnel-push-pop.at  |  14 +-
 tests/tunnel.at   |  28 ++--
 23 files changed, 337 insertions(+), 119 deletions(-)

diff --git a/build-aux/extract-ofp-fields b/build-aux/extract-ofp-fields
index af7c69b..d5b8a82 100755
--- a/build-aux/extract-ofp-fields
+++ b/build-aux/extract-ofp-fields
@@ -39,6 +39,7 @@ FORMATTING = {"decimal":("MFS_DECIMAL",  1,   
8),
   "TCP flags":  ("MFS_TCP_FLAGS",2,   2)}
 
 PREREQS = {"none": "MFP_NONE",
+   "Ethernet": "MFP_ETHERNET",
"ARP": "MFP_ARP",
"VLAN VID": "MFP_VLAN_VID",
"IPv4": "MFP_IPV4",
diff --git a/datapath/linux/compat/include/linux/openvswitch.h 
b/datapath/linux/compat/include/linux/openvswitch.h
index d22102e..7990638 100644
--- a/datapath/linux/compat/include/linux/openvswitch.h
+++ b/datapath/linux/compat/include/linux/openvswitch.h
@@ -363,6 +363,8 @@ enum ovs_key_attr {
/* Only used within kernel data path. */
OVS_KEY_ATTR_TUNNEL_INFO,  /* struct ovs_tunnel_info */
 #endif
+
+   OVS_KEY_ATTR_PACKET_TYPE,  /* be32 packet type */
__OVS_KEY_ATTR_MAX
 };
 
diff --git a/include/openvswitch/match.h b/include/openvswitch/match.h
index 06fa04c..ce06919 100644
--- a/include/openvswitch/match.h
+++ b/include/openvswitch/match.h
@@ -115,6 +115,7 @@ void match_set_ct_ipv6_dst(struct match *, const struct 
in6_addr *);
 void match_set_ct_ipv6_dst_masked(struct match *, const struct in6_addr *,
   const struct in6_addr *);
 
+void match_set_packet_type(struct match *, ovs_be32 packet_type);
 void match_set_skb_priority(struct match *, uint32_t skb_priority);
 void match_set_dl_type(struct match *, ovs_be16);
 void match_set_dl_src(struct match *, const struct 

[ovs-dev] [PATCH v7 0/3] userspace: Support for L3 tunneling

2017-05-25 Thread Zoltán Balogh
From: Jan Scheurich 

This patch set is part of an initiative to deal with non-Ethernet packets in 
OVS for advanced use cases like L3 tunneling or NSH. The initiative is 
centering on the new OpenFlow concepts of "Packet type-aware pipeline" (PTAP) 
and "Generic encap/decap actions" (EXT-382). The overall design is documented 
in 
https://docs.google.com/document/d/1oWMYUH8sjZJzWa72o2q9kU0N6pNE-rwZcLH3-kbbDR8

The patches implement the user-space parts of the support for L3 tunnels 
connected to the legacy Ethernet-only pipeline in OVS. In large parts it is an 
adaptation of the earlier work on L3 tunneling by Lorand Jakab, Simon Horman, 
Jiri Benc and Yi Yang, adapted to the new design for packet type aware 
pipelines as prototyped by Jean Tourrilhes. 

Key changes compared to earlier patch series are the introduction of explicit 
packet_type members in the structs dp_packet and flow, as well as a simpler 
handling of L3 tunnels limited to the ofproto layer.

The present series v7 supersedes v6 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332367.html). Header 
file vxlangpe.h was removed, its content was moved into VXLAN section of 
lib/packets.h. Two patches were merged into a single one and fixes were done 
based on review comments.
The present series v6 supersedes v5 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332151.html). The 
reason of creating v6 is that tunnel handling has been changed on master 
branch, so rebasing was necessary.
The present series v5 supersedes v4 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/331424.html), v4 
fixes struct ovs_action_push_eth, so kernel and userspace use same data 
structure and removes a patch from the series which was applied to master.
The series v4 supersedes v3 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/330488.html), v4 
fixes sparse warnings coding style and removes a patch from the series.
The series v3 superseded v2 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/330444.html) which 
added support for vxlan-gpe tunnels in the netdev-dpdk datapath based on 
earlier patches 14-16 out of a patch set by Yi Yang 
(https://mail.openvswitch.org/pipermail/ovs-dev/2017-February/328498.html). 

   userspace: Switching of L3 packets in L2 pipeline 
   userspace: L3 tunnel support for GRE and LISP 
   userspace: add vxlan gpe support to vport

For native L3 tunneling with the userspace datapath these patches are complete 
and could be merged.

The necessary kernel module changes for L3 tunneling have already been 
upstreamed to the net-next kernel and back-ported to OVS. To apply L3 tunneling 
to the kernel datapath, one will need the following additional contributions:

* [PATCH v2 0/7] create tunnel devices using rtnetlink interface
   https://mail.openvswitch.org/pipermail/ovs-dev/2017-March/329893.html 
* An additional user-space patch based on the above to configure the layer3 
tunnel option in the kernel datapath

Changes v1 -> v2:
* Rebased to master (f40c558 ovn: Gratuitous ARP for distributed NAT rules)
* Moved new packet_type member to fill a 4-byte padding in struct flow
* Define the packet_type constants to be in host byte order
* Update the display format of packet_type in match and flow key printouts to a 
pair format "(ns, type)"
* Renamed dp_packet_l2() to dp_packet_eth()
* Removed unnecessary wrappers dp_packet_packet_type() and 
dp_packet_set_packet_type()
* Fixed "sparse" warnings
* Removed misleading or unnecessary comments
* Added support for vxlan-gpe tunnel vports for Ethernet, IPv4, IPv6 and NSH 
payload

Changes v2 -> v3:
* Removed unused function dp_packet_is_l3()
* Using VLOG_DROP_DBG and VLOG_DBG instead of VLOG_DBG_RL in 
dp_netdev_flow_add()
* Moved changes related comment from flow_put_on_md() into commit message
* PT_NS* macros were replaced with inline functions
* Unnecessary if statements removed from match_format()
* Using assignment operator instead of memset where it's possible
* Improved some commit messages

Changes v3 -> v4:
* Fixed "sparse" warnings
* Fixed coding style
* Removed patch "ofproto-dpif-upcall: Intialize dump-seq of new flow to zero"
* Rebased to origin/master (9a84f46)

Changes v4 -> v5:
* Eth_type member removed from struct ovs_action_push_eth.
* Patch "userspace: Add packet_type in dp_packet and flow" exluded.

Changes v5 -> v6:
* Rebased to origin/master (f5f6455)
* Patch "userspace: Support for push_eth and pop_eth actions" exluded.

Changes v6 -> v7:
* Rebased to origin/master (b50fcaa)
* Patch "dpif-netlink: Don't send PACKET_TYPE to kernel" merged into patch 
"userspace: Switching of L3 packets in L2 pipeline".
* Patch "ofproto-dpif-xlate: refactor compose_output_action__" excluded.
* Fixed coding style. 
* Printout format "packet_type=(0,0x0)" changed into "packet_type=(0,0)".
* Fixed unit test 785.
* Dropping packets from GRE tunnels with GRE protocol < 0x600.
* Nl_msg_put_exclude_packet_type() reworked 

[ovs-dev] [PATCH v2 5/6] userspace: Complete Packet In handling

2017-05-19 Thread Zoltán Balogh
From: Jan Scheurich 

Send packet_in for non-Ethernet packets.
Include packet_type in Packet In for ptap bridges.

Signed-off-by: Jan Scheurich 
---
 lib/flow.c   |  4 
 lib/ofp-print.c  |  3 +--
 ofproto/ofproto-dpif-xlate.c | 10 +-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lib/flow.c b/lib/flow.c
index 4f7a041..d3b3cee 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -991,6 +991,10 @@ flow_get_metadata(const struct flow *flow, struct match 
*flow_metadata)
 }
 
 match_set_in_port(flow_metadata, flow->in_port.ofp_port);
+if (flow->packet_type != htonl(PT_ETH)) {
+match_set_packet_type(flow_metadata, flow->packet_type);
+}
+
 if (flow->ct_state != 0) {
 match_set_ct_state(flow_metadata, flow->ct_state);
 if (is_ct_valid(flow, NULL, NULL) && flow->ct_nw_proto != 0) {
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 7ca9531..2408bff 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -217,10 +217,9 @@ ofp_print_packet_in(struct ds *string, const struct 
ofp_header *oh,
 }
 
 if (verbosity > 0) {
-/* Packet In can only carry Ethernet packets. */
 char *packet = ofp_packet_to_string(public->packet,
 public->packet_len,
-htonl(PT_ETH));
+
public->flow_metadata.flow.packet_type);
 ds_put_cstr(string, packet);
 free(packet);
 }
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 7240a24..3a69c21 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -4267,11 +4267,6 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
 return;
 }
 
-if (packet->packet_type != htonl(PT_ETH)) {
-dp_packet_delete(packet);
-return;
-}
-
 /* A packet sent by an action in a table-miss rule is considered an
  * explicit table miss.  OpenFlow before 1.3 doesn't have that concept so
  * it will get translated back to OFPR_ACTION for those versions. */
@@ -4305,6 +4300,11 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
 };
 flow_get_metadata(>xin->flow, >pin.up.public.flow_metadata);
 
+/* Send packet_type only from packet-type-aware bridges. */
+if (!ctx->xbridge->packet_type_aware) {
+am->pin.up.public.flow_metadata.wc.masks.packet_type = 0;
+}
+
 /* Async messages are only sent once, so if we send one now, no
  * xlate cache entry is created.  */
 if (ctx->xin->allow_side_effects) {
-- 
1.9.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v2 4/6] tests: Added unit tests in packet-type-aware.at

2017-05-19 Thread Zoltán Balogh
From: Jan Scheurich 

Packet type-aware unit tests.

 ptap - create packet-type-aware bridge
 ptap - legal flow entries in ptap bridge
 ptap - triangle bridge setup with L2 and L3 GRE tunnels

First and second unit tests perform basic verification.

The third one is a triangular bridge setup test case. It tests dataplane
in non-PTAP and ptap bridges in conjunction with L2 and L3 GRE tunnels.
It uses veth ports, therefore requires root privileges.

A simplified version of the third test is added to system userspace unit tests.

 GRE tunneling test setup for PTAP bridge

 192.168.10.10   192.168.10.20 192.168.10.30
  n1   n2n3
  || |
   +--o--+  +--o--+   +--o--+
   |br-in1   |  |br-in2   |   |br-in3   |
   | |  |   (PTAP)|   | |
   +--o--+  +--o--+   +--o--+
 gre  gre   gre
   10.0.0.1(10.0.0.2)(10.0.0.3)
  (20.0.0.1)20.0.0.2 (20.0.0.3)
  (30.0.0.1) LOCAL (30.0.0.2) LOCAL   30.0.0.3  LOCAL
   +---o-+  +---o-+   +---o-+
   |br-p1|  |br-p2|   |br-p3|
   +--o--+  +--o--+   +--o--+
 p1-0 || p2-0| p3-0
 p0-1 || p0-2| p0-3
   +--oo-o--+
   |  br0   |
   ++

   GRE tunnel ports:
  No Bridge  NameTypeRemote bridge & ports
 ---
  1020   br-in1  gre-12  l2  br-in2 2010 (versatile)
  1021   br-in1  gre-12_l3   l3same
  1030   br-in1  gre-13  l2  br-in3 3010 (l2)
  2010   br-in2  gre-21  versatile   br-in1 1020 (l2), 1021 (l3)
  2030   br-in2  gre-13  versatile   br-in3 3020 (l2), 3021 (l3)
  3010   br-in1  gre-31  l2  br-in1 1030 (l2)
  3020   br-in1  gre-32  l2  br-in2 2010 (versatile)
  3021   br-in1  gre-32_l3   l3same

Signed-off-by: Jan Scheurich 
---
 tests/automake.mk   |   6 +-
 tests/packet-type-aware.at  | 540 
 tests/system-userspace-packet-type-aware.at | 422 ++
 tests/system-userspace-testsuite.at |   1 +
 tests/testsuite.at  |   1 +
 5 files changed, 968 insertions(+), 2 deletions(-)
 create mode 100644 tests/packet-type-aware.at
 create mode 100644 tests/system-userspace-packet-type-aware.at

diff --git a/tests/automake.mk b/tests/automake.mk
index c6bd120..08d5a2d 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -95,7 +95,8 @@ TESTSUITE_AT = \
tests/ovn-sbctl.at \
tests/ovn-controller.at \
tests/ovn-controller-vtep.at \
-   tests/mcast-snooping.at
+   tests/mcast-snooping.at \
+   tests/packet-type-aware.at
 
 SYSTEM_KMOD_TESTSUITE_AT = \
tests/system-common-macros.at \
@@ -105,7 +106,8 @@ SYSTEM_KMOD_TESTSUITE_AT = \
 SYSTEM_USERSPACE_TESTSUITE_AT = \
tests/system-userspace-testsuite.at \
tests/system-ovn.at \
-   tests/system-userspace-macros.at
+   tests/system-userspace-macros.at \
+   tests/system-userspace-packet-type-aware.at
 
 SYSTEM_TESTSUITE_AT = \
tests/system-common-macros.at \
diff --git a/tests/packet-type-aware.at b/tests/packet-type-aware.at
new file mode 100644
index 000..976b0fd
--- /dev/null
+++ b/tests/packet-type-aware.at
@@ -0,0 +1,540 @@
+AT_BANNER([packet-type-aware pipeline])
+
+AT_SETUP([ptap - create packet-type-aware bridge])
+
+OVS_VSWITCHD_START([])
+
+AT_CHECK([
+ovs-vsctl set bridge br0 \
+datapath_type=dummy \
+other-config:packet-type-aware=true
+], [0])
+
+AT_CHECK([ovs-vsctl list bridge br0 | grep other_config], [0], [dnl
+other_config: {datapath-id="fedcba9876543210", 
hwaddr="aa:55:aa:55:00:00", packet-type-aware="true"}
+])
+
+AT_CHECK([ovs-ofctl -Oopenflow13 dump-table-features br0 | grep packet_type], 
[0], [dnl
+  packet_type: exact match or wildcard
+])
+AT_CHECK([ovs-ofctl -Oopenflow14 dump-table-features br0 | grep packet_type], 
[0], [dnl
+  packet_type: exact match or wildcard
+])
+AT_CHECK([ovs-ofctl -Oopenflow15 dump-table-features br0 | grep packet_type], 
[0], [dnl
+  packet_type: exact match or wildcard
+])
+
+AT_CHECK([
+

  1   2   >