]> git.proxmox.com Git - mirror_ovs.git/log
mirror_ovs.git
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>
6 years agoovsdb-idlc.in: Support more interfaces for passing pointers of individual tables.
Han Zhou [Mon, 13 Aug 2018 17:48:02 +0000 (10:48 -0700)]
ovsdb-idlc.in: Support more interfaces for passing pointers of individual tables.

This is a follow-up patch for commit 0eb1e37c, to add more interfaces
that supports passing around pointers of individual tables, which will
be used in incremental processing.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovsdb-idl.c: Update conditions when handling change tracking list.
Han Zhou [Mon, 13 Aug 2018 17:48:01 +0000 (10:48 -0700)]
ovsdb-idl.c: Update conditions when handling change tracking list.

There are places with the pattern:
    if (!ovs_list_is_empty(&row->track_node)) {
        ovs_list_remove(&row->track_node);
    }
    ovs_list_push_back(&row->table->track_list,
                       &row->track_node);

It seems to be trying to prevent double removing the node from a list,
but actually it doesn't, and may be misleading.

The function ovs_list_is_empty() returns true only if the node has been
initialized with ovs_list_init(). If a node is deleted but not
initialized, the check will return false and the above code will continue
deleting it again. But if a node is already initialized, calling
ovs_list_remove() is a no-op. So the check is not necessary and misleading.

In fact there is already a double removal resulted by this code: the function
ovsdb_idl_db_clear() removes the node but it then calls ovsdb_idl_row_destroy()
immediately which removes the node again. It should not result in any real
issue yet since the list was not changed so the second removal just
assigns the pointers with same value.

It is in fact not necessary to remove and then add back to the list, because
the purpose of the change tracking is just to tell if a row is changed
or not. So this patch removes the "check and remove" code before adding
the node to a list, but instead, adding it to the list only if it is
not in a list. This way it ensures the node is added to a list only once
in one idl loop. (ovsdb_idl_db_track_clear() will be called in each
iteration and the check ovs_list_is_empty() will return true at the first
check in next iteration).

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovsdb-idl: Remove a misleading comment for change tracking.
Han Zhou [Mon, 13 Aug 2018 17:48:00 +0000 (10:48 -0700)]
ovsdb-idl: Remove a misleading comment for change tracking.

The comment was added when the feature was introduced but what it
described is not what is implemented, probably because of revisions
after code reviews.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agopython jsonrpc: Allow jsonrpc_session to have more than one remote.
Numan Siddique [Tue, 7 Aug 2018 11:38:11 +0000 (17:08 +0530)]
python jsonrpc: Allow jsonrpc_session to have more than one remote.

Python IDL implementation doesn't have the support to connect to the
cluster dbs. This patch adds this support. We are still missing the
support in python idl class to connect to the cluster master. That
support will be added in an upcoming patch.

This patch is similar to the commit 8cf6bbb184 which added multiple remote
support in the C jsonrpc implementation.

Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovs python: ovs.stream.open_block() returns success even if the remote is unreachable
Numan Siddique [Tue, 7 Aug 2018 11:37:58 +0000 (17:07 +0530)]
ovs python: ovs.stream.open_block() returns success even if the remote is unreachable

The python function ovs.socket_util.check_connection_completion() uses select()
(provided by python) to monitor the socket file descriptor. The select()
returns 1 when the file descriptor becomes ready. For error cases like -
111 (Connection refused) and 113 (No route to host) (POLLERR), ovs.poller._SelectSelect.poll()
expects the exceptfds list to be set by select(). But that is not the case.
As per the select() man page, writefds list will be set for POLLERR.
Please see "Correspondence between select() and poll() notifications" section of select(2)
man page.

Because of this behavior, ovs.socket_util.check_connection_completion() returns success
even if the remote is unreachable or not listening on the port.

This patch fixes this issue by using poll() to check the connection status similar to
the C implementation of check_connection_completion().

A new function 'get_system_poll() is added in ovs/poller.py which returns the
select.poll() object. If select.poll is monkey patched by eventlet/gevent, it
gets the original select.poll() and returns it.

The test cases added in this patch fails without the fix.

Suggested-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agocompat: Substitute more dependable define
Greg Rose [Mon, 13 Aug 2018 23:00:16 +0000 (16:00 -0700)]
compat: Substitute more dependable define

The compat layer ip_tunnel_get_stats64 function was checking for the
Linux kernel version to determine if the return was void or a pointer.
This is not very reliable and caused compile warnings on SLES 12 SP3.
In acinclude.m4 create a more reliable method of determining when to
use a void return vs. a pointer return.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovsdb-idl.c: Fix IDL index problem when rows are updated.
Han Zhou [Sat, 11 Aug 2018 03:29:46 +0000 (20:29 -0700)]
ovsdb-idl.c: Fix IDL index problem when rows are updated.

In current IDL index code it doesn't updated index when handling
"update2" messages, which is the default case. The consequence
is that when a row is updated, the index is not updated accordingly,
and even worse, it causes crash when calling ovsdb_idl_destroy().
It can be easily reproduced by the test cases added in this patch.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agotest-ovsdb.c: Fix wrong indent.
Han Zhou [Sat, 11 Aug 2018 03:29:45 +0000 (20:29 -0700)]
test-ovsdb.c: Fix wrong indent.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovn-controller: Fix warning message when unable to assign meter ID.
Han Zhou [Mon, 13 Aug 2018 19:36:17 +0000 (12:36 -0700)]
ovn-controller: Fix warning message when unable to assign meter ID.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agocheckpatch: Improve accuracy and specificity of sign-off checking.
Ben Pfaff [Fri, 10 Aug 2018 20:15:41 +0000 (13:15 -0700)]
checkpatch: Improve accuracy and specificity of sign-off checking.

This also makes a start at a testsuite for checkpatch.

CC: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@bytheb.org>
6 years agoAdd ovs.compat module to python package
Terry Wilson [Fri, 10 Aug 2018 15:13:23 +0000 (10:13 -0500)]
Add ovs.compat module to python package

