]> git.proxmox.com Git - mirror_ovs.git/log
mirror_ovs.git
5 years agoOVN: add mac address only support to IPAM/MACAM
Lorenzo Bianconi [Fri, 28 Dec 2018 17:18:04 +0000 (18:18 +0100)]
OVN: add mac address only support to IPAM/MACAM

Add the capability to assign just L2 address to IPAM/MACAM since
in the current implementation either subnet or ipv6_prefix are mandatory
to enable IPAM

Tested-by: Yossi Segev <ysegev@redhat.com>
Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodoc: Add missing ':doc:' role
Stephen Finucane [Fri, 28 Dec 2018 13:46:43 +0000 (13:46 +0000)]
doc: Add missing ':doc:' role

This was rendering in italics instead of cross-referencing as intended.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodatapath-windows: Fix race condition when deleting internal ports
Alin Gabriel Serdean [Fri, 21 Dec 2018 13:55:27 +0000 (15:55 +0200)]
datapath-windows: Fix race condition when deleting internal ports

We need to hold the port lock until all the operations with a port are
completed.

Found by inspection.

Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Acked-by: Anand Kumar <kumaranand@vmware.com>
5 years agotests: Include actual Address Sanitizer output in testsuite log.
Ben Pfaff [Tue, 11 Dec 2018 01:37:43 +0000 (17:37 -0800)]
tests: Include actual Address Sanitizer output in testsuite log.

This will make it easier to get the Address Sanitizer output in cases
where we only have the testsuite.log, which happens with some autobuilders.

Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovn-sb.ovsschema: Avoid duplicated IPs in Encap table.
Han Zhou [Tue, 18 Dec 2018 22:18:34 +0000 (14:18 -0800)]
ovn-sb.ovsschema: Avoid duplicated IPs in Encap table.

When adding a new chassis, if there is an old chassis with same IP
existed in Encap table, it is allowed to be added today. However,
allowing it to be added results in problems:

1. The new chassis cannot work because none of the other chassises
   are able to create tunnel to it, because of the IP confliction
   with already existed tunnel to the old chassis.

2. All the other chassises will continuously retry creating the tunnel
   and complaining about the error.

So, instead of hiding the problem, it is better to expose it while
trying to add the second chassis with duplicated IP. This patch
ensures it from the ovsdb schema.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agonf_conntrack_proto: Fix HAVE_NET_NS_GET macro for nf_conntrack
Yifeng Sun [Wed, 12 Dec 2018 21:24:16 +0000 (13:24 -0800)]
nf_conntrack_proto: Fix HAVE_NET_NS_GET macro for nf_conntrack

In previous code, macro HAVE_NET_NS_SET is used in code but
never generated by config. This patch fixes it.

Fixes: 179fccce34db ("compat: Backport nf_ct_netns_{get, put}()")
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoodp-util: Fix fuzz runtime error of invalid dont_send value
Yifeng Sun [Thu, 27 Dec 2018 00:52:23 +0000 (16:52 -0800)]
odp-util: Fix fuzz runtime error of invalid dont_send value

Oss-fuzz complains that (struct user_action_cookie)->controller->dont_send
has invalid vlue, like below:
runtime error: load of value 26, which is not a valid value for type 'bool'

From this piece of code "cookie.controller.dont_send ? 1 : 0", it looks
like that we want to tolerate values than 0 and 1.

Thus, this patch changes the types of dont_send and continuation from bool
to uint8_t in order to make oss-fuzz happy.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11330
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agosystem-traffic.at: avoid a race condition on monitor log
David Marchand [Fri, 21 Dec 2018 13:29:59 +0000 (14:29 +0100)]
system-traffic.at: avoid a race condition on monitor log

Rather than letting the test framework kill any remaining ofctl monitor,
ask and wait for it to gracefully exit before looking at the log file.
This solves random failures of tests 29, 30 and 50.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoAUTHORS: Update ZhiPeng Lu's email address.
Ben Pfaff [Thu, 27 Dec 2018 17:58:36 +0000 (09:58 -0800)]
AUTHORS: Update ZhiPeng Lu's email address.

5 years agofix rpmbuild fails for rhel
luzhipeng-zte [Sat, 22 Dec 2018 15:13:42 +0000 (23:13 +0800)]
fix rpmbuild fails for rhel

This patch fixes the rpm build fail for rhel. The error is:
Checking for unpackaged file(s): /usr/lib/rpm/check-files /root/rpmbuild/BUILDROOT/openvswitch-2.10.0-1.x86_64
error: Installed (but unpackaged) file(s) found:
   /usr/share/openvswitch/scripts/ovs-monitor-ipsec

Signed-off-by: ZhiPeng LU <luzhipeng@uniudc.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovn: Fix incorrect comparison of the NB and SB band action
Maks Naumov [Tue, 25 Dec 2018 23:19:27 +0000 (01:19 +0200)]
ovn: Fix incorrect comparison of the NB and SB band action

Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agocirrus: Enable testing of Python3 and SSL.
Ilya Maximets [Wed, 26 Dec 2018 15:24:01 +0000 (18:24 +0300)]
cirrus: Enable testing of Python3 and SSL.

This does not increase testing time significantly, but
increases the coverage.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agocirrus: Enable tests on FreeBSD.
Ilya Maximets [Wed, 26 Dec 2018 15:24:00 +0000 (18:24 +0300)]
cirrus: Enable tests on FreeBSD.

Since all the tests fixed to work properly on FreeBSD we
could enable running of the testsuite.

+ minor refactoring of the yml file.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovsdb-idl.at: Increase timeouts for tests with multiple remotes.
Ilya Maximets [Wed, 26 Dec 2018 15:23:59 +0000 (18:23 +0300)]
ovsdb-idl.at: Increase timeouts for tests with multiple remotes.

Tests with multiple remotes always involves connection attempts
to the wrong destinations. This includes few reconnection cycles
for 1 second each and also possible long timeouts for blocking
connections.

Let's increase the timeouts for these tests to allow them finish
successfully.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoofproto-macros.at: Ignore "Socket is not connected" log messages.
Ilya Maximets [Wed, 26 Dec 2018 15:23:58 +0000 (18:23 +0300)]
ofproto-macros.at: Ignore "Socket is not connected" log messages.

FreeBSD likely reports ENOTCONN instead of EPIPE/ECONNRESET in case
of sending to the disconnected socket.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovsdb-idl.at: Better choosing of wrong ports.
Ilya Maximets [Wed, 26 Dec 2018 15:23:57 +0000 (18:23 +0300)]
ovsdb-idl.at: Better choosing of wrong ports.

On some systems (ex. FreeBSD) kernel could allocate outcoming tcp ports
too close to the listening port of ovsdb-server. This could lead to having
outcoming tcp port of test-ovsdb application equal to one of the
WRONG_PORTs. In this case self-connection to the WRONG_PORT succeeds and
fails the tests:

  WRONG_PORT_1=51835
  WRONG_PORT_2=51836
  remotes="tcp:127.0.0.1:51835,tcp:127.0.0.1:51834,tcp:127.0.0.1:51836"
  # lsof -P -n -i @127.0.0.1
  COMMAND     PID TYPE  NODE NAME
  ovsdb-ser 82174 IPv4   TCP 127.0.0.1:51834 (LISTEN)
  python2.7 82179 IPv4   TCP 127.0.0.1:51835->127.0.0.1:51835 (ESTABLISHED)
  python2.7 82179 IPv4   TCP 127.0.0.1:51836->127.0.0.1:51836 (ESTABLISHED)

  ./ovsdb-idl.at:312: $PYTHON $srcdir/test-ovsdb.py  -t10 idl \
                                   $srcdir/idltest.ovsschema $remote
  Alarm clock
  ./ovsdb-idl.at:312: exit code was 1, expected 0

