]> git.proxmox.com Git - mirror_ovs.git/log
mirror_ovs.git
6 years agodatapath: lisp: Fix uninitialized field in tunnel_cfg.
Yunjian Wang [Tue, 11 Sep 2018 07:12:17 +0000 (15:12 +0800)]
datapath: lisp: Fix uninitialized field in tunnel_cfg.

The tunnel_cfg had the gro_receive and gro_complete fields uninitialized
in function lisp_open(). This caused an uninitialized memory read.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
6 years agoflow: Document parse_tcp_flags() assumptions and semantics.
Ben Pfaff [Fri, 7 Sep 2018 17:03:08 +0000 (10:03 -0700)]
flow: Document parse_tcp_flags() assumptions and semantics.

Reported-by: Bhargava Shastry <bshastry@sect.tu-berlin.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
6 years agoodp-util: Don't attempt to write IPv6 flow label bits that don't exist.
Ben Pfaff [Thu, 6 Sep 2018 22:42:06 +0000 (15:42 -0700)]
odp-util: Don't attempt to write IPv6 flow label bits that don't exist.

The ipv6_label field member of struct ovs_key_ipv6 is 32 bits in size,
but an IPv6 label is only 20 bits, so the upper 12 bits are not writable
and must be 0 in the mask.  The code wasn't careful about this so it could
try to write them anyway.  This commit fixes the problem.

Reported-by: nm_r@directbox.com
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-September/047357.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
6 years agolib/tc: treat vlan id and prio as independent fields
Pieter Jansen van Vuuren [Mon, 10 Sep 2018 10:08:25 +0000 (11:08 +0100)]
lib/tc: treat vlan id and prio as independent fields

Previously the key was used to check the presence of vlan id and
prio fields instead of using the mask. Additionally the vlan id
field was considered to be present if only the prio field was set,
and vice versa. f.e. setting the following:

ovs-ofctl -OOpenFlow13,OpenFlow15 add-flow br0 \
priority=10,cookie=1,table=0,ip,dl_vlan_pcp=2,actions=output:2

Resulted in (instead of wildcarding vlan_id, filter matches 0):
filter protocol 802.1Q pref 1 flower chain 0
filter protocol 802.1Q pref 1 flower chain 0 handle 0x1
 vlan_id 0
 vlan_prio 2
 vlan_ethtype ip
 eth_type ipv4
 ip_flags nofrag
 in_hw
       action order 1: mirred (Egress Redirect to device eth1) stolen
       index 2 ref 1 bind 1 installed 5 sec used 5 sec
       Action statistics:
       Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
       backlog 0b 0p requeues 0
       cookie 47040ae7a94fff6afd7ed8aa04b11ba4

Signed-off-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
6 years agotests: Add $(AM_V_GEN) annotation to fuzz-regression-list.at target.
Ben Pfaff [Mon, 10 Sep 2018 19:51:25 +0000 (12:51 -0700)]
tests: Add $(AM_V_GEN) annotation to fuzz-regression-list.at target.

Fixes: 2bdeb9a70e3c ("tests: Add regression tests for all the bugs found by oss-fuzz so far.")
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agotests: Add regression tests for all the bugs found by oss-fuzz so far.
Ben Pfaff [Thu, 30 Aug 2018 20:58:50 +0000 (13:58 -0700)]
tests: Add regression tests for all the bugs found by oss-fuzz so far.

This will make it harder for bugs found by oss-fuzz to reappear.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Yifeng Sun <pkusunyifeng@gmail.com>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoofp-port: Further cleanups and fixes for ofputil_decode_port_stats().
Ben Pfaff [Thu, 30 Aug 2018 20:58:49 +0000 (13:58 -0700)]
ofp-port: Further cleanups and fixes for ofputil_decode_port_stats().

This fixes leaks on the error path in parse_intel_port_custom_property().

ofp_print_ofpst_port_reply() failed to free the custom_stats in decoded
port stats.  This fixes the problem.