Signed-off-by: Terry Wilson <twilson@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Timothy Redaelli <tredaelli@redhat.com>
6 years agorhel: Install the network scripts in a new subpackage
Timothy Redaelli [Tue, 7 Aug 2018 16:52:10 +0000 (18:52 +0200)]
rhel: Install the network scripts in a new subpackage

Starting from Fedora 29, the legacy network scripts are installed in
the "network-scripts" package and so the network scripts ("ifup-ovs",
"ifdown-ovs") should be installed only when the "network-scripts" package
is installed.

This commit introduces (on Fedora 29+) a new subpackage
(network-scripts-openvswitch). This subpackage is installed, by default, only
if the "network-scripts" package is installed too (reverse weak dependency).

Reported-by: Lubomir Rintel <lkundrak@v3.sk>
Reported-at: https://src.fedoraproject.org/rpms/openvswitch/pull-request/4
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovs-sandbox: Generate the SSL keys using the default key length
Timothy Redaelli [Thu, 9 Aug 2018 18:02:02 +0000 (20:02 +0200)]
ovs-sandbox: Generate the SSL keys using the default key length

This commit removes the explicit set of 1024-bit RSA keys when the RSA
keys are generated on "make sandbox" and so the default (2048-bit) is used.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Maxime Coquelin <maxime.coquelin@redhat.com>
6 years agoovn-architecture: Use the default key length in examples
Timothy Redaelli [Thu, 9 Aug 2018 18:02:01 +0000 (20:02 +0200)]
ovn-architecture: Use the default key length in examples

This commit removes the explicit set of 1024-bit RSA keys on
ovn-architecture examples and so the default (2048-bit) is used.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Maxime Coquelin <maxime.coquelin@redhat.com>
6 years agotests: Use the default key length when generating RSA keys
Timothy Redaelli [Thu, 9 Aug 2018 18:02:00 +0000 (20:02 +0200)]
tests: Use the default key length when generating RSA keys

This commit removes the explicit set of 1024-bit RSA keys when ovs-pki
is launched and so the default (2048-bit) is used.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Maxime Coquelin <maxime.coquelin@redhat.com>
6 years agovswitch.xml: Update dpdk-init documentation.
Kevin Traynor [Thu, 9 Aug 2018 15:13:58 +0000 (16:13 +0100)]
vswitch.xml: Update dpdk-init documentation.

dpdk-init is now a string. Add description of 'true' and 'try'.

Fixes: 3e52fa5644cd ("dpdk: reflect status and version in the database")
Cc: aconole@redhat.com
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
6 years agoreleases: Add 2.10 entry for supported DPDK versions.
Ian Stokes [Wed, 8 Aug 2018 11:00:30 +0000 (12:00 +0100)]
releases: Add 2.10 entry for supported DPDK versions.

This commit adds an entry for OVS 2.10 and the supported DPDK version in
releases.rst.

Signed-off-by: Ian Stokes <ian.stokes@intel.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
6 years agoofproto-dpif-xlate: Improve log message.
Ben Pfaff [Tue, 7 Aug 2018 18:18:56 +0000 (11:18 -0700)]
ofproto-dpif-xlate: Improve log message.

Until now, the bridge name was at the end of the log message, after the
flow, which made it easy to miss.  This commit moves it before the flow
where it is easier to spot.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
6 years agotests: Don't log to syslog during tests.
Ben Pfaff [Wed, 8 Aug 2018 23:04:56 +0000 (16:04 -0700)]
tests: Don't log to syslog during tests.

Until now, "make check" generated a huge amount of output to syslog.  This
commit suppresses it.

Acked-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoMerge branch 'dpdk_merge' of https://github.com/istokes/ovs into HEAD
Ben Pfaff [Wed, 8 Aug 2018 23:08:01 +0000 (16:08 -0700)]
Merge branch 'dpdk_merge' of https://github.com/istokes/ovs into HEAD

6 years agounixctl: Style fix.
Ben Pfaff [Wed, 8 Aug 2018 20:30:53 +0000 (13:30 -0700)]
unixctl: Style fix.

Reported-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
Acked-by: Justin Pettit <jpettit@ovn.org>
6 years agoofp-port: Drop of useless indirection in ofputil_pull_ofp14_port_stats().
Ben Pfaff [Fri, 27 Jul 2018 18:14:44 +0000 (11:14 -0700)]
ofp-port: Drop of useless indirection in ofputil_pull_ofp14_port_stats().

Signed-off-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
6 years agoofp-port: Fix buffer overread parsing Intel custom statistics.
Ben Pfaff [Fri, 27 Jul 2018 18:14:43 +0000 (11:14 -0700)]
ofp-port: Fix buffer overread parsing Intel custom statistics.

CC: Michal Weglicki <michalx.weglicki@intel.com>
Fixes: 971f4b394c6e ("netdev: Custom statistics.")
Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9445
Signed-off-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
6 years agonetdev-dpdk: Use hex for PCI vendor ID.
Kevin Traynor [Fri, 3 Aug 2018 19:03:32 +0000 (20:03 +0100)]
netdev-dpdk: Use hex for PCI vendor ID.

Match the prefix and formatting.

Fixes: 8a9562d21a40 ("dpif-netdev: Add DPDK netdev.")
Cc: pshelar@ovn.org
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
6 years agonetdev-dpdk: Fix failure to configure flow control at netdev-init.
Sugesh Chandran [Tue, 31 Jul 2018 11:04:32 +0000 (12:04 +0100)]
netdev-dpdk: Fix failure to configure flow control at netdev-init.

Configuring flow control at ixgbe netdev-init is throwing error in port
start.

For eg: without this fix, user cannot configure flow control on ixgbe dpdk
port as below,

"
    ovs-vsctl add-port br0 dpdk0 -- set Interface dpdk0 type=dpdk \
        options:dpdk-devargs=0000:05:00.1 options:rx-flow-ctrl=true
"

Instead,  it must be configured as two different commands,

"
    ovs-vsctl add-port br0 dpdk0 -- set Interface dpdk0 type=dpdk \
               options:dpdk-devargs=0000:05:00.1
    ovs-vsctl set Interface dpdk0 options:rx-flow-ctrl=true