It's more likely to have outcoming port not equal to TCP_PORT + 101 or 102.
Let's use them instead.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agopython: jsonrpc: Pick new remote on disconnect.
Ilya Maximets [Wed, 26 Dec 2018 15:23:54 +0000 (18:23 +0300)]
python: jsonrpc: Pick new remote on disconnect.

If attempt to open non-blocking connection results with EINPROGRESS,
further polling will trigger DISCONNECT action in case of failures.
While handling this action, jsonrpc python library closes the
connection but does not change the current remote. This leads to
subsequent connection to the same remote. And the story starts from
the beginning producing infinite attempts to connect to a single
remote regardless of existense of others. Like this:

 reconnect | DBG | tcp:127.0.0.1:45932: entering BACKOFF
 reconnect | INFO | tcp:127.0.0.1:45932: connecting...
 reconnect | DBG | tcp:127.0.0.1:45932: entering CONNECTING
 poller | DBG | 999-ms timeout
 reconnect | INFO | tcp:127.0.0.1:45932: connection attempt timed out
 reconnect | DBG | tcp:127.0.0.1:45932: entering BACKOFF
 poller | DBG | 0-ms timeout
 reconnect | INFO | tcp:127.0.0.1:45932: connecting...
 <...>
 reconnect | DBG | tcp:127.0.0.1:45932: entering CONNECTING
 poller | DBG | 1999-ms timeout
 reconnect | INFO | tcp:127.0.0.1:45932: connection attempt timed out
 reconnect | INFO | tcp:127.0.0.1:45932: waiting 4 seconds before reconnect
 reconnect | DBG | tcp:127.0.0.1:45932: entering BACKOFF
 <...>

Fix that by always picking the new remote on disconnect.
This mimics the behaviour of jsonrpc C library.

Fixes "multiple remotes" tests on FreeBSD.

CC: Numan Siddique <nusiddiq@redhat.com>
Fixes: 31e434fc985c ("python jsonrpc: Allow jsonrpc_session to have more than one remote.")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovn.at: Replace not portable '\+' in sed with '*'.
Ilya Maximets [Tue, 25 Dec 2018 17:53:09 +0000 (20:53 +0300)]
ovn.at: Replace not portable '\+' in sed with '*'.

'*' has different semantics in common case, but it's not
important here.

This fixes test on FreBSD.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agotests: Enable logging for ovsdb test.
Ilya Maximets [Tue, 25 Dec 2018 17:54:15 +0000 (20:54 +0300)]
tests: Enable logging for ovsdb test.

It's useful to see the connection attempts and the transactions
in case of test failures.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovsdb-idl.at: Add IDL tests for C library with TCP connection.
Ilya Maximets [Fri, 21 Dec 2018 13:12:25 +0000 (16:12 +0300)]
ovsdb-idl.at: Add IDL tests for C library with TCP connection.

Unlike Python IDL, C library tested only with unix sockets.
These tests enlarges the coverage.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agosocket-util: Report POLLHUP as an error while connection completion checking.
Ilya Maximets [Fri, 21 Dec 2018 13:09:50 +0000 (16:09 +0300)]
socket-util: Report POLLHUP as an error while connection completion checking.

Otherwise failed non-blocking connection could be reported as
connected. This causes errors in all following operations with the
socket.

At least this is true on FreeBSD, where POLLHUP could be set without
POLLERR.

For example, stream_open_block() tests fails with the following error
reporting successful connection to the 'WRONG_PORT':

  ./ovsdb-idl.at:1817:
             $PYTHON2 $srcdir/test-stream.py tcp:127.0.0.1:$WRONG_PORT
  stdout:
  ./ovsdb-idl.at:1817: exit code was 0, expected 1
  2399. ovsdb-idl.at:1817:  FAILED (ovsdb-idl.at:1817)

Also added new tests to track this issue in C library:
  'Check Stream open block - C - tcp'
  'Check Stream open block - C - tcp6'

CC: Numan Siddique <nusiddiq@redhat.com>
Fixes: c1aa16d191d2 ("ovs python: ovs.stream.open_block() returns success even if the remote is unreachable")
Fixes: d6cedfd9d29d ("socket-util: Avoid using SO_ERROR.")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agocmap: Fix hashing in cmap_find_protected().
Zang MingJie [Mon, 24 Dec 2018 09:12:19 +0000 (17:12 +0800)]
cmap: Fix hashing in cmap_find_protected().

cmap_find_protected calculated wrong h2 hash which causing entries with
duplicated id inserted into the cmap.

Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-December/047945.html
Signed-off-by: Zang MingJie <zealot0630@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodatapath-windows: Use layers info to extract IP header in IpFragment
Anand Kumar [Fri, 9 Nov 2018 19:08:33 +0000 (11:08 -0800)]
datapath-windows: Use layers info to extract IP header in IpFragment

- Rely on layers l3Offset field to get offset of IP header.
- Aslo fix passing 'newNbl' to IP fragment which is not required.
- Fixed including a header file twice.

Signed-off-by: Anand Kumar <kumaranand@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
5 years agoofproto-dpif.at: Make sFlow sampling tests invariant to IP version.
Ilya Maximets [Thu, 20 Dec 2018 17:23:12 +0000 (20:23 +0300)]
ofproto-dpif.at: Make sFlow sampling tests invariant to IP version.

sflow.log reports the first ip address of the 'loopback' interface.
It could be different on different systems. For example, on FreeBSD
IPv6 [::1] address goes first despite of IPv4 127.0.0.1 on Linux.

Let's just replace it to IPv4 always to make tests work.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agopmd.at: Replace not portable sed pattern with awk.
Ilya Maximets [Thu, 20 Dec 2018 17:24:17 +0000 (20:24 +0300)]
pmd.at: Replace not portable sed pattern with awk.

':a', 'ba' and other suff is not portable.
Additionally removed CORE_QUEUE* macroses as they only complicates
the tests. 'sort' used instead.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoofproto-macros.at: Ignore attempts to open '127.0.0.1' as a device.
Ilya Maximets [Thu, 20 Dec 2018 17:31:39 +0000 (20:31 +0300)]
ofproto-macros.at: Ignore attempts to open '127.0.0.1' as a device.

While configuring sFlow agent OVS tries to treat the value as a name
of the interface at first, after that it tries to treat it as an ip
address. While trying to create netdev from the 'agent', netdev-bsd
calls 'netdev_get_flags()' which produces following warning:

   failed to get flags for network device 127.0.0.1

This does not happen with netdev-linux because it uses its own
implementation of 'get_flags' while creating the netdev.

Let's just ignore the warning for sFlow tests.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovsdb-cluster.at: Make torture tests BSD compliant.
Ilya Maximets [Thu, 20 Dec 2018 17:31:59 +0000 (20:31 +0300)]
ovsdb-cluster.at: Make torture tests BSD compliant.

'read' requires explicit argument.
'sed' partially replaced with more portable 'tr' because '\n'
could not be recognized as a line break.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agotest-ovsdb.py: Add line breaks to the error messages.
Ilya Maximets [Thu, 20 Dec 2018 17:33:03 +0000 (20:33 +0300)]
test-ovsdb.py: Add line breaks to the error messages.

'sys.stderr.write' does not add them.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovs-macros.at: Hide 'exec -a' checking from user.
Ilya Maximets [Thu, 20 Dec 2018 17:33:44 +0000 (20:33 +0300)]
ovs-macros.at: Hide 'exec -a' checking from user.

