]> git.proxmox.com Git - mirror_ovs.git/log
mirror_ovs.git
7 years agodatapath: Refactor labels initialization.
Jarno Rajahalme [Thu, 9 Mar 2017 01:18:22 +0000 (17:18 -0800)]
datapath: Refactor labels initialization.

Upstream commit:

    Refactoring conntrack labels initialization makes changes in later
    patches easier to review.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: Simplify labels length logic.
Jarno Rajahalme [Thu, 9 Mar 2017 01:18:22 +0000 (17:18 -0800)]
datapath: Simplify labels length logic.

Upstream commit:

    commit b87cec3814ccc7f6afb0a1378ee7e5110d07cdd3
    Author: Jarno Rajahalme <jarno@ovn.org>
    Date:   Thu Feb 9 11:21:56 2017 -0800

    openvswitch: Simplify labels length logic.

    Since 23014011ba42 ("netfilter: conntrack: support a fixed size of 128
    distinct labels"), the size of conntrack labels extension has fixed to
    128 bits, so we do not need to check for labels sizes shorter than 128
    at run-time.  This patch simplifies labels length logic accordingly,
    but allows the conntrack labels size to be increased in the future
    without breaking the build.  In the event of conntrack labels
    increasing in size OVS would still be able to deal with the 128 first
    label bits.

Suggested-by: Joe Stringer <joe@ovn.org>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: Unionize ovs_key_ct_label with a u32 array.
Jarno Rajahalme [Thu, 9 Mar 2017 01:18:22 +0000 (17:18 -0800)]
datapath: Unionize ovs_key_ct_label with a u32 array.

Upstream commit:

    commit cb80d58fae76d8ea93555149b2b16e19b89a1f4f
    Author: Jarno Rajahalme <jarno@ovn.org>
    Date:   Thu Feb 9 11:21:55 2017 -0800

    openvswitch: Unionize ovs_key_ct_label with a u32 array.

    Make the array of labels in struct ovs_key_ct_label an union, adding a
    u32 array of the same byte size as the existing u8 array.  It is
    faster to loop through the labels 32 bits at the time, which is also
    the alignment of netlink attributes.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: Do not trigger events for unconfirmed connections.
Jarno Rajahalme [Thu, 9 Mar 2017 01:18:22 +0000 (17:18 -0800)]
datapath: Do not trigger events for unconfirmed connections.

Upstream commit:

    commit 193e30967897f3a8b6f9f137ac30571d832c2c5c
    Author: Jarno Rajahalme <jarno@ovn.org>
    Date:   Thu Feb 9 11:21:54 2017 -0800

    openvswitch: Do not trigger events for unconfirmed connections.
    Receiving change events before the 'new' event for the connection has
    been received can be confusing.  Avoid triggering change events for
    setting conntrack mark or labels before the conntrack entry has been
    confirmed.

Fixes: 182e3042e15d ("openvswitch: Allow matching on conntrack mark")
Fixes: c2ac66735870 ("openvswitch: Allow matching on conntrack label")
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream commit:

    commit 2317c6b51e4249dbfa093e1b88cab0a9f0564b7f
    Author: Jarno Rajahalme <jarno@ovn.org>
    Date:   Fri Feb 17 18:11:58 2017 -0800

    openvswitch: Set event bit after initializing labels.

    Connlabels are included in conntrack netlink event messages only if
    the IPCT_LABEL bit is set in the event cache (see
    ctnetlink_conntrack_event()).  Set it after initializing labels for a
    new connection.

    Found upon further system testing, where it was noticed that labels
    were missing from the conntrack events.

Fixes: 193e30967897 ("openvswitch: Do not trigger events for unconfirmed con
nections.")
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Fixes: 372ce9737d2b ("datapath: Allow matching on conntrack mark")
Fixes: 038e34abaa31 ("datapath: Allow matching on conntrack label")
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: Use inverted tuple in ovs_ct_find_existing() if NATted.
Jarno Rajahalme [Thu, 9 Mar 2017 01:18:22 +0000 (17:18 -0800)]
datapath: Use inverted tuple in ovs_ct_find_existing() if NATted.

Upstream commit:

    commit 9ff464db50e437eef131f719cc2e9902eea9c607
    Author: Jarno Rajahalme <jarno@ovn.org>
    Date:   Thu Feb 9 11:21:53 2017 -0800

    openvswitch: Use inverted tuple in ovs_ct_find_existing() if NATted.

    The conntrack lookup for existing connections fails to invert the
    packet 5-tuple for NATted packets, and therefore fails to find the
    existing conntrack entry.  Conntrack only stores 5-tuples for incoming
    packets, and there are various situations where a lookup on a packet
    that has already been transformed by NAT needs to be made.  Looking up
    an existing conntrack entry upon executing packet received from the
    userspace is one of them.

    This patch fixes ovs_ct_find_existing() to invert the packet 5-tuple
    for the conntrack lookup whenever the packet has already been
    transformed by conntrack from its input form as evidenced by one of
    the NAT flags being set in the conntrack state metadata.

Fixes: 05752523e565 ("openvswitch: Interface with NAT.")
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This patch also adds a test case to OVS system tests to verify the
behavior.

The following is a more thorough explanation of what is going on:

When we have evidence that an existing conntrack entry could exist, we
must invert the tuple if NAT has already been applied, as the current
packet headers do not match any tuple stored in conntrack.  For
example, if a packet from private address X to a public address B is
source-NATted to A, the conntrack entry will have the following tuples
(ignoring the protocol and port numbers) after the conntrack entry is
committed:

Original direction tuple: (X,B)
Reply direction tuple: (B,A)

Now, if a reply packet is already transformed back to the private
address space (e.g., with a CT(nat) action), the tuple corresponding
to the current packet headers is:

Current packet tuple: (B,X)

This does not match either of the conntrack tuples above.  Normally
this does not matter, as the conntrack lookup was already done using
the tuple (B,A), but if the current packet does not match any flow in
the OVS datapath, the packet is sent to userspace via an upcall,
during which the packet's skb is freed, and the conntrack entry
pointer in the skb is lost.  When the packet is reintroduced to the
datapath, any further conntrack action will need to perform a new
conntrack lookup to find the entry again.  Prior to this patch this
second lookup failed.  The datapath flow setup corresponding to the
upcall can succeed, however, allowing all further packets in the reply
direction to re-use the conntrack entry pointer in the skb, so
typically the lookup failure only causes a packet drop.

The solution is to invert the tuple derived from the current packet
headers in case the conntrack state stored in the packet metadata
indicates that the packet has been transformed by NAT:

Inverted tuple: (X,B)

With this the conntrack entry can be found, matching the original
direction tuple.

This same logic also works for the original direction packets:

Current packet tuple (after reverse NAT): (A,B)
Inverted tuple: (B,A)

While the current packet tuple (A,B) does not match either of the
conntrack tuples, the inverted one (B,A) does match the reply
direction tuple.

Since the inverted tuple matches the reverse direction tuple the
direction of the packet must be reversed as well.

Fixes: c5f6c06b58d6 ("datapath: Interface with NAT.")
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: Fix comments for skb->_nfct
Jarno Rajahalme [Thu, 9 Mar 2017 01:18:22 +0000 (17:18 -0800)]
datapath: Fix comments for skb->_nfct

Upstream commit:

    commit 5e17da634a21b1200853fe82ba67d6571f2beabe
    Author: Jarno Rajahalme <jarno@ovn.org>
    Date:   Thu Feb 9 11:21:52 2017 -0800

    openvswitch: Fix comments for skb->_nfct

    Fix comments referring to skb 'nfct' and 'nfctinfo' fields now that
    they are combined into '_nfct'.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: add and use nf_ct_set helper
Florian Westphal [Thu, 9 Mar 2017 01:18:22 +0000 (17:18 -0800)]
datapath: add and use nf_ct_set helper

Upstream commit:

    commit c74454fadd5ea6fc866ffe2c417a0dba56b2bf1c
    Author: Florian Westphal <fw@strlen.de>
    Date:   Mon Jan 23 18:21:57 2017 +0100

    netfilter: add and use nf_ct_set helper

    Add a helper to assign a nf_conn entry and the ctinfo bits to an sk_buff.
    This avoids changing code in followup patch that merges skb->nfct and
    skb->nfctinfo into skb->_nfct.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: add and use skb_nfct helper
Florian Westphal [Thu, 9 Mar 2017 01:18:22 +0000 (17:18 -0800)]
datapath: add and use skb_nfct helper

Upstream commit:

    commit cb9c68363efb6d1f950ec55fb06e031ee70db5fc
    Author: Florian Westphal <fw@strlen.de>
    Date:   Mon Jan 23 18:21:56 2017 +0100

    skbuff: add and use skb_nfct helper

    Followup patch renames skb->nfct and changes its type so add a helper to
    avoid intrusive rename change later.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: Allow compiling against Linux 4.10
Jarno Rajahalme [Thu, 9 Mar 2017 01:18:22 +0000 (17:18 -0800)]
datapath: Allow compiling against Linux 4.10

OVS in-tree datapath compiles against Linux 4.10 kernel, so allow it.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
7 years agoid-pool: Allocate the lowest available ids.
Ilya Maximets [Tue, 21 Feb 2017 14:49:25 +0000 (17:49 +0300)]
id-pool: Allocate the lowest available ids.

This simple change makes id-pool to always allocate the
lowest possible id from the pool. No any other code affected
because, actually, there is no users of 'id_pool_free_id' in
OVS.

This behaviour of id-pool will be used in the next patch.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoDocumentation: Fix DPDK doc
Cian Ferriter [Tue, 21 Feb 2017 11:13:32 +0000 (11:13 +0000)]
Documentation: Fix DPDK doc

OVS no longer expects DPDK devices to start with dpdk and end with a
portid. Update docs to reflect this.

Signed-off-by: Cian Ferriter <cian.ferriter@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoofp-actions: Fix translation of set_field for nw_ecn
Eric Garver [Tue, 21 Feb 2017 19:22:53 +0000 (14:22 -0500)]
ofp-actions: Fix translation of set_field for nw_ecn

When using set_field for nw_ecn with OF1.0 or OF1.1, you get an error
instead of a proper translation. This use to work before 4b684612d900
("ofp-actions: Translate mod_nw_ecn action to OF1.1 properly.") because
it would fallback to using NXM.

e.g.

[root@rhel7 ~]# ovs-ofctl -O OpenFlow10 add-flow br0 'ip actions=set_field:2->nw_ecn'
OFPT_ERROR (xid=0x4): OFPBAC_BAD_ARGUMENT
NXT_FLOW_MOD (xid=0x4):
...

$ ovs-ofctl -O OpenFlow11 add-flow br0 'ip actions=set_field:2->nw_ecn'
ovs-ofctl: none of the usable flow formats (NXM,OXM) is among the
allowed flow formats (OpenFlow11)

Fixes: 4b684612d900 ("ofp-actions: Translate mod_nw_ecn action to OF1.1 properly.")
Signed-off-by: Eric Garver <e@erig.me>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovs-tcpdump: Set mirror port mtu
Aaron Conole [Wed, 22 Feb 2017 19:59:41 +0000 (14:59 -0500)]
ovs-tcpdump: Set mirror port mtu

When using ovs-tcpdump to mirror interfaces with MTU larger than the default,
Open vSwitch will lower the interfaces we are interested in monitoring.
Instead, probe the MTU and set the mirrored port's MTU value correctly.

Fixes: 314ce6479a83 ("ovs-tcpdump: Add a tcpdump wrapper utility")
Reported-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoofproto/bond: Simplify bond_may_recirc()
Andy Zhou [Sat, 25 Feb 2017 01:57:48 +0000 (17:57 -0800)]
ofproto/bond: Simplify bond_may_recirc()

The extra information passed back is no longer used outside bond.c.
Make the API simpler.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agodpdk: Export packet_set_ipv6_addr() for DPDK.
Darrell Ball [Thu, 16 Feb 2017 08:47:32 +0000 (00:47 -0800)]
dpdk: Export packet_set_ipv6_addr() for DPDK.

The NAT changes in this series need both packet_set_ipv4_addr()
and packet_set_ipv6_addr() exporting, however, the ipv4 api was
exported with an unrelated patch.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovs-fields.7: Use a more general approach to groff encodings.
Ben Pfaff [Thu, 26 Jan 2017 18:26:30 +0000 (10:26 -0800)]
ovs-fields.7: Use a more general approach to groff encodings.

It turns out that, since groff 1.20 around 2009, groff comes with a
preprocessor named "preconv" that can fix encoding issues.  Use it instead
of the existing hack.

Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpif-netdev: Simple DROP meter implementation.
Jarno Rajahalme [Thu, 23 Feb 2017 19:27:57 +0000 (11:27 -0800)]
dpif-netdev: Simple DROP meter implementation.

Meters may be used by any flow, so some kind of locking must be used.
In this version we have an adaptive mutex for each meter, which may
not be optimal for DPDK.  However, this should serve as a basis for
further improvement.

A batch of packets is first tried as a whole, and only if some of the
meter bands are hit, we need to process the packets individually.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Andy Zhou <azhou@ovn.org>
7 years agoofproto: Meter translation.
Jarno Rajahalme [Thu, 23 Feb 2017 19:27:56 +0000 (11:27 -0800)]
ofproto: Meter translation.

Translate OpenFlow METER instructions to datapath meter actions.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Andy Zhou <azhou@ovn.org>
7 years agoofproto: Fix thread safety annotation.
Jarno Rajahalme [Thu, 23 Feb 2017 19:27:55 +0000 (11:27 -0800)]
ofproto: Fix thread safety annotation.

ofproto_check_ofpacts() requires ofproto_mutex, but the header did not
tell that so the trace did not take the mutex.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Andy Zhou <azhou@ovn.org>
7 years agodpif: Meter framework.
Jarno Rajahalme [Thu, 23 Feb 2017 19:27:54 +0000 (11:27 -0800)]
dpif: Meter framework.

Add DPIF-level infrastructure for meters.  Allow meter_set to modify
the meter configuration (e.g. set the burst size if unspecified).

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Andy Zhou <azhou@ovn.org>
7 years agorhel: Use correct default port for OVN SB database
Lance Richardson [Wed, 8 Mar 2017 20:19:40 +0000 (15:19 -0500)]
rhel: Use correct default port for OVN SB database

Fix typo in OVN SB database TCP port number.

Fixes: commit 55f36be59122 ("rhel: Firewall service files for OVN.")
Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
7 years agopython: List 3.5 as a supported version.
Russell Bryant [Tue, 28 Feb 2017 13:36:17 +0000 (08:36 -0500)]
python: List 3.5 as a supported version.

All tests pass with Python 3.5 so list it as supported.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agoMakefile: Drop vestiges of support for non-GNU Make.
Ben Pfaff [Wed, 8 Mar 2017 04:48:08 +0000 (20:48 -0800)]
Makefile: Drop vestiges of support for non-GNU Make.

Open vSwitch has documented a requirement for GNU Make for a long time, yet
it had vestiges catering to other make implementations.  This removes
those.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
7 years agopackaging: Make Fedora spec file CentOS compatible
Leif Madsen [Mon, 6 Mar 2017 20:46:43 +0000 (15:46 -0500)]
packaging: Make Fedora spec file CentOS compatible

On CentOS, the package names aren't prefixed with python2, but rather
are prefixed with simply python. This change addresses that and fixes
up some documentation that was outdated, and updates the Vagrantfile
to use the proper spec file and package names.

Fixes: bb1a7ca21107 ("fedora: Add python3-openvswitch split package")
Signed-off-by: Leif Madsen <lmadsen@redhat.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
7 years agovagrant: Use official boxes for Fedora and Centos
Timothy Redaelli [Thu, 9 Feb 2017 14:00:36 +0000 (15:00 +0100)]
vagrant: Use official boxes for Fedora and Centos

Change CentOS version to last 7 (7.3 at the moment),
since old kernel-devel version is no longer available.

Add net-tools to CentOS since netstat is needed for some tests.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Andy Zhou <azhou@ovn.org>
7 years agoodp-execute: Apply clone action on batch of packets instead of one by one.
Sugesh Chandran [Thu, 9 Feb 2017 15:41:53 +0000 (15:41 +0000)]
odp-execute: Apply clone action on batch of packets instead of one by one.

Clone action is optimized by cloning a batch of packets together instead of
executing independently on every packet in a batch.

Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
Signed-off-by: Zoltán Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltán Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoMakefile: Break the build if .gitignore files are distributed.
Ben Pfaff [Wed, 8 Mar 2017 00:29:53 +0000 (16:29 -0800)]
Makefile: Break the build if .gitignore files are distributed.

This would have found a .gitignore file recently added to the distribution.

CC: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Markos Chandras <mchandras@suse.de>
7 years agodoc: Add info on distributions shipping openvswitch package.
Bhanuprakash Bodireddy [Tue, 7 Feb 2017 21:18:23 +0000 (21:18 +0000)]
doc: Add info on distributions shipping openvswitch package.

List details of various popular distributions shipping Open vSwitch
packages. Also include the information of the distros supporting DPDK
accelerated datapath.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoDocumentation: Update DPDK doc with extended statistics.
Bhanuprakash Bodireddy [Tue, 7 Feb 2017 21:18:22 +0000 (21:18 +0000)]
Documentation: Update DPDK doc with extended statistics.

Add instructions on how to retrieve extended statistics for DPDK physical
and vhost ports.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agowindows: Fix uninitialized variable in netlink-socket
Alin Serdean [Mon, 6 Mar 2017 16:22:39 +0000 (16:22 +0000)]
windows: Fix uninitialized variable in netlink-socket

The variable `request_nlmsg` was used without being initialized.

This patch assigns a value to it before being used.

Found by inspection.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agowindows: automake.mk: Remove the .gitignore file from distributed files
Markos Chandras [Sat, 4 Feb 2017 17:11:11 +0000 (17:11 +0000)]
windows: automake.mk: Remove the .gitignore file from distributed files

Commit d183efc22b2b ("This commit adds the windows installer to the
OVS tree.) added the .gitignore file to the distributed files but this
file shouldn't be part of the distributed archive.

CC: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Fixes: d183efc22b2b ("This commit adds the windows installer to the OVS tree.")
Signed-off-by: Markos Chandras <mchandras@suse.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovn: specify options:nat-addresses as "router"
Mickey Spiegel [Fri, 3 Feb 2017 04:48:24 +0000 (20:48 -0800)]
ovn: specify options:nat-addresses as "router"

Currently in OVN, the "nat-addresses" in the "options" column of a
logical switch port of type "router" must be specified manually.
Typically the user would specify as "nat-addresses" all of the NAT
external IP addresses and load balancer IP addresses that have
already been specified separately on the router.

This patch allows the logical switch port's "nat-addresses" to be
specified as the string "router".  When ovn-northd sees this string,
it automatically copies the following into the southbound
Port_Binding's "nat-addresses" in the "options" column:
    The options:router-port's MAC address.
    Each NAT external IP address (of any NAT type) specified on the
    logical router of options:router-port.
    Each load balancer IP address specified on the logical router of
    options:router-port.
This will cause the controller where the gateway router resides to
issue gratuitous ARPs for each NAT external IP address and for each
load balancer IP address specified on the gateway router.

Signed-off-by: Mickey Spiegel <mickeys.dev@gmail.com>
Acked-by: Gurucharan Shetty <guru@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agowindows: add include to stream-windows.c
Alin Serdean [Mon, 6 Feb 2017 04:41:41 +0000 (04:41 +0000)]
windows: add include to stream-windows.c

fatal_signal_unlink_file_now is used but the header for it is missing in
the include section.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
7 years agowindows: add function definition to poll-loop.h
Alin Serdean [Mon, 6 Feb 2017 04:41:41 +0000 (04:41 +0000)]
windows: add function definition to poll-loop.h

poll_wevent_wait_at is used in the #define but the function definition
is missing.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
7 years agowindows: fix calls in netlink-socket
Alin Serdean [Mon, 6 Feb 2017 04:41:40 +0000 (04:41 +0000)]
windows: fix calls in netlink-socket

Add nl_sock_transact forward declaration, since it is used before
being on implemented. This applies only on Windows.

Move nl_sock_subscribe_packet__ function before it is used.

It makes more sense to move it rather than adding a forward declaration
since it is used by the two functions defined above it.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
7 years agowindows: add forward declaration to dpif-netlink
Alin Serdean [Mon, 6 Feb 2017 04:41:40 +0000 (04:41 +0000)]
windows: add forward declaration to dpif-netlink

dpif_netlink_port_query__ is used before it is defined on Windows.

Add a forward declaration to it.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
7 years agowindows: Add definition of getrusage
Alin Serdean [Mon, 6 Feb 2017 04:41:40 +0000 (04:41 +0000)]
windows: Add definition of getrusage

getrusage is implemented in lib/getrusage-windows.c.

This patch just adds its definition to include/windows/sys/resource.h,
which serves for files that include <sys/resource.h>.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
7 years agowindows: Remove dead code in daemon-windows
Alin Serdean [Sun, 5 Feb 2017 23:49:29 +0000 (23:49 +0000)]
windows: Remove dead code in daemon-windows

Found by inspection.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
7 years agodatapath-windows: Trigger conntrack event after setting mark and label
Sairam Venugopal [Thu, 2 Mar 2017 21:41:03 +0000 (13:41 -0800)]
datapath-windows: Trigger conntrack event after setting mark and label

New Conntrack Entry event should be triggered after setting the mark and
label fields. The current RW lock implementation prevents Event Handler
from reading the entry until mark/label is set.

Fixing the workflow to trigger the event after setting mark/label.

Signed-off-by: Sairam Venugopal <vsairam@vmware.com>
Acked-by: Shashank Ram <rams@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
7 years agoflake8: Fix build with flake8-import-order installed.
Russell Bryant [Tue, 7 Mar 2017 16:14:30 +0000 (11:14 -0500)]
flake8: Fix build with flake8-import-order installed.

OpenStack CI is currently failing due to some flake8 warnings
emitted from the flake8-import-order plugin.  Just ignore all of
those warnings since they're just style things that aren't important.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agoofproto-dpif-xlate: fix build.
Jarno Rajahalme [Tue, 7 Mar 2017 00:02:55 +0000 (16:02 -0800)]
ofproto-dpif-xlate: fix build.

Recent patch 27d931da3ac ("ofproto-dpif: Enhance
execute_controller_action().") missed some new action enumerations
added previously.

Fixes: 27d931da3ac ("ofproto-dpif: Enhance execute_controller_action().")
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
7 years agoxlate: Translate openflow clone into odp sample action.
Andy Zhou [Tue, 14 Feb 2017 22:40:04 +0000 (14:40 -0800)]
xlate: Translate openflow clone into odp sample action.

When datapath does not support the 'clone' action directly, generate
sample action (with 100% probability) instead.

Specifically, currently, there is no plan to support the 'clone'
action on the Linux kernel datapath directly, so the sample action
will be used to translate the openflow clone action for this datapath.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
7 years agolib: Refactor nested netlink APIs.
Andy Zhou [Tue, 14 Feb 2017 22:39:48 +0000 (14:39 -0800)]
lib: Refactor nested netlink APIs.

Future patches will make use of those changes.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
7 years agoofproto-dpif: Enhance execute_controller_action().
Andy Zhou [Mon, 13 Feb 2017 22:28:35 +0000 (14:28 -0800)]
ofproto-dpif: Enhance execute_controller_action().

Allow execute_controller_action() to accept actions encoded with
nested netlink attributes.

execute_controller_action() can be called during 'xlate_actions'. It
tries executes all actions translated so far to get the current packet
that needs to be sent to the controller.  This works fine until when
the action is enclosed within a nested netlink message, and the
action translation has not finished yet.

For example;
A, clone(B, controller, C)

In this case, we can not execute 'clone' since its translation has not
be finished (missing C), However, A still needs to be executed before
the packet can be sent to the controller.

This solution is to make a copy of the odp actions translated so far,
and 'fix up' the copy so that it can be executed. The original odp
actions are left intact so that xlate can continue.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
7 years agoconntrack: Fix checks for TCP, UDP, and IPv6 header sizes.
Ben Pfaff [Sat, 4 Mar 2017 05:16:17 +0000 (21:16 -0800)]
conntrack: Fix checks for TCP, UDP, and IPv6 header sizes.

Otherwise a malformed packet could cause a read up to about 40 bytes past
the end of the packet.  The packet would still likely be dropped because
of checksum verification.

Reported-by: Bhargava Shastry <bshastry@sec.t-labs.tu-berlin.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agoFAQ: Add another question about do-nothing flows.
Ben Pfaff [Mon, 6 Mar 2017 16:10:59 +0000 (08:10 -0800)]
FAQ: Add another question about do-nothing flows.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Gurucharan Shetty <guru@ovn.org>
7 years agodatapath-windows: Fix GENEVE option header
Alin Serdean [Mon, 6 Mar 2017 16:16:38 +0000 (16:16 +0000)]
datapath-windows: Fix GENEVE option header

The GENEVE option header is defined in big endian, however we support only
little endian on Windows at the moment.

This patch changes the GENEVE option header into little endian.

Found while testing.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Yin Lin <linyi@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
7 years agorhel: remove duplicate line from rhel/automake.mk
Lance Richardson [Thu, 9 Feb 2017 21:30:26 +0000 (16:30 -0500)]
rhel: remove duplicate line from rhel/automake.mk

Fixes: commit 55f36be59122 ("rhel: Firewall service files for OVN.")
Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agotun-metadata: Fix memory leak in tun_metadata_table_mod().
Yi-Hung Wei [Tue, 7 Feb 2017 21:14:27 +0000 (13:14 -0800)]
tun-metadata: Fix memory leak in tun_metadata_table_mod().

In testcase "tunnel - Geneve metadata", valgrind reports a memory leak with
the following call stack.
    xcalloc (util.c:95)
    tun_metadata_alloc (tun-metadata.c:89)
    tun_metadata_table_mod (tun-metadata.c:151)
    handle_tlv_table_mod (ofproto.c:7782)
    handle_openflow__ (ofproto.c:7961)
    handle_openflow (ofproto.c:8023)
    ofconn_run (connmgr.c:1427)
    connmgr_run (connmgr.c:363)
    ofproto_run (ofproto.c:1813)
    bridge_run__ (bridge.c:2899)
    bridge_run (bridge.c:2956)
    main (ovs-vswitchd.c:111)

Reported-by: William Tu <u9012063@gmail.com>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: Simplify do_execute_actions().
andy zhou [Fri, 3 Mar 2017 03:29:52 +0000 (19:29 -0800)]
datapath: Simplify do_execute_actions().

Upstream commit:
    commit 5b8784aaf29be20ba8d363e1124d7436d42ef9bf
    Author: Andy Zhou <azhou@ovn.org>
    Date: Fri Jan 27 13:45:28 2017 -0800

    openvswitch: Simplify do_execute_actions().

    do_execute_actions() implements a worthwhile optimization: in case
    an output action is the last action in an action list, skb_clone()
    can be avoided by outputing the current skb. However, the
    implementation is more complicated than necessary.  This patch
    simplify this logic.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream: 5b8784aaf29b ("openvswitch: Simplify do_execute_actions().")
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
7 years agodatapath: maintain correct checksum state in conntrack actions.
Lance Richardson [Fri, 3 Mar 2017 03:29:51 +0000 (19:29 -0800)]
datapath: maintain correct checksum state in conntrack actions.

Upstream commit:
    commit 75f01a4c9cc291ff5cb28ca1216adb163b7a20ee
    Author: Lance Richardson <lrichard@redhat.com>
    Date: Thu Jan 12 19:33:18 2017 -0500

    openvswitch: maintain correct checksum state in conntrack actions

    When executing conntrack actions on skbuffs with checksum mode
    CHECKSUM_COMPLETE, the checksum must be updated to account for
    header pushes and pulls. Otherwise we get "hw csum failure"
    logs similar to this (ICMP packet received on geneve tunnel
    via ixgbe NIC):

    [  405.740065] genev_sys_6081: hw csum failure
    [  405.740106] CPU: 3 PID: 0 Comm: swapper/3 Tainted: G          I     4.10.0-rc3+ #1
    [  405.740108] Call Trace:
    [  405.740110]  <IRQ>
    [  405.740113]  dump_stack+0x63/0x87
    [  405.740116]  netdev_rx_csum_fault+0x3a/0x40
    [  405.740118]  __skb_checksum_complete+0xcf/0xe0
    [  405.740120]  nf_ip_checksum+0xc8/0xf0
    [  405.740124]  icmp_error+0x1de/0x351 [nf_conntrack_ipv4]
    [  405.740132]  nf_conntrack_in+0xe1/0x550 [nf_conntrack]
    [  405.740137]  ? find_bucket.isra.2+0x62/0x70 [openvswitch]
    [  405.740143]  __ovs_ct_lookup+0x95/0x980 [openvswitch]
    [  405.740145]  ? netif_rx_internal+0x44/0x110
    [  405.740149]  ovs_ct_execute+0x147/0x4b0 [openvswitch]
    [  405.740153]  do_execute_actions+0x22e/0xa70 [openvswitch]
    [  405.740157]  ovs_execute_actions+0x40/0x120 [openvswitch]
    [  405.740161]  ovs_dp_process_packet+0x84/0x120 [openvswitch]
    [  405.740166]  ovs_vport_receive+0x73/0xd0 [openvswitch]
    [  405.740168]  ? udp_rcv+0x1a/0x20
    [  405.740170]  ? ip_local_deliver_finish+0x93/0x1e0
    [  405.740172]  ? ip_local_deliver+0x6f/0xe0
    [  405.740174]  ? ip_rcv_finish+0x3a0/0x3a0
    [  405.740176]  ? ip_rcv_finish+0xdb/0x3a0
    [  405.740177]  ? ip_rcv+0x2a7/0x400
    [  405.740180]  ? __netif_receive_skb_core+0x970/0xa00
    [  405.740185]  netdev_frame_hook+0xd3/0x160 [openvswitch]
    [  405.740187]  __netif_receive_skb_core+0x1dc/0xa00
    [  405.740194]  ? ixgbe_clean_rx_irq+0x46d/0xa20 [ixgbe]
    [  405.740197]  __netif_receive_skb+0x18/0x60
    [  405.740199]  netif_receive_skb_internal+0x40/0xb0
    [  405.740201]  napi_gro_receive+0xcd/0x120
    [  405.740204]  gro_cell_poll+0x57/0x80 [geneve]
    [  405.740206]  net_rx_action+0x260/0x3c0
    [  405.740209]  __do_softirq+0xc9/0x28c
    [  405.740211]  irq_exit+0xd9/0xf0
    [  405.740213]  do_IRQ+0x51/0xd0
    [  405.740215]  common_interrupt+0x93/0x93

Fixes: 7f8a436eaa2c ("openvswitch: Add conntrack action")
Signed-off-by: Lance Richardson <lrichard@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream: 75f01a4c9cc2 ("openvswitch: maintain correct checksum state in conntrack actions")
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
7 years agodatapath: make ndo_get_stats64 a void function
stephen hemminger [Wed, 1 Mar 2017 01:17:17 +0000 (17:17 -0800)]
datapath: make ndo_get_stats64 a void function

Upstream commit:
    commit bc1f44709cf27fb2a5766cadafe7e2ad5e9cb221
    Author: stephen hemminger <stephen@networkplumber.org>
    Date:   Fri Jan 6 19:12:52 2017 -0800

    net: make ndo_get_stats64 a void function

    The network device operation for reading statistics is only called
    in one place, and it ignores the return value. Having a structure
    return value is potentially confusing because some future driver could
    incorrectly assume that the return value was used.

    Fix all drivers with ndo_get_stats64 to have a void function.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This seems to be fine for all prior Linux versions as well.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agolacp: Fix formatting typo.
nickcooper-zhangtonghao [Thu, 2 Mar 2017 13:02:53 +0000 (05:02 -0800)]
lacp: Fix formatting typo.

Signed-off-by: nickcooper-zhangtonghao <nic@opencloud.tech>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpdk: Improve manpage for dpdk memory configuration.
nickcooper-zhangtonghao [Thu, 2 Mar 2017 13:02:52 +0000 (05:02 -0800)]
dpdk: Improve manpage for dpdk memory configuration.

Signed-off-by: nickcooper-zhangtonghao <nic@opencloud.tech>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodoc: Fix issues.rst formatting typo.
nickcooper-zhangtonghao [Thu, 2 Mar 2017 13:02:51 +0000 (05:02 -0800)]
doc: Fix issues.rst formatting typo.

The preformatted block is only finished when the text
falls back to the same indentation level as a paragraph
prior to the preformatted block.

Signed-off-by: nickcooper-zhangtonghao <nic@opencloud.tech>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agomcast-snooping: Add and improve mcast-snooping tests.
nickcooper-zhangtonghao [Fri, 3 Mar 2017 11:08:47 +0000 (03:08 -0800)]
mcast-snooping: Add and improve mcast-snooping tests.

Signed-off-by: nickcooper-zhangtonghao <nic@opencloud.tech>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agomcast-snooping: Avoid segfault for vswitchd.
nickcooper-zhangtonghao [Fri, 3 Mar 2017 09:37:21 +0000 (01:37 -0800)]
mcast-snooping: Avoid segfault for vswitchd.

The ports which are attached mrouters or hosts, were destroyed
by users via ovs-vsctl commands. Currently the vswitch will
segfault if users use "ovs-appctl mdb/show" to show mdb info.
This patch avoids a segfault.

Signed-off-by: nickcooper-zhangtonghao <nic@opencloud.tech>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agomcast-snooping: Flush ports mdb when VLAN configuration changed.
nickcooper-zhangtonghao [Fri, 3 Mar 2017 09:37:20 +0000 (01:37 -0800)]
mcast-snooping: Flush ports mdb when VLAN configuration changed.

If VLAN configuration(e.g. id, mode) change occurs, the IGMP
snooping-learned multicast groups from this port on the VLAN are
deleted. This avoids a MCAST_ENTRY_DEFAULT_IDLE_TIME delay before
mdb is updated again. Hardware switches (e.g. cisco) also do that.

Signed-off-by: nickcooper-zhangtonghao <nic@opencloud.tech>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodatapath: netns: make struct pernet_operations::id unsigned int.
Alexey Dobriyan [Wed, 1 Mar 2017 01:35:07 +0000 (17:35 -0800)]
datapath: netns: make struct pernet_operations::id unsigned int.

Upstream commit:
    commit c7d03a00b56fc23c3a01a8353789ad257363e281
    Author: Alexey Dobriyan <adobriyan@gmail.com>
    Date:   Thu Nov 17 04:58:21 2016 +0300

    netns: make struct pernet_operations::id unsigned int

    Make struct pernet_operations::id unsigned.

    There are 2 reasons to do so:

    1)
    This field is really an index into an zero based array and
    thus is unsigned entity. Using negative value is out-of-bound
    access by definition.

    2)
    On x86_64 unsigned 32-bit data which are mixed with pointers
    via array indexing or offsets added or subtracted to pointers
    are preffered to signed 32-bit data.

    "int" being used as an array index needs to be sign-extended
    to 64-bit before being used.

            void f(long *p, int i)
            {
                    g(p[i]);
            }

      roughly translates to

            movsx   rsi, esi
            mov     rdi, [rsi+...]
            call    g

    MOVSX is 3 byte instruction which isn't necessary if the variable is
    unsigned because x86_64 is zero extending by default.

    Now, there is net_generic() function which, you guessed it right, uses
    "int" as an array index:

            static inline void *net_generic(const struct net *net, int id)
            {
                    ...
                    ptr = ng->ptr[id - 1];
                    ...
            }

    And this function is used a lot, so those sign extensions add up.

    Patch snipes ~1730 bytes on allyesconfig kernel (without all junk
    messing with code generation):

            add/remove: 0/0 grow/shrink: 70/598 up/down: 396/-2126 (-1730)

    Unfortunately some functions actually grow bigger.
    This is a semmingly random artefact of code generation with register
    allocator being used differently. gcc decides that some variable
    needs to live in new r8+ registers and every access now requires REX
    prefix. Or it is shifted into r12, so [r12+0] addressing mode has to be
    used which is longer than [r8]

    However, overall balance is in negative direction:

            add/remove: 0/0 grow/shrink: 70/598 up/down: 396/-2126 (-1730)
            function                                     old     new   delta
            nfsd4_lock                                  3886    3959     +73
            tipc_link_build_proto_msg                   1096    1140     +44
            mac80211_hwsim_new_radio                    2776    2808     +32
            tipc_mon_rcv                                1032    1058     +26
            svcauth_gss_legacy_init                     1413    1429     +16
            tipc_bcbase_select_primary                   379     392     +13
            nfsd4_exchange_id                           1247    1260     +13
            nfsd4_setclientid_confirm                    782     793     +11
                    ...
            put_client_renew_locked                      494     480     -14
            ip_set_sockfn_get                            730     716     -14
            geneve_sock_add                              829     813     -16
            nfsd4_sequence_done                          721     703     -18
            nlmclnt_lookup_host                          708     686     -22
            nfsd4_lockt                                 1085    1063     -22
            nfs_get_client                              1077    1050     -27
            tcf_bpf_init                                1106    1076     -30
            nfsd4_encode_fattr                          5997    5930     -67
            Total: Before=154856051, After=154854321, chg -0.00%

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[Committer notes]

It looks like changing the type of this doesn't affect the build on older
kernels, so we can just make the change. I didn't go through all of the
compat code to update the net_id variables there as none of that code should
be enabled on kernels with this patch.

Upstream: c7d03a00b56f ("netns: make struct pernet_operations::id unsigned int")
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
7 years agodatapath: allow L3 netdev ports
Yang, Yi Y [Mon, 6 Feb 2017 13:04:42 +0000 (21:04 +0800)]
datapath: allow L3 netdev ports

Upstream commit:
    commit 217ac77a3c2524d999730b2a80b61fcc2d0f734a
    Author: Jiri Benc <jbenc@redhat.com>
    Date:   Thu Nov 10 16:28:24 2016 +0100

    openvswitch: allow L3 netdev ports

    Allow ARPHRD_NONE interfaces to be added to ovs bridge.

    Based on previous versions by Lorand Jakab and Simon Horman.

Signed-off-by: Lorand Jakab <lojakab@cisco.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: add Ethernet push and pop actions
Yang, Yi Y [Mon, 6 Feb 2017 13:04:41 +0000 (21:04 +0800)]
datapath: add Ethernet push and pop actions

Upstream commit:
    commit 91820da6ae85904d95ed53bf3a83f9ec44a6b80a
    Author: Jiri Benc <jbenc@redhat.com>
    Date:   Thu Nov 10 16:28:23 2016 +0100

    openvswitch: add Ethernet push and pop actions

    It's not allowed to push Ethernet header in front of another Ethernet
    header.

    It's not allowed to pop Ethernet header if there's a vlan tag. This
    preserves the invariant that L3 packet never has a vlan tag.

    Based on previous versions by Lorand Jakab and Simon Horman.

Signed-off-by: Lorand Jakab <lojakab@cisco.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
[Committer notes]

Fix build with the upstream commit by folding in the required switch
case enum handlers.

Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: netlink: support L3 packets
Yang, Yi Y [Mon, 6 Feb 2017 13:04:40 +0000 (21:04 +0800)]
datapath: netlink: support L3 packets

Upstream commit:
    commit 0a6410fbde597ebcf82dda4a0b0e889e82242678
    Author: Jiri Benc <jbenc@redhat.com>
    Date:   Thu Nov 10 16:28:22 2016 +0100

    openvswitch: netlink: support L3 packets

    Extend the ovs flow netlink protocol to support L3 packets. Packets without
    OVS_KEY_ATTR_ETHERNET attribute specify L3 packets; for those, the
    OVS_KEY_ATTR_ETHERTYPE attribute is mandatory.

    Push/pop vlan actions are only supported for Ethernet packets.

    Based on previous versions by Lorand Jakab and Simon Horman.

Signed-off-by: Lorand Jakab <lojakab@cisco.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream commit:
    commit 87e159c59d9f325d571689d4027115617adb32e6
    Author: Jarno Rajahalme <jarno@ovn.org>
    Date:   Mon Dec 19 17:06:33 2016 -0800

    openvswitch: Add a missing break statement.

    Add a break statement to prevent fall-through from
    OVS_KEY_ATTR_ETHERNET to OVS_KEY_ATTR_TUNNEL.  Without the break
    actions setting ethernet addresses fail to validate with log messages
    complaining about invalid tunnel attributes.

Fixes: 0a6410fbde ("openvswitch: netlink: support L3 packets")
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream commit:
    commit df30f7408b187929dbde72661c7f7c615268f1d0
    Author: pravin shelar <pshelar@ovn.org>
    Date:   Mon Dec 26 08:31:27 2016 -0800

    openvswitch: upcall: Fix vlan handling.

    Networking stack accelerate vlan tag handling by
    keeping topmost vlan header in skb. This works as
    long as packet remains in OVS datapath. But during
    OVS upcall vlan header is pushed on to the packet.
    When such packet is sent back to OVS datapath, core
    networking stack might not handle it correctly. Following
    patch avoids this issue by accelerating the vlan tag
    during flow key extract. This simplifies datapath by
    bringing uniform packet processing for packets from
    all code paths.

Fixes: 5108bbaddc ("openvswitch: add processing of L3 packets").
CC: Jarno Rajahalme <jarno@ovn.org>
CC: Jiri Benc <jbenc@redhat.com>
Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
[Committer Notes]

Squashed in the following upstream commits to retain bisectability:
87e159c59d9f ("openvswitch: Add a missing break statement.")
df30f7408b18 ("openvswitch: upcall: Fix vlan handling.")

Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: add processing of L3 packets
Yang, Yi Y [Mon, 6 Feb 2017 13:04:39 +0000 (21:04 +0800)]
datapath: add processing of L3 packets

Upstream commit:
    commit 5108bbaddc37c1c8583f0cf2562d7d3463cd12cb
    Author: Jiri Benc <jbenc@redhat.com>
    Date:   Thu Nov 10 16:28:21 2016 +0100

    openvswitch: add processing of L3 packets

    Support receiving, extracting flow key and sending of L3 packets (packets
    without an Ethernet header).

    Note that even after this patch, non-Ethernet interfaces are still not
    allowed to be added to bridges. Similarly, netlink interface for sending and
    receiving L3 packets to/from user space is not in place yet.

    Based on previous versions by Lorand Jakab and Simon Horman.

Signed-off-by: Lorand Jakab <lojakab@cisco.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: support MPLS push and pop for L3 packets
Yang, Yi Y [Mon, 6 Feb 2017 13:04:38 +0000 (21:04 +0800)]
datapath: support MPLS push and pop for L3 packets

Upstream commit:
    commit 1560a074df6297e76278e459ca3eb9ff83a6f878
    Author: Jiri Benc <jbenc@redhat.com>
    Date:   Thu Nov 10 16:28:20 2016 +0100

    openvswitch: support MPLS push and pop for L3 packets

    Update Ethernet header only if there is one.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: pass mac_proto to ovs_vport_send
Yang, Yi Y [Mon, 6 Feb 2017 13:04:37 +0000 (21:04 +0800)]
datapath: pass mac_proto to ovs_vport_send

Upstream commit:
    commit e2d9d8358cb961340ef88620b6a25ba4557033d5
    Author: Jiri Benc <jbenc@redhat.com>
    Date:   Thu Nov 10 16:28:19 2016 +0100

    openvswitch: pass mac_proto to ovs_vport_send

    We'll need it to alter packets sent to ARPHRD_NONE interfaces.

    Change do_output() to use the actual L2 header size of the packet when
    deciding on the minimum cutlen. The assumption here is that what matters is
    not the output interface hard_header_len but rather the L2 header of the
    particular packet. For example, ARPHRD_NONE tunnels that encapsulate
    Ethernet should get at least the Ethernet header.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
[Committer notes]

This is not identical to upstream, because the OVS tree is missing
upstream commit c66549ffd666 ("openvswitch: correctly fragment packet
with mpls headers")

Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: add mac_proto field to the flow key
Yang, Yi Y [Mon, 6 Feb 2017 13:04:36 +0000 (21:04 +0800)]
datapath: add mac_proto field to the flow key

Upstream commit:
    commit 329f45bc4f191c663dc156c510816411a4310578
    Author: Jiri Benc <jbenc@redhat.com>
    Date:   Thu Nov 10 16:28:18 2016 +0100

    openvswitch: add mac_proto field to the flow key

    Use a hole in the structure. We support only Ethernet so far and will add
    a support for L2-less packets shortly. We could use a bool to indicate
    whether the Ethernet header is present or not but the approach with the
    mac_proto field is more generic and occupies the same number of bytes in the
    struct, while allowing later extensibility. It also makes the code in the
    next patches more self explaining.

    It would be nice to use ARPHRD_ constants but those are u16 which would be
    waste. Thus define our own constants.

    Another upside of this is that we can overload this new field to also denote
    whether the flow key is valid. This has the advantage that on
    refragmentation, we don't have to reparse the packet but can rely on the
    stored eth.type. This is especially important for the next patches in this
    series - instead of adding another branch for L2-less packets before calling
    ovs_fragment, we can just remove all those branches completely.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: use hard_header_len instead of hardcoded ETH_HLEN
Yang, Yi Y [Mon, 6 Feb 2017 13:04:35 +0000 (21:04 +0800)]
datapath: use hard_header_len instead of hardcoded ETH_HLEN

Upstream commit:
    commit 738314a084aae5f76ff760279034b39d52c42e8b
    Author: Jiri Benc <jbenc@redhat.com>
    Date:   Thu Nov 10 16:28:17 2016 +0100

    openvswitch: use hard_header_len instead of hardcoded ETH_HLEN

    On tx, use hard_header_len while deciding whether to refragment or drop the
    packet. That way, all combinations are calculated correctly:

    * L2 packet going to L2 interface (the L2 header len is subtracted),
    * L2 packet going to L3 interface (the L2 header is included in the packet
      lenght),
    * L3 packet going to L3 interface.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: handle NF_REPEAT from nf_conntrack_in()
Pablo Neira Ayuso [Thu, 16 Feb 2017 01:34:20 +0000 (17:34 -0800)]
datapath: handle NF_REPEAT from nf_conntrack_in()

Upstream commit:
    commit 08733a0cb7decce40bbbd0331a0449465f13c444
    Author: Pablo Neira Ayuso <pablo@netfilter.org>
    Date:   Thu Nov 3 10:56:43 2016 +0100

    netfilter: handle NF_REPEAT from nf_conntrack_in()

    NF_REPEAT is only needed from nf_conntrack_in() under a very specific
    case required by the TCP protocol tracker, we can handle this case
    without returning to the core hook path. Handling of NF_REPEAT from the
    nf_reinject() is left untouched.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
[Committer notes]
    Shift the functionality into the compat code, protected by v4.10
    version check. This allows the datapath/conntrack.c to match
    upstream.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: use core MTU range checking in core net infra
Jarod Wilson [Thu, 16 Feb 2017 01:34:19 +0000 (17:34 -0800)]
datapath: use core MTU range checking in core net infra

Upstream commit:
    commit 61e84623ace35ce48975e8f90bbbac7557c43d61
    Author: Jarod Wilson <jarod@redhat.com>
    Date:   Fri Oct 7 22:04:33 2016 -0400

    net: centralize net_device min/max MTU checking

    While looking into an MTU issue with sfc, I started noticing that almost
    every NIC driver with an ndo_change_mtu function implemented almost
    exactly the same range checks, and in many cases, that was the only
    practical thing their ndo_change_mtu function was doing. Quite a few
    drivers have either 68, 64, 60 or 46 as their minimum MTU value checked,
    and then various sizes from 1500 to 65535 for their maximum MTU value. We
    can remove a whole lot of redundant code here if we simple store min_mtu
    and max_mtu in net_device, and check against those in net/core/dev.c's
    dev_set_mtu().

    In theory, there should be zero functional change with this patch, it just
    puts the infrastructure in place. Subsequent patches will attempt to start
    using said infrastructure, with theoretically zero change in
    functionality.

CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream commit:
    commit 91572088e3fdbf4fe31cf397926d8b890fdb3237
    Author: Jarod Wilson <jarod@redhat.com>
    Date:   Thu Oct 20 13:55:20 2016 -0400

    net: use core MTU range checking in core net infra

    ...

    openvswitch:
    - set min/max_mtu, remove internal_dev_change_mtu
    - note: max_mtu wasn't checked previously, it's been set to 65535, which
      is the largest possible size supported

    ...

Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Upstream commit:
    commit 425df17ce3a26d98f76e2b6b0af2acf4aeb0b026
    Author: Jarno Rajahalme <jarno@ovn.org>
    Date:   Tue Feb 14 21:16:28 2017 -0800

    openvswitch: Set internal device max mtu to ETH_MAX_MTU.

    Commit 91572088e3fd ("net: use core MTU range checking in core net
    infra") changed the openvswitch internal device to use the core net
    infra for controlling the MTU range, but failed to actually set the
    max_mtu as described in the commit message, which now defaults to
    ETH_DATA_LEN.

    This patch fixes this by setting max_mtu to ETH_MAX_MTU after
    ether_setup() call.

Fixes: 91572088e3fd ("net: use core MTU range checking in core net infra")
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This backport detects the new max_mtu field in the struct netdevice
and uses the upstream code if it exists, and local backport code if
not.  The latter case is amended with bounds checks with new upstream
macros ETH_MIN_MTU and ETH_MAX_MTU and the corresponding error
messages from the upstream commit.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: remove unnecessary EXPORT_SYMBOLs
Jiri Benc [Thu, 16 Feb 2017 01:34:18 +0000 (17:34 -0800)]
datapath: remove unnecessary EXPORT_SYMBOLs

Upstream commit:
    commit 76e4cc7731a1e0c07e202999b9834f9d9be66de4
    Author: Jiri Benc <jbenc@redhat.com>
    Date:   Wed Oct 19 11:26:37 2016 +0200

    openvswitch: remove unnecessary EXPORT_SYMBOLs

    Some symbols exported to other modules are really used only by
    openvswitch.ko. Remove the exports.

    Tested by loading all 4 openvswitch modules, nothing breaks.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: remove unused functions
Jiri Benc [Thu, 16 Feb 2017 01:34:17 +0000 (17:34 -0800)]
datapath: remove unused functions

Upstream commit:
    commit f33eb0cf9984f79e8643eaac888e4b6a06a8e221
    Author: Jiri Benc <jbenc@redhat.com>
    Date:   Wed Oct 19 11:26:36 2016 +0200

    openvswitch: remove unused functions

    ovs_vport_deferred_free is not used anywhere. It's the only caller of
    free_vport_rcu thus this one can be removed, too.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: add NETIF_F_HW_VLAN_STAG_TX to internal dev.
Jiri Benc [Mon, 10 Oct 2016 15:02:44 +0000 (17:02 +0200)]
datapath: add NETIF_F_HW_VLAN_STAG_TX to internal dev.

Upstream commit:
    commit 3145c037e74926dea9241a3f68ada6f294b0119a
    Author: Jiri Benc <jbenc@redhat.com>
    Date:   Mon Oct 10 17:02:44 2016 +0200

    openvswitch: add NETIF_F_HW_VLAN_STAG_TX to internal dev

    The internal device does support 802.1AD offloading since 018c1dda5ff1
    ("openvswitch: 802.1AD Flow handling, actions, vlan parsing, netlink
    attributes").

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Eric Garver <e@erig.me>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream: 3145c037e749 ("openvswitch: add NETIF_F_HW_VLAN_STAG_TX to internal dev")
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
7 years agodatapath: avoid resetting flow key while installing new flow.
pravin shelar [Thu, 16 Feb 2017 01:34:16 +0000 (17:34 -0800)]
datapath: avoid resetting flow key while installing new flow.

Upstream commit:
    commit 2279994d07ab67ff7a1d09bfbd65588332dfb6d8
    Author: pravin shelar <pshelar@ovn.org>
    Date:   Mon Sep 19 13:51:00 2016 -0700

    openvswitch: avoid resetting flow key while installing new flow.

    since commit commit db74a3335e0f6 ("openvswitch: use percpu
    flow stats") flow alloc resets flow-key. So there is no need
    to reset the flow-key again if OVS is using newly allocated
    flow-key.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: Fix Frame-size larger than 1024 bytes warning.
pravin shelar [Thu, 16 Feb 2017 01:34:15 +0000 (17:34 -0800)]
datapath: Fix Frame-size larger than 1024 bytes warning.

Upstream commit:
    commit 190aa3e77880a05332ea1ccb382a51285d57adb5
    Author: pravin shelar <pshelar@ovn.org>
    Date:   Mon Sep 19 13:50:59 2016 -0700

    openvswitch: Fix Frame-size larger than 1024 bytes warning.

    There is no need to declare separate key on stack,
    we can just use sw_flow->key to store the key directly.

    This commit fixes following warning:

    net/openvswitch/datapath.c: In function ‘ovs_flow_cmd_new’:
    net/openvswitch/datapath.c:1080:1: warning: the frame size of 1040 bytes
    is larger than 1024 bytes [-Wframe-larger-than=]

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: use percpu flow stats
Thadeu Lima de Souza Cascardo [Thu, 16 Feb 2017 01:34:14 +0000 (17:34 -0800)]
datapath: use percpu flow stats

Upstream commit:
    commit db74a3335e0f645e3139c80bcfc90feb01d8e304
    Author: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
    Date:   Thu Sep 15 19:11:53 2016 -0300

    openvswitch: use percpu flow stats

    Instead of using flow stats per NUMA node, use it per CPU. When using
    megaflows, the stats lock can be a bottleneck in scalability.

    On a E5-2690 12-core system, usual throughput went from ~4Mpps to
    ~15Mpps when forwarding between two 40GbE ports with a single flow
    configured on the datapath.

    This has been tested on a system with possible CPUs 0-7,16-23. After
    module removal, there were no corruption on the slab cache.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Cc: pravin shelar <pshelar@ovn.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: fix flow stats accounting when node 0 is not possible
Thadeu Lima de Souza Cascardo [Thu, 16 Feb 2017 01:34:13 +0000 (17:34 -0800)]
datapath: fix flow stats accounting when node 0 is not possible

Upstream commit:
    commit 40773966ccf1985a1b2bb570a03cbeaf1cbd4e00
    Author: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
    Date:   Thu Sep 15 19:11:52 2016 -0300

    openvswitch: fix flow stats accounting when node 0 is not possible

    On a system with only node 1 as possible, all statistics is going to be
    accounted on node 0 as it will have a single writer.

    However, when getting and clearing the statistics, node 0 is not going
    to be considered, as it's not a possible node.

    Tested that statistics are not zero on a system with only node 1
    possible. Also compile-tested with CONFIG_NUMA off.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This patch contained a memory leak that is fixed in this backport.
The next patch silently fixed that in upstream, too.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: 802.1AD Flow handling, actions, vlan parsing, netlink attributes
Yang, Yi Y [Mon, 13 Feb 2017 02:39:15 +0000 (10:39 +0800)]
datapath: 802.1AD Flow handling, actions, vlan parsing, netlink attributes

Upstream commit:
    commit 018c1dda5ff1e7bd1fe2d9fd1d0f5b82dc6fc0cd
    Author: Eric Garver <e@erig.me>
    Date:   Wed Sep 7 12:56:59 2016 -0400

    openvswitch: 802.1AD Flow handling, actions, vlan parsing, netlink attributes

    Add support for 802.1ad including the ability to push and pop double
    tagged vlans. Add support for 802.1ad to netlink parsing and flow
    conversion. Uses double nested encap attributes to represent double
    tagged vlan. Inner TPID encoded along with ctci in nested attributes.

    This is based on Thomas F Herbert's original v20 patch. I made some
    small clean ups and bug fixes.

Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com>
Signed-off-by: Eric Garver <e@erig.me>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream commit:
    commit 20ecf1e4e30005ad50f561a92c888b6477f99341
    Author: Jiri Benc <jbenc@redhat.com>
    Date:   Mon Oct 10 17:02:42 2016 +0200

    openvswitch: vlan: remove wrong likely statement

    This code is called whenever flow key is being extracted from the packet.
    The packet may be as likely vlan tagged as not.

Fixes: 018c1dda5ff1 ("openvswitch: 802.1AD Flow handling, actions, vlan parsing, netlink attributes")
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Eric Garver <e@erig.me>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream commit:
    commit 72ec108d701506fa6cd2f66ec5b15ea71df3c464
    Author: Jiri Benc <jbenc@redhat.com>
    Date:   Mon Oct 10 17:02:43 2016 +0200

    openvswitch: fix vlan subtraction from packet length

    When the packet has its vlan tag in skb->vlan_tci, the length of the VLAN
    header is not counted in skb->len. It doesn't make sense to subtract it.

Fixes: 018c1dda5ff1 ("openvswitch: 802.1AD Flow handling, actions, vlan parsing, netlink attributes")
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Eric Garver <e@erig.me>
Signed-off-by: David S. Miller <davem@davemloft.net>
[Committer notes]

The following commits upstream fix bugs in this patch, so to retain
bisectability of the OVS tree they were rolled into this commit:

20ecf1e4e300 openvswitch: vlan: remove wrong likely statement
72ec108d7015 openvswitch: fix vlan subtraction from packet length

Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Acked-by: Eric Garver <e@erig.me>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: backport: vlan: Check for vlan ethernet types for 8021.q or 802.1ad
Yang, Yi Y [Mon, 13 Feb 2017 02:39:14 +0000 (10:39 +0800)]
datapath: backport: vlan: Check for vlan ethernet types for 8021.q or 802.1ad

Upstream commit:
    commit fe19c4f971a55cea3be442d8032a5f6021702791
    Author: Eric Garver <e@erig.me>
    Date:   Wed Sep 7 12:56:58 2016 -0400

    This is to simplify using double tagged vlans. This function allows all
    valid vlan ethertypes to be checked in a single function call.
    Also replace some instances that check for both ETH_P_8021Q and
    ETH_P_8021AD.

    Patch based on one originally by Thomas F Herbert.

Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com>
Signed-off-by: Eric Garver <e@erig.me>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Acked-by: Eric Garver <e@erig.me>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: backport: openvswitch: 802.1ad uapi changes.
Yang, Yi Y [Mon, 13 Feb 2017 02:39:13 +0000 (10:39 +0800)]
datapath: backport: openvswitch: 802.1ad uapi changes.

Upstream commit:
    commit 8c146bb9d59aa2ac45222171916ece186c4b3943
    Author: Thomas F Herbert <thomasfherbert@gmail.com>
    Date:   Wed Sep 7 12:56:57 2016 -0400

    openvswitch: Add support for 8021.AD

    Change the description of the VLAN tpid field.

Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Acked-by: Eric Garver <e@erig.me>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: backport: vlan: Introduce helper functions to check if skb is tagged
Yang, Yi Y [Mon, 13 Feb 2017 02:39:12 +0000 (10:39 +0800)]
datapath: backport: vlan: Introduce helper functions to check if skb is tagged

Upstream commit:
    commit f5a7fb88e1f82542ca14ba93a1d4fa35471c60ca
    Author: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
    Date:   Fri Mar 27 14:31:11 2015 +0900

    vlan: Introduce helper functions to check if skb is tagged

    Separate the two checks for single vlan and multiple vlans in
    netif_skb_features().  This allows us to move the check for multiple
    vlans to another function later.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Acked-by: Eric Garver <e@erig.me>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodatapath: backport: Fix vlan_insert_tag_set_proto().
Yang, Yi Y [Mon, 13 Feb 2017 02:39:16 +0000 (10:39 +0800)]
datapath: backport: Fix vlan_insert_tag_set_proto().

Fix cvlan test failure on old kernel versions with 802.1ad. The root
cause is the upcall re-inserts the VLAN back into the raw packet data,
but the TPID is hard coded to 0x8100. This affects kernels for which
HAVE_VLAN_INSERT_TAG_SET_PROTO is not set.

The below patch allows the cvlan and 802.ad tests to pass on debian
with 3.16 kernel.

Signed-off-by: Eric Garver <e@erig.me>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Acked-by: Eric Garver <e@erig.me>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agoFAQ: Update kernel support info.
Jarno Rajahalme [Tue, 28 Feb 2017 01:44:52 +0000 (17:44 -0800)]
FAQ: Update kernel support info.

OVS 2.7 works with Linux kernels 3.10-4.9.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
7 years agorhel-systemd: Document systemd behavior
Eelco Chaudron [Wed, 8 Feb 2017 16:28:22 +0000 (17:28 +0100)]
rhel-systemd: Document systemd behavior

This is a follow up patch to document the systemd behavior including
the change introduced by the "rhel-systemd: Restart openvswitch
service if a daemon crashes", still under review.

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Russell Bryant <russell@ovn.org>
7 years agorhel-systemd: Restart openvswitch service if a daemon crashes
Eelco Chaudron [Mon, 27 Feb 2017 20:56:41 +0000 (15:56 -0500)]
rhel-systemd: Restart openvswitch service if a daemon crashes

Currently if either ovsdb-server or ovs-vswitchd is crashing the
daemon is not restarting leaving the system in faulty state.
This patch will detect the daemon crash and will restart the
openvswitch service.

Here is a (bit to wide) table showing the behavior before and after
the patch. Note that only the Crash behavior has changed:

Before patch:
                               |       Process Status        |             systemctl <> status            |
                               | ovs-vswitchd | ovsdb-server | openvswitch  | ovs-vswitchd | ovsdb-server |
                               +--------------+--------------+--------------+--------------+--------------+
systemctl start openvswitch*   | started      | started      |active,exited |active,running|active,running|
Crash vswitchd                 | crashed      | stopped      |inactive, dead|failed        |inactive,dead |
Crash ovsdb                    | stopped      | crashed      |inactive, dead|inactive,dead |failed        |
systemctl restart openvswitch  | re-started   | re-started   |active,exited |active,running|active,running|
systemctl restart ovs-vswitchd | re-started   | re-started   |active,exited |active,running|active,running|
systemctl restart ovsdb-server | re-started   | re-started   |active,exited |active,running|active,running|
systemctl stop openvswitch     | stopped      | stopped      |inactive, dead|inactive,dead |inactive,dead |
systemctl stop ovs-vswitchd    | stopped      | stopped      |inactive, dead|inactive,dead |inactive,dead |
systemctl stop ovsdb-server    | stopped      | stopped      |inactive, dead|inactive,dead |inactive,dead |
systemctl start ovs-vswitchd*  | started      | started      |inactive, dead|active,running|active,running|
systemctl start ovsdb-server*  | not started  | started      |inactive, dead|inactive, dead|active,running|

With patch:
                               |       Process Status        |             systemctk <> status            |
                               | ovs-vswitchd | ovsdb-server | openvswitch  | ovs-vswitchd | ovsdb-server |
                               +--------------+--------------+--------------+--------------+--------------+
systemctl start openvswitch*   | started      | started      |active,exited |active,running|active,running|
Crash vswitchd                 | crash,started| re-started   |active,exited |active,running|active,running|
Crash ovsdb                    | re-started   | crash,started|active,exited |active,running|active,running|
systemctl restart openvswitch  | re-started   | re-started   |active,exited |active,running|active,running|
systemctl restart ovs-vswitchd | re-started   | re-started   |active,exited |active,running|active,running|
systemctl restart ovsdb-server | re-started   | re-started   |active,exited |active,running|active,running|
systemctl stop openvswitch     | stopped      | stopped      |inactive, dead|inactive,dead |inactive,dead |
systemctl stop ovs-vswitchd    | stopped      | stopped      |inactive, dead|inactive,dead |inactive,dead |
systemctl stop ovsdb-server    | stopped      | stopped      |inactive, dead|inactive,dead |inactive,dead |
systemctl start ovs-vswitchd*  | started      | started      |inactive, dead|active,running|active,running|
systemctl start ovsdb-server*  | not started  | started      |inactive, dead|inactive, dead|active,running|

* These commands where executed when no ovs related processes where
  running. All other commands where executed when OVS was successfully
  running.

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Acked-by: Markos Chandras <mchandras@suse.de>
Acked-by: Aaron Conole <aconole@redhat.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Russell Bryant <russell@ovn.org>
7 years agomsi: add ovs-vswitchd trigger info
Alin Serdean [Tue, 21 Feb 2017 21:50:53 +0000 (21:50 +0000)]
msi: add ovs-vswitchd trigger info

This patch changes the service ovs-vswitchd from "auto" execution to
"demand" start.

This patch also introduces a custom action for the ovs-vswitchd service
in which the following command will be executed before the service startup:

sc triggerinfo ovs-vswitchd \
start/strcustom/6066F867-7CA1-4418-85FD-36E3F9C0600C/VmmsWmiEventProvider

The above command is a service trigger available since Windows 7.
More on the topic:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd405513%28v=vs.85%29.aspx

In out case we will wait until Microsoft-Windows-Hyper-V-VMMS has triggered
that the WMI provider: VmmsWmiEventProvider has started.

The change is needed because the network service inside VMMS starts slower than
ovs-vswitchd, which will cause a race condition because we check if the OVS
extension is enabled on a single switch.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
7 years agoovs-ctl: allow passing user:group to daemons
Aaron Conole [Tue, 21 Feb 2017 22:31:05 +0000 (17:31 -0500)]
ovs-ctl: allow passing user:group to daemons

The Open vSwitch daemons allow passing --user user[:group] to allow
spawning under different user privileges.  ovs-ctl now accepts --ovs-user
in the same form to pass this argument on, as well as create databases and
data directories with the appropriate privileges.

Signed-off-by: Aaron Conole <aconole@redhat.com>
Reviewed-by: Markos Chandras <mchandras@suse.de>
Signed-off-by: Andy Zhou <azhou@ovn.org>
7 years agoofproto/bond: fix interal flow leak of tcp-balance bond
Huanle Han [Sun, 19 Feb 2017 10:41:27 +0000 (18:41 +0800)]
ofproto/bond: fix interal flow leak of tcp-balance bond

ofproto_dpif_delete_internal_flow() never deletes any flows
because out_port and out_group mismatch.

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
Signed-off-by: Andy Zhou <azhou@ovn.org>
7 years agoofproto/bond: Fix bond post recirc rule leak.
Andy Zhou [Thu, 23 Feb 2017 08:38:16 +0000 (00:38 -0800)]
ofproto/bond: Fix bond post recirc rule leak.

When bond is removed or when its configuration changes,
the post recirculation rules that are installed by current
bond configuration, if any, should be also be removed.

Reported-by: Huanle Han <hanxueluo@gmail.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2017-February/328969.html
CC: Huanle Han <hanxueluo@gmail.com>
Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Huanle Han <hanxueluo@gmail.com>
7 years agoofproto/bond: Fix bond reconfiguration race condition.
Andy Zhou [Thu, 23 Feb 2017 07:31:31 +0000 (23:31 -0800)]
ofproto/bond: Fix bond reconfiguration race condition.

During the upcall thread bond output translation, bond_may_recirc()
is currently called outside the lock. In case the main thread executes
bond_reconfigure() at the same time, the upcall thread may find bond
state to be inconsistent when calling bond_update_post_recirc_rules().

This patch fixes the race condition by acquiring the write lock
before calling bond_may_recirc(). The APIs are refactored slightly.

The race condition can result in the following stack trace. Copied
from 'Reported-at':

    Thread 23 handler69:
    Invalid write of size 8
        update_recirc_rules (bond.c:385)
        bond_update_post_recirc_rules__ (bond.c:952)
        bond_update_post_recirc_rules (bond.c:960)
        output_normal (ofproto-dpif-xlate.c:2102)
        xlate_normal (ofproto-dpif-xlate.c:2858)
        xlate_output_action (ofproto-dpif-xlate.c:4407)
        do_xlate_actions (ofproto-dpif-xlate.c:5335)
        xlate_actions (ofproto-dpif-xlate.c:6198)
        upcall_xlate (ofproto-dpif-upcall.c:1129)
        process_upcall (ofproto-dpif-upcall.c:1271)
        recv_upcalls (ofproto-dpif-upcall.c:822)
        udpif_upcall_handler (ofproto-dpif-upcall.c:740)
    Address 0x18630490 is 1,904 bytes inside a block of size 12,288 free'd
        free (vg_replace_malloc.c:529)
        bond_entry_reset (bond.c:1635)
        bond_reconfigure (bond.c:457)
        bundle_set (ofproto-dpif.c:2896)
        ofproto_bundle_register (ofproto.c:1343)
        port_configure (bridge.c:1159)
        bridge_reconfigure (bridge.c:785)
        bridge_run (bridge.c:3099)
        main (ovs-vswitchd.c:111)
    Block was alloc'd at
        malloc (vg_replace_malloc.c:298)
        xmalloc (util.c:110)
        bond_entry_reset (bond.c:1629)
        bond_reconfigure (bond.c:457)
        bond_create (bond.c:245)
        bundle_set (ofproto-dpif.c:2900)
        ofproto_bundle_register (ofproto.c:1343)
        port_configure (bridge.c:1159)
        bridge_reconfigure (bridge.c:785)
        bridge_run (bridge.c:3099)
        main (ovs-vswitchd.c:111)

Reported-by: Huanle Han <hanxueluo@gmail.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2017-February/328969.html
CC: Huanle Han <hanxueluo@gmail.com>
Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Huanle Han <hanxueluo@gmail.com>
7 years agoovs-appctl: Document -T and --timeout options.
Ben Pfaff [Thu, 23 Feb 2017 20:40:01 +0000 (12:40 -0800)]
ovs-appctl: Document -T and --timeout options.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
7 years agorhel: Add hostname as dependency
Jakub Libosvar [Thu, 9 Feb 2017 11:11:28 +0000 (12:11 +0100)]
rhel: Add hostname as dependency

ovs-ctl script uses hostname. This patch adds dependency for
rhel systems.

Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
7 years agofedora: Add python3-openvswitch split package
Timothy Redaelli [Tue, 21 Feb 2017 15:29:51 +0000 (16:29 +0100)]
fedora: Add python3-openvswitch split package

Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1412694
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Russell Bryant <russell@ovn.org>
7 years agoofproto: Remove 'ofproto/self-check' from ovs-vswitchd manpage
Timothy Redaelli [Tue, 21 Feb 2017 11:13:42 +0000 (12:13 +0100)]
ofproto: Remove 'ofproto/self-check' from ovs-vswitchd manpage

ofproto/self-check was removed in commit e79a6c83, so this patch
removes the man page item.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodocs: fix typo in testing.rst
Lance Richardson [Mon, 20 Feb 2017 18:12:30 +0000 (13:12 -0500)]
docs: fix typo in testing.rst

Coverage section refers to "check-lcoc" target, should be
"check-lcov".

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agoMakefile.am: Suppress echoing of config-h-check.
Timothy Redaelli [Wed, 22 Feb 2017 16:18:28 +0000 (17:18 +0100)]
Makefile.am: Suppress echoing of config-h-check.

Fixes: c458e4a372d1 ("Makefile.am: Avoid include/ depending on lib/.")
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agoovn pacemaker: Pass --db-(n/s)b-addr option when starting ovsdb-servers
Numan Siddique [Wed, 22 Feb 2017 14:58:36 +0000 (20:28 +0530)]
ovn pacemaker: Pass --db-(n/s)b-addr option when starting ovsdb-servers

When pacemaker script, starts the ovsdb-servers in all the nodes,
it doesn't pass the --db-(n/s)b-addr=MASTER_IP option.
When pacemaker promotes a master, it won't be listening on the
master ip address unless "ovn-nbctl set-connection" is used.

In this patch this option, along with --db-(n/s)b-create-insecure-remote=yes
for "tcp" connection types is passed when starting the OVN ovsdb-servers
to overcome this issue.

Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Andy Zhou <azhou@ovn.org>
7 years agowindows: Broken internal netdevs
Alin Serdean [Fri, 17 Feb 2017 11:10:27 +0000 (11:10 +0000)]
windows: Broken internal netdevs

Commit fa07525f9cf3fa698ebc23ea09da477d3d881a87 fixed error logging for
for regular netdevs, however it overlooked "internal" netdevs.

This patch allows "internal" netdev objects to be created and passed to
dpif_port_add().

Reported-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Nithin Raju <Nithin@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
7 years agodoc: Describe backporting process.
Joe Stringer [Fri, 10 Feb 2017 23:01:11 +0000 (15:01 -0800)]
doc: Describe backporting process.

This patch documents the backporting process, and provides a walkthrough
for developers who would like to backport upstream Linux patches into
the Open vSwitch tree. Nothing in this documentation should be
surprising or new; it merely puts the existing process into words.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Stephen Finucane <stephen@that.guru>
7 years agoMakefile.am: Avoid include/ depending on lib/.
Yi-Hung Wei [Sat, 18 Feb 2017 01:47:45 +0000 (17:47 -0800)]
Makefile.am: Avoid include/ depending on lib/.

Add a build check that public openvswitch header file should not include
internal library.

Suggested-by: Joe Stringer <joe@ovn.org>
Suggested-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agometa-flow: Remove cmap dependency.
Yi-Hung Wei [Sat, 18 Feb 2017 01:47:44 +0000 (17:47 -0800)]
meta-flow: Remove cmap dependency.

Previous patch 04f48a68 ("ofp-actions: Fix variable length meta-flow OXMs.")
introduced dependency of an internal library (cmap.h) to ovs public
interface (meta-flow.h) that may cause potential building problem. In this
patch, we remove cmap from struct mf_field, and provide a wrapper struct
vl_mff_map that resolve the dependency problem.

Fixes: 04f48a68c428 ("ofp-actions: Fix variable length meta-flow OXMs.")
Suggested-by: Joe Stringer <joe@ovn.org>
Suggested-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Joe Stringer <joe@ovn.org>