"

The DPDK ixgbe driver is now validating all the 'rte_eth_fc_conf' fields before
trying to configuring the dpdk ethdev. Hence OVS can no longer set the
'dont care' fields to just '0' as before. This commit make sure all the
'rte_eth_fc_conf' fields are populated with default values before the dev
init.

Also to avoid read error on unsupported ports, the flow control parameters
are now read only when user is trying to configure/update it.

Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
6 years agodpif-netdev: Fix zero length keys insertion to EMC.
Ilya Maximets [Wed, 25 Jul 2018 16:09:31 +0000 (19:09 +0300)]
dpif-netdev: Fix zero length keys insertion to EMC.

'key.len' should be calculated before inserting to EMC, otherwise
resulting entry will match with any packet with the same hash.

CC: Yipeng Wang <yipeng1.wang@intel.com>
Fixes: 60d8ccae135f ("dpif-netdev: Add SMC cache after EMC cache")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Yipeng Wang <yipeng1.wang@intel.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
6 years agotable: fix html buffer output
Aaron Conole [Wed, 8 Aug 2018 00:34:52 +0000 (20:34 -0400)]
table: fix html buffer output

Prior to this commit, html output exhibits a doppler effect for
content by continually printing strings passed from
table_print_html_cell.

Fixes: cb139fa8b3a1 ("table: New function table_format() for formatting a table as a string.")
Cc: Ben Pfaff <blp@ovn.org>
Cc: Jakub Sitnicki <jsitnicki@gmail.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agotable: append newline when printing tables
Aaron Conole [Wed, 8 Aug 2018 00:34:51 +0000 (20:34 -0400)]
table: append newline when printing tables