Messages like 'exec: -a: not found' are a bit annoying.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agopython: Catch setsockopt exceptions for TCP stream.
Ilya Maximets [Thu, 20 Dec 2018 17:35:57 +0000 (20:35 +0300)]
python: Catch setsockopt exceptions for TCP stream.

'sock.setsockopt' could throw exceptions. For example, if non-blocking
connection failed before the call:

  Traceback (most recent call last):
    File "../.././test-ovsdb.py", line 896, in <module>
      main(sys.argv)
    File "../.././test-ovsdb.py", line 891, in main
      func(*args)
    File "../.././test-ovsdb.py", line 604, in do_idl
      ovs.stream.Stream.open(r))
    File "/root/git_/ovs/python/ovs/stream.py", line 190, in open
      error, sock = cls._open(suffix, dscp)
    File "/root/git_/ovs/python/ovs/stream.py", line 744, in _open
      sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
    File "/usr/local/lib/python2.7/socket.py", line 228, in meth
      return getattr(self._sock,name)(*args)
  socket.error: [Errno 54] Connection reset by peer

This fixes tests on FreeBSD.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoodp.at: Make 'sed -i' BSD compatible.
Ilya Maximets [Wed, 19 Dec 2018 15:00:20 +0000 (18:00 +0300)]
odp.at: Make 'sed -i' BSD compatible.

'sed -i' on FreeBSD always expects backup filename extention
passed while GNU version expects it only if specified without
extra space after the '-i'. Let's specify the backup extention
to make BSD sed work.
This fixes test on FreeBSD.

CC: Joe Stringer <joe@ovn.org>
Fixes: 07659514c3c1 ("Add support for connection tracking.")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoutil: Make parse_int_string() only succeed if it parses a non-empty string.
Ben Pfaff [Wed, 19 Dec 2018 03:12:59 +0000 (19:12 -0800)]
util: Make parse_int_string() only succeed if it parses a non-empty string.

strtoull() doesn't necessarily set errno if it finds nothing to parse, but
this code didn't check for that case.

Reported-by: Ilya Maximets <i.maximets@samsung.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2018-December/354622.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoodp-util: Don't try to parse geneve data if not provided.
Ilya Maximets [Tue, 18 Dec 2018 15:56:16 +0000 (18:56 +0300)]
odp-util: Don't try to parse geneve data if not provided.

Despite of linux, 'strtoull' on FreeBSD sets errno to EINVAL in case
of no digits found. This causes odp_flow parsing failure if
there is no geneve data inside it. For example, ovs fails to parse
following flow on FreeBSD:

  tunnel(<...>,geneve({class=0xffff,type=1,len=0}),<...>)

Moving the parsing attempt under the if condition fixes the following
unit test failure:

  tunnel.at:780: testing tunnel - Geneve option present ...
  ./tunnel.at:810: ovs-appctl ofproto/trace ovs-dummy \
      'tunnel(<...>,geneve({class=0xffff,type=1,len=0}), ...'
  --- /dev/null 2018-12-18 13:24:55.001110000 +0000
  +++ /tmp/cirrus-ci-build/tests/testsuite.dir/at-groups/848/stderr
  @@ -0,0 +1,2 @@
  +ovs-dummy: unknown bridge
  +ovs-appctl: ovs-vswitchd: server returned an error

CC: Jesse Gross <jesse@kernel.org>
Fixes: 622a0a8e764d ("odp-util: Geneve netlink decoding.")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovn.at: Drop bash specific 'function' keyword.
Ilya Maximets [Tue, 18 Dec 2018 12:54:53 +0000 (15:54 +0300)]
ovn.at: Drop bash specific 'function' keyword.

This keyword is not portable and also optional in bash.
Fixes test on FreeBSD.

CC: Miguel Angel Ajo <majopela@redhat.com>
Fixes: 508b7f961bd6 ("ovn: l3ha, make is_chassis_active aware of gateway_chassis")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agostopwatch: Fix qsort comparison function.
Ilya Maximets [Tue, 18 Dec 2018 16:38:27 +0000 (19:38 +0300)]
stopwatch: Fix qsort comparison function.

Current version is broken because it converts first argument to
integer and after that substracts the duoble value. At the end
the result converted to integer again.
This does not cause unit test failures because qsort on linux
accidentially makes right order. On FreeBSD this leads to the
test failure:

  TEST '10-intervals-linear-growth'
  Assertion \
  '|(&stats)->pctl_95 - (&d->expected_stats)->pctl_95| < 1e-1' failed:
          |9 - 10| < 0.1

CC: Mark Michelson <mmichels@redhat.com>
Acked-by: Mark Michelson <mmichels@redhat.com>
Fixes: aed45befeff2 ("Add stopwatch timing API")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoofproto-dpif.at: Reduce code duplication.
Ilya Maximets [Tue, 18 Dec 2018 12:03:37 +0000 (15:03 +0300)]
ofproto-dpif.at: Reduce code duplication.

Almost equal 'check_dpflow_stats()' functions defined 4 times.
Make it common to reduce code duplication.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoofproto-dpif.at: Stop using not portable bash arrays.
Ilya Maximets [Tue, 18 Dec 2018 12:03:36 +0000 (15:03 +0300)]
ofproto-dpif.at: Stop using not portable bash arrays.

Fixes select group test on FreeBSD:
  test-source: 27: Syntax error: word unexpected (expecting ")")

CC: Jan Scheurich <jan.scheurich@ericsson.com>
Fixes: 06db81ccfe6d ("ofproto-dpif: Use dp_hash as default selection method")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoofproto-dpif.at: Stop using not portable 'read -d'.
Ilya Maximets [Tue, 18 Dec 2018 12:03:35 +0000 (15:03 +0300)]
ofproto-dpif.at: Stop using not portable 'read -d'.

'read -d' is a bash extention. Replace it with simple 'cat'.
This fixes 'select group' tests on FreeBSD.

CC: Jan Scheurich <jan.scheurich@ericsson.com>
Fixes: 06db81ccfe6d ("ofproto-dpif: Use dp_hash as default selection method")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agotests: Drop RECHECK support for valgrind tests.
Ilya Maximets [Tue, 18 Dec 2018 11:57:25 +0000 (14:57 +0300)]
tests: Drop RECHECK support for valgrind tests.

valgrind tests always runs with '-d' option which breaks the
re-checking. Lets just drop the rechecking support for these
targets.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agotests: Don't pass TESTSUITEFLAGS while re-checking.
Ilya Maximets [Tue, 18 Dec 2018 11:57:24 +0000 (14:57 +0300)]
tests: Don't pass TESTSUITEFLAGS while re-checking.

This fixes 'RECHECK=yes' functionality in case of configured test
range. For example, before the patch following cmdline will result in
running all of the 1000 tests re-checking in case of any failure:

  make -j8 check TESTSUITEFLAGS='1000-1999' RECHECK=yes

This happens because ranges and pattern matching options has higher
priority than the '--recheck'.
With patch, only failed tests from the range will be re-checked.

With this patch applied we're dropping support of '--verbose' and
'--trace' options while re-check, but, IMHO, these options makes
sense mostly while debugging individual tests and not much usable
while running recheck of a whole testsuite.
'--jobs' we're resetting each time anyway.

Not sure if someone overrides default '--directory'. For me it looks
not very useful. Changing the color mode also looks not much
profitable.

OTOH, re-checking the ranges or keyword matched tests is very useful,
for example, if you're trying to split up single testsuite check in
a few independent CI jobs.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoodp-util: Keep Address Sanitizer happy.
Darrell Ball [Mon, 17 Dec 2018 23:00:27 +0000 (15:00 -0800)]
odp-util: Keep Address Sanitizer happy.