parse_intel_port_custom_property() had a memory leak if there was more than
one custom stats property (which there shouldn't be, but still).  This
fixes the problem.

There was a function netdev_free_custom_stats_counters() meant for freeing
custom_stats, but hardly anything used it.  This adopts it consistently.

It wasn't safe to free the custom stats if ofputil_decode_port_stats()
returned an error.  Using netdev_free_custom_stats_counters() avoids this
pitfall.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9972
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
6 years agooss-fuzz: Fuzz miniflow APIs also.
Bhargava Shastry [Mon, 10 Sep 2018 13:14:02 +0000 (15:14 +0200)]
oss-fuzz: Fuzz miniflow APIs also.

This patch increases coverage of `lib/flow.c` from 39% to 43%, covers three
additional files and increases coverage in five other source/header files.

Signed-off-by: Bhargava Shastry <bshastry at sect.tu-berlin.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agolib/tc: reject offloading of non-Ethernet packets
Louis Peens [Wed, 5 Sep 2018 13:26:24 +0000 (15:26 +0200)]
lib/tc: reject offloading of non-Ethernet packets

When a packet is marked with the special ethtype of OFP_DL_TYPE_NOT_ETH_TYPE
it got wrongly installed into tc datapath as a match on a packet with that
ethtype. This prevents that from happening.

Signed-off-by: Louis Peens <louis.peens@netronome.com>
Reviewed-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
6 years agovswitch.xml: Better explain vlan-limit.
Ben Pfaff [Fri, 7 Sep 2018 17:39:18 +0000 (10:39 -0700)]
vswitch.xml: Better explain vlan-limit.

CC: Eric Garver <e@erig.me>
Requested-by: Jerry Lilijun <jerry.lilijun@huawei.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Eric Garver <e@erig.me>
6 years agonetdev-vport: reject concomitant incompatible tunnels
Eelco Chaudron [Mon, 3 Sep 2018 14:36:05 +0000 (14:36 +0000)]
netdev-vport: reject concomitant incompatible tunnels

This patch will make sure VXLAN tunnels with and without the group
based policy (GBP) option enabled can not coexist on the same
destination UDP port.

In theory, VXLAN tunnel with and without GBP enables can be
multiplexed on the same UDP port as long as different VNI's are
used. However currently OVS does not support this, hence this patch to
check for this condition.

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoossfuzz: Add parse_tcp_flags() to flow_extract_target.
Bhargava Shastry [Fri, 7 Sep 2018 12:03:01 +0000 (14:03 +0200)]
ossfuzz: Add parse_tcp_flags() to flow_extract_target.

This patch invokes parse_tcp_flags() in flow_extract_target.c after doing a
basic sanitization check (that packet contains at least an ETH header).

A cursory evaluation shows that the patch improves line coverage of
lib/flow.c from 37% to 39%.

Signed-off-by: Bhargava Shastry <bshastry at sect.tu-berlin.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agodhparams: Fix .c file generation with OpenSSL >= 1.1.1-pre9
Timothy Redaelli [Fri, 7 Sep 2018 13:14:53 +0000 (15:14 +0200)]
dhparams: Fix .c file generation with OpenSSL >= 1.1.1-pre9

Since OpenSSL upstream commit 201b305a2409
("apps/dsaparam.c generates code that is intended to be pasted or included into
an existing source file: the function is static, and the code doesn't include
dsa.h.  Match the generated C source style of dsaparam.") "openssl dhparam -C"
generates the get_dh functions as static, but the functions are used inside
stream-ssl.c and so the static keyword cannot be used.

This commit removes the static keyword from the get_dh functions during
dhparams.c file generation by restoring the current behaviour.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agodatapath: stt: Remove unused if statement in function stt_cleanup().
Yunjian Wang [Fri, 7 Sep 2018 10:21:04 +0000 (18:21 +0800)]
datapath: stt: Remove unused if statement in function stt_cleanup().

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
6 years agolib/tc: add single mpls match offload support
Pieter Jansen van Vuuren [Sun, 2 Sep 2018 13:07:49 +0000 (14:07 +0100)]
lib/tc: add single mpls match offload support

Add TC offload support for classifying single MPLS tagged traffic.

Signed-off-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Reviewed-by: John Hurley <john.hurley@netronome.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
6 years agolib/tc: Avoid matching on tunnel ttl or tos if not needed
Or Gerlitz [Thu, 6 Sep 2018 10:52:26 +0000 (13:52 +0300)]
lib/tc: Avoid matching on tunnel ttl or tos if not needed

The tunnel ttl key is not masked when provided to the tc lib, hence we
wrongly attempted to match on it, when we got non zero ttl key with a zero
mask. Fix it by applying the mask. Use the same practice for the tunnel tos.

Fixes: dd83253e117c ('lib/tc: Support matching on ip tunnel tos and ttl')
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reported-by: Eli Britstein <elibr@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
6 years agolib/tc: Put the tunnel match fields as part of the tc/flower key struct
Or Gerlitz [Thu, 6 Sep 2018 10:52:25 +0000 (13:52 +0300)]
lib/tc: Put the tunnel match fields as part of the tc/flower key struct

Move the tunnel match fields to be part of the tc/flower key structure.

This is pre-step for being able to apply masked match where needed.

Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
6 years agoovs-ctl: Allow add-remote without vswitchd started.
Darrell Ball [Thu, 6 Sep 2018 23:40:47 +0000 (16:40 -0700)]
ovs-ctl: Allow add-remote without vswitchd started.

'add_managers ()' is filtering add-remote if vswitchd is not started.
However, if we actually filter here we end up with a bricked system,
blackholing all traffic.  Allowing add_manager() to proceed may mean
extra churn in controllers in some cases, but this is far better than
the alternative of a bricked system.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agosystem-traffic: Fix conntrack per zone limit test.
Tiago Lam [Thu, 6 Sep 2018 13:18:40 +0000 (14:18 +0100)]
system-traffic: Fix conntrack per zone limit test.

Commit 3f1087c added a per zone limit test which relied on the
CHECK_CT_DPIF_FLUSH_BY_CT_TUPLE m4 macro to skip the test when executing
in a userspace datapath (since the per zone limit feature is not yet
implemented in userspace). That macro, however, has been removed in
commit 271e48a ("conntrack: Support conntrack flush by ct 5-tuple")
which was causing the test to fail when executing in userspace.

Instead, a new m4 macro, CHECK_CT_DPIF_PER_ZONE_LIMIT, is introduced to
make the same differentiation, until userspace doesn't support the per
zone limit.

CC: Yi-Hung Wei <yihung.wei@gmail.com>
Fixes: 3f1087c ("system-traffic: Add conntrack per zone limit test case")
Signed-off-by: Tiago Lam <tiago.lam@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
6 years agoovn: Detect and prevent duplicate address assignments.
Mark Michelson [Thu, 6 Sep 2018 20:01:38 +0000 (16:01 -0400)]
ovn: Detect and prevent duplicate address assignments.

This patch alters the 'ovn-nbctl lsp-set-addresses' command to check if
the IP addresses being added are duplicates of already-set IP addresses.
Test cases have been added for this detection.

This patch also adds a warning message to ovn-northd if duplicate IPv4
addresses are detected on a switch.

Signed-off-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoerspan: set erspan_ver to 1 by default when adding an erspan dev
Xin Long [Thu, 6 Sep 2018 21:38:34 +0000 (14:38 -0700)]
erspan: set erspan_ver to 1 by default when adding an erspan dev

Upstream commit:
    commit 84581bdae9587023cea1d139523f0ef0f28bd88d
    Author: Xin Long <lucien.xin@gmail.com>
    Date:   Mon Aug 27 18:41:32 2018 +0800

    erspan: set erspan_ver to 1 by default when adding an erspan dev

    After erspan_ver is introudced, if erspan_ver is not set in iproute, its
    value will be left 0 by default. Since Commit 02f99df1875c ("erspan: fix
    invalid erspan version."), it has broken the traffic due to the version
    check in erspan_xmit if users are not aware of 'erspan_ver' param, like
    using an old version of iproute.

    To fix this compatibility problem, it sets erspan_ver to 1 by default
    when adding an erspan dev in erspan_setup. Note that we can't do it in
    ipgre_netlink_parms, as this function is also used by ipgre_changelink.

Fixes: 02f99df1875c ("erspan: fix invalid erspan version.")
Reported-by: Jianlin Shi <jishi@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Fixes: 5e720da59d ("erspan: fix invalid erspan version.")
Cc: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovn.at: Skip ACL rate-limiting test on slow/overloaded systems.
Justin Pettit [Wed, 5 Sep 2018 23:51:09 +0000 (16:51 -0700)]
ovn.at: Skip ACL rate-limiting test on slow/overloaded systems.

In ACL rate-limiting test, we send three sets of 100 packets.  One of
the sets drops packets at a rate of 10 per second, one at a rate of 5
per second, and one not at all.  On my setup, it takes roughly 0.67
seconds to send those 300 packets, but we have reports of it taking over
15 seconds on others.  The test was intended to allow some flexibility
in run-time, but it's very difficult to design a mechanism that can all
possibilities.

To prevent false test failures, this patch changes the test to check
the duration count of the meter, and if it's greater than nine seconds,
just skip the test.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Reported-by: Thomas Goirand <zigo@debian.org>
6 years agodaemon-unix: Use same name for original or restarted children.
Ben Pfaff [Thu, 6 Sep 2018 17:44:47 +0000 (10:44 -0700)]
daemon-unix: Use same name for original or restarted children.

Linux has an idea of process name that is visible in /proc/$pid/comm.  This
is "ovs-vswitchd" for a freshly started ovs-vswitchd process.  When the
monitor code restarted a crash child, it changed it to the empty string.
This confused the daemon_is_running check in ovs-lib.in, which checks
comm.  This commit fixes the problem by setting the program name as comm
in newly restarted children.

VMware-BZ: #2191724
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Gurucharan Shetty <guru@ovn.org>
6 years agorhel: add 4.4 kernel in kmod build with mulitple versions, fedora
Martin Xu [Wed, 5 Sep 2018 16:25:37 +0000 (09:25 -0700)]
rhel: add 4.4 kernel in kmod build with mulitple versions, fedora

Extends 22c33c303932 (rhel: support kmod build against mulitple kernel
versions, fedora) to kernel version 4.4.x, x>=73 for SLES 12 SP3

Signed-off-by: Martin Xu <martinxu9.ovs@gmail.com>
CC: Greg Rose <gvrose8192@gmail.com>
CC: Markos Chandras <mchandras@suse.de>
CC: Ben Pfaff <blp@ovn.org>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Tested-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovs-macros: Make tests log how long they waited when they succeed.
Ben Pfaff [Tue, 4 Sep 2018 20:59:06 +0000 (13:59 -0700)]
ovs-macros: Make tests log how long they waited when they succeed.

Many OVS tests wait up for 10 seconds for a condition to become true.
Usually these conditions are ones that should take only a second or so to
actually become true in practice, but on a busy and slow machine it's
possible that some tests might fail or come close to failing because 10
seconds is simply not enough there.

This commit adds logging for the case where a condition actually succeeds
to indicate the amount of time that was waited.  This should make it easier
to identify whether we need to increase the maximum wait time from 10
seconds to something longer, by allowing us to see whether some of the
successful waits came close to timing out.

Reported-by: Thomas Goirand <zigo@debian.org>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-September/047340.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Thomas Goirand <zigo@debian.org>
6 years agorhel: allow passing more flags to configure, fedora
Martin Xu [Fri, 31 Aug 2018 18:52:42 +0000 (11:52 -0700)]
rhel: allow passing more flags to configure, fedora

Define a variable _ovs_config_extra_flags to allow passing more flags to
configure when building OVS kmod RPM. For example, to build with a
non-standard openssl and add an RPATH, use the following command

make rpm-fedora-kmod RPMBUILD_OPT='-D "_ovs_config_extra_flags
--with-openssl=<path to your openssl header> LDFLAGS=\"\${LDFLAGS} -Xlinker
-rpath=<path to your openssl lib>\""'

Signed-off-by: Martin Xu <martinxu9.ovs@gmail.com>
CC: Greg Rose <gvrose8192@gmail.com>
CC: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Reviewed-by: Markos Chandras <mchandras@suse.de>
6 years agorhel: use full path for /sbin/depmod
Martin Xu [Fri, 31 Aug 2018 18:52:40 +0000 (11:52 -0700)]
rhel: use full path for /sbin/depmod

Fixes: 22c33c303932 (rhel: support kmod build against mulitple kernel versions, fedora)
Fixes: c8cd1307b248 (rhel: support kmod build against multiple 7.2 kernels, rhel6)
Signed-off-by: Martin Xu <martinxu9.ovs@gmail.com>
CC: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
6 years agorhel: openvswitch-kmod-fedora.spec.in file bug fix
Martin Xu [Fri, 31 Aug 2018 18:52:39 +0000 (11:52 -0700)]
rhel: openvswitch-kmod-fedora.spec.in file bug fix

Patch 22c33c303932 used /usr/src/linux/<kernel version> as path of the
linux headers, which does not work for SLES. Use /lib/modules/<kernel
version>/build instead.

Fixes 22c33c303932 (rhel: support kmod build against mulitple kernel versions,
fedora)

Signed-off-by: Martin Xu <martinxu9.ovs@gmail.com>
CC: Greg Rose <gvrose8192@gmail.com>
CC: Markos Chandras <mchandras@suse.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Reviewed-by: Markos Chandras <mchandras@suse.de>
6 years agoossfuzz: Improve coverage of flow_extract_target
Bhargava Shastry [Wed, 5 Sep 2018 14:41:49 +0000 (16:41 +0200)]
ossfuzz: Improve coverage of flow_extract_target

This commit improves test coverage of the ossfuzz flow extract test harness
by extending the harness with additional API calls from lib/flow.c

An additional minor change is adding a config option to
flow_extract_target.options file in `tests/ossfuzz/config` to suppress
debug output while fuzzing.

A cursory evaluation shows that the patch covers 8 additional files and
improves line coverage of lib/flow.c from 23% to 37%.

Signed-off-by: Bhargava Shastry <bshastry at sect.tu-berlin.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agodpif-netdev: Prevent unsafe access when retrieving meter stats.
Justin Pettit [Wed, 29 Aug 2018 00:38:25 +0000 (17:38 -0700)]
dpif-netdev: Prevent unsafe access when retrieving meter stats.

dpif_netdev_meter_get() retrieved a pointer to a meter entry without
holding a lock.  It's possible that another thread could have deleted
that entry between retrieving the pointer and dereferencing the pointer.
This makes the function hold the lock the entire time the meter entry is
needed.

Found by inspection.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
6 years agodpif-netdev: Don't check if xcalloc() failed when creating meter.
Justin Pettit [Wed, 29 Aug 2018 00:28:28 +0000 (17:28 -0700)]
dpif-netdev: Don't check if xcalloc() failed when creating meter.

xcalloc() can't return null.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Ben Pfaff <blp@ovn.org>
6 years agocompat: Remove unused function
Greg Rose [Fri, 31 Aug 2018 17:26:47 +0000 (10:26 -0700)]
compat: Remove unused function

The compat function rpl_nf_conntrack_in() does not appear to be used
anywhere and emits warnings as such during builds < 4.10.

The patch passes Travis:

https://travis-ci.org/gvrose8192/ovs-experimental/builds/423097292

Remove it.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoutilities: Drop shebang from bash completion script
Markos Chandras [Tue, 28 Aug 2018 13:25:37 +0000 (14:25 +0100)]
utilities: Drop shebang from bash completion script

This fixes the following warning when building Open vSwitch on the
openSUSE Build Service:

  W: non-executable-script /usr/share/bash-completion/completions/ovs-appctl-bashcomp.bash
  This text file contains a shebang or is located in a path dedicated
  for executables, but lacks the executable bits and cannot thus be
  executed. If the file is meant to be an executable script, add the
  executable bits, otherwise remove the shebang or move the file
  elsewhere.

The file is meant to be sourced instead of executed, so we can simply
drop the shebang.

Signed-off-by: Markos Chandras <mchandras@suse.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agodatapath: Fix builds on older kernels.
Darrell Ball [Wed, 29 Aug 2018 02:54:01 +0000 (19:54 -0700)]
datapath: Fix builds on older kernels.

On older kernels, for example 3.19, the function rt6_get_cookie() is
not available and used with ipv6 config enabled;  it was introduced in
4.2.  Put back the replacement function if it does not exist.
Add a 3.19 version to travis.

CC: Yifeng Sun <pkusunyifeng@gmail.com>
Fixes: bf61b8b1c1db ("datapath: Add support for kernel 4.16.x & 4.17.x.")
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Yifeng Sun <pkusunyifeng@gmail.com>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
6 years agoofp-actions: Re-fix error path for parsing OpenFlow actions.
Ben Pfaff [Fri, 24 Aug 2018 21:50:14 +0000 (14:50 -0700)]
ofp-actions: Re-fix error path for parsing OpenFlow actions.

A previous commit attempted to fix the error path when the actions nested
within clone provoked an error.  However, this commit just introduced a new
problem in another case, since it made ofpacts_pull_openflow_actions__()
restore a previously valid pointer to data that might have been
reallocated.

This commit takes another approach.  Instead of trying to restore anything
at all, it just defines ofpacts_pull_openflow_actions__() to clear the
output buffer when there's an error.  It seems that this is less error
prone.  Most of the callers don't care; this commit fixes up the ones that
do.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9975
Fixes: 20cdd1dbd546 ("ofp-actions: Avoid assertion failure for clone(ct(...bad actions...)).")
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Yifeng Sun <pkusunyifeng@gmail.com>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
6 years agonx-match: Avoid double-free on some error paths.
Ben Pfaff [Fri, 24 Aug 2018 21:50:12 +0000 (14:50 -0700)]
nx-match: Avoid double-free on some error paths.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9966
Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9968
Fixes: f1eb32b9641c ("ofp-group: Fix memory leak in error cases parsing group requests.")
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
6 years agovswitch.xml: Fix key type and description style of tc-policy.
Ilya Maximets [Fri, 24 Aug 2018 15:13:19 +0000 (18:13 +0300)]
vswitch.xml: Fix key type and description style of tc-policy.

The set of supported values specified.
Style fixed to look good in man page. Fixed indents.

CC: Paul Blakey <paulb@mellanox.com>
Fixes: 691d20cbdcf3 ("other-config: Add tc-policy switch to
                      control tc flower flag")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
6 years agodebian: Move libovn out from package libopenvswitch.
Han Zhou [Sat, 25 Aug 2018 01:07:24 +0000 (18:07 -0700)]
debian: Move libovn out from package libopenvswitch.

Since we are packaging OVN and OVS components separately, libovn
shouldn't belong to OVS, so move it to ovn-common. Also, remove
it from libopenvswitch-dev.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: aginwala <aginwala@ebay.com>
6 years agodpif-netdev: Avoid reordering of packets in a batch with same megaflow
Vishal Deep Ajmera [Fri, 27 Jul 2018 18:26:37 +0000 (23:56 +0530)]
dpif-netdev: Avoid reordering of packets in a batch with same megaflow

OVS reads packets in batches from a given port and packets in the
batch are subjected to potentially 3 levels of lookups to identify
the datapath megaflow entry (or flow) associated with the packet.
Each megaflow entry has a dedicated buffer in which packets that match
the flow classification criteria are collected. This buffer helps OVS
perform batch processing for all packets associated with a given flow.

Each packet in the received batch is first subjected to lookup in the
Exact Match Cache (EMC). Each EMC entry will point to a flow. If the
EMC lookup is successful, the packet is moved from the rx batch to the
per-flow buffer.

Packets that did not match any EMC entry are rearranged in the rx batch
at the beginning and are now subjected to a lookup in the megaflow cache.
Packets that match a megaflow cache entry are *appended* to the per-flow
buffer.

Packets that do not match any megaflow entry are subjected to slow-path
processing through the upcall mechanism. This cannot change the order of
packets as by definition upcall processing is only done for packets
without matching megaflow entry.

The EMC entry match fields encompass all potentially significant header
fields, typically more than specified in the associated flow's match
criteria. Hence, multiple EMC entries can point to the same flow. Given
that per-flow batching happens at each lookup stage, packets belonging
to the same megaflow can get re-ordered because some packets match EMC
entries while others do not.

The following example can illustrate the issue better. Consider
following batch of packets (labelled P1 to P8) associated with a single
TCP connection and associated with a single flow. Let us assume that
packets with just the ACK bit set in TCP flags have been received in a
prior batch also and a corresponding EMC entry exists.

1. P1 (TCP Flag: ACK)
2. P2 (TCP Flag: ACK)
3. P3 (TCP Flag: ACK)
4. P4 (TCP Flag: ACK, PSH)
5. P5 (TCP Flag: ACK)
6. P6 (TCP Flag: ACK)
7. P7 (TCP Flag: ACK)
8. P8 (TCP Flag: ACK)

The megaflow classification criteria does not include TCP flags while
the EMC match criteria does. Thus, all packets other than P4 match
the existing EMC entry and are moved to the per-flow packet batch.
Subsequently, packet P4 is moved to the same per-flow packet batch as
a result of the megaflow lookup. Though the packets have all been
correctly classified as being associated with the same flow, the
packet order has not been preserved because of the per-flow batching
performed during the EMC lookup stage. This packet re-ordering has
performance implications for TCP applications.

This patch preserves the packet ordering by performing the per-flow
batching after both the EMC and megaflow lookups are complete. As an
optimization, packets are flow-batched in emc processing till any
packet in the batch has an EMC miss.

A new flow map is maintained to keep the original order of packet
along with flow information. Post fastpath processing, packets from
flow map are *appended* to per-flow buffer.

Signed-off-by: Vishal Deep Ajmera <vishal.deep.ajmera@ericsson.com>
Co-authored-by: Venkatesan Pradeep <venkatesan.pradeep@ericsson.com>
Signed-off-by: Venkatesan Pradeep <venkatesan.pradeep@ericsson.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
6 years agovswitch.xml: Fix type of dpdk-init key.
Ilya Maximets [Fri, 24 Aug 2018 15:18:01 +0000 (18:18 +0300)]
vswitch.xml: Fix type of dpdk-init key.

This adds available modes to the man page.

CC: Kevin Traynor <ktraynor@redhat.com>
Fixes: 6d947d508a51 ("vswitch.xml: Update dpdk-init documentation.")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
6 years agonetdev: Clean up class initialization.
Ben Pfaff [Wed, 15 Aug 2018 17:38:09 +0000 (10:38 -0700)]
netdev: Clean up class initialization.

The macros are hard to read.  This makes it a little more readable.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
6 years agonetdev-dpdk: Support the link speed of XL710
Xu Binbin [Mon, 13 Aug 2018 02:27:42 +0000 (10:27 +0800)]
netdev-dpdk: Support the link speed of XL710

In the scenario of XL710, the link speed which stored in the table
of Interface is not 40G. Because the implementation of query of link
speed only support to 10G, the parameter 'current' will be a random
value in the scenario of higher link speed. In this case, incorrect
link speed of XL710 nic will be stored in the database.

Signed-off-by: Xu Binbin <xu.binbin1@zte.com.cn>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
6 years agoofproto-dpif-trace: Make -generate send packets to controller again.
Ben Pfaff [Fri, 24 Aug 2018 19:25:39 +0000 (12:25 -0700)]
ofproto-dpif-trace: Make -generate send packets to controller again.

Prior to the OVS 2.9 development cycle, any flow that sent a packet to a
controller required that the flow be slow-pathed.  In some cases this led
to poor performance, so OVS 2.9 made controller actions fast-pathable.  As
a side effect of the change, "ovs-appctl ofproto/trace -generate" no longer
sent packets to the controller.  This usually didn't matter but it broke
the Faucet tutorial, which relied on this behavior.  This commit
reintroduces the original behavior and thus should fix the tutorial.

CC: Justin Pettit <jpettit@ovn.org>
Fixes: d39ec23de384 ("ofproto-dpif: Don't slow-path controller actions.")
Reported-by: macman31 <https://github.com/macman31>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/145
Reported-by: Brad Cowie <brad@cowie.nz>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-August/047234.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
6 years agoovn: Fix the issue in IPv6 Neigh Solicitation responder for router IPs
Numan Siddique [Fri, 24 Aug 2018 19:26:52 +0000 (00:56 +0530)]
ovn: Fix the issue in IPv6 Neigh Solicitation responder for router IPs

Commit [1] added a new action 'nd_na_router' to set the router bit
in the 'flags' field of the Neighbour Adv packet for router IPs.
This action was used in the router pipeline. But the logical switch
pipeline also adds the Neighbour Adv flows for router IPs but with
'nd_na' action (which the commit [1] didn't handle).

This patch fixes this by changing the action to 'nd_na_router' for
router IPs.

Without this patch, the IPv6 functionality is broken.

[1] - "c9756229ed: ovn: Set proper Neighbour Adv flag when replying
for NS request for router IP"

Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Han Zhou <hzhou8@ebay.com>
6 years agodpctl: Fix memory leak in dp_exists().
Yunjian Wang [Mon, 27 Aug 2018 11:52:55 +0000 (19:52 +0800)]
dpctl: Fix memory leak in dp_exists().

Fixes: ffdcd110fa62 ("dpctl: Make opt_dpif_open() more general.")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoofproto-dpif: Check for EBUSY as well
Greg Rose [Fri, 24 Aug 2018 20:36:29 +0000 (13:36 -0700)]
ofproto-dpif: Check for EBUSY as well

Guru reported that we can't create more than one geneve tunnel.
Sometimes a driver will return EBUSY as well as EEXIST for some
duplicate configurations.  Check for EBUSY too.

Fixes: 7521e0cf9e ("ofproto-dpif: Let the dpif report when a ...")
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-August/047214.html
Reported-by: Guru Shetty <guru@ovn.org>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agooss-fuzz: Move oss-fuzz test harnesses and fuzzer configs to ovs source repo
Bhargava Shastry [Tue, 21 Aug 2018 23:00:31 +0000 (16:00 -0700)]
oss-fuzz: Move oss-fuzz test harnesses and fuzzer configs to ovs source repo

Signed-off-by: Bhargava Shastry <bshastry@sec.t-labs.tu-berlin.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agosystem-tests: Extend tests of simulated packets to kernel 4.17.x
Yifeng Sun [Tue, 21 Aug 2018 14:42:09 +0000 (07:42 -0700)]
system-tests: Extend tests of simulated packets to kernel 4.17.x

GRE-related tests are skipped on ubuntu-18.04.1 because the
vanilla `ip` will fail to set dev's mac address. This bug
is described in this link:

https://bugzilla.redhat.com/show_bug.cgi?id=1550097

This patch enables GRE tests to run even if the buggy `ip`
is being used.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Tested-by: Greg Rose <gvrose8192@gmail.com>
6 years agodatapath: Add support for kernel 4.16.x & 4.17.x
Yifeng Sun [Tue, 21 Aug 2018 14:42:08 +0000 (07:42 -0700)]
datapath: Add support for kernel 4.16.x & 4.17.x

Add support for kernel version up to 4.17.x. On Travis, build passed
for all kernel versions. And no new test fails are introduced by this
patch.

Cleaned up file datapath/linux/compat/include/net/ip6_fib.h which
has no effect to kernel module but brings complexity to porting.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Tested-by: Greg Rose <gvrose8192@gmail.com>
6 years agotunnel, tests: Sort flow output in ERSPAN v1/v2 metadata
Alin Gabriel Serdean [Tue, 21 Aug 2018 14:18:06 +0000 (17:18 +0300)]
tunnel, tests: Sort flow output in ERSPAN v1/v2 metadata

Sort the flows by input port in the test:
tunnel.at:512: testing tunnel - ERSPAN v1/v2 metadata ...

This tests fails on Windows due to the hash function sensitivity described
in:
https://mail.openvswitch.org/pipermail/ovs-dev/2018-August/350685.html

Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
6 years agoerspan: add big endian bit fields.
William Tu [Tue, 21 Aug 2018 23:03:14 +0000 (16:03 -0700)]
erspan: add big endian bit fields.

Big-endian systems arrange bit fields in the opposite order.
The patch follows the linux kernel's approach by defining the
big and little endian bit-field of ERSPAN header using #ifdef.

Tested on zelenka.debian.org
(https://db.debian.org/machines.cgi?host=zelenka).

Tested-by: Ben Pfaff <blp@ovn.org>
Reported-by: James Page <james.page@canonical.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2018-August/351382.html
Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agotests: Fix hash function dependencies in "tunnel - ERSPAN v1/v2 metadata".
Ben Pfaff [Tue, 21 Aug 2018 16:22:03 +0000 (09:22 -0700)]
tests: Fix hash function dependencies in "tunnel - ERSPAN v1/v2 metadata".

This test only worked if each OpenFlow port was assigned a particular
datapath port number: p1 to port 3, p2 to port 2, p3 and p4 to port 1.
This happened consistently on little-endian architectures because of the
use of a particular hash function, but on big-endian architectures it
failed because the hash function was different.

This commit fixes the problem by adding the non-dummy ports separately.
(Dummy ports try to take the datapath port number corresponding to their
name, when it is available.)  This does result in swapping a couple of
datapaths port numbers, so that p1 has port 1, p2 has port 2, and the
erspan ports have port 3, hence the size of the patch.

Reported-by: James Page <james.page@canonical.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2018-August/351382.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
6 years agoovn-ctl: allow configuring user:group for daemons
Aaron Conole [Wed, 8 Aug 2018 14:36:10 +0000 (10:36 -0400)]
ovn-ctl: allow configuring user:group for daemons

Add two options, one for controlling the ovs daemon user/group, and the
other for controlling the ovn daemon user/group.  This allows a fine-grained
split between OVN and OVS daemons, and keeps the syntax and user/group
separation from ovs-ctl when running ovn-ctl.

Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agorhel: support kmod build against mulitple kernel versions, fedora
Martin Xu [Mon, 20 Aug 2018 21:24:05 +0000 (14:24 -0700)]
rhel: support kmod build against mulitple kernel versions, fedora

This patch ports changes from kmod rhel6 spec file to fedora spec file,
to support packaging kernel modules built against multiple versions of
kernel sources.

RHEL 7.4 introduced backward incompatible changes in the kernel. As
a result, prebuilt PRM packages against kernels newer than 693.17.1
will cannot be used on systems with older kernels, vice versa.

Intended to work only on RHEL 7.4 (kernel version 3.10.0-693.yy.zz).
This patch allows multiple kernel version numbers delimited by
whitespace to be passed as variable "kversion". The result RPM packages
the kernel module .ko files from all specified kernel versions. For
example,

make rpm-fedora-kmod \
    RPMBUILD_OPT='-D "kversion 3.10.0-693.1.1.el7.x86_64 \
    3.10.0-693.17.1.el7.x86_64"'

By default, make tries to build against the current running kernel.

This patch also includes a script to update the weak-update symlinks
if the system kernel version is upgraded or downgraded after
openvswitch-kmod is installed.

Signed-off-by: Martin Xu <martinxu9.ovs@gmail.com>
CC: Greg Rose <gvrose8192@gmail.com>
CC: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Flavio Leitner <fbl@redhat.com>
6 years agoovn-northd: Support learning neighbor from ARP request.
Han Zhou [Mon, 20 Aug 2018 05:27:31 +0000 (22:27 -0700)]
ovn-northd: Support learning neighbor from ARP request.

Current LR dynamic ARP learning support only ARP responses. If a
IP-MAC binding is learned, it will not get updated even if a host
send a GARP *request* to inform the new binding. This patch supports
learning neighbor changes from ARP requests, including GARP requests.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovn-northd: LR respond ARP from valid subnet only.
Han Zhou [Mon, 20 Aug 2018 05:27:30 +0000 (22:27 -0700)]
ovn-northd: LR respond ARP from valid subnet only.

Currently ovn LR datapath responds ARP requests even if the ARP
requestor's src IP doesn't belong to the LR port's subnets. This
may generate unnecessary ARP responses and there could also be
security concerns. This patch restricts the ARP response only if
the requestor's IP matches the LR port's subnets.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovn: Add DHCP support for option 252.
Mark Michelson [Mon, 20 Aug 2018 20:14:00 +0000 (16:14 -0400)]
ovn: Add DHCP support for option 252.

This adds DHCP support for web proxy auto detection.

Signed-off-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Numan Siddique <nusiddiq@redhat.com>
6 years agosocket-util: Rate limit logs for bind attempts.
Ben Pfaff [Mon, 20 Aug 2018 23:08:09 +0000 (16:08 -0700)]
socket-util: Rate limit logs for bind attempts.

This reduces the amount of logging when higher-level code retries binding
ports that are in use.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
6 years agonetdev-linux: Avoid division by 0 if kernel reports bad scheduler data.
Ben Pfaff [Sat, 18 Aug 2018 17:17:37 +0000 (10:17 -0700)]
netdev-linux: Avoid division by 0 if kernel reports bad scheduler data.

If the kernel reported a value of 0 for the second value in
/proc/net/psched, it would cause a division-by-zero fault in
read_psched().  I don't know of a kernel that would actually do that, but
it's still better to be safe.

Found by clang static analyzer.

Reported-by: Bhargava Shastry <bshastry@sect.tu-berlin.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
6 years agoovsdb-idl: Fix recently introduced Python 3 tests.
Ben Pfaff [Sat, 18 Aug 2018 22:11:19 +0000 (15:11 -0700)]
ovsdb-idl: Fix recently introduced Python 3 tests.

CC: Numan Siddique <nusiddiq@redhat.com>
Fixes: c1aa16d191d2 ("ovs python: ovs.stream.open_block() returns success even if the remote is unreachable")
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2018-August/351311.html
Reported-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
6 years agoofp-group: Fix memory leak in error cases parsing group requests.
Ben Pfaff [Fri, 10 Aug 2018 19:42:31 +0000 (12:42 -0700)]
ofp-group: Fix memory leak in error cases parsing group requests.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9424#c4
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovsdb-client: Make "wait" command logging more sensible.
Ben Pfaff [Mon, 6 Aug 2018 21:36:34 +0000 (14:36 -0700)]
ovsdb-client: Make "wait" command logging more sensible.

The "wait" command in ovsdb-client (which was introduced as part of the
clustering support) fairly often logs things that are normal for it but
in other circumstances might be cause for concern, for example messages
about being unable to connect to a remote.  Until now, it has tried to
suppress some of those itself by raising log levels.  Unfortunately, in
some cases this had the opposite effect because it overrode any settings on
the command line, such as an attempt in ovsdb-cluster.at to suppress all
logging related to the timeval module.  This commit drops the special
log levels from the "wait" command and puts equivalents into the tests
themselves.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
6 years agoofp-port: Fix null dereference parsing Intel custom statistics.
Ben Pfaff [Fri, 10 Aug 2018 19:30:40 +0000 (12:30 -0700)]
ofp-port: Fix null dereference parsing Intel custom statistics.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9788
Fixes: 7333c3b1ce02 ("ofp-port: Fix buffer overread parsing Intel custom statistics.")
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoofp-actions: Avoid assertion failure for clone(ct(...bad actions...)).
Ben Pfaff [Wed, 15 Aug 2018 21:57:13 +0000 (14:57 -0700)]
ofp-actions: Avoid assertion failure for clone(ct(...bad actions...)).

decode_NXAST_RAW_CT() temporarily pulls data off the beginning of its
ofpacts output ofpbuf and, on its error path, fails to push it back on.
At a higher layer, decode_NXAST_RAW_CLONE() asserts, via
ofpact_finish_CLONE(), that the ofpact_clone that it put is still in the
place where it put it, which causes an assertion failure.

The root cause here is the failure to re-push the clone header.  One could
fix that, but it would be pretty easy for that to go wrong again on some
other obscure error path.  Instead, this commit just makes the problem go
away by always saving and restoring 'ofpact->data' if a decode fails.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9862
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
6 years agodpif-netlink: Prevent abort in probe_broken_meters().
Justin Pettit [Fri, 17 Aug 2018 19:48:54 +0000 (12:48 -0700)]
dpif-netlink: Prevent abort in probe_broken_meters().

Commit 92d0d515d ("dpif-netlink: Probe for broken Linux meter
implementations.") introduced a deadlock on the 'once' structure
declared in probe_broken_meters() with the following callstack:

        probe_broken_meters()
        probe_broken_meters__()
        dpif_netlink_meter_set()
        probe_broken_meters()

This commit introduce a modified version of dpif_netlink_meter_set()
that sets a meter without calling the probe.

Reported-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
6 years agosystem-traffic: Add conntrack per zone limit test case
Yi-Hung Wei [Fri, 17 Aug 2018 09:05:12 +0000 (02:05 -0700)]
system-traffic: Add conntrack per zone limit test case

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
6 years agodpctl: Implement dpctl commands for conntrack per zone limit
Yi-Hung Wei [Fri, 17 Aug 2018 09:05:11 +0000 (02:05 -0700)]
dpctl: Implement dpctl commands for conntrack per zone limit

This patch implments the following three commands on dpctl so that
users can use ovs-dpctl or ovs-appctl to set, delete, and get the
per zone limit.

For example,

$ ovs-appctl dpctl/ct-set-limits default=10 zone=0,limit=5 zone=1,limit=3
$ ovs-appctl dpct/ct-del-limits zone=0
$ ovs-appctl dpct/ct-get-limits zone=1,2,3

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
6 years agodpctl: Export next argument to be parsed in opt_dpif_open().
Yi-Hung Wei [Fri, 17 Aug 2018 09:05:10 +0000 (02:05 -0700)]
dpctl: Export next argument to be parsed in opt_dpif_open().

Make opt_dpif_open() to export the next argument to be parsed
in opt_dpif_open().  It will be useful for the following patches.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
6 years agodpif-netlink: Implement conntrack zone limit
Yi-Hung Wei [Fri, 17 Aug 2018 09:05:09 +0000 (02:05 -0700)]
dpif-netlink: Implement conntrack zone limit

This patch provides the implementation of conntrack zone limit
in dpif-netlink.  It basically utilizes the netlink API to
communicate with OVS kernel module to set, delete, and get conntrack
zone limit.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
6 years agoct-dpif: Helper functions for conntrack zone limit
Yi-Hung Wei [Fri, 17 Aug 2018 09:05:08 +0000 (02:05 -0700)]
ct-dpif: Helper functions for conntrack zone limit

This patch implments some helper function for conntrack zone limit.
It will be useful for the following patches.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
6 years agodpif: Support conntrack zone limit.
Yi-Hung Wei [Fri, 17 Aug 2018 09:05:07 +0000 (02:05 -0700)]
dpif: Support conntrack zone limit.

This patch defines the dpif interface to support conntrack
per zone limit.  Basically, OVS users can use this interface
to set, delete, and get the conntrack per zone limit for various
dpif interfaces.  The following patch will make use of the proposed
interface to implement the feature.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
6 years agodatapath: conntrack: Support conntrack zone limit
Yi-Hung Wei [Fri, 17 Aug 2018 09:05:06 +0000 (02:05 -0700)]
datapath: conntrack: Support conntrack zone limit

Upstream commit:
    commit 11efd5cb04a184eea4f57b68ea63dddd463158d1
    Author: Yi-Hung Wei <yihung.wei@gmail.com>
    Date:   Thu May 24 17:56:43 2018 -0700

    openvswitch: Support conntrack zone limit

    Currently, nf_conntrack_max is used to limit the maximum number of
    conntrack entries in the conntrack table for every network namespace.
    For the VMs and containers that reside in the same namespace,
    they share the same conntrack table, and the total # of conntrack entries
    for all the VMs and containers are limited by nf_conntrack_max.  In this
    case, if one of the VM/container abuses the usage the conntrack entries,
    it blocks the others from committing valid conntrack entries into the
    conntrack table.  Even if we can possibly put the VM in different network
    namespace, the current nf_conntrack_max configuration is kind of rigid
    that we cannot limit different VM/container to have different # conntrack
    entries.

    To address the aforementioned issue, this patch proposes to have a
    fine-grained mechanism that could further limit the # of conntrack entries
    per-zone.  For example, we can designate different zone to different VM,
    and set conntrack limit to each zone.  By providing this isolation, a
    mis-behaved VM only consumes the conntrack entries in its own zone, and
    it will not influence other well-behaved VMs.  Moreover, the users can
    set various conntrack limit to different zone based on their preference.

    The proposed implementation utilizes Netfilter's nf_conncount backend
    to count the number of connections in a particular zone.  If the number of
    connection is above a configured limitation, ovs will return ENOMEM to the
    userspace.  If userspace does not configure the zone limit, the limit
    defaults to zero that is no limitation, which is backward compatible to
    the behavior without this patch.

    The following high leve APIs are provided to the userspace:
      - OVS_CT_LIMIT_CMD_SET:
        * set default connection limit for all zones
        * set the connection limit for a particular zone
      - OVS_CT_LIMIT_CMD_DEL:
        * remove the connection limit for a particular zone
      - OVS_CT_LIMIT_CMD_GET:
        * get the default connection limit for all zones
        * get the connection limit for a particular zone

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
6 years agodatapath: Add conntrack limit netlink definition
Yi-Hung Wei [Fri, 17 Aug 2018 09:05:05 +0000 (02:05 -0700)]
datapath: Add conntrack limit netlink definition

Upstream commit:
    commit 5972be6b2495c6bffbf444497517fd1c070eef78
    Author: Yi-Hung Wei <yihung.wei@gmail.com>
    Date:   Thu May 24 17:56:42 2018 -0700

    openvswitch: Add conntrack limit netlink definition

    Define netlink messages and attributes to support user kernel
    communication that uses the conntrack limit feature.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
6 years agodatapath: compat: Introduce static key support
Yi-Hung Wei [Fri, 17 Aug 2018 09:05:04 +0000 (02:05 -0700)]
datapath: compat: Introduce static key support

Static keys allow the inclusion of seldom used features in
performance-sensitive fast-path kernel code, via a GCC feature and a
code patching technique. For more information:
    * https://www.kernel.org/doc/Documentation/static-keys.txt

Since upstream ovs kernel module now uses some static key API that was
introduced in v4.3 kernel, we shall backport them to the compat module
for older kernel supprots.

This backport is based on upstream net-next commit 11276d5306b8
("locking/static_keys: Add a new static_key interface").

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
6 years agodatapath: compat: Backports nf_conncount
Yi-Hung Wei [Fri, 17 Aug 2018 09:05:03 +0000 (02:05 -0700)]
datapath: compat: Backports nf_conncount

This patch backports the nf_conncount backend that counts the number
of connections matching an arbitrary key.  The following patch will
use the feature to support connection tracking zone limit in ovs
kernel datapath.

This backport is based on an upstream net-next upstream commits.
5c789e131cbb ("netfilter: nf_conncount: Add list lock and gc worker, and RCU for init tree search")
34848d5c896e ("netfilter: nf_conncount: Split insert and traversal")
2ba39118c10a ("netfilter: nf_conncount: Move locking into count_tree()")
976afca1ceba ("netfilter: nf_conncount: Early exit in nf_conncount_lookup() and cleanup")
cb2b36f5a97d ("netfilter: nf_conncount: Switch to plain list")
2a406e8ac7c3 ("netfilter: nf_conncount: Early exit for garbage collection")
b36e4523d4d5 ("netfilter: nf_conncount: fix garbage collection confirm race")
21ba8847f857 ("netfilter: nf_conncount: Fix garbage collection with zones")
5e5cbc7b23ea ("netfilter: nf_conncount: expose connection list interface")
35d8deb80c30 ("netfilter: conncount: Support count only use case")
6aec208786c2 ("netfilter: Refactor nf_conncount")
d384e65f1e75 ("netfilter: return booleans instead of integers")
625c556118f3 ("netfilter: connlimit: split xt_connlimit into front and backend")

The upstream nf_conncount has a couple of export functions while
this patch only export the ones that ovs kernel module needs.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
6 years agocompat: Backport nf_ct_netns_{get, put}()
Yi-Hung Wei [Fri, 17 Aug 2018 09:05:02 +0000 (02:05 -0700)]
compat: Backport nf_ct_netns_{get, put}()

This patch backports nf_ct_netns_get/put() in order to support a feature
in the follow up patch.

nf_ct_netns_{get,put} were first introduced in upstream net-next commit
ecb2421b5ddf ("netfilter: add and use nf_ct_netns_get/put") in kernel
v4.10, and then updated in commmit 7e35ec0e8044 ("netfilter: conntrack:
move nf_ct_netns_{get,put}() to core") in kernel v4.15.  We need to
invoke nf_ct_netns_get/put() when the underlying nf_conntrack_l3proto
supports net_ns_{get,put}().

Therefore, there are 3 cases that we need to consider.
1) Before nf_ct_{get,put}() is introduced.
    We just mock nf_ct_nets_{get,put}() and do nothing.

2) After 1) and before v4.15
    Backports based on commit 7e35ec0e8044 .

3) Staring from v4.15
    Use the upstream version.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
6 years agoporting: Add fixes to support kernel 4.15.x
Yifeng Sun [Thu, 16 Aug 2018 16:52:55 +0000 (09:52 -0700)]
porting: Add fixes to support kernel 4.15.x

This patch enables OVS kernel module to run on kernel 4.15.x.
Two conntrack-related tests failed:
 - conntrack - multiple zones, local
 - conntrack - multi-stage pipeline, local
This might be due to conntrack policy changes for packets coming
from local ports on kernel 4.15. More survey will be done later.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Co-authored-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Gregory Rose <gvrose8192@gmail.com>
Reviewed-by: Gregory Rose <gvrose8192@gmail.com>
6 years agoofp-ed-props: Fix hang for crafted OpenFlow encap/decap properties.
Ben Pfaff [Wed, 15 Aug 2018 22:03:43 +0000 (15:03 -0700)]
ofp-ed-props: Fix hang for crafted OpenFlow encap/decap properties.

decode_ed_prop() accepted encap/decap properties with a reported length of
0, without consuming any data from the property list, which yielded an
infinite loop.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9918
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Darrell Ball<dlu998@gmail.com>
6 years agodns-resolve: Fix a bug that frees node inside HMAP_FOR_EACH
Yifeng Sun [Thu, 16 Aug 2018 12:28:26 +0000 (05:28 -0700)]
dns-resolve: Fix a bug that frees node inside HMAP_FOR_EACH

HMAP_FOR_EACH_SAFE should be used when node is freed inside.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovsdb-idl: Adjust indexes during transactions.
Ben Pfaff [Tue, 14 Aug 2018 18:31:46 +0000 (11:31 -0700)]
ovsdb-idl: Adjust indexes during transactions.

When transactions modified tables with indexes, the indexes were not
properly updated to reflect the changes.  For deleted rows, in particular,
this could cause use-after-free errors.

This commit fixes the problem and adds some simple test cases provided by
Han Zhou that, without the fix, cause a crash.

Reported-by: Han Zhou <zhouhan@gmail.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-August/047185.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agodpif-netlink: Probe for broken Linux meter implementations.
Justin Pettit [Thu, 9 Aug 2018 00:31:17 +0000 (17:31 -0700)]
dpif-netlink: Probe for broken Linux meter implementations.

Meter support was introduced in Linux 4.15.  In some versions of Linux
4.15, 4.16, and 4.17, there was a bug that never set the id when the
meter was created, so all meters essentially had an id of zero.  This
commit adds a probe to check for that condition and disable meters on
those kernels.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
6 years agodpif: Don't pass in '*meter_id' to meter_set commands.
Justin Pettit [Wed, 8 Aug 2018 02:51:26 +0000 (19:51 -0700)]
dpif: Don't pass in '*meter_id' to meter_set commands.

The original intent of the API appears to be that the underlying DPIF
implementaion would choose a local meter id.  However, neither of the
existing datapath meter implementations (userspace or Linux) implemented
that; they expected a valid meter id to be passed in, otherwise they
returned an error.  This commit follows the existing implementations and
makes the API somewhat cleaner.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
6 years agocheckpatch: support macro continuation
Bala Sankaran [Thu, 16 Aug 2018 15:56:46 +0000 (11:56 -0400)]
checkpatch: support macro continuation

Added a test to identify a macro and skip
printing errors if the condition or loop
is part of a macro.

Additional tests are added to checkpatch
testsuite that cover conditionals and
loop constructs.

Signed-off-by: Bala Sankaran <bsankara@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agosystem-traffic: Add 5 new tunnel tests that don't need native linux modules
Yifeng Sun [Wed, 15 Aug 2018 13:24:50 +0000 (06:24 -0700)]
system-traffic: Add 5 new tunnel tests that don't need native linux modules

Introduce 5 new tests that don't require native gre or erspan tunnels but
sends simulated raw packets.

These tests are supposed to only run for kernel version from 3.10.x to 4.15.x
where compatible gre is being used by OVS kernel module.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Greg Rose <gvrose8192@gmail.com>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
6 years agosystem-traffic: Skip 5 tunnel tests on certain kernel versions
Yifeng Sun [Wed, 15 Aug 2018 13:24:49 +0000 (06:24 -0700)]
system-traffic: Skip 5 tunnel tests on certain kernel versions

Skip gre, erspan and ip6erspan related tests on kernel version from 3.10.x
to 4.15.x because compatible gre is used and these tests will always fail.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Greg Rose <gvrose8192@gmail.com>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
6 years agotests: Add two m4 functions to skip tests for certain kernel versions
Yifeng Sun [Wed, 15 Aug 2018 13:24:48 +0000 (06:24 -0700)]
tests: Add two m4 functions to skip tests for certain kernel versions

Some tests depend on native Linux gre modules to setup testing environments.
However, some kernel versions require OVS to use compatible gre modules. In
this case, these tests always fail.

This patch helps to skip a test if it fails due to this reason. The new m4
functions will be used by later patches.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Greg Rose <gvrose8192@gmail.com>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
6 years agoip6_gre: Fix a bug that clears address bits
Yifeng Sun [Wed, 15 Aug 2018 13:24:47 +0000 (06:24 -0700)]
ip6_gre: Fix a bug that clears address bits

In compatible gre module, skb->cb is solely used as ovs_gso_cb.
However, IPCB(skb) also points to skb->cb. IPCB(skb)->flags overlaps
with ovs_gso_cb.tun_dst. As a result, this bug clears the 16-23 bit
in the address of ovs_gso_cb.tun_dst and causes kernel to crash.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Greg Rose <gvrose8192@gmail.com>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
6 years agoovn-nbctl test: Add different search string for getopt BSD variant
Alin Gabriel Serdean [Thu, 16 Aug 2018 16:31:39 +0000 (19:31 +0300)]
ovn-nbctl test: Add different search string for getopt BSD variant

2714. ovn-nbctl.at:1443: testing ovn-nbctl - commands parser error paths

fails due to:
ovn-nbctl.at:1443: ovn-nbctl --if-exists=foo list Logical_Switch
stderr:
ovn-nbctl: option '--if-exists=foo' requires an argument
./ovn-nbctl.at:1443: grep 'option .* doesn'\''t allow an argument' stderr
stdout:
./ovn-nbctl.at:1443: exit code was 1, expected 0

This is due to the difference between getopt BSD and GNU variant.

Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
6 years agodpctl: Make opt_dpif_open() more general.
Darrell Ball [Fri, 10 Aug 2018 15:56:17 +0000 (08:56 -0700)]
dpctl: Make opt_dpif_open() more general.

By making opt_dpif_open() more general, it can be used effectively
by all potential callers and avoids trying to open potentially bogus
datapaths provided by the user. Also, the error handling is improved by
reducing bogus errors and having more specific real errors.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agonetdev: Retry getting interfaces on inconsistent dumps from kernel
Daniel Alvarez [Mon, 13 Aug 2018 12:07:45 +0000 (14:07 +0200)]
netdev: Retry getting interfaces on inconsistent dumps from kernel

This patch in glibc [0] is fixing a bug where we may be getting
inconsistent dumps from the kernel when listing interfaces due to
a race condition.

This could happen if we try to retrieve them while interfaces are
being added/removed from the system at the same time.
For systems running against old glibc versions, this patch is retrying
the operation up to 3 times and then proceeding by logging a
warning.

Note that 3 times should be enough to not delay the operation much
and since it's unlikely that we hit the race condition 3 times in
a row. Still, if this happened, this patch is not changing the
current behavior.

[0] https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c1f86a33ca32e26a9d6e29fc961e5ecb5e2e5eb4

Signed-off-by: Daniel Alvarez <dalvarez@redhat.com>
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Co-authored-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoip_tunnel: Fix bugs that could crash kernel
Yifeng Sun [Fri, 20 Jul 2018 18:04:42 +0000 (11:04 -0700)]
ip_tunnel: Fix bugs that could crash kernel

Without this patch, OVS kernel module can delete itn->fb_tunnel_dev
one more time than necessary, which causes kernel crash.

On kernel 4.4.0-116-generic, the crash can be reproduced by running
the simple test provided below through check-kernel.

  make & make modules_install
  rmmod ip_gre gre ip_tunnel
  modprobe openvswitch
  make check-kernel TESTSUITEFLAGS=x
  dmesg

Simple test:

AT_SETUP([datapath - crash test])
OVS_CHECK_GRE()
ip link del gre0
OVS_TRAFFIC_VSWITCHD_START()
AT_CHECK([ovs-vsctl -- set bridge br0])
ADD_BR([br-underlay], [set bridge br-underlay])
AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"])
AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"])
ADD_NAMESPACES(at_ns0)
ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24")
AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"])
AT_CHECK([ip link set dev br-underlay up])
ADD_OVS_TUNNEL([gre], [br0], [at_gre0], [172.31.1.1], [10.1.1.100/24])
tcpdump -U -i br-underlay -w underlay.pcap &
sleep 1
OVS_TRAFFIC_VSWITCHD_STOP
AT_CLEANUP

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
6 years agoofproto-dpif-upcall: Fix for flow limit issue in revalidator
Vishal Deep Ajmera [Fri, 3 Aug 2018 00:34:23 +0000 (06:04 +0530)]
ofproto-dpif-upcall: Fix for flow limit issue in revalidator

When the revalidator thread takes a long time to dump data path
flows (e.g. due to busy CPU), it reduces the maximum limit for
new flows that can be added. This results in more upcalls for
packets which do not find data path flows and temporarily reduces
overall throughput. When the situation improves and the revalidator
gets enough CPU cycles, it should increase the flow limit allowing
more flows to get inserted.

Currently the flow limit does not increase if the existing number of
flows is less than 2000 and does not allow any new flows due to
incorrect condition check. This results in a permanent drop in
performance in OVS with no automatic recovery.

This patch fixes the conditional check for increasing flow limit.

Signed-off-by: Vishal Deep Ajmera <vishal.deep.ajmera@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agotests: Drop setting aliases for control utils.
Ilya Maximets [Tue, 14 Aug 2018 07:53:17 +0000 (10:53 +0300)]
tests: Drop setting aliases for control utils.

Not needed anymore. 'OVS_CTL_TIMEOUT' env used instead.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agotests: Use environment variable for default timeout.
Ilya Maximets [Tue, 14 Aug 2018 07:53:16 +0000 (10:53 +0300)]
tests: Use environment variable for default timeout.

Introduce new 'OVS_CTL_TIMEOUT' environment variable
that, if set, will be used as a default timeout for
OVS control utilities. Setting it in 'atlocal.in' will
cover all the hangs inside the testsuite, even when
utils called in a subshell.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoutilities: Fix and unify parsing of timeout option.
Ilya Maximets [Tue, 14 Aug 2018 07:53:15 +0000 (10:53 +0300)]
utilities: Fix and unify parsing of timeout option.

Parsing of the '--timeout' option implemented differently
for every single control utility and, which is more
important, highly inaccurate. In most cases unsigned result
of 'strtoul' stored in signed variable. Parsing failures are
not tracked. 'ovs-appctl' even uses just 'atoi' without any
checking of the argument or result.

This patch unifies the parsing by using 'str_to_uint'.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agotest-unixctl.py: Don't suppress exceptions.
Ben Pfaff [Fri, 15 Jun 2018 22:11:10 +0000 (15:11 -0700)]
test-unixctl.py: Don't suppress exceptions.

A user reported a failure of test 2364 "vlog - RFC5424 facility - Python2"
with an exit code that says that the test-unixctl process died from an
uncaught exception.  Unfortunately the exception didn't show up in the log.
This commit should make the exception show up (it deletes some boilerplate
we use in our Python-based daemons to make them restart themselves on
failure, which isn't needed or appropriate for a test script).

Reported-by: Sanket Sudake <sanket@infracloud.io>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-May/046840.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Numan Siddique <nusiddiq@redhat.com>
6 years agoovsdb-server: Don't log closing session at program termination.
Ben Pfaff [Fri, 15 Jun 2018 22:11:09 +0000 (15:11 -0700)]
ovsdb-server: Don't log closing session at program termination.

When ovsdb-server closes a remote connection, it logs a message about it
that includes the reason.  Until now this has included sessions that it
closes when it exits.  That meant that, when --run was used, there was a
race between noticing that the subprocess exited and noticing that the
session that that subprocess (presumably) had open had been closed.  If
it noticed the latter first, nothing was logged (because it didn't log
anything if a session was closed in the ordinary way by the client).  If
it noticed the former first, it logged a message about closing the session
itself.

This is a benign race that causes no real problems--except that the tests
didn't expect to see the log message from the former case and fail with
errors like the following:

    1826. ovsdb-server.at:92: testing truncating database log with bad transaction ...
    ./ovsdb-server.at:96: ovsdb-tool create db schema
    stderr:
    stdout:
    ./ovsdb-server.at:104: ovsdb-server --remote=punix:socket db --run="sh txnfile"
    --- /dev/null   2018-04-24 08:50:58.769000000 +0000
    +++ /root/openvswitch-2.9.2/rpm/rpmbuild/BUILD/openvswitch-2.9.2/tests/testsuite.dir/at-groups/1826/stderr      2018-05-29 14:29:56.529257295 +0000
    @@ -0,0 +1,2 @@
    +2018-05-29T14:29:56Z|00001|ovsdb_jsonrpc_server|INFO|unix#0: disconnecting (removing ordinals database due to server termination)
    +2018-05-29T14:29:56Z|00002|ovsdb_jsonrpc_server|INFO|unix#0: disconnecting (removing _Server database due to server termination)

This fixes the race.  This particular log message isn't too useful since
it's pretty obvious that ovsdb-server is closing those sessions, since
after all it's exiting!

Reported-by: Sanket Sudake <sanket@infracloud.io>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-May/046840.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Numan Siddique <nusiddiq@redhat.com>
6 years agoconfigure: Enable GCC relevant new 8.x warning options.
Ben Pfaff [Thu, 14 Jun 2018 21:49:23 +0000 (14:49 -0700)]
configure: Enable GCC relevant new 8.x warning options.

These don't trigger any new actual warnings in my own build.

GCC 8.x adds other new warning options that are enabled by -Wall or
-Wextra.  This commit doesn't explicitly enable those because OVS already
enables -Wall and -Wextra.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@bytheb.org>
6 years agoofproto: Fix coredump in ofproto_destroy__().
liucheng (J) [Tue, 14 Aug 2018 04:08:27 +0000 (04:08 +0000)]
ofproto: Fix coredump in ofproto_destroy__().

There is a coredump when I add and delete bridges. When the rcu thread call
ofproto_destroy__, the main thread may call ofproto_create. But the
ofproto_destroy__ fun doesn't have the ofproto_mutex when access the
all_ofprotos.

 #0  0x00007f824aa0d197 in raise () from /usr/lib64/libc.so.6
 #1  0x00007f824aa0e888 in abort () from /usr/lib64/libc.so.6
 #2  0x0000000000658249 in PAT_abort ()
 #3  0x000000000065538d in patchIllInsHandler ()
 #4  <signal handler called>
 #5  0x0000000000478a5b in hmap_remove (node=0x3320150, hmap=0x95fc40 <all_ofprotos>) at include/openvswitch/hmap.h:287
 #6  ofproto_destroy__ (ofproto=0x3320150) at ofproto/ofproto.c:1642
 #7  0x0000000000535e46 in ovsrcu_call_postponed () at lib/ovs_rcu.c:323
 #8  0x0000000000536014 in ovsrcu_postpone_thread (arg=<optimized out>) at lib/ovs_rcu.c:338
 #9  0x0000000000538488 in ovsthread_wrapper (aux_=<optimized out>) at lib/ovs_thread.c:682
 #10 0x00007f824c130dc5 in start_thread () from /usr/lib64/libpthread.so.0
 #11 0x00007f824aacf7bd in clone () from /usr/lib64/libc.so.6

Signed-off-by: Cheng Liu <liucheng11@huawei.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovsdb-idl: Track changes for table references.
Han Zhou [Mon, 13 Aug 2018 17:48:03 +0000 (10:48 -0700)]
ovsdb-idl: Track changes for table references.

If a change of a row is tracked, make sure the rows that reference
this row are also added in tracked changes, unless change tracking
is not required for those rows.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>