With commit cb139fa8b3a1 ("table: New function table_format() for
formatting a table as a string.") a new mechanism for formatting
tables was introduced, and the table_print method was refactored to
use this.

During that refactor, calls to 'puts' were replaced with
'ds_put_cstr', and table print was changed to use 'fputs(...,
stdout)'.  Unfortunately, fputs() does not append a newline to the
string provided, and changes the output strings of, for example,
ovsdb-client dump to print all on one line.  This means
post-processing scripts that are chained after ovsdb-client would
either block indefinitely (if they don't detect EOF), or process the
entire bundle at once (rather than seeing each table on a separate
line).

Fixes: cb139fa8b3a1 ("table: New function table_format() for formatting a table as a string.")
Cc: Ben Pfaff <blp@ovn.org>
Cc: Jakub Sitnicki <jsitnicki@gmail.com>
Reported-by: Terry Wilson <twilson@redhat.com>
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1608508
Signed-off-by: Aaron Conole <aconole@redhat.com>
Suggested-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Terry Wilson <twilson@redhat.com>
Tested-by: Terry Wilson <twilson@redhat.com>
6 years agoofctl: Fixup compare_flows function
Alin Gabriel Serdean [Mon, 6 Aug 2018 21:34:45 +0000 (00:34 +0300)]
ofctl: Fixup compare_flows function

In the case there was no sorting criteria the flows on Windows were being
rearranged because it was always returning zero.

Also check if there we need sorting to save a few cycles.

CC: Ben Pfaff <blp@ovn.org>
Co-authored-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agorhel: Use correct user in the logrotate configuration file
Markos Chandras [Wed, 8 Aug 2018 14:27:25 +0000 (17:27 +0300)]
rhel: Use correct user in the logrotate configuration file

The /var/log/openvswitch directory is owned by the openvswitch user but
logrotate could be running as root or as another user. As a result of
which, rpmlint prints the following warning when building the spec file
on SUSE Linux Enterprise:

openvswitch.x86_64: W: suse-logrotate-user-writable-log-dir /var/log/openvswitch openvswitch:openvswitch 0750
The log directory is writable by unprivileged users. Please fix the
permissions so only root can write there or add the 'su' option
to your logrotate config

In order to fix that, we should run the logrotate script as the same
user which runs the various Open vSwitch daemons. If this is a new
installation, then this user is the 'openvswitch' one, but if we are
upgrading from an older release, then the user is normally 'root'.
As such, we set the initial user to 'root' and we fix this up in the
%post scriptlet.

Cc: Aaron Conole <aconole@redhat.com>
Cc: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Markos Chandras <mchandras@suse.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Timothy Redaelli <tredaelli@redhat.com>
6 years agodatapath: meter: Fix setting meter id for new entries
Justin Pettit [Tue, 7 Aug 2018 23:45:26 +0000 (16:45 -0700)]
datapath: meter: Fix setting meter id for new entries

Upstream commit:
    From: Justin Pettit <jpettit@ovn.org>
    Date: Sat, 28 Jul 2018 15:26:01 -0700
    Subject: [PATCH] openvswitch: meter: Fix setting meter id for new entries

    The meter code would create an entry for each new meter.  However, it
    would not set the meter id in the new entry, so every meter would appear
    to have a meter id of zero.  This commit properly sets the meter id when
    adding the entry.

Fixes: 96fbc13d7e77 ("openvswitch: Add meter infrastructure")
Signed-off-by: Justin Pettit <jpettit@ovn.org>
Cc: Andy Zhou <azhou@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Justin Pettit <jpettit@ovn.org>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovn-controller: Use ovsdb index for mac-binding update.
Han Zhou [Wed, 11 Jul 2018 18:05:44 +0000 (11:05 -0700)]
ovn-controller: Use ovsdb index for mac-binding update.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovn-trace: Fix warnings when port is found but not in current datapath.
Han Zhou [Tue, 7 Aug 2018 02:44:02 +0000 (19:44 -0700)]
ovn-trace: Fix warnings when port is found but not in current datapath.

When port group is used, ovn-trace may print warnings like this:

$ ovn-trace ls1 'inport == "lp111" && eth.src == f0:00:00:00:01:11 && eth.dst == f0:00:00:00:01:12  && ip4.src == 192.168.11.1 && ip4.dst == 192.168.11.2 && ip.ttl == 10'
2018-08-02T01:43:23Z|00001|ovntrace|WARN|lp211: not in datapath ls1
2018-08-02T01:43:23Z|00002|ovntrace|WARN|lp211: unknown logical port
2018-08-02T01:43:23Z|00003|ovntrace|WARN|lp221: not in datapath ls1
2018-08-02T01:43:23Z|00004|ovntrace|WARN|lp221: unknown logical port
2018-08-02T01:43:23Z|00005|ovntrace|WARN|lp231: not in datapath ls1
2018-08-02T01:43:23Z|00006|ovntrace|WARN|lp231: unknown logical port

There are 2 warnings:

For the first one, it might be reasonable
before port group is supported, but now since ports in a port group
can span across multiple datapaths, this situation is normal, and
warning should not be printed.

For the second one, it is misleading, and it should not be printed
in this situation even before port group is supported. It should be
printed only if the port is not found at all.

This patch fixes both.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agoovn-northd: Improve efficiency of stateful checking for ACLs on port groups.
Han Zhou [Tue, 7 Aug 2018 02:44:01 +0000 (19:44 -0700)]
ovn-northd: Improve efficiency of stateful checking for ACLs on port groups.

Currently in has_stateful_acl(), to check if a datapath has stateful ACLs,
it needs to iterate all port groups and check if the current datapath is
related to each port group, and then iterate the ACLs on the port group. This
is inefficient if there are a lot of port groups. A typical scenario is in
OpenStack each tenant will have a default security group which will be mapped
as a port group, and the default security group is supposed to contain ports
of the tenant only, so most likely only the logical switches belonging to the
tenant should be related to the port group, but we are checking all the port
groups belonging to all tenants for each datapath.

To improve this, a reverse direction of hmap is built from logical switch to
port group, so that the iteration is avoided. The time complexity of this
function improves from O(P * A) to O(PL * A), P = total number of port groups
in NB, PL = number of port groups related to the logical switch, A = number
of ACLs.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agoovn-northd: Simplify struct ovn_port_group.
Han Zhou [Tue, 7 Aug 2018 02:44:00 +0000 (19:44 -0700)]
ovn-northd: Simplify struct ovn_port_group.

Remove the redundant members that's already in nb_pg.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agodatapath: support upstream ndo_udp_tunnel_add in net_device_ops
wenxu [Sat, 4 Aug 2018 08:31:36 +0000 (16:31 +0800)]
datapath: support upstream ndo_udp_tunnel_add in net_device_ops

It makes datapath can support both ndo_add_udp_tunnel_port and
ndo_add_vxlan/geneve_port. The newer kernels don't support vxlan/geneve
specific NDO's anymore

Signed-off-by: wenxu <wenxu@ucloud.cn>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Tested-by: Greg Rose <gvrose8192@gmail.com>
6 years agoip_gre: remove redundant variables t_hlen
YueHaibing [Tue, 7 Aug 2018 21:48:53 +0000 (14:48 -0700)]
ip_gre: remove redundant variables t_hlen

Upstream commit:
    From: YueHaibing <yuehaibing@huawei.com>
    Date: Wed, 1 Aug 2018 10:04:02 +0800
    Subject: [PATCH] ip_gre: remove redundant variables t_hlen

    After commit ffc2b6ee4174 ("ip_gre: fix IFLA_MTU ignored on NEWLINK")
    variable t_hlen is assigned values that are never read,
    hence they are redundant and can be removed.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoip_gre: fix IFLA_MTU ignored on NEWLINK
Xin Long [Tue, 7 Aug 2018 21:48:52 +0000 (14:48 -0700)]
ip_gre: fix IFLA_MTU ignored on NEWLINK

Upstream commit:
    From: Xin Long <lucien.xin@gmail.com>
    Date: Tue, 27 Feb 2018 19:19:39 +0800
    Subject: [PATCH] ip_gre: fix IFLA_MTU ignored on NEWLINK

    It's safe to remove the setting of dev's needed_headroom and mtu in
    __gre_tunnel_init, as discussed in [1], ip_tunnel_newlink can do it
    properly.

    Now Eric noticed that it could cover the mtu value set in do_setlink
    when creating a ip_gre dev. It makes IFLA_MTU param not take effect.

    So this patch is to remove them to make IFLA_MTU work, as in other
    ipv4 tunnels.

      [1]: https://patchwork.ozlabs.org/patch/823504/

Fixes: c54419321455 ("GRE: Refactor GRE tunneling code.")
Reported-by: Eric Garver <e@erig.me>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Part of this commit already made it into __gre_tunnel_init but
the piece for erspan_tunnel_init did not make it in so fix that
now.

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 agotests: Ignore recirc_id in "MPLS xlate action" test.
Ben Pfaff [Thu, 12 Jul 2018 21:55:31 +0000 (14:55 -0700)]
tests: Ignore recirc_id in "MPLS xlate action" test.

When I run this test with DPDK enabled, it fails because it ends up using
a different recirculation ID when DPDK is not enabled.  I guess that's a
little weird but the recirculation IDs are not supposed to be significant,
so this change makes the test ignore it.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Aaron Conole <aconole@redhat.com>
6 years agodns-resolve: Only ask unbound to read /etc/resolv.conf if it exists.
Ben Pfaff [Tue, 7 Aug 2018 19:40:13 +0000 (12:40 -0700)]
dns-resolve: Only ask unbound to read /etc/resolv.conf if it exists.

The unbound library complains if we ask it to read /etc/resolv.conf but
that file doesn't exist.  It's better to just skip reading it in that case.

Reported-by: Flavio Leitner <fbl@sysclose.org>
Reporetd-at: https://mail.openvswitch.org/pipermail/ovs-dev/2018-August/350751.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
6 years agoAUTHORS: Add Zak Whittington.
Ben Pfaff [Tue, 7 Aug 2018 21:34:44 +0000 (14:34 -0700)]
AUTHORS: Add Zak Whittington.

Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoofproto-dpif-xlate: use new info-level logging helper when sending out an in_port
Zak Whittington [Tue, 7 Aug 2018 21:13:17 +0000 (14:13 -0700)]
ofproto-dpif-xlate: use new info-level logging helper when sending out an in_port

Added new helper function similar to xlate_report_error called
xlate_report_info that logs info-level messages, and used that
function to add an extra log message when attempting to send
out an in-port.

VMware-BZ: 2158607
Signed-off-by: Zak Whittington <zwhitt.vmware@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovn-nbctl: Make daemon mode more transparent.
Ben Pfaff [Tue, 24 Jul 2018 19:53:20 +0000 (12:53 -0700)]
ovn-nbctl: Make daemon mode more transparent.

This makes ovn-nbctl transparently use daemon mode if an appropriate
environment variable is set.

It also transforms ovn-nbctl.at so that it runs each ovn-nbctl test in
"direct" mode and in daemon mode.  It uses a combination of m4 macros and
shell functions to keep from expanding the generated testsuite more than
necessary.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agoovn-nbctl: Separate command-line options parsing and interpretation.
Ben Pfaff [Thu, 2 Aug 2018 22:27:32 +0000 (15:27 -0700)]
ovn-nbctl: Separate command-line options parsing and interpretation.

This will allow selected options to be interpreted locally and others to
be passed to the daemon, when the daemon is in use.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agounixctl: Make path to unixctl_server socket available to the client.
Ben Pfaff [Tue, 24 Jul 2018 17:45:25 +0000 (10:45 -0700)]
unixctl: Make path to unixctl_server socket available to the client.

Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoraft: Fix use-after-free error in raft_store_snapshot().
Ben Pfaff [Mon, 6 Aug 2018 21:35:27 +0000 (14:35 -0700)]
raft: Fix use-after-free error in raft_store_snapshot().

raft_store_snapshot() constructs a new snapshot in a local variable then
destroys the current snapshot and replaces it by the new one.  Until now,
it has not cloned the data in the new snapshot until it did the
replacement.  This led to the unexpected consequence that, if 'servers' in
the old and new snapshots was the same, then it would first be freed and
later cloned, which could cause a segfault.

Multiple people reported the crash.  Gurucharan Shetty provided a
reproduction case.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agoAUTHORS: Add Bala Sankaran.
Ben Pfaff [Mon, 6 Aug 2018 23:59:32 +0000 (16:59 -0700)]
AUTHORS: Add Bala Sankaran.

Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agocheckpatch: warn on possible bare return
Bala Sankaran [Tue, 31 Jul 2018 20:37:38 +0000 (16:37 -0400)]
checkpatch: warn on possible bare return

void functions do not need to have a return statement, because
such statements are redundant. Warn the user of such instances.

An interim line check is added to allow gathering additional
context for each line that is being processed.

Signed-off-by: Bala Sankaran <bsankara@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovs-vtep: Pass log level arguments to underlying utils.
Ilya Maximets [Wed, 1 Aug 2018 15:54:22 +0000 (18:54 +0300)]
ovs-vtep: Pass log level arguments to underlying utils.

Control utils should be called with the same verbose level
at least to manage output to system logs. For example, to
disable unwanted syslog messages in unit tests or to enable
higher debug levels if needed.
New arguments added before '-vconsole:off' because it's
still inconvenient to have console output.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agojson: Use unnamed embedded union.
Flavio Leitner [Thu, 2 Aug 2018 21:44:10 +0000 (18:44 -0300)]
json: Use unnamed embedded union.

Otherwise the code does not build.

Fixes: fa37affad362 ("Embrace anonymous unions.")
Signed-off-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agotests: Test for ovs-ofctl snoop command
Ashish Varma [Mon, 6 Aug 2018 22:53:37 +0000 (15:53 -0700)]
tests: Test for ovs-ofctl snoop command

Added test for snoop command to check for the initial handshake messages
when a bridge connects to a controller via 'unix' connection method.

Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agostream-ssl: Define SSL_OP_NO_SSL_MASK for OpenSSL versions that lack it.
Ben Pfaff [Mon, 6 Aug 2018 22:39:44 +0000 (15:39 -0700)]
stream-ssl: Define SSL_OP_NO_SSL_MASK for OpenSSL versions that lack it.

10 of the travis builds are failing such as
TESTSUITE=1 KERNEL=3.16.54 for gcc and clang.

Fixes: ab16d2c2871b ("stream-ssl: Don't enable new TLS versions by default")
CC: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Han Zhou <hzhou8@ebay.com>
Acked-by: Darrell Ball <dlu998@gmail.com>
6 years agoutilities: Launch ovsdb-tool without using PAM
Timothy Redaelli [Mon, 6 Aug 2018 10:03:40 +0000 (12:03 +0200)]
utilities: Launch ovsdb-tool without using PAM

When ovsdb-server is starting, it performs some DB steps such as
creating and upgrading the OvS DB. When we are running as
'non-root' user, the 'runuser' tool is used to manage the privileges.
However, when this happens during systemd boot, we observe the following
errors in journald:

Jun 21 07:32:57 virt systemd[1]: session-c1.scope: Failed to add PIDs to
scope's control group: No such process
Jun 21 07:32:57 virt systemd[1]: Failed to start Session c1 of user openvswitch.
Jun 21 07:32:57 virt systemd[1]: session-c1.scope: Unit entered failed state.

According to the analysis performed on openSUSE bugzilla[1], it seems
that ovsdb-server.service creates (via the call to runuser) a user
session and therefore call pam_systemd which in its turn tries to start
a systemd user instance: "user@474.service". However "user@474.service"
is supposed to be started after systemd-user-sessions.service which is
supposed to be started after network.target. Additionally,
ovsdb-server.service uses Before=network.target hence the deadlock.

This commit uses "setpriv" instead of "runuser" to launch "ovsdb-tool" that
doesn't use PAM and so it permits to launch "ovsdb-tool" as a user without
having the deadlock. Since some old versions for "setpriv" (such as the
one used by RHEL7) doesn't support the username / groupname, but only the
user ids / group ids, "id" is used to get the user ID and the group IDs.
To replicate the same behaviour of "runuser", the effective group ID of
the user is used as GID (usually "openvswitch") and the remaining group
IDs are used as supplementary groups (usually "hugetlbfs", if OVS is
built with DPDK support).

[1]: https://bugzilla.suse.com/show_bug.cgi?id=1098630
Reported-by: Markos Chandras <mchandras@suse.de>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2018-July/349716.html
Co-authored-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
6 years agoovs-ofctl: Better validate OpenFlow message length in "ofp-parse-pcap".
Ben Pfaff [Tue, 31 Jul 2018 20:28:29 +0000 (13:28 -0700)]
ovs-ofctl: Better validate OpenFlow message length in "ofp-parse-pcap".

Reported-by: Oscar Wilde <xdxiaobin@gmail.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-July/047070.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
6 years agorhel: Add gcc and gcc-c++ to BuildRequires
Timothy Redaelli [Mon, 6 Aug 2018 18:21:32 +0000 (20:21 +0200)]
rhel: Add gcc and gcc-c++ to BuildRequires

Starting from Fedora 29, gcc and gcc-c++ won't be installed by default in
buildroot and so it's necessary to specify them explicitly in the spec file.

https://fedoraproject.org/wiki/Changes/Remove_GCC_from_BuildRoot

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agodpctl: Simplify dpctl_flush_conntrack.
Darrell Ball [Mon, 6 Aug 2018 17:55:26 +0000 (10:55 -0700)]
dpctl: Simplify dpctl_flush_conntrack.

The function dpctl_flush_conntrack() and other such new functions with
multiple optional arguments can be simplified by reodering the checks
for optional parameters, where the datapath argument is checked for
last.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoutilities: Install ovs-tcp{dump, undump} also when only Python3 is enabled
Timothy Redaelli [Fri, 3 Aug 2018 18:28:08 +0000 (20:28 +0200)]
utilities: Install ovs-tcp{dump, undump} also when only Python3 is enabled

Since commit 793bdb6c0500 ("ovs-tcpdump: Fix incompatibilities with python3")
and commit 227abb77d3d1 ("ovs-tcpundump: Fix incompatibilities with python3")
ovs-tcpdump and ovs-tcpdump works with Python3 as well.

This commit allows ovs-tcpdump and ovs-tcpundump to be installed also when
only Python3 is enabled.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agodb-ctl-base: Fix build with gcc 7.3 with O3.
Darrell Ball [Mon, 16 Jul 2018 18:33:39 +0000 (11:33 -0700)]
db-ctl-base: Fix build with gcc 7.3 with O3.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agostream-ssl: Don't enable new TLS versions by default
Timothy Redaelli [Fri, 27 Jul 2018 14:29:40 +0000 (16:29 +0200)]
stream-ssl: Don't enable new TLS versions by default

Currently protocol_flags is populated by the list of SSL and TLS
protocols by hand. This means that when a new TLS version is added to
openssl (in this case TLS v1.3 is added to openssl 1.1.1 beta)
ovsdb-server automatically enable support to it with the default ciphers.
This can be a security problem (since other ciphers can be enabled) and it
also makes a test (SSL db: implementation) to fail.

This commit changes the 'protocol_flags' to use the list of all protocol
flags as provided by openssl library (SSL_OP_NO_SSL_MASK) so there is no
need to keep the list updated by hand.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoutilities: don't use a bashism to check that datapath exists
Timothy Redaelli [Wed, 1 Aug 2018 15:48:21 +0000 (17:48 +0200)]
utilities: don't use a bashism to check that datapath exists

[[ ]] syntax is not supported, at least, by dash that Debian, Ubuntu and other
linux distributions may use instead of bash.

This commit uses, instead, a POSIX way that is compatible with any POSIX
shell (bash, dash, busybox sh, etc).

CC: Martin Xu <martinxu9.ovs@gmail.com>
Fixes: 9763d17fbd05 ("utilities: check datapath exists before conntrack flush")
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
6 years agopcap-file: Fix formatting of log message.
Ben Pfaff [Tue, 31 Jul 2018 20:34:59 +0000 (13:34 -0700)]
pcap-file: Fix formatting of log message.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
6 years agometa-flow: Make mf_vl_mff_mf_from_nxm_header() require a valid field.
Ben Pfaff [Tue, 31 Jul 2018 21:51:54 +0000 (14:51 -0700)]
meta-flow: Make mf_vl_mff_mf_from_nxm_header() require a valid field.

All the users of mf_vl_mff_mf_from_nxm_header() expect it to always obtain
a valid field or to report an error.  In practice, it did not report an
error in the case where the field was unknown (although it did report an
error in some other cases).  This commit fixes the problem.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9652
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
6 years agoovsdb-cluster: Add comment to test.
Ben Pfaff [Fri, 3 Aug 2018 23:39:44 +0000 (16:39 -0700)]
ovsdb-cluster: Add comment to test.

I thought I had added this while revising a previous patch but oops.

Fixes: 7ee9c6e03416 ("tests: Fix cluster torture test.")
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovsdb-tool: Only check leader completeness when we can, in "check-cluster".
Ben Pfaff [Wed, 25 Jul 2018 21:10:26 +0000 (14:10 -0700)]
ovsdb-tool: Only check leader completeness when we can, in "check-cluster".

Generally when we know the leader for a term, in "check-cluster", it's
because we read that leader's log file.  In that case, we have the leader's
log_end because it told us.  However, taking a snapshot can discard that
data.  In that case, log_end is 0 and we should not try to check for leader
completeness on that basis.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agoovsdb-tool: Check for duplicate server IDs in "check-cluster".
Ben Pfaff [Wed, 25 Jul 2018 20:58:12 +0000 (13:58 -0700)]
ovsdb-tool: Check for duplicate server IDs in "check-cluster".

The user shouldn't provide a given server's log more than once but this
check makes sure.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agoovsdb-tool: Read server headers first, before full logs, in "check-cluster".
Ben Pfaff [Wed, 25 Jul 2018 20:57:38 +0000 (13:57 -0700)]
ovsdb-tool: Read server headers first, before full logs, in "check-cluster".

Having the headers available before reading the complete logs means that
server IDs can be associated with the server file names earlier, which can
improve error messages in some cases.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agoovsdb-tool: Fix logic for displaying server names in "check-cluster".
Ben Pfaff [Wed, 25 Jul 2018 20:44:49 +0000 (13:44 -0700)]
ovsdb-tool: Fix logic for displaying server names in "check-cluster".

Without this patch, server names are displayed as UUIDs even when we know
the file name; file names are easier for the user to read.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agotests: Suppress "long poll interval" messages for ovsdb-cluster tests.
Ben Pfaff [Thu, 26 Jul 2018 16:35:28 +0000 (09:35 -0700)]
tests: Suppress "long poll interval" messages for ovsdb-cluster tests.

The cluster torture tests can provoke these messages, especially if run in
parallel or with valgrind, and they shouldn't cause a failure.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agotests: Fix use of variable in cluster torture test.
Ben Pfaff [Wed, 25 Jul 2018 17:55:59 +0000 (10:55 -0700)]
tests: Fix use of variable in cluster torture test.

remove_server() is supposed to deal with its argument $i, not $victim.  In
this case they happen to have the same value so the difference is moot,
but it's still best to be clear.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agotests: Fix cluster torture test.
Ben Pfaff [Wed, 25 Jul 2018 17:31:47 +0000 (10:31 -0700)]
tests: Fix cluster torture test.

A previous commit to improve timing also caused the cluster torture test to
be skipped (unless it failed early).  This is related to the shell "while"
loop's use of a variable $phase to indicate how far it got in the test
procedure.  A very fast machine, or one on which the races went just the
right way, might finish the test before all the torture properly starts, so
the code is designed to just skip the test if that happens.  However, a
commit to improve the accuracy ended up skipping it all the time.

Prior to the timing commit, the loop looked something like this:

    phase=0
    while :; do
        ...things that eventually increment $phase to 2...
    done
    AT_SKIP_IF([test $phase != 2])

This works fine.

The timing commit changed the "while :" to "(...something...) | while
read".  This looks innocuous but it actually causes everything inside the
"while" loop to run in a subshell.  Thus, the increments to $phase are not
visible after the loop ends, and the test always gets skipped.

This commit fixes the problem by storing the phase in a file instead of a
shell variable.

Fixes: 0f03ae3754ec ("ovsdb: Improve timing in cluster torture test.")
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agonx-match: Fix memory leak in oxm_pull_field_array() error case.
Ben Pfaff [Thu, 26 Jul 2018 22:43:27 +0000 (15:43 -0700)]
nx-match: Fix memory leak in oxm_pull_field_array() error case.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9424
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
6 years agorhel: bug fix kmod spec file, rhel6
Martin Xu [Wed, 1 Aug 2018 23:00:59 +0000 (16:00 -0700)]
rhel: bug fix kmod spec file, rhel6

This patch fixes a scenario not working for RHEL7.3 in commit 89dd5819cf18.
When multiple versions passed into the kversion for the spec file, the
variable is used as is for the kernel module paths for command
weak-modules --add-modules. Then the modules cannot be found.

Fixes: 89dd5819cf18 (rhel: support kmod-openvswitch build against
multiple kernels, rhel6)

Signed-off-by: Martin Xu <martinxu9.ovs@gmail.com>
CC: Greg Rose <gvrose8192@gmail.com>
CC: Ben Pfaff <blp@ovn.org>
CC: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
6 years agorhel: support kmod build against multiple 7.2 kernels, rhel6
Martin Xu [Wed, 1 Aug 2018 23:00:58 +0000 (16:00 -0700)]
rhel: support kmod build against multiple 7.2 kernels, rhel6

This patch extends commit 89dd5819cf18 (rhel: support kmod-openvswitch
build against multiple kernels, rhel6) to support building kmod RPMs
with multiple minor revisions within 3.10.0-327 kernels. It was
discovered for RHEL 7.2 that 41.3 minor revision introduced backward
incompatible changes.

VMware-BZ: #2170334

Signed-off-by: Martin Xu <martinxu9.ovs@gmail.com>
CC: Greg Rose <gvrose8192@gmail.com>
CC: Ben Pfaff <blp@ovn.org>
CC: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
6 years agounixctl: Use absolute paths on Windows too.
Ben Pfaff [Tue, 24 Jul 2018 16:58:56 +0000 (09:58 -0700)]
unixctl: Use absolute paths on Windows too.

When this case was adapted for Windows, asb_file_name() simply didn't work
at all there.  Now, it should work OK, and it seems like the right thing
to do, and it makes the code more straightforward too.

Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoutil: Fix abs_file_name() bugs on Windows.
Ben Pfaff [Tue, 24 Jul 2018 16:48:45 +0000 (09:48 -0700)]
util: Fix abs_file_name() bugs on Windows.

abs_file_name() believed that a file name that begins with / or contains :
is absolute and that any other file name is relative.  On Windows, this is
wrong in at least the following ways:

   * / and \ are interchangeable on Windows.

   * A name that begins with \\ or // is also absolute.

   * A name that begins with X: but not X:\ is not absolute.

   * A name with : in some position other than the second position is
     not absolute (although it might not be valid either?).

Furthermore, Windows has more than one current working directory (one per
volume letter), so trying to make a file name absolute by just prefixing
the current working directory for the current volume results in silliness.

This patch attempts to fix the problem.

This makes OVS link against shlwapi, which is needed to use
PathIsRelative().

Found by inspection.

Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovn: Modify restart_controller in ovn-ctl to use --restart
Mark Michelson [Mon, 30 Jul 2018 13:47:45 +0000 (09:47 -0400)]
ovn: Modify restart_controller in ovn-ctl to use --restart

The --restart flag allows for uninterrupted packet flowage when exiting
ovn-controller. This patch modifies the restart_controller argument to
ovn-ctl to use --restart.

Signed-off-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovn: Add '--restart' flag to ovn-controller exit.
Mark Michelson [Mon, 30 Jul 2018 13:47:44 +0000 (09:47 -0400)]
ovn: Add '--restart' flag to ovn-controller exit.

When "--restart" is passed to ovn-controller's exit command, then
database entries are not removed for this hypervisor. This means that
* Encaps
* Chassis
* OVS ports
are not removed.

The reasoning is that if the intent is to restart ovn-controller, this
will allow for tunnels to remain up and allow for traffic not to be
interrupted during the restart. When ovn-controller is started again, it
picks back up from where it was.

Signed-off-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoAUTHORS: Update email address for Jakub Sitnicki.
Jakub Sitnicki [Thu, 2 Aug 2018 08:33:06 +0000 (10:33 +0200)]
AUTHORS: Update email address for Jakub Sitnicki.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
6 years agoovn: Allow for automatic dynamic updates of IPAM
Mark Michelson [Thu, 2 Aug 2018 12:52:56 +0000 (08:52 -0400)]
ovn: Allow for automatic dynamic updates of IPAM

OVN offers a method of IP address management that allows for an IPv4 subnet or
IPv6 prefix to be specified on a logical switch. Then by specifying a
switch port's address as "dynamic" or "<mac address> dynamic", OVN will
automatically assign addresses to the switch port.

While this works great for initial assignment of addresses, addresses do
not automatically adjust when changes are made to the switch's
configuration. For instance:
* If the subnet, ipv6_prefix, or exclude_ips for a logical switch
changes, the affected switch ports are not updated.
* If a switch port with a static IP address is added to the switch, and
that address conflicts with a dynamically assigned IP address, the
dynamic address is not updated.
* If a MAC address switched from being statically assigned to
dynamically assigned, the MAC address would not be updated.
* If a statically assigned MAC address changed, then the IPv6 address
would not be updated.

This patch solves all of the above issues by changing the algorithm for
IPAM assignment. There are essentially three steps.
1) While joining logical ports, all statically-assigned addresses (i.e.
any ports without "dynamic" addresses) have their addresses registered
to IPAM. This gives them top priority.
2) All logical ports with dynamic addresses are inspected. Any changes
that must be made to the addresses are collected to be made later. Any
addresses that do not require change are registered to IPAM. This allows
for previously assigned dynamic addresses to be kept.
3) All gathered changes are enacted.