An Address Sanitizer false positive.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoconntrack: Keep Address Sanitizer happy.
Darrell Ball [Mon, 17 Dec 2018 23:00:26 +0000 (15:00 -0800)]
conntrack: Keep Address Sanitizer happy.

An Address Sanitizer false positive.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoconntrack: Enforce conn_type for conn_clean().
Darrell Ball [Mon, 17 Dec 2018 22:43:14 +0000 (14:43 -0800)]
conntrack: Enforce conn_type for conn_clean().

Add check to validate that 'conn_clean()' is only called for
conntrack entries of default 'conn_type'.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoconntrack: Enforce conn_type for flush tuple.
Darrell Ball [Mon, 17 Dec 2018 22:43:13 +0000 (14:43 -0800)]
conntrack: Enforce conn_type for flush tuple.

The user should only reference a conntrack entry by the forward
direction context, as per 'conntrack_flush()', enforce this by
checking for 'default' conn_type.  The likelihood of a user
not using the original tuple is low, but it should be guarded
against, logged and documented.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoconntrack: Check all addresses for ephemeral ports.
Darrell Ball [Mon, 17 Dec 2018 22:43:12 +0000 (14:43 -0800)]
conntrack: Check all addresses for ephemeral ports.

When fallback to ephemeral ports triggers to find a NAT translation,
it may happen that the full address range is not explored; i.e. if
all ephemeral ports are being used for the address range >= the
first address checked and there are other addresses in the
available range, then they would not be explored for availability.
The likelihood of hitting this condition is rare. The fix is to
reset the first address to the minimum address when starting to
search ephemeral ports.  Found by inspection.

Fixes: 286de2729955 ("dpdk: Userspace Datapath: Introduce NAT Support.")
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoconntrack: Skip ephemeral ports fallback for DNAT.
Darrell Ball [Mon, 17 Dec 2018 22:43:11 +0000 (14:43 -0800)]
conntrack: Skip ephemeral ports fallback for DNAT.

Ephemeral port fallback is being done for DNAT and the code could be hit in
some special cases and testing configurations.  Also good packets are
expected to be persistently dropped in this case, which is not a common
user goal.  Regardless, this is incorrect, so filter this out.  Also, rename
the variable used for checking whether ephemeral ports need to be checked.

Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2018-August/351629.html
Fixes: 286de2729955 ("dpdk: Userspace Datapath: Introduce NAT Support.")
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoRevert "datapath: Derive IP protocol number for IPv6 later frags"
Greg Rose [Tue, 18 Dec 2018 17:43:19 +0000 (09:43 -0800)]
Revert "datapath: Derive IP protocol number for IPv6 later frags"

This reverts commit 2f748bf8016c ("datapath: Derive IP protocol...")

This commit is causing some ipv6 fragmentation errors in some older
kernels.  Revert for now and then we can determine how to implement
this patch with appropriate compatability layer changes to prevent
errors on older kernels.

CC: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodatapath: compat: Fix static key backport
Yi-Hung Wei [Fri, 14 Dec 2018 23:28:55 +0000 (15:28 -0800)]
datapath: compat: Fix static key backport

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

However, in Canonical's Trusty kernel, it introduced partial static
support which have different definition of some of the macros that
breaks the compatibility code.

For example, in net-next git tree commit 11276d5306b8
("locking/static_keys: Add a new static_key interface").
+ #define DEFINE_STATIC_KEY_TRUE(name)   \
+       struct static_key_true name = STATIC_KEY_TRUE_INIT

On the other hand, in Canonical's Trusty git tree commit 13f5d5d1cccb6
("x86/KVM/VMX: Add module argument for L1TF mitigation")
+ #define DEFINE_STATIC_KEY_TRUE(name)   \
+       struct static_key name = STATIC_KEY_INIT_TRUE

This commit resolves the ovs kernel module compatibility issue on
Trusty kernel.

VMware-BZ: #2251101
Fixes: 6660a9597a49 ("datapath: compat: Introduce static key support")
Tested-by: Greg Rose <gvrose8192@gmail.com>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovn: Fix the invalid eth.dst and ip6.dst set by nd_ns action for certain cases.
Numan Siddique [Mon, 17 Dec 2018 16:19:44 +0000 (21:49 +0530)]
ovn: Fix the invalid eth.dst and ip6.dst set by nd_ns action for certain cases.

When an IPv6 packet enters a router pipeline and it needs to be routed via
the nexthop IP address set in the static route, OVN generates an IPv6
Neigh Solicitation request if the nexthop IP is not resolved yet. But
right now, the generated IPv6 Neigh Solicitation packet doesn't set
the eth.dst to the mutlicast address derived from the nexthop and
ip6.dst to the solicited-node multicast address corresponding to the
nexthop address. Instead it generates these values from the actual
ip6.dst of the original packet.

This patch fixes this issue.

Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoopenvswitch: kernel datapath clone action
Yifeng Sun [Fri, 14 Dec 2018 22:32:23 +0000 (14:32 -0800)]
openvswitch: kernel datapath clone action

Upstream commit:
    commit b233504033dbd65740e59681820ccfd0a2a8ec53
    Author: Yifeng Sun <pkusunyifeng@gmail.com>
    Date:   Mon Jul 2 08:18:03 2018 -0700

    openvswitch: kernel datapath clone action

    Add 'clone' action to kernel datapath by using existing functions.
    When actions within clone don't modify the current flow, the flow
    key is not cloned before executing clone actions.

    This is a follow up patch for this incomplete work:
    https://patchwork.ozlabs.org/patch/722096/

    v1 -> v2:
    Refactor as advised by reviewer.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Tested-by: Greg Rose <gvrose8192@gmail.com>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Co-authored-by: Andy Zhou <azhou@ovn.org>
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Andy Zhou <azhou@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoacinclude: Include libmnl when needed
Timothy Redaelli [Fri, 14 Dec 2018 10:45:20 +0000 (11:45 +0100)]
acinclude: Include libmnl when needed

DPDK 18.11 uses libmnl when MLX5 PMD is enabled.

This commit makes OVS to link to libmnl when MLX5 PMD is enabled on
DPDK.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
5 years agotests: Strip "lt-" prefix when checking daemon process names.
Ben Pfaff [Sun, 16 Dec 2018 16:25:59 +0000 (08:25 -0800)]
tests: Strip "lt-" prefix when checking daemon process names.

When libtool is in the picture to deal with shared libraries, processes
end up with an "lt-" prefix in their process names.  This caused the
process name check in daemon.at to fail.  This commit fixes the problem by
stripping off that prefix.

Fixes: d8c6955a03ea ("tests: Simplify and improve the daemon tests.")
Reported-by: Timothy Redaelli <tredaelli@redhat.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2018-December/354574.html
Acked-by: Timothy Redaelli <tredaelli@redhat.com>
Tested-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodatapath: fix spelling mistake "execeeds" -> "exceeds"
Colin Ian King [Thu, 13 Dec 2018 23:08:25 +0000 (15:08 -0800)]
datapath: fix spelling mistake "execeeds" -> "exceeds"

Upstream commit:
    commit 43d0e96022ae3c66743c01bba6c18a3afec7b578
    Author: Colin Ian King <colin.king@canonical.com>
    Date:   Tue Nov 27 14:37:17 2018 +0000

    openvswitch: fix spelling mistake "execeeds" -> "exceeds"

    There is a spelling mistake in a net_warn_ratelimited message, fix this.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
CC: Colin Ian King <colin.king@canonical.com>
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodatapath: load NAT helper
Flavio Leitner [Thu, 13 Dec 2018 23:08:24 +0000 (15:08 -0800)]
datapath: load NAT helper

