cascardo/ovs.git
8 years agodatapath-windows: Move UDP checksum computation to Offload.c
Yin Lin [Tue, 24 May 2016 23:28:03 +0000 (23:28 +0000)]
datapath-windows: Move UDP checksum computation to Offload.c

UDP checksum computation is shared by both vxlan and geneve on Windows.
Move the function so that the code can be shared.

Signed-off-by: Yin Lin <linyi@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoacinclude: fix issue when configuring with --with-dpdk
Mauricio Vasquez B [Wed, 1 Jun 2016 16:48:07 +0000 (18:48 +0200)]
acinclude: fix issue when configuring with --with-dpdk

when an empty path is given to the --with-dpdk option
(--with-dpdk="" or --width-dpdk=$NON_SET_ENV_VARIABLE) the configure
script does not show any error and configures OvS without DPDK support,
this can create some confusion.

This patch modifies that behavior showing an explicity error in that case.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovs-vtep: Make compatible with python2.7 and 3.
Joe Stringer [Tue, 24 May 2016 01:11:03 +0000 (18:11 -0700)]
ovs-vtep: Make compatible with python2.7 and 3.

Translate commandline calls to UTF-8, appease flake8 and use six's
integer types. This allows the testsuite to pass when using python3 as
your default system python version.

Signed-off-by: Joe Stringer <joe@ovn.org>
Tested-by: Darrell Ball <dlu998@gmail.com>
8 years agolist.h: Define OVS_LIST_POISON statically
Nithin Raju [Fri, 27 May 2016 17:54:58 +0000 (10:54 -0700)]
list.h: Define OVS_LIST_POISON statically

Looks like part of the patch committed in e32c1f7c
got left out while moving header files.

Fixes: e32c1f7c0d65 ("list.h: Define OVS_LIST_POISON statically")
Signed-off-by: Nithin Raju <nithin@vmware.com>
Reported-by: Joe Stringer <joe@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoxlate: Skip recirculation for output and set actions
Simon Horman [Wed, 25 May 2016 01:34:31 +0000 (10:34 +0900)]
xlate: Skip recirculation for output and set actions