The change contains new tests that ensure that dynamic addresses are
updated when appropriate.

This patch also alters some existing IPAM tests. Those tests assumed
that dynamic addresses would not be updated automatically, so those
tests either had to be altered or removed.

Signed-off-by: Mark Michelson <mmichels@redhat.com>
Acked-by: Jakub Sitnicki <jsitnicki@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovn: Fix typos in "ovn -- Address Set generation..." test.
Ben Pfaff [Tue, 31 Jul 2018 19:45:41 +0000 (12:45 -0700)]
ovn: Fix typos in "ovn -- Address Set generation..." test.

These caused the test to fail.

CC: Jakub Sitnicki <jkbs@redhat.com>
Fixes: 984c7d5ea8fe ("ovn-northd: Propagate dynamic addresses to port group address sets.")
Signed-off-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
6 years agoofproto-dpif: Fix typo in registered command
Alin Gabriel Serdean [Mon, 23 Jul 2018 14:45:30 +0000 (17:45 +0300)]
ofproto-dpif: Fix typo in registered command

Also split line at 79 characters.

Found by inspection.

Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Acked-by: Ben Pfaff <blp@ovn.org>
6 years agoAdd opterr and optopt to Windows headers
Alin Gabriel Serdean [Tue, 31 Jul 2018 12:08:13 +0000 (15:08 +0300)]
Add opterr and optopt to Windows headers