Upstream commit:
    commit 17c357efe5eceebdc3971a48b3d4d61a03c1178b
    Author: Flavio Leitner <fbl@redhat.com>
    Date:   Fri Sep 28 14:51:28 2018 -0300

    openvswitch: load NAT helper

    Load the respective NAT helper module if the flow uses it.

Signed-off-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
CC: Flavio Leitner <fbl@redhat.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodatapath: fix return type of ndo_start_xmit function
YueHaibing [Thu, 13 Dec 2018 23:08:23 +0000 (15:08 -0800)]
datapath: fix return type of ndo_start_xmit function

Upstream commit:
    commit eddf11e18dff0e8671e06ce54e64cfc843303ab9
    Author: YueHaibing <yuehaibing@huawei.com>
    Date:   Wed Sep 26 17:15:38 2018 +0800

    net: ovs: fix return type of ndo_start_xmit function

    The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
    which is a typedef for an enum type, so make sure the implementation in
    this driver has returns 'netdev_tx_t' value, and change the function
    return type to netdev_tx_t.

    Found by coccinelle.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
CC: YueHaibing <yuehaibing@huawei.com>
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodatapath: Derive IP protocol number for IPv6 later frags
Yi-Hung Wei [Thu, 13 Dec 2018 23:08:22 +0000 (15:08 -0800)]
datapath: Derive IP protocol number for IPv6 later frags

Upstream commit:
    commit fa642f08839bf2ff35b2f6c6a6c062aee8121ba8
    Author: Yi-Hung Wei <yihung.wei@gmail.com>
    Date:   Tue Sep 4 15:33:41 2018 -0700

    openvswitch: Derive IP protocol number for IPv6 later frags

    Currently, OVS only parses the IP protocol number for the first
    IPv6 fragment, but sets the IP protocol number for the later fragments
    to be NEXTHDF_FRAGMENT.  This patch tries to derive the IP protocol
    number for the IPV6 later frags so that we can match that.

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>
CC: Yi-Hung Wei <yihung.wei@gmail.com>
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodatapath: check tunnel option type in tunnel flags
Pieter Jansen van Vuuren [Thu, 13 Dec 2018 23:08:21 +0000 (15:08 -0800)]
datapath: check tunnel option type in tunnel flags

Upstream commit:
    commit 256c87c17c53e60882a43dcf3e98f3bf859eaf6f
    Author: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
    Date:   Tue Jun 26 21:39:36 2018 -0700

    net: check tunnel option type in tunnel flags

    Check the tunnel option type stored in tunnel flags when creating options
    for tunnels. Thereby ensuring we do not set geneve, vxlan or erspan tunnel
    options on interfaces that are not associated with them.

    Make sure all users of the infrastructure set correct flags, for the BPF
    helper we have to set all bits to keep backward compatibility.

Signed-off-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
CC: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agocompat: Fixup ip_tunnel_info_opts_set
Greg Rose [Thu, 13 Dec 2018 23:08:20 +0000 (15:08 -0800)]
compat: Fixup ip_tunnel_info_opts_set

A new flags parameter has been added in 4.19 so add compat fixup.

Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodatapath: kzalloc() -> kcalloc()
Kees Cook [Thu, 13 Dec 2018 23:08:19 +0000 (15:08 -0800)]
datapath: kzalloc() -> kcalloc()

Upstream commit:
    commit 6396bb221514d2876fd6dc0aa2a1f240d99b37bb
    Author: Kees Cook <keescook@chromium.org>
    Date:   Tue Jun 12 14:03:40 2018 -0700

    treewide: kzalloc() -> kcalloc()

    The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

            kzalloc(a * b, gfp)

    with:
            kcalloc(a * b, gfp)

    as well as handling cases of:

            kzalloc(a * b * c, gfp)

    with:

            kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

            kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

            kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
      kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
      , ...)
    |
      kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
      , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
      kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
      , ...)
    |
      kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
      , ...)
    |
      kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
      , ...)
    |
      kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
      , ...)
    |
      kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
      , ...)
    |
      kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
      , ...)
    |
      kzalloc(
    - sizeof(char) * COUNT
    + COUNT
      , ...)
    |
      kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
      , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
      (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
      , ...)
    |
    - kzalloc
    + kcalloc
      (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
      , ...)
    |
    - kzalloc
    + kcalloc
      (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
      , ...)
    |
    - kzalloc
    + kcalloc
      (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
      , ...)
    |
    - kzalloc
    + kcalloc
      (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
      , ...)
    |
    - kzalloc
    + kcalloc
      (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
      , ...)
    |
    - kzalloc
    + kcalloc
      (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
      , ...)
    |
    - kzalloc
    + kcalloc
      (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
      , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
      (
    - SIZE * COUNT
    + COUNT, SIZE
      , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
      kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
      , ...)
    |
      kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
      , ...)
    |
      kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
      , ...)
    |
      kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
      , ...)
    |
      kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
      , ...)
    |
      kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
      , ...)
    |
      kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
      , ...)
    |
      kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
      , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
      kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
      , ...)
    |
      kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
      , ...)
    |
      kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
      , ...)
    |
      kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
      , ...)
    |
      kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
      , ...)
    |
      kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
      , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
      kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
      kzalloc(C1 * C2 * C3, ...)
    |
      kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
      , ...)
    |
      kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
      , ...)
    |
      kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
      , ...)
    |
      kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
      , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
      kzalloc(sizeof(THING) * C2, ...)
    |
      kzalloc(sizeof(TYPE) * C2, ...)
    |
      kzalloc(C1 * C2 * C3, ...)
    |
      kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
      (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
      , ...)
    |
    - kzalloc
    + kcalloc
      (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
      , ...)
    |
    - kzalloc
    + kcalloc
      (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
      , ...)
    |
    - kzalloc
    + kcalloc
      (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
      , ...)
    |
    - kzalloc
    + kcalloc
      (
    - (E1) * E2
    + E1, E2
      , ...)
    |
    - kzalloc
    + kcalloc
      (
    - (E1) * (E2)
    + E1, E2
      , ...)
    |
    - kzalloc
    + kcalloc
      (
    - E1 * E2
    + E1, E2
      , ...)
    )

Signed-off-by: Kees Cook <keescook@chromium.org>
CC: Kees Cook <keescook@chromium.org>
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodatapath: kmalloc() -> kmalloc_array()
Kees Cook [Thu, 13 Dec 2018 23:08:18 +0000 (15:08 -0800)]
datapath: kmalloc() -> kmalloc_array()