Until 8bf009bf8ab4 ("xlate: Always recirculate after an MPLS POP to a
non-MPLS ethertype.") the translation code took some care to only
recirculate as a result of a pop_mpls action if necessary. This was
implemented using per-action checks and resulted in some maintenance
burden.

Unfortunately recirculation is a relatively expensive operation and a
performance degradation of up to 35% has been observed with the above
mentioned patch applied for the arguably common case of:

pop_mpls,set(l2 field),output

This patch attempts to strike a balance between performance and
maintainability by special casing set and output actions such
that recirculation may be avoided.

This partially reverts the above mentioned commit. In particular most
of the C code outside of do_xlate_actions().

Signed-off-by: Simon Horman <simon.horman@netronome.com>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agotests: bfd.at: Fix bridge name in comment
Markos Chandras [Thu, 26 May 2016 15:23:02 +0000 (16:23 +0100)]
tests: bfd.at: Fix bridge name in comment

The bridge sitting between 'br-bfd0' and 'br-bfd1' is called 'br-sw'
instead of 'br2' and the patch ports are 'p0-sw' and 'p1-sw' instead
of 'p0-2' and 'p1-2' respectively so fix the comment.

Signed-off-by: Markos Chandras <mchandras@suse.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoutil: Drop 'date' and 'time' arguments from ovs_set_program_name
Markos Chandras [Thu, 26 May 2016 09:02:54 +0000 (10:02 +0100)]
util: Drop 'date' and 'time' arguments from ovs_set_program_name

The 'date' and 'time' arguments are normally being set by
'ovs_set_program_name' using __DATE__ and __TIME__. However, this
breaks reproducible builds since even without any changes in the
toolchain, build system etc, the end binary will still differ in
that regard. This is also visible when building with -Wdate-time:

utilities/ovs-dpctl.c:61:29: warning: macro "__DATE__" might prevent
reproducible builds [-Wdate-time]
     set_program_name(argv[0]);
                             ^

and it's also something that triggers the following warning in the
openSUSE OBS builds:

[...]
openvswitch.x86_64: W: file-contains-date-and-time /usr/bin/ovs-ofctl
openvswitch.x86_64: W: file-contains-date-and-time /usr/bin/ovs-appctl
Your file uses  __DATE and __TIME__ this causes the package to rebuild
when not needed
[...]

This patch drops these two arguments from ovs_set_program_name__ and
renames the function to ovs_set_program_name dropping the previous
preprocessor macro in the process.

This finally removes the remaining references to __DATE__ and __TIME__
from the sources which is something that has already been done in
commit 26bfaeaa9687 ("Stop using __DATE__ and __TIME__ in startup
string.") for the kernel datapath.

Cc: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Markos Chandras <mchandras@suse.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agovagrant: Enable silent-rules for configure.
Joe Stringer [Fri, 20 May 2016 18:49:59 +0000 (11:49 -0700)]
vagrant: Enable silent-rules for configure.

In the majority of cases, developers debugging their code using vagrant
will be more interested in compiler errors/warnings than the exact
invocation of the compiler. By enabling silent-rules, the verbosity of
compilation is lowered and it is easier to identify these pieces of
information.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
8 years agovagrant: Update default box to Fedora-23.
Joe Stringer [Thu, 26 May 2016 00:17:37 +0000 (17:17 -0700)]
vagrant: Update default box to Fedora-23.

This brings a newer kernel (4.2) and newer iproute2, allowing more of
the tests to run by default.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
8 years agovagrant: Update dependencies.
Joe Stringer [Fri, 20 May 2016 18:49:55 +0000 (11:49 -0700)]
vagrant: Update dependencies.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
8 years agotests: Eliminate some intermittent failures due to races.
Jarno Rajahalme [Wed, 25 May 2016 23:43:42 +0000 (16:43 -0700)]
tests: Eliminate some intermittent failures due to races.

Wait until a megaflow is set up before sending more packets to have
deterministic stats for the megaflows.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoofproto: update mtu when port is getting removed as well
ak47izatool@gmail.com [Wed, 25 May 2016 15:03:43 +0000 (21:03 +0600)]
ofproto: update mtu when port is getting removed as well

When we're adding the port into ovs bridge, its mtu is updated to the minimal
mtu of the included port. But when the port is getting removed, no such update
is performed, which leads to bug. For example, when the port with minimal mtu
is removed, bridge's mtu must adapt to new value, but it won't happen.
How to reproduce the problem:

$ ovs-vsctl add-br testing
$ ip link add name gretap11 type gretap local 10.0.0.1 remote 10.0.0.100
$ ip link add name gretap12 type gretap local 10.0.0.1 remote 10.0.0.200
$ ip link set dev gretap12 mtu 1600
$ ovs-vsctl add-port testing gretap11
$ ovs-vsctl add-port testing gretap12
$ ip a sh testing
16: testing: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN
group default qlen 1
    link/ether 7a:42:95:00:96:40 brd ff:ff:ff:ff:ff:ff

$ ovs-vsctl del-port gretap11
$ ip a sh testing
16: testing: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN
group default qlen 1
    link/ether 7a:42:95:00:96:40 brd ff:ff:ff:ff:ff:ff

$## as we can see here, 'testing' bridge mtu is stuck, while it must
adapt to new '1600' value,
$## cause there is only one port 'gretap12' left, and it's mtu is '1600':

$ ip a sh gretap12
19: gretap12@NONE: <BROADCAST,MULTICAST> mtu 1600 qdisc noop master
ovs-system state DOWN group default qlen 1000
    link/ether b2:c6:1d:9f:be:0d brd ff:ff:ff:ff:ff:ff

My commit fixes this problem - mtu update is performed on port removal as well.

Signed-off-by: wisd0me <ak47izatool@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
8 years agodatapath-windows: o/p buffer must fit NL error message
Nithin Raju [Thu, 19 May 2016 22:31:49 +0000 (15:31 -0700)]
datapath-windows: o/p buffer must fit NL error message

OVS_IOCTL_WRITE and OVS_IOCTL_TRANSACT can generate a
netlink error that is represented by a OVS_MESSAGE_ERROR
struct. We want to make sure at the entry point of the
ioctl processing that the output buffer is big enough
to hold the error message. We were earlier checking
for struct OVS_MESSAGE which is smaller.

Since we are ensuring that output buffer can fit
OVS_MESSAGE_ERROR at the top of the ioctl function,
there's no need to check for that later.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
8 years agodatapath-windows: don't map output buffer in OVS_IOCTL_WRITE
Nithin Raju [Thu, 19 May 2016 22:31:48 +0000 (15:31 -0700)]
datapath-windows: don't map output buffer in OVS_IOCTL_WRITE

The contract of OVS_IOCTL_WRITE is that write operations
will not need the output buffer. Only the input buffer
will be used in the IRP. So, better to not map the output
buffer at all.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
8 years agodatapath-windows: remove extract flow in OvsDoRecirc()
Nithin Raju [Tue, 17 May 2016 17:15:22 +0000 (10:15 -0700)]
datapath-windows: remove extract flow in OvsDoRecirc()

It is not necessary to do a flow extract in OvsDoRecirc().
In fact, doing it would overwrite the tunnel key within
'key'. So, let's remove the call.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Sairam Venugopal <vsairam@vmware.com>
Co-Authored-by: Sairam Venugopal <vsairam@vmware.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Acked-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
8 years agodatapath-windows: Use l2 port and tunkey during execute
Nithin Raju [Tue, 17 May 2016 17:15:21 +0000 (10:15 -0700)]
datapath-windows: Use l2 port and tunkey during execute

While testing DFW and recirc code it was found that userspace
was calling into packet execute with the tunnel key and the
vport added as part of the execute structure. We were not passing
this along to the code that executes actions. The right thing is
to contruct the key based on all of the attributes sent down from
userspace.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
8 years agodatapath-windows: Make _MapTunAttrToFlowPut() global
Nithin Raju [Tue, 17 May 2016 17:15:20 +0000 (10:15 -0700)]
datapath-windows: Make _MapTunAttrToFlowPut() global

Move this function out from file scope.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
8 years agodatapath-windows: add nlMsgHdr to OvsPacketExecute
Nithin Raju [Tue, 17 May 2016 17:15:19 +0000 (10:15 -0700)]
datapath-windows: add nlMsgHdr to OvsPacketExecute

We'll need this for parsing nested attributes.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
8 years agonetdev-dpdk.c: Add ingress-policing functionality.
Ian Stokes [Tue, 24 May 2016 16:36:51 +0000 (17:36 +0100)]
netdev-dpdk.c: Add ingress-policing functionality.

This patch provides the modifications required in netdev-dpdk.c and
vswitch.xml to enable ingress policing for DPDK interfaces.

This patch implements the necessary netdev functions to netdev-dpdk.c as
well as various helper functions required for ingress policing.

The vswitch.xml has been modified to explain the expected parameters and
behaviour when using ingress policing.

The INSTALL.DPDK.md guide has been modified to provide an example
configuration of ingress policing.

Signed-off-by: Ian Stokes <ian.stokes@intel.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
8 years agonetdev-dpdk.c: Add generic policer functions.
Ian Stokes [Tue, 24 May 2016 16:36:50 +0000 (17:36 +0100)]
netdev-dpdk.c: Add generic policer functions.

Add generic policer functions to avoid code duplication.

Policing can be implemented on both egress and ingress paths.
Currently the QoS egress-policer implementation uses it's own specific run
and packet handle policer functions. This patch makes the policer functions
generic so that they can be used regardless of whether the policer is egress
or ingress by just requiring a pointer to the rte_meter used for policing
to be passed.

Signed-off-by: Ian Stokes <ian.stokes@intel.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
8 years agoofp-actions: Allow conntrack action in group buckets.
Jarno Rajahalme [Tue, 24 May 2016 07:25:36 +0000 (00:25 -0700)]
ofp-actions: Allow conntrack action in group buckets.

Conntrack action used in group buckets lets
us do simple load-balancing.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
[guru@ovn.org updated the commit message and made
a small change to the test output format]
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agotests: Use on_exit in ovsdb-idl tests.
Daniele Di Proietto [Mon, 23 May 2016 21:36:24 +0000 (14:36 -0700)]
tests: Use on_exit in ovsdb-idl tests.

Instead of hardcoding 'kill `cat pid`' on every call to AT_CHECK is
simpler to use on_exit.

This makes sure that we kill every started daemon and fixes a travis
build timeout.

Suggested-by: Ben Pfaff <blp@ovn.org>
Tested-at: https://travis-ci.org/ddiproietto/ovs/builds/132404750
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agonetdev-native-tnl: Fix IPv6 tos bits handling.
Pravin B Shelar [Tue, 24 May 2016 03:27:14 +0000 (20:27 -0700)]
netdev-native-tnl: Fix IPv6 tos bits handling.

IPv6 tunnels ignores outer tos bits on recieve and does not
set it on xmit. Following patch fixes it.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agonetdev-native-tnl: Introduce ip_build_header()
Pravin B Shelar [Tue, 24 May 2016 03:27:14 +0000 (20:27 -0700)]
netdev-native-tnl: Introduce ip_build_header()

The native tunneling build tunnel header code is spread across
two different modules, it makes pretty hard to follow the code.
Following patch refactors the code to move all code to
netdev-ative-tnl module.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agoupcall: Unregister dpif cbs in udpif_destroy().
Joe Stringer [Tue, 17 May 2016 03:08:01 +0000 (20:08 -0700)]
upcall: Unregister dpif cbs in udpif_destroy().

During udpif_create(), we register callbacks for handling upcalls and
purging the datapath; however, in the corresponding udpif_destroy() we
never did this. This could potentially lead to dereference of
uninitialized memory in the userspace datapath if the main thread
destroys the udpif then executes an OpenFlow packet-out.

Fixes: e4e74c3a2b9a ("dpif-netdev: Purge all ukeys when reconfigure pmd.")
Fixes: 623540e4617e ("dpif-netdev: Streamline miss handling.")
Reported-by: William Tu <u9012063@gmail.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agonetdev-dpdk: Use ->reconfigure() call to change rx/tx queues.
Daniele Di Proietto [Fri, 26 Feb 2016 23:58:24 +0000 (15:58 -0800)]
netdev-dpdk: Use ->reconfigure() call to change rx/tx queues.

This introduces in dpif-netdev and netdev-dpdk the first use for the
newly introduce reconfigure netdev call.

When a request to change the number of queues comes, netdev-dpdk will
remember this and notify the upper layer via
netdev_request_reconfigure().

The datapath, instead of periodically calling netdev_set_multiq(), can
detect this and call reconfigure().

This mechanism can also be used to:
* Automatically match the number of rxq with the one provided by qemu
  via the new_device callback.
* Provide a way to change the MTU of dpdk devices at runtime.
* Move a DPDK vhost device to the proper NUMA socket.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
8 years agonetdev: Add reconfigure request mechanism.
Daniele Di Proietto [Thu, 25 Feb 2016 01:25:11 +0000 (17:25 -0800)]
netdev: Add reconfigure request mechanism.

A netdev provider, especially a PMD provider (like netdev DPDK) might
not be able to change some of its parameters (such as MTU, or number of
queues) without stopping everything and restarting.

This commit introduces a mechanism that allows a netdev provider to
request a restart (netdev_request_reconfigure()).  The upper layer can
be notified via netdev_wait_reconf_required() and
netdev_is_reconf_required().  After closing all the rxqs the upper layer
can finally call netdev_reconfigure(), to make sure that the new
configuration is in place.

This will be used by next commit to reconfigure rx and tx queues in
netdev-dpdk.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
8 years agodpif-netdev: Handle errors in reconfigure_pmd_threads().
Daniele Di Proietto [Thu, 7 Apr 2016 22:19:28 +0000 (15:19 -0700)]
dpif-netdev: Handle errors in reconfigure_pmd_threads().

Errors returned by netdev_set_multiq() and netdev_rxq_open() weren't
handled properly in reconfigure_pmd_threads().  In case of error now we
remove the port from the datapath.

Also, part of the code is moved in a new function, port_reconfigure().

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
8 years agodpif-netdev: Change pmd thread configuration in dpif_netdev_run().
Daniele Di Proietto [Tue, 23 Feb 2016 23:33:43 +0000 (15:33 -0800)]
dpif-netdev: Change pmd thread configuration in dpif_netdev_run().

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
8 years agoofproto-dpif: Call dpif_poll_threads_set() before dpif_run().
Daniele Di Proietto [Tue, 23 Feb 2016 19:36:10 +0000 (11:36 -0800)]
ofproto-dpif: Call dpif_poll_threads_set() before dpif_run().

An upcoming commit will make dpif_poll_threads_set() record the
requested configuration and dpif_run() apply it, so it makes sense to
change the order.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
8 years agoovs-thread: Do not quiesce in ovs_mutex_cond_wait().
Daniele Di Proietto [Mon, 4 Apr 2016 23:38:57 +0000 (16:38 -0700)]
ovs-thread: Do not quiesce in ovs_mutex_cond_wait().

ovs_mutex_cond_wait() is used in many functions in dpif-netdev to
synchronize with pmd threads, but we can't guarantee that the callers do
not hold RCU references, so it's better to avoid quiescing.

In system_stats_thread_func() the code relied on ovs_mutex_cond_wait()
to introduce a quiescent state, so explicit calls to
ovsrcu_quiesce_start() and ovsrcu_quiesce_end() are added there.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agodpif-netdev: Use hmap for ports.
Daniele Di Proietto [Mon, 4 Apr 2016 18:15:12 +0000 (11:15 -0700)]
dpif-netdev: Use hmap for ports.

netdev objects are hard to use with RCU, because it's not possible to
split removal and reclamation.  Postponing the removal means that the
port is not removed and cannot be readded immediately.  Waiting for
reclamation means introducing a quiescent state, and that may introduce
subtle bugs, due to the RCU model we use in userspace.

This commit changes the port container from cmap to hmap.  'port_mutex'
must be held by readers and writers.  This shouldn't have performance
impact, as readers in the fast path use a thread local cache.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
8 years agohmap: Use struct for hmap_at_position().
Daniele Di Proietto [Sat, 2 Apr 2016 01:31:22 +0000 (18:31 -0700)]
hmap: Use struct for hmap_at_position().

The interface will be more similar to the cmap.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
8 years agodpif-netdev: Add pmd thread local port cache for transmission.
Daniele Di Proietto [Wed, 6 Apr 2016 01:41:09 +0000 (18:41 -0700)]
dpif-netdev: Add pmd thread local port cache for transmission.

A future commit will stop using RCU for 'dp->ports' and use a mutex for
reading/writing them.  To avoid taking a mutex in dp_execute_cb(), which
is called in the fast path, this commit introduces a pmd thread local
cache of ports.

The downside is that every port add/remove now needs to synchronize with
every pmd thread.

Among the advantages, keeping a per thread port mapping could allow
greater control over the txq assigment.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
8 years agodpif-netdev: Fix race condition in pmd thread initialization.
Daniele Di Proietto [Wed, 6 Apr 2016 01:02:14 +0000 (18:02 -0700)]
dpif-netdev: Fix race condition in pmd thread initialization.

The pmds and the main threads are synchronized using a condition
variable.  The main thread writes a new configuration, then it waits on
the condition variable.  A pmd thread reads the new configuration, then
it calls signal() on the condition variable. To make sure that the pmds
and the main thread have a consistent view, each signal() should be
backed by a wait().

Currently the first signal() doesn't have a corresponding wait().  If
the pmd thread takes a long time to start and the signal() is received
by a later wait, the threads will have an inconsistent view.

The commit fixes the problem by removing the first signal() from the
pmd thread.

This is hardly a problem on current master, because the main thread
will call the first wait() a long time after the creation of a pmd
thread.  It becomes a problem with the next commits.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
8 years agodpif-netdev: Add functions to modify rxq without reloading pmd threads.
Daniele Di Proietto [Wed, 6 Apr 2016 00:01:25 +0000 (17:01 -0700)]
dpif-netdev: Add functions to modify rxq without reloading pmd threads.

This commit introduces some functions to add/remove rxqs from pmd
threads without reloading them.  They will be used by next commits.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
8 years agodpif-netdev: Factor out port_create() from do_add_port().
Daniele Di Proietto [Tue, 5 Apr 2016 20:14:56 +0000 (13:14 -0700)]
dpif-netdev: Factor out port_create() from do_add_port().

Instead of performing every operation inside do_port_add() it seems
clearer to introduce port_create(), since we already have
port_destroy().

No functional change.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
8 years agodpif-netdev: Remove unused 'index' in dp_netdev_pmd_thread.
Daniele Di Proietto [Thu, 7 Apr 2016 19:54:10 +0000 (12:54 -0700)]
dpif-netdev: Remove unused 'index' in dp_netdev_pmd_thread.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
8 years agodpif-netdev: Destroy 'port_mutex' in dp_netdev_free().
Daniele Di Proietto [Tue, 5 Apr 2016 01:10:33 +0000 (18:10 -0700)]
dpif-netdev: Destroy 'port_mutex' in dp_netdev_free().

Found by inspection.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Tested-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
8 years agonetdev-native-tnl: Fix a build error on NetBSD 7.0
YAMAMOTO Takashi [Fri, 20 May 2016 05:52:19 +0000 (05:52 +0000)]
netdev-native-tnl: Fix a build error on NetBSD 7.0

netinet/ip6.h is not a standalone header there.

Signed-off-by: YAMAMOTO Takashi <yamamoto@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Tested-by: Jeff Feng <jianhua@us.ibm.com>
8 years agonetdev-dpdk: Improve pthread_getaffinity_np() fail handling.
Kevin Traynor [Thu, 19 May 2016 12:51:32 +0000 (13:51 +0100)]
netdev-dpdk: Improve pthread_getaffinity_np() fail handling.

Prevent pthread_setaffinity_np() being called with a potentially
invalid cpu_set_t and add a default (core 0x1).

Also, only call pthread_getaffinity_np() if no dpdk-lcore-mask specified.

Signed-off-by: Kevin Traynor <kevin.traynor@intel.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
8 years agonetdev-dpdk: Fix coremask logic.
Kevin Traynor [Thu, 19 May 2016 12:51:31 +0000 (13:51 +0100)]
netdev-dpdk: Fix coremask logic.

Only set the thread affinity back to the pre rte_eal_init() value
when the user has not specified a coremask.

Fixes: 88964e6428dc("netdev-dpdk: Autofill lcore coremask if absent")
Signed-off-by: Kevin Traynor <kevin.traynor@intel.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
8 years agoofproto-dpif-xlate: Fix IGMP megaflow matching.
Ben Pfaff [Sun, 8 May 2016 17:34:10 +0000 (10:34 -0700)]
ofproto-dpif-xlate: Fix IGMP megaflow matching.

IGMP translations wasn't setting enough bits in the wildcards to ensure
different packets were handled differently.

Reported-by: "O'Reilly, Darragh" <darragh.oreilly@hpe.com>
Reported-at: http://openvswitch.org/pipermail/discuss/2016-April/021036.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agodpif-netdev: Initialize packet RSS hash in dpif_netdev_execute().
Daniele Di Proietto [Wed, 18 May 2016 01:38:20 +0000 (18:38 -0700)]
dpif-netdev: Initialize packet RSS hash in dpif_netdev_execute().

The datapath code expects the RSS hash to always be initialized.  This
is enforced by checking in emc_processing() that the hash is valid, and
eventually by computing a new one.

Unfortunately, there is another entry point to the datapath,
dpif_netdev_execute().  A packet generated by OVS (BFD frame,
packet-out from controller) doesn't have a valid RSS hash and so is
allowed to enter the datapath with an uninitialized hash value.

This commit recomputes the hash (if not valid) in dpif_netdev_execute().

The only place where we would use an invalid hash is netdev-vport, in
push_udp_header().  This caused an uninitialized memory read, and a
random value to be assigned to the outer tunnel header source port.

Reported-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: William Tu <u9012063@gmail.com>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agodpif: Pass flow parameter to dpif_execute().
Daniele Di Proietto [Wed, 18 May 2016 01:26:02 +0000 (18:26 -0700)]
dpif: Pass flow parameter to dpif_execute().

All the callers of the function already have a copy of the extracted
flow in their stack (or a few frames before).

This is useful for different resons:
* It forces the callers to also call flow_extract() on the packet, which
  is necessary to initialize the l2,l3,l4 pointers.
* It will be used in the userspace datapath to generate the RSS hash by
  a following commit
* It can be used by the userspace connection tracker to avoid extracting
  the l3 type again.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoflow: Fix uninitialized reads in [mini]flow_hash_5tuple().
Daniele Di Proietto [Wed, 18 May 2016 02:18:51 +0000 (19:18 -0700)]
flow: Fix uninitialized reads in [mini]flow_hash_5tuple().

Almost every caller expects [mini]flow_hash_5tuple() to be able to deal
with all kinds of flows, not only TCP and UDP.

Currently, when dealing with non L4 flows, the function may access
uninitialized memory.  This commit changes it to return prematurely with
a partial hash value instead of reading uninitialized memory.

Found by valgrind.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoutilities/checkpatch.py: Check for appropriate bracing
Aaron Conole [Fri, 20 May 2016 15:52:59 +0000 (11:52 -0400)]
utilities/checkpatch.py: Check for appropriate bracing

Teach checkpatch.py to understand that if/for/while blocks should always
end with braces on the same line (if possible). This does not address
multi-line if/for/while blocks, but provides a point where such blocks
could be added.

Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agostp: Initialize mutex whenever we register unixctl command.
Ben Pfaff [Fri, 20 May 2016 14:49:02 +0000 (07:49 -0700)]
stp: Initialize mutex whenever we register unixctl command.

The stp/tcn command, which locks the mutex, was being registered without
initializing the mutex, so calling stp/tcn before STP was enabled on the
switch caused a crash.  This commit fixes the bug by initializing the mutex
at the same time we register the stp/tcn command.

Reported-by: Ding Zhi <zhi.ding@6wind.com>
Reported-at: http://openvswitch.org/pipermail/dev/2016-May/071381.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Quentin Monnet <quentin.monnet@6wind.com>
8 years agopython: Add TCP passive-mode to IDL.
Ofer Ben-Yacov [Wed, 18 May 2016 15:29:13 +0000 (18:29 +0300)]
python: Add TCP passive-mode to IDL.

Requested-by: "D M, Vikas" <vikas.d-m@hpe.com>
Requested-by: "Kamat, Maruti Haridas" <maruti.kamat@hpe.com>
Requested-by: "Sukhdev Kapur" <sukhdev@arista.com>
Requested-by: "Migliaccio, Armando" <armando.migliaccio@hpe.com>
Signed-off-by: "Ofer Ben-Yacov" <ofer.benyacov@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoutilities/ovs-ctl.in: Only add_managers with vswitchd
Aaron Conole [Fri, 20 May 2016 14:50:46 +0000 (10:50 -0400)]
utilities/ovs-ctl.in: Only add_managers with vswitchd

The ovs-ctl script was changed recently to have per-service start/stop
control. However, when that change was made the add_managers() call was
overlooked. This results in calls to `ovs-ctl --no-ovs-vswitchd start`
telling the ovsdb-server to connect to the remote controllers.

The fix presented will defer signaling to remote managers until the
following are both true:
1. At least one of OVSDB_SERVER or OVS_VSWITCHD was told to start
2. Both daemons are running.

Fixes: 7fc28c50c012 ("ovs-ctl: Allow selective start for db and switch")
Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoutilities: Tweak python shebangs to use env
YAMAMOTO Takashi [Fri, 13 May 2016 14:36:15 +0000 (14:36 +0000)]
utilities: Tweak python shebangs to use env

"python" command provided by pkg_alternatives is a shell script.
At least on NetBSD-7, execve can't execute scripts whose interpreter
is another shell script.  (While some "rich" shells like zsh seem
to have handle the case by itself, NetBSD's /bin/sh doesn't.)
Workaround the issue by using env command for shebangs for
these scripts.

Noticed with the recent tunnel-push-pop.at tests using ovs-pcap command.

Signed-off-by: YAMAMOTO Takashi <yamamoto@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoovn-controller-vtep.at: Pre-sort output before feeding to "sort -d"
YAMAMOTO Takashi [Fri, 13 May 2016 14:11:20 +0000 (14:11 +0000)]
ovn-controller-vtep.at: Pre-sort output before feeding to "sort -d"

NetBSD's "sort -d" preserves the order of lines which doesn't have
alphanumeric and blanks.  eg. empty lines and [].
It means it sometimes preserve unstable order of the list output.

Also, simply remove -d option where the expected output doesn't
include [].

Signed-off-by: YAMAMOTO Takashi <yamamoto@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoovsdb-server.at: Fix races
YAMAMOTO Takashi [Fri, 13 May 2016 12:57:48 +0000 (12:57 +0000)]
ovsdb-server.at: Fix races

As ovsdb-server creates pid file before unixctl socket, waiting
for pid file creation is not enough.  Fix the race by retrying
with "version" command before assuming the server is up.

Signed-off-by: YAMAMOTO Takashi <yamamoto@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agodpif: Remove a warning
YAMAMOTO Takashi [Fri, 13 May 2016 11:42:55 +0000 (11:42 +0000)]
dpif: Remove a warning

Remove "attempted to unregister a datapath provider that is not registered"
warning.  It's normal for --enabled-dummy=system with userland-only build.
ovn-controller-vtep.at tests use the flag and fail on the extra warning.

Alternatively, we can make the tests ignore this specific warning.
But currently it doesn't make much sense as dp_unregister_provider
is only used for --enabled-dummy.

Signed-off-by: YAMAMOTO Takashi <yamamoto@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoovn test: add '-O OpenFlow13' to ovs-ofctl
Flavio Fernandes [Tue, 17 May 2016 01:02:52 +0000 (21:02 -0400)]
ovn test: add '-O OpenFlow13' to ovs-ofctl

Make test calls to ovs-ofctl in test use the protocol parameter
'-O OpenFlow13', so it is consistent with the existing dump-flows
invocations.

Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovn test: remove check for non-existing bridge in hv3
Flavio Fernandes [Tue, 17 May 2016 01:02:51 +0000 (21:02 -0400)]
ovn test: remove check for non-existing bridge in hv3

In OVN vtep test, the network topology is like this:

  hv1---\
         >-- [net1] <-- vtep --> [net2] <-- hv3
  hv2---/

The logical switch lsw0 created in this test has no logical
port corresponding to hv3, so that hypervisor does not have
any bridges created by OVN. With this test change, we are
replacing the 'show br-int' with a check to ensure that
'br-int' is not present.

Fixes: 8dab102238f0 ("ovn: Add more details to test output.")
Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovn test: improve vtep test description and fix typo
Flavio Fernandes [Tue, 17 May 2016 01:02:50 +0000 (21:02 -0400)]
ovn test: improve vtep test description and fix typo

- Add vtep as keyword and in description of test 2028
- Fix minor typo: 'information'

Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovn-nbctl: Fix memory leak reported by Valgrind.
William Tu [Sun, 15 May 2016 15:52:33 +0000 (08:52 -0700)]
ovn-nbctl: Fix memory leak reported by Valgrind.

Definitely lost is reported by test 2026: ovn -- 3 HVs, 1 LS, 3 lports/HV.
  ds_put_char__ (dynamic-string.c:82)
  ds_put_char (dynamic-string.h:88)
  process_escape_args (process.c:103)
  main (ovn-nbctl.c:92)
Another leak shown at ovn-sbctl.c with similar pattern.

Signed-off-by: William Tu <u9012063@gmail.com>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agotnl-ports: Handle STT ports.
Pravin B Shelar [Wed, 18 May 2016 00:35:33 +0000 (17:35 -0700)]
tnl-ports: Handle STT ports.

STT uses TCP port so we need to filter traffic on basis of TCP
port numbers.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agotunnel: Add IP ECN related functions.
Pravin B Shelar [Wed, 18 May 2016 00:35:28 +0000 (17:35 -0700)]
tunnel: Add IP ECN related functions.

Set and get functions for IP explicit congestion notification flag.
These function would be used by STT reassembly code.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agodpif-netdev: Refactor userspace action
Pravin B Shelar [Wed, 18 May 2016 00:33:44 +0000 (17:33 -0700)]
dpif-netdev: Refactor userspace action

Large segment support need to use this refactored function to
send individual segments.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agodpif-netdev: Refactor fast path process function.
Pravin B Shelar [Wed, 18 May 2016 00:33:32 +0000 (17:33 -0700)]
dpif-netdev: Refactor fast path process function.

Once datapath support large packets, we need to segment packet before
sending it to upcall. Refactoring this code make it bit cleaner.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agodpif-netdev: Fix memory leak in tunnel header push action.
Pravin B Shelar [Wed, 18 May 2016 00:33:10 +0000 (17:33 -0700)]
dpif-netdev: Fix memory leak in tunnel header push action.

in case of error from netdev_push_header() batch of packets was not
freed. Following patch fixes this issue.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agodpif-netdev: Fix memory leak in tunnel header pop action.
Pravin B Shelar [Wed, 18 May 2016 00:32:37 +0000 (17:32 -0700)]
dpif-netdev: Fix memory leak in tunnel header pop action.

The tunnel header pop action can leak batch of packet
in case of error. Following patch fixex the error code path.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agodpif-netdev: create batch object
Pravin B Shelar [Wed, 18 May 2016 00:32:33 +0000 (17:32 -0700)]
dpif-netdev: create batch object

DPDK datapath operate on batch of packets. To pass the batch of
packets around we use packets array and count.  Next patch needs
to associate meta-data with each batch of packets. So Introducing
a batch structure to make handling the metadata easier.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agodpif-netdev: rename packet_batch
Pravin B Shelar [Wed, 18 May 2016 00:32:28 +0000 (17:32 -0700)]
dpif-netdev: rename packet_batch

Next patch introduces new structure named packet_batch. So
I am renaming it to packet_batch_per_flow.
This does not change any functionality.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agodp-packet: use packet reset function.
Pravin B Shelar [Wed, 18 May 2016 00:32:23 +0000 (17:32 -0700)]
dp-packet: use packet reset function.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agodp-packet: Add private data
Pravin B Shelar [Wed, 18 May 2016 00:32:17 +0000 (17:32 -0700)]
dp-packet: Add private data

This scratchpad can be used by any layer to keep private data.
STT will use it for TCP reassembly state.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agonetdev: Return number of packet from netdev_pop_header()
Pravin B Shelar [Wed, 18 May 2016 00:32:06 +0000 (17:32 -0700)]
netdev: Return number of packet from netdev_pop_header()

Current tunnel-pop API does not allow the netdev implementation
retain a packet but STT can keep a packet from batch of packets
during TCP reassembly processing. To return exact count of
valid packet STT need to pass this number of packet parameter
as a reference.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agonetdev-vport: Factor-out tunnel Push-pop code into separate module.
Pravin B Shelar [Wed, 18 May 2016 00:31:33 +0000 (17:31 -0700)]
netdev-vport: Factor-out tunnel Push-pop code into separate module.

It is better to move tunnel push-pop action specific functions into
separate module.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
8 years agonat: documentation and parsing fixes.
Jarno Rajahalme [Wed, 18 May 2016 23:28:36 +0000 (16:28 -0700)]
nat: documentation and parsing fixes.

Add the missing NAT documentation to ovs-ofctl man page and add
validation of the NAT flags to NAT action decoding and parsing.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoovs-dev.py: Update for python3.
Joe Stringer [Sat, 14 May 2016 22:08:08 +0000 (15:08 -0700)]
ovs-dev.py: Update for python3.

Adapt to python-2.6+, including support for 3.

Signed-off-by: Joe Stringer <joe@ovn.org>
8 years agoovs-dev.py: PEP-8ify.
Joe Stringer [Sat, 14 May 2016 21:18:27 +0000 (14:18 -0700)]
ovs-dev.py: PEP-8ify.

Signed-off-by: Joe Stringer <joe@ovn.org>
8 years agotests: Enable color output for unit tests, if available.
Flavio Fernandes [Wed, 18 May 2016 15:00:49 +0000 (11:00 -0400)]
tests: Enable color output for unit tests, if available.

Reference thread in mailing list:
http://openvswitch.org/pipermail/discuss/2016-May/021339.html

Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovs-vtep: Support running multiple ovs-vtep processes
nickcooper-zhangtonghao [Fri, 6 May 2016 03:07:57 +0000 (23:07 -0400)]
ovs-vtep: Support running multiple ovs-vtep processes

Include ovs-vtep physical switch name as part of logical switch name to
support running multiple ovs-vtep processes sharing the same ovsdb and vswitchd.

Signed-off-by: nickcooper-zhangtonghao <nickcooper-zhangtonghao@opencloud.tech>
Tested-by: Darrell Ball <dlu998@gmail.com>
Acked-by: Justin Pettit <jpettit@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agotests: Add test for partial map updates.
Edward Aymerich [Mon, 2 May 2016 20:07:20 +0000 (14:07 -0600)]
tests: Add test for partial map updates.

Insert basic functionality for testing partial map updates
and add a new test table named "simple2".

Signed-off-by: Edward Aymerich <edward.aymerich@hpe.com>
Signed-off-by: Arnoldo Lutz <arnoldo.lutz.guevara@hpe.com>
Co-authored-by: Arnoldo Lutz <arnoldo.lutz.guevara@hpe.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovsdb-idlc.in: Autogenerate partial map updates functions.
Edward Aymerich [Mon, 2 May 2016 20:01:46 +0000 (14:01 -0600)]
ovsdb-idlc.in: Autogenerate partial map updates functions.

Code inserted that autogenerates corresponding map functions to set and
delete elements in map columns.
Inserts description to the functions that are autogenerated.

Signed-off-by: Edward Aymerich <edward.aymerich@hpe.com>
Signed-off-by: Arnoldo Lutz <arnoldo.lutz.guevara@hpe.com>
Co-authored-by: Arnoldo Lutz <arnoldo.lutz.guevara@hpe.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovsdb-idl: Add partial map updates functionality.
Edward Aymerich [Mon, 2 May 2016 19:59:44 +0000 (13:59 -0600)]
ovsdb-idl: Add partial map updates functionality.

In the current implementation, every time an element of either a map or set
column has to be modified, the entire content of the column is sent to the
server to be updated. This is not a major problem if the information contained
in the column for the corresponding row is small, but there are cases where
these columns can have a significant amount of elements per row, or these
values are updated frequently, therefore the cost of the modifications becomes
high in terms of time and bandwidth.

In this solution, the ovsdb-idl code is modified to use the RFC 7047 'mutate'
operation, to allow sending partial modifications on map columns to the server.
The functionality is exposed to clients in the vswitch idl. This was
implemented through map operations.

A map operation is defined as an insertion, update or deletion of a key-value
pair inside a map. The idea is to minimize the amount of map operations
that are send to the OVSDB server when a transaction is committed.

In order to keep track of the requested map operations, structs map_op and
map_op_list were defined with accompanying functions to manipulate them. These
functions make sure that only one operation is send to the server for each
key-value that wants to be modified, so multiple operation on a key value are
collapsed into a single operation.

As an example, if a client using the IDL updates several times the value for
the same key, the functions will ensure that only the last value is send to
the server, instead of multiple updates. Or, if the client inserts a key-value,
and later on deletes the key before committing the transaction, then both
actions cancel out and no map operation is send for that key.

To keep track of the desired map operations on each transaction, a list of map
operations (struct map_op_list) is created for every column on the row on which
a map operation is performed. When a new map operation is requested on the same
column, the corresponding map_op_list is checked to verify if a previous
operations was performed on the same key, on the same transaction. If there is
no previous operation, then the new operation is just added into the list. But
if there was a previous operation on the same key, then the previous operation
is collapsed with the new operation into a single operation that preserves the
final result if both operations were to be performed sequentially. This design
keep a small memory footprint during transactions.

When a transaction is committed, the map operations lists are checked and
all map operations that belong to the same map are grouped together into a
single JSON RPC "mutate" operation, in which each map_op is transformed into
the necessary "insert" or "delete" mutators. Then the "mutate" operation is
added to the operations that will be send to the server.

Once the transaction is finished, all map operation lists are cleared and
deleted, so the next transaction starts with a clean board for map operations.

Using different structures and logic to handle map operations, instead of
trying to force the current structures (like 'old' and 'new' datums in the row)
to handle then, ensures that map operations won't mess up with the current
logic to generate JSON messages for other operations, avoids duplicating the
whole map for just a few changes, and is faster for insert and delete
operations, because there is no need to maintain the invariants in the 'new'
datum.

Signed-off-by: Edward Aymerich <edward.aymerich@hpe.com>
Signed-off-by: Arnoldo Lutz <arnoldo.lutz.guevara@hpe.com>
Co-authored-by: Arnoldo Lutz <arnoldo.lutz.guevara@hpe.com>
[blp@ovn.org made style changes and factored out error checking]
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agodpif-netlink: Only warn when OVS datapath Netlink family is unavailable.
Ciara Loftus [Tue, 17 May 2016 13:28:39 +0000 (14:28 +0100)]
dpif-netlink: Only warn when OVS datapath Netlink family is unavailable.

OVS using DPDK (or the userspace datapath without DPDK) can still function
correctly without the module loaded.

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agonetdev: Initialise DPDK netdev classes only once
Ciara Loftus [Tue, 17 May 2016 13:28:38 +0000 (14:28 +0100)]
netdev: Initialise DPDK netdev classes only once

DPDK netdev classes were being initialised twice, resulting in warning
logs like so:

netdev|WARN|attempted to register duplicate netdev provider: dpdk

This commit removes one of the initialisation calls.

Fixes: 0692257923fe ("netdev: Fix potential deadlock.")
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoappveyor: Update OpenSSL version
Alin Serdean [Wed, 11 May 2016 20:49:09 +0000 (20:49 +0000)]
appveyor: Update OpenSSL version

OpenSSL version changed from 1.0.2g to 1.0.2h this patch bumps the
version.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoofproto-dpif-xlate: Fix compilation with GCC 4.6.
Ben Pfaff [Tue, 17 May 2016 23:29:39 +0000 (16:29 -0700)]
ofproto-dpif-xlate: Fix compilation with GCC 4.6.

Without this change, GCC 4.6 reports:

ofproto/ofproto-dpif-xlate.c: In function ‘xlate_actions’:
ofproto/ofproto-dpif-xlate.c:5117:27: error: missing initializer
ofproto/ofproto-dpif-xlate.c:5117:27: error: (near initialization for
    ‘(anonymous).masks.vlan_tci’)

Reported-by: Joe Stringer <joe@ovn.org>
Reported-at: https://travis-ci.org/openvswitch/ovs/builds/130256491
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
8 years agotests: Add support for helgrind thread error detector.
William Tu [Sat, 30 Apr 2016 05:13:46 +0000 (22:13 -0700)]
tests: Add support for helgrind thread error detector.

Helgrind is a Valgrind tool for detecting thread errors, reporting three
classes of errors: misuses of the POSIX pthreads API, potential deadlocks
arising from lock ordering problems, and data races -- accessing memory
without adequate locking.  Similar to valgrind, users do "make check-helgrind"
and results will be saved at tests/testsuite.dir/<N>/helgrind.*.

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agotests: Remove redundant ofport_request.
William Tu [Fri, 29 Apr 2016 17:11:25 +0000 (10:11 -0700)]
tests: Remove redundant ofport_request.

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agopinctrl: Fix "sparse" warning.
Ben Pfaff [Tue, 17 May 2016 14:44:06 +0000 (07:44 -0700)]
pinctrl: Fix "sparse" warning.

The ofport member should be an ofp_port_t, since it represents an OpenFlow
port number.

Fixes: 0ee8aaf658dd ("ovn: Send GARP on localnet.")
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
8 years agovtep: Add other_config to Global table.
Dennis Sam [Wed, 11 May 2016 18:51:29 +0000 (11:51 -0700)]
vtep: Add other_config to Global table.

Extend the Global table to allow for additional configurations by re-using
the idea of an other_config column.

Signed-off-by: Dennis Sam <dsam@arista.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoofproto-dpif-upcall: Fix UFID usage with flow_modify.
Joe Stringer [Fri, 13 May 2016 21:17:12 +0000 (14:17 -0700)]
ofproto-dpif-upcall: Fix UFID usage with flow_modify.

As per the delete_op_init{,__}() functions, the UFID should only be
passed down if ukey->ufid_present is set. Otherwise it is possible to
request a flow modification only using a UFID in a datapath that doesn't
support UFID, which will fail.

Fixes: 43b2f131a229 ("ofproto: Allow in-place modifications of datapath flows.")
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agodpctl: Sort port listing in "show" command.
Justin Pettit [Thu, 12 May 2016 00:28:54 +0000 (17:28 -0700)]
dpctl: Sort port listing in "show" command.

The port listing did not consistently print in the same order.  While it
is a better user experience to see the ports printed in order, more
importantly, this fixes a unit test ("dpctl - add-if set-if del-if")
that would occasionally fail due to expecting that the ports are printed
in order.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agodatapath-windows: Validate Netlink packets' integrity.
Paul Boca [Wed, 27 Apr 2016 08:05:47 +0000 (08:05 +0000)]
datapath-windows: Validate Netlink packets' integrity.

Solved access violation when trying to access Netlink message - obtained
with forged IOCTLs.

Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoclassifier: Use ccmaps for staged lookup indices.
Jarno Rajahalme [Sat, 23 Apr 2016 02:40:09 +0000 (19:40 -0700)]
classifier: Use ccmaps for staged lookup indices.

Use the new ccmap type instead of cmap for staged lookup indices to
fix the problem with slow removal of rules with large number of
duplicates.  This was problematic especially when many rules shared
the same match in packet metadata (e.g., a port number, but nothing
else), causing a large number of duplicates to be inserted into the
staged lookup index.  ccmap only keeps the count of inserted (hash)
values, so duplicates do not add any performance penalty.

Reported-by: Alok Kumar Maurya <alok-kumar.maurya@hpe.com>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agolib: Add new 'counting cmap' type.
Jarno Rajahalme [Sat, 23 Apr 2016 02:40:09 +0000 (19:40 -0700)]
lib: Add new 'counting cmap' type.

cmap implements duplicates as linked lists, which causes removal of
rules to become (O^2) with large number of duplicates.  This patch
fixes the problem by introducing a new 'counting' variant of the cmap
(ccmap), which can be efficiently used to keep counts of inserted hash
values provided by the caller.  This does not require a node in the
user data structure, so this makes the user implementation a bit more
memory efficient, too.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoovn: Fix localnet ports deletion and recreation sometimes after restart.
Ramu Ramamurthy [Fri, 29 Apr 2016 00:23:59 +0000 (20:23 -0400)]
ovn: Fix localnet ports deletion and recreation sometimes after restart.

On graceful restart of ovn-controller, the chassis row is inserted in the
Chassis table. During this transaction, there is a window of time where an
idl row-read may not return the newly created row - even though the row
should exist, but the transaction is in an incomplete state.  As a result,
get_chassis() in binding_run() returns a null chassis record binding_run
exits early, and does not create local_datapaths, and patch_run deletes
localnet patch ports. In a later run, the localnet patch ports are
recreated.

This is reproducable consistently but not on every restart.  The fix is to
handle the case that the chassis record may be null in binding_run, and yet
create local_datapaths.

Restart logs follow with commentary:

2016-04-28T18:35:42.448Z|00001|vlog|INFO|opened log file /home/ovs/ovs/tests/testsuite.dir/2035/hv/ovn-controller.log
2016-04-28T18:35:42.449Z|00002|reconnect|INFO|unix:/home/ovs/ovs/tests/testsuite.dir/2035/hv/db.sock: connecting...
2016-04-28T18:35:42.449Z|00003|reconnect|INFO|unix:/home/ovs/ovs/tests/testsuite.dir/2035/hv/db.sock: connected
2016-04-28T18:35:42.452Z|00004|reconnect|INFO|unix:/home/ovs/ovs/tests/testsuite.dir/2035/ovn-sb/ovn-sb.sock: connecting...
2016-04-28T18:35:42.452Z|00005|reconnect|INFO|unix:/home/ovs/ovs/tests/testsuite.dir/2035/ovn-sb/ovn-sb.sock: connected
2016-04-28T18:35:42.454Z|00006|ovsdb_idl|INFO|ovsdb_idl_txn_insert:
                Chassis row inserted into transaction above
2016-04-28T18:35:42.454Z|00007|binding|INFO|Claiming lport localvif2 for this chassis.
2016-04-28T18:35:42.454Z|00008|binding|INFO|Claiming lport localvif3 for this chassis.
2016-04-28T18:35:42.454Z|00009|binding|INFO|Claiming lport localcif4 for this chassis.
2016-04-28T18:35:42.454Z|00010|binding|INFO|Claiming lport localcif5 for this chassis.
2016-04-28T18:35:42.454Z|00011|binding|INFO|Claiming lport localcif1 for this chassis.
2016-04-28T18:35:42.454Z|00012|binding|INFO|Claiming lport localvif1 for this chassis.
2016-04-28T18:35:42.454Z|00013|binding|INFO|Claiming lport localvif201 for this chassis.
2016-04-28T18:35:42.454Z|00014|binding|INFO|Claiming lport localcif3 for this chassis.
2016-04-28T18:35:42.454Z|00015|binding|INFO|Claiming lport localcif2 for this chassis.
               Binding run found the chassis record and has claimed the vifs
2016-04-28T18:35:42.455Z|00016|ofctrl|INFO|unix:/home/ovs/ovs/tests/testsuite.dir/2035/hv/br-int.mgmt: connecting to switch
2016-04-28T18:35:42.455Z|00017|rconn|INFO|unix:/home/ovs/ovs/tests/testsuite.dir/2035/hv/br-int.mgmt: connecting...
2016-04-28T18:35:42.455Z|00018|pinctrl|INFO|unix:/home/ovs/ovs/tests/testsuite.dir/2035/hv/br-int.mgmt: connecting to switch
2016-04-28T18:35:42.456Z|00019|rconn|INFO|unix:/home/ovs/ovs/tests/testsuite.dir/2035/hv/br-int.mgmt: connecting...
2016-04-28T18:35:42.457Z|00020|ovsdb_idl|INFO|ovsdb_idl_row_clear_new:
                At this point read of Chassis table returns no rows, and
                the transaction status is still incomplete.
2016-04-28T18:35:42.457Z|00021|binding|INFO|no chassis rec!
                Binding run exits early because chassis_rec was null
2016-04-28T18:35:42.459Z|00022|patch|INFO|removing port patch-br-int-to-localnet201
2016-04-28T18:35:42.459Z|00023|patch|INFO|removing port patch-br-int-to-localnet1
2016-04-28T18:35:42.459Z|00024|patch|INFO|removing port patch-localnet1-to-br-int
2016-04-28T18:35:42.459Z|00025|patch|INFO|removing port patch-localnet201-to-br-int
               Localnet ports are removed above, because local_datapaths dont exist
2016-04-28T18:35:42.459Z|00026|rconn|INFO|unix:/home/ovs/ovs/tests/testsuite.dir/2035/hv/br-int.mgmt: connected
2016-04-28T18:35:42.460Z|00027|rconn|INFO|unix:/home/ovs/ovs/tests/testsuite.dir/2035/hv/br-int.mgmt: connected
2016-04-28T18:35:42.460Z|00028|ovsdb_idl|INFO|ovsdb_idl_row_create:
               Now, the transaction is complete

Signed-off-by: Ramu Ramamurthy <ramu.ramamurthy@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovn: Send GARP on localnet.
Ramu Ramamurthy [Tue, 26 Apr 2016 21:31:07 +0000 (17:31 -0400)]
ovn: Send GARP on localnet.

In some use cases such as VM migration or when VMs reuse IP addresses, VMs
become unreachable externally because external switches/routers on localnet
have stale port-mac or ARP caches. The problem resolves after some time
when the caches ageout which could be minutes for port-mac bindings or
hours for ARP caches.

To fix this, send some gratuitous ARPs when a logical port on a localnet
datapath gets added. Such gratuitous ARPs help on a best-effort basis to
update the mac-port bindings and ARP caches of external switches and
routers on the localnet.

Reported-at: https://bugs.launchpad.net/networking-ovn/+bug/1545897
Reported-by: Kyle Mestery <mestery@mestery.com>
Signed-off-by: Ramu Ramamurthy <ramu.ramamurthy@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovn: Move extract_lport_addresses
Ramu Ramamurthy [Tue, 26 Apr 2016 21:31:06 +0000 (17:31 -0400)]
ovn: Move extract_lport_addresses

Move the function extract_lport_addresses to a file
in ovn/lib since that function can be used by ovn-controller also
to parse addresses stored in the mac column of the
port_binding table. Currently that function is used only
in ovn_northd.

Signed-off-by: Ramu Ramamurthy <ramu.ramamurthy@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agodaemon-unix: Properly handle missing users or groups.
Christian Ehrhardt [Mon, 25 Apr 2016 07:12:19 +0000 (09:12 +0200)]
daemon-unix: Properly handle missing users or groups.

From the manpages of getgrnam_r (getpwnam_r is similar):
"If no matching group record was found, these functions return 0 and
store NULL in *result."

The code checked only against errors, but non existing users didn't set
e != 0 therefore the code could try to set arbitrary uid/gid values.

Fixes: e91b927d lib/daemon: support --user option for all OVS daemon
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agomcast-snooping: Trigger revalidation when adding a new multicast group.
Ben Pfaff [Mon, 16 May 2016 20:13:36 +0000 (13:13 -0700)]
mcast-snooping: Trigger revalidation when adding a new multicast group.

Otherwise it takes a long time for flows to be updated when a new group
entry is added.

Reported-by: "O'Reilly, Darragh" <darragh.oreilly@hpe.com>
Reported-at: http://openvswitch.org/pipermail/discuss/2016-May/021224.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: "O'Reilly, Darragh" <darragh.oreilly@hpe.com>
Tested-at: http://openvswitch.org/pipermail/discuss/2016-May/021244.html

8 years agoacinclude.m4: Fix skb_get_hash function detection
Markos Chandras [Tue, 10 May 2016 08:21:00 +0000 (09:21 +0100)]
acinclude.m4: Fix skb_get_hash function detection

Commit e2f3178f0582 ("datapath: Add support for kernel 3.14.") added
support for 3.14 kernels and a new OVS_GREP_IFELSE check for the
"skg_get_hash" function in the process. "skb_get_hash" was introduced
in the Linux kernel commit 3958afa1b272 ("net: Change skb_get_rxhash to
skb_get_hash") which exists in >=3.14 but the OVS_GREP_IFELSE macro
also matches the "skb_get_hash_raw" function which exists in older
kernels. As a result of which, the check makes the build system
behave as if the "skb_get_hash" function is available in these older
kernels leading to build failures. We fix this by explicitly checking
for "skb_get_hash(" which matches the function definition.

Signed-off-by: Markos Chandras <mchandras@suse.de>
Signed-off-by: Jesse Gross <jesse@kernel.org>
8 years agoovsdb-server: Fix memory leak reported by Valgind.
William Tu [Fri, 13 May 2016 17:33:07 +0000 (10:33 -0700)]
ovsdb-server: Fix memory leak reported by Valgind.

Reported by test 1657: ovsdb-server/add-db and remove-db.
  ds_put_format (dynamic-string.c:142)
  query_db_remotes (ovsdb-server.c:798)
  reconfigure_remotes (ovsdb-server.c:988)
  main_loop (ovsdb-server.c:156)

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovn-controller: Fix errors reported by Valgrind.
William Tu [Fri, 13 May 2016 18:58:43 +0000 (11:58 -0700)]
ovn-controller: Fix errors reported by Valgrind.

Fix two errors reported by test 2026: ovn -- 3 HVs, 1 LS, 3 lports/HV.
1. Conditional jump or move depends on uninitialised value(s)
    physical_run (physical.c:366)
    main (ovn-controller.c:382)
2. Use of uninitialised value of size 8
    bitmap_set1 (bitmap.h:97)
    update_ct_zones (binding.c:115)
    binding_run (binding.c:228)
    main (ovn-controller.c:362)

Signed-off-by: William Tu <u9012063@gmail.com>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoofproto-dpif-xlate: Always generate wildcards.
Ben Pfaff [Sat, 23 Apr 2016 00:45:03 +0000 (17:45 -0700)]
ofproto-dpif-xlate: Always generate wildcards.

Until now, the flow translation code has tried to avoid constructing a
set of wildcards during translation in the cases where it can, because
wildcards are large and somewhat expensive.  However, this has problems
that we hadn't previously realized.  Specifically, the generated actions
can depend on the constructed wildcards, to decide which bits of a field
need to be set in a masked set_field action.  This means that in practice
translation needs to always construct the wildcards.

(It might be possible to avoid masked set_field when we're not constructing
wildcards, but this would mean that we'd generate different actions
depending on whether wildcards were being constructed, which seems rather
confusing at best.  Also, the cases in which we don't need wildcards anyway
are fairly obscure, meaning that the benefits of avoiding them in those
cases are minimal and that it's going to be hard to get test coverage.  The
latter is probably why we didn't notice this until now.)

Reported-by: William Tu <u9012063@gmail.com>
Reported-at: http://openvswitch.org/pipermail/dev/2016-April/069219.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
Tested-by: William Tu <u9012063@gmail.com>