Until now we only had optind defined in the header.

Since we are using the BSD getopt variant add opterr and optopt.

Fixes: 3ec06ea9c668 ("ovn-nbctl: Initial support for daemon mode.")
Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
6 years agoovs-pki: generate x.509 v3 certificate
Qiuyu Xiao [Tue, 31 Jul 2018 21:08:52 +0000 (14:08 -0700)]
ovs-pki: generate x.509 v3 certificate

This patch modifies ovs-pki to generate x.509 version 3 certificate.
Compared with the x.509 v1 certificate generated by ovs-pki, version 3
certificate adds subjectAltName field and sets its value the same as
common name (CN). The main reason for this change is to enable
strongSwan IKE daemon to extract certificate identity string from the
subjectAltName field, which makes OVN IPsec implementation easier.

Signed-off-by: Qiuyu Xiao <qiuyu.xiao.qyx@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agolib/tc: Support matching on ip tunnel tos and ttl
Or Gerlitz [Tue, 31 Jul 2018 10:40:39 +0000 (13:40 +0300)]
lib/tc: Support matching on ip tunnel tos and ttl

Support matching on tos and ttl of ip tunnels
for the TC data-path.

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 agolib/tc: Support setting tos and ttl for TC IP tunnels
Or Gerlitz [Tue, 31 Jul 2018 10:40:38 +0000 (13:40 +0300)]
lib/tc: Support setting tos and ttl for TC IP tunnels

Allow to set the tos and ttl for TC tunnels.

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 agolib/tc: Support matching on ip tos
Or Gerlitz [Tue, 31 Jul 2018 10:40:37 +0000 (13:40 +0300)]
lib/tc: Support matching on ip tos

Add the missing code to match on ip tos when dealing
with the TC data-path.

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 agolib/tc: Handle ttl for ipv6 too
Or Gerlitz [Tue, 31 Jul 2018 10:40:36 +0000 (13:40 +0300)]
lib/tc: Handle ttl for ipv6 too

TTL can and should be used to match on IPv6's hop-limit, fix that.

Fixes: ab7ecf266b0a ('netdev-tc-offloads: Add nw_ttl matching using flower')
Fixes: 0b4b5203d12e ('tc: Add ip layer ttl matching')
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 agoAUTHORS: Add Qiuyu Xiao.
Ben Pfaff [Tue, 31 Jul 2018 22:19:54 +0000 (15:19 -0700)]
AUTHORS: Add Qiuyu Xiao.

Signed-off-by: Ben Pfaff <blp@ovn.org>