Upstream commit:
    commit 6da2ec56059c3c7a7e5f729e6349e74ace1e5c57
    Author: Kees Cook <keescook@chromium.org>
    Date:   Tue Jun 12 13:55:00 2018 -0700

    treewide: kmalloc() -> kmalloc_array()

    The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
    patch replaces cases of:

            kmalloc(a * b, gfp)

    with:
            kmalloc_array(a * b, gfp)

    as well as handling cases of:

            kmalloc(a * b * c, gfp)

    with:

            kmalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

            kmalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

            kmalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The tools/ directory was manually excluded, since it has its own
    implementation of kmalloc().

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
      kmalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
      , ...)
    |
      kmalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
      , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
      kmalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
      , ...)
    |
      kmalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
      , ...)
    |
      kmalloc(
    - sizeof(char) * (COUNT)
    + COUNT
      , ...)
    |
      kmalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
      , ...)
    |
      kmalloc(
    - sizeof(u8) * COUNT
    + COUNT
      , ...)
    |
      kmalloc(
    - sizeof(__u8) * COUNT
    + COUNT
      , ...)
    |
      kmalloc(
    - sizeof(char) * COUNT
    + COUNT
      , ...)
    |
      kmalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
      , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kmalloc
    + kmalloc_array
      (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
      , ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
      , ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
      , ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
      , ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
      , ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
      , ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
      , ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
      , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kmalloc
    + kmalloc_array
      (
    - SIZE * COUNT
    + COUNT, SIZE
      , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
      kmalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
      , ...)
    |
      kmalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
      , ...)
    |
      kmalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
      , ...)
    |
      kmalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
      , ...)
    |
      kmalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
      , ...)
    |
      kmalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
      , ...)
    |
      kmalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
      , ...)
    |
      kmalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
      , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
      kmalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
      , ...)
    |
      kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
      , ...)
    |
      kmalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
      , ...)
    |
      kmalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
      , ...)
    |
      kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
      , ...)
    |
      kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
      , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
      kmalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kmalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kmalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kmalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kmalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kmalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kmalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    |
      kmalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
      , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
      kmalloc(C1 * C2 * C3, ...)
    |
      kmalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
      , ...)
    |
      kmalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
      , ...)
    |
      kmalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
      , ...)
    |
      kmalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
      , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
      kmalloc(sizeof(THING) * C2, ...)
    |
      kmalloc(sizeof(TYPE) * C2, ...)
    |
      kmalloc(C1 * C2 * C3, ...)
    |
      kmalloc(C1 * C2, ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
      , ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
      , ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
      , ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
      , ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - (E1) * E2
    + E1, E2
      , ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - (E1) * (E2)
    + E1, E2
      , ...)
    |
    - kmalloc
    + kmalloc_array
      (
    - E1 * E2
    + E1, E2
      , ...)
    )

Signed-off-by: Kees Cook <keescook@chromium.org>
CC: Kees Cook <keescook@chromium.org>
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoAUTHORS: Add Martin Xu.
Ben Pfaff [Thu, 13 Dec 2018 19:29:47 +0000 (11:29 -0800)]
AUTHORS: Add Martin Xu.

Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agorhel: Add 'SYSTEMD_NO_WRAP=yes' in ovs init script for SLES
Martin Xu [Mon, 10 Dec 2018 14:33:19 +0000 (06:33 -0800)]
rhel: Add 'SYSTEMD_NO_WRAP=yes' in ovs init script for SLES

The variable equivalent to RHEL's 'SYSTEMCTL_SKIP_REDIRECT=yes' on SLES
12 is 'SYSTEMD_NO_WRAP=yes'

VMware-BZ: #2245358
Reviewed-by: Markos Chandras <mchandras@suse.de>
CC: Markos Chandras <mchandras@suse.de>
CC: Ansis Atteka <aatteka@ovn.org>
CC: Ben Pfaff <blp@ovn.org>
Signed-off-by: Martin Xu <martinxu9.ovs@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodpdk: Update to use DPDK 18.11.
Ophir Munk [Mon, 10 Dec 2018 22:15:38 +0000 (22:15 +0000)]
dpdk: Update to use DPDK 18.11.

This commit adds support for DPDK v18.11, it includes the following
changes.

1. Enable compilation and linkage with dpdk 18.11.0
   The following dpdk commits which were introduced after dpdk 17.11.x
   require OVS updates to accommodate to the dpdk changes.
   - ce17edde ("ethdev: introduce Rx queue offloads API")
   - ab3ce1e0 ("ethdev: remove old offload API")
   - c06ddf96 ("meter: add configuration profile")
   - e58638c3 ("ethdev: fix TPID handling in flow API")
   - cd8c7c7c ("ethdev: replace bus specific struct with generic dev")
   - ac8d22de ("ethdev: flatten RSS configuration in flow API")

2. Limit configured rss hash functions to only those supported
   by the eth device.

3. Set default RSS key in struct action_rss_data, required by OVS
   commit- e8a2b5bf ("netdev-dpdk: implement flow offload with rte flow")
   when configured with "other_config:hw-offload=true".

4. DEV_RX_OFFLOAD_CRC_STRIP has been removed from DPDK 18.11.
   DEV_RX_OFFLOAD_KEEP_CRC can now be used to keep the CRC.
   Use the correct flag and check it is supported.

5. rte_eth_dev_attach/detach have been removed from DPDK 18.11.
   Replace them with rte_dev_probe/remove.

6. Update docs and travis to use DPDK18.11.

This commit squashes the following commits present on the dpdk-latest
branch:

7f021f902bb3 ("netdev-dpdk: Upgrade to dpdk v18.08")
270d9216f1ed ("netdev-dpdk: Set scatter based on capabilities")
bef2cdc8f412 ("netdev-dpdk: Fix returning the field of malloced struct.")
73c1a65167fc ("redhat: change variable used for non-root user support")
eb485f60ce44 ("dpdk: Update to use DPDK 18.11.")

For credit all authors of the original commits above have been added as
co-authors for this commmit.

From: Ophir Munk <ophirmu@mellanox.com>
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Co-authored-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Co-authored-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Co-authored-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
5 years agosparse: Fix incompatibility with glibc 2.28 and later.
Ben Pfaff [Wed, 12 Dec 2018 17:45:21 +0000 (09:45 -0800)]
sparse: Fix incompatibility with glibc 2.28 and later.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
5 years agoovn: Fix indentation in TODO.
Ben Pfaff [Thu, 20 Sep 2018 23:44:11 +0000 (16:44 -0700)]
ovn: Fix indentation in TODO.

Some items listed under ovsdb-server should have been top-level items.

Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoOVN: add selected mac address to MACAM in update_dynamic_addresses
Lorenzo Bianconi [Wed, 21 Nov 2018 16:03:39 +0000 (17:03 +0100)]
OVN: add selected mac address to MACAM in update_dynamic_addresses

Add selected dynamic mac address to MACAM in update_dynamic_addresses
and not just in in ipam_add_port_addresses/ipam_insert_lsp_addresses
since the second approach can produce a duplicated L2 address in a
IPv6-only network if ipv6_prefix is provided after logical port creation.
The issue can be triggered with the following reproducer:

$ovn-nbctl ls-add sw0
$ovn-nbctl lsp-add sw0 sw0-port1
$ovn-nbctl lsp-set-addresses sw0-port1 "dynamic"
$ovn-nbctl lsp-add sw0 sw0-port2
$ovn-nbctl lsp-set-addresses sw0-port2 "dynamic"
$ovs-vsctl add-port br-int p1 -- \
    set Interface p1 external_ids:iface-id=sw0-port1
$ovs-vsctl add-port br-int p2 -- \
    set Interface p2 external_ids:iface-id=sw0-port2
[..]
$ovn-nbctl --wait=sb set Logical-switch sw0 \
    other_config:ipv6_prefix="aef0::"

$ovn-nbctl list logical_switch_port
_uuid               : 1e0e2ed8-20c6-48dc-bfa8-d823e48c9f45
addresses           : [dynamic]
dhcpv4_options      : []
dhcpv6_options      : []
dynamic_addresses   : "0a:00:00:00:00:01 aef0::800:ff:fe00:1"
enabled             : []
external_ids        : {}
name                : "sw0-port1"
options             : {}
parent_name         : []
port_security       : []
tag                 : []
tag_request         : []
type                : ""
up                  : true

_uuid               : cfeab7fb-e20b-41f1-974c-f99e0b5293d7
addresses           : [dynamic]
dhcpv4_options      : []
dhcpv6_options      : []
dynamic_addresses   : "0a:00:00:00:00:01 aef0::800:ff:fe00:1"
enabled             : []
external_ids        : {}
name                : "sw0-port2"
options             : {}
parent_name         : []
port_security       : []
tag                 : []
tag_request         : []
type                : ""
up                  : true

Fixes: c814545b43ac ("OVN: configure L2 address according to the used IP
address")

Acked-by: Mark Michelson <mmichels@redhat.com>
Acked-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agopinctrl: Check requested IP in DHCPREQUEST messages
Gregory Smith [Wed, 12 Dec 2018 18:46:11 +0000 (10:46 -0800)]
pinctrl: Check requested IP in DHCPREQUEST messages

See RFC 2131, section 4.3.2. When handling a DHCPREQUEST message, the
server should validate that the client's requested IP matches the
offered IP. If not, the server should reply with a DHCPNAK. The client's
requested IP is either specified as the Requested IP Address (option
50), or as the ciaddr, depending on the client's state.

Signed-off-by: Gregory Smith <gasmith@nutanix.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodhcp: Mark dhcp_header as packed.
Ben Pfaff [Wed, 12 Dec 2018 18:46:10 +0000 (10:46 -0800)]
dhcp: Mark dhcp_header as packed.

This structure isn't performance-sensitive and making it packed simplifies
thinking about access to it.

CC: Gregory Smith <gasmith@nutanix.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovn-controller: Inject GARPs to logical switch pipeline to update neighbors
Daniel Alvarez [Tue, 4 Dec 2018 18:14:35 +0000 (19:14 +0100)]
ovn-controller: Inject GARPs to logical switch pipeline to update neighbors

Prior to this patch, GARPs announcing NAT addresses or new VIFs
were sent out to localnet ofport through an output action.
This can lead to problems since local datapaths won't get those
GARPs and ovn-controller won't update MAC_Binding entries (as
upstream switch will not send back the GARP to this port hence
other logical routers won't update their neighbours).

This patch is changing the behavior so that GARPs get injected
to OVN pipeline of the external switch. This way, they'll get
broadcasted to local pipelines and also sent out to the external
network through the localnet port.

Acked-by: Han Zhou <hzhou8@ebay.com>
Acked-by: Numan Siddique <nusiddiq@redhat.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-October/047604.html
Signed-off-by: Daniel Alvarez <dalvarez@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agonetdev: Add comment to allow removing a workaround in the future
Daniel Alvarez [Fri, 16 Nov 2018 10:42:29 +0000 (11:42 +0100)]
netdev: Add comment to allow removing a workaround in the future

This patch [0] in glibc fixes an issue which is right now workarounded
in OVS by [1]. I'm adding a comment to indicate that from glibc 2.28
and beyond, the workaround is not needed so that we can eventually
remove it.

[0] https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c1f86a33ca32e26a9d6e29fc961e5ecb5e2e5eb4
[1] https://github.com/openvswitch/ovs/commit/3434d306866d825084d2d186d1f8dd98662ff650

Signed-off-by: Daniel Alvarez <dalvarez@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoAUTHORS: Add Martin Fong.
Ben Pfaff [Wed, 12 Dec 2018 18:02:21 +0000 (10:02 -0800)]
AUTHORS: Add Martin Fong.

Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovs-tcpdump: Add --span to mirror all ports on bridge.
Martin Fong [Fri, 9 Nov 2018 20:16:02 +0000 (12:16 -0800)]
ovs-tcpdump: Add --span to mirror all ports on bridge.

Signed-off-by: Martin Fong <mwfong@csl.sri.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoofproto: Return correct error codes from meter_set.
Tony van der Peet [Wed, 21 Nov 2018 20:44:43 +0000 (09:44 +1300)]
ofproto: Return correct error codes from meter_set.

This routine should return enum ofperr, but in a couple of places
doesn't. When adding one more meter when the meter table is full,
this results in an incorrect error message.

Signed-off-by: Tony van der Peet <tony.vanderpeet@alliedtelesis.co.nz>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoutilities: Add smap related command and iterator to the GDB script
Eelco Chaudron [Thu, 22 Nov 2018 15:18:14 +0000 (16:18 +0100)]
utilities: Add smap related command and iterator to the GDB script

Adds "ovs_dump_smap <struct smap *>" command

Example output:

Breakpoint 1, trtcm_policer_qos_construct (details=0x135bad0, conf=0x7ffd31f5da28) at lib/netdev-dpdk.c:4154
(gdb) ovs_dump_smap 0x135bad0
cbs: 2048
cir: 151800
eir: 151800
pbs: 2048

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agocirrus: Add Cirrus CI integration for FreeBSD build
Ilya Maximets [Tue, 11 Dec 2018 14:34:17 +0000 (17:34 +0300)]
cirrus: Add Cirrus CI integration for FreeBSD build

CirrusCI [1] is free for open-sorce projects and provides similar
to TravisCI interfaces. One significant difference is ability
to run tasks on FreeBSD instances.

This patch adds simple configuration file to test OVS build
on two FreeBSD releases with gcc and clang.
Unit tests are commented out because they are broken for now.

To enable the automated checks Cirrus CI application from GitHub
Marketplace should be installed. See details in Quick Start guide [2].

[1] https://cirrus-ci.org
[2] https://cirrus-ci.org/guide/quick-start/

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agotreewide: Wider use of packet batch APIs.
Ilya Maximets [Mon, 10 Dec 2018 17:17:53 +0000 (20:17 +0300)]
treewide: Wider use of packet batch APIs.

This patch replaces most of direct accesses to the dp_packet_batch
internal components by appropriate APIs.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
5 years agotests: Fix syntax in another ODP test.
Ben Pfaff [Mon, 10 Dec 2018 17:45:47 +0000 (09:45 -0800)]
tests: Fix syntax in another ODP test.

Reported-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agotests: Simplify and improve the daemon tests.
Ben Pfaff [Mon, 10 Dec 2018 17:43:19 +0000 (09:43 -0800)]
tests: Simplify and improve the daemon tests.

The daemon tests used files a lot when shell variables were easier to use
and easier to understand.  This commit changes that.

The tests created empty databases that aren't really needed anymore.  This
commit changes them to use the ovsdb-server --no-db option instead.

The tests had a lot of common code for checking the ancestry of processes.
This commit factors out a new shell function check_ancestors.

The tests tended to use random pidfile names.  This switches to just using
the defaults, which are fine.

The tests didn't check the names of the child processes.  This adds those
checks using the new check_process_name shell function.  This should avoid
regression of the bug fixed by commit 266f79e32c60 ("daemon-unix: Use
same name for original or restarted children.")

Other minor improvements too.

I only made small updates to the Windows-specific test, because it is hard
for me to verify.

Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodpctl: Simplify opt_dpif_open().
Darrell Ball [Mon, 19 Nov 2018 19:09:26 +0000 (11:09 -0800)]
dpctl: Simplify opt_dpif_open().

The commonly used function, opt_dpif_open(), recently became more complex
to check for a datapath argument. Unnecessary dummy parameters for most users
were hence added.  Revert back and call the intended api, dp_arg_exists(), to
query for a datapath argument being supplied.

Fixes: 4eeec031d4c4 ("dpctl: Implement dpctl commands for conntrack per zone limit")
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoAUTHORS: Add David Marchand and Scott Cheloha.
Ben Pfaff [Mon, 10 Dec 2018 21:04:20 +0000 (13:04 -0800)]
AUTHORS: Add David Marchand and Scott Cheloha.

Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovs-ctl: fix system-id.conf owner
David Marchand [Thu, 22 Nov 2018 15:37:57 +0000 (16:37 +0100)]
ovs-ctl: fix system-id.conf owner

As far as RPMs are concerned, system-id.conf file is declared as being
owned by openvswitch.
At the first ovs startup, ovs-ctl creates this file if none exists without
ensuring this.

We end up with an inconsistency:
$ rpm -V openvswitch
.....UG..  c /etc/openvswitch/system-id.conf

Fix this when ovs-ctl is the one who creates the file.

Note: this issue ends up being hidden after a RPM upgrade, since the
openvswitch user is enforced on the whole /etc/openvswitch directory as a
%post operation.

Acked-by: Timothy Redaelli <tredaelli@redhat.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agorhel: Don't ship static libraries
Timothy Redaelli [Tue, 20 Nov 2018 18:40:50 +0000 (19:40 +0100)]
rhel: Don't ship static libraries

Since commit bc4fd439586f ("rhel: Ship ovs shared libraries, fedora")
openvswitch-devel RPM package includes both static and shared library.
This is against the Fedora Packaging Guidelines [1].

This commit prevent the static libraries and libtool archives to be shipped.

[1] https://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_Static_Libraries

Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovs-thread: Add thread safety annotation to cond_wait.
Ilya Maximets [Mon, 10 Dec 2018 17:05:23 +0000 (20:05 +0300)]
ovs-thread: Add thread safety annotation to cond_wait.

This fixes build with clang on FreeBSD:

  lib/ovs-thread.c:266:13: error:

  calling function 'pthread_cond_wait' requires holding mutex \
  'mutex->lock' exclusively [-Werror,-Wthread-safety-analysis]

      error = pthread_cond_wait(cond, &mutex->lock);
              ^

Fixes: 97be153858b4 ("clang: Add annotations for thread safety check.")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovs-thread: Drop xpthread_meutex_{un}lock finctions.
Ilya Maximets [Mon, 10 Dec 2018 17:05:22 +0000 (20:05 +0300)]
ovs-thread: Drop xpthread_meutex_{un}lock finctions.

There are no users of these functions.
This change fixes clang build on FreeBSD:

  lib/ovs-thread.c:158:1: error: \
      mutex 'mutex' is still held at the end of function \
      [-Werror,-Wthread-safety-analysis]
  XPTHREAD_FUNC1(pthread_mutex_lock, pthread_mutex_t *);
  ^
  lib/ovs-thread.c:138:5: note: expanded from macro 'XPTHREAD_FUNC1'
      }
      ^

Fixes: 4dff0893c376 ("ovs-atomic-pthreads: Use global shared locks for atomic_flag also.")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agotests: Remove redzone flag for FreeBSD 12+.
Ilya Maximets [Mon, 10 Dec 2018 17:05:21 +0000 (20:05 +0300)]
tests: Remove redzone flag for FreeBSD 12+.

'redzone' not supported in new versions of jemalloc
(since jemalloc 5.0.0).

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoconfigure.ac: More enhanced check for pthread library.
Ilya Maximets [Mon, 10 Dec 2018 17:05:20 +0000 (20:05 +0300)]
configure.ac: More enhanced check for pthread library.

FreeBSD 12 supports 'pthread_rwlock_tryrdlock' without 'pthread'
library. Let's add check for more rare function.
OTOH, Travis-CI environment supports 'pthread_rwlockattr_destroy',
but does not support 'pthread_rwlock_tryrdlock' without 'pthread'.
So, both checks needed.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agotests: keep some datapath parsing tests from hanging
Scott Cheloha [Thu, 29 Nov 2018 00:38:03 +0000 (18:38 -0600)]
tests: keep some datapath parsing tests from hanging

The arguments to sed(1) need to be on the same line in the shell
script or it will just sit there awaiting input.

Signed-off-by: Scott Cheloha <scottcheloha@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoAUTHORS: Add Yousong Zhou.
Ben Pfaff [Tue, 4 Dec 2018 02:15:43 +0000 (18:15 -0800)]
AUTHORS: Add Yousong Zhou.

Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovs-ctl: fallback to "uname -n" for fetching hostname
Yousong Zhou [Tue, 4 Dec 2018 01:41:26 +0000 (01:41 +0000)]
ovs-ctl: fallback to "uname -n" for fetching hostname

The command "hostname" is not available in OpenWrt by default.  Strace
result of hostname-3.13 on centos7 shows that bare "hostname" command
calls uname() to fetch node name.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoofctl_parse_target: Fix memory leaks if there is no usable protocol
Yifeng Sun [Wed, 28 Nov 2018 00:10:11 +0000 (16:10 -0800)]
ofctl_parse_target: Fix memory leaks if there is no usable protocol

When there is no usable protocol, ofctl_parse_flows__ returns without
properly freeing memory. A previous patch failed to fix this issue.
This patch fixes it.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11406
Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11408
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoodp-util: Validate values of vid and pcp in push_vlan action
Yifeng Sun [Wed, 28 Nov 2018 00:10:12 +0000 (16:10 -0800)]
odp-util: Validate values of vid and pcp in push_vlan action

Oss-fuzz complains that 'vid << VLAN_VID_SHIFT' is causing an error of
"Undefined-shift in parse_odp_action". This is because an invalid
value of vid is passed in push_vlan. This patch adds validation to
the value of vid, in addition to the value of pcp.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11520
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovs-ofctl: update a man page about group syntax
Nobuhiro MIKI [Wed, 28 Nov 2018 13:47:20 +0000 (22:47 +0900)]
ovs-ofctl: update a man page about group syntax

Signed-off-by: Nobuhiro MIKI <nob@bobuhiro11.net>
5 years agoovn-sb.xml: Remove outdated paragragh which is not true any more.
Numan Siddique [Tue, 27 Nov 2018 16:50:24 +0000 (22:20 +0530)]
ovn-sb.xml: Remove outdated paragragh which is not true any more.

Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoDocumentation: Fixing some minor spelling mistakes and consistent usage of certain...
Ashish Varma [Wed, 28 Nov 2018 18:49:50 +0000 (10:49 -0800)]
Documentation: Fixing some minor spelling mistakes and consistent usage of certain keywords.

Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovs-ofctl: Correct "out_group" field usage text in manpage.
Ashish Varma [Thu, 29 Nov 2018 21:44:34 +0000 (13:44 -0800)]
ovs-ofctl: Correct "out_group" field usage text in manpage.

Right now the man page of ovs-ofctl has "out_group=port". Correcting the
output to group instead of port.

Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodatapath: use KARCH when building linux datapath modules
Yousong Zhou [Fri, 30 Nov 2018 07:30:04 +0000 (07:30 +0000)]
datapath: use KARCH when building linux datapath modules

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoovs-save: compatible with busybox ip command
Yousong Zhou [Fri, 30 Nov 2018 07:30:03 +0000 (07:30 +0000)]
ovs-save: compatible with busybox ip command

Busybox ip command will have exit code 1 for `ip -V` or `ip help` etc.,
use `ip link show` to cover both iproute2 and busybox ip command

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agodebian: Install correct vtep-ctl.
Ben Pfaff [Tue, 30 Oct 2018 18:21:06 +0000 (11:21 -0700)]
debian: Install correct vtep-ctl.

The previous syntax installed the libtool wrapper script instead of the
actual binary.  This fixes the problem.

CC: James Page <james.page@ubuntu.com>
Fixes: 3d8dededeaf8 ("debian: Rationalize packaging using new debhelper.")
Reported-by: hubo <hubo@jiedaibao.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-October/047625.html
Acked-by: Justin Pettit <jpettit@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
5 years agoosvdb: Add some helpful comments.
Ben Pfaff [Thu, 1 Nov 2018 16:29:07 +0000 (09:29 -0700)]
osvdb: Add some helpful comments.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
5 years agoofp-table: Parse table features messages more carefully.
Ben Pfaff [Wed, 29 Aug 2018 20:16:36 +0000 (13:16 -0700)]
ofp-table: Parse table features messages more carefully.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>