]> git.proxmox.com Git - mirror_ovs.git/log
mirror_ovs.git
6 years agosandbox: disable ssl for backup ovn southbound db
Lance Richardson [Tue, 13 Jun 2017 17:51:06 +0000 (13:51 -0400)]
sandbox: disable ssl for backup ovn southbound db

Since the sandbox environment was changed to enable SSL usage for
OVN_Southbound connections, the backup southbound server emits
the log message "socket_util|ERR|6642: bind: Address already in use"
every 2.5 seconds.

Fix by configuring the backup db server to not use remote configuration
from the database (the unix: socket can still be used, as was the
case before SSL was enabled).

Fixes: 0ced2a5c5e47 ("sandbox: use ssl for ovn-controller to sb db connection")
Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoconntrack: Reset nat_info in un_nat conns.
Darrell Ball [Tue, 13 Jun 2017 14:46:29 +0000 (07:46 -0700)]
conntrack: Reset nat_info in un_nat conns.

Un-nat conns have no nat_info as do default conns.
However, un-nat conns are originally templated from the
corresponding default conns and therefore need to
have their nat_info explicitly nulled.  This
otherwise exposes a double free if conntrack_destroy()
were to be used to destroy the connection tracker.  This
would apply to cleaning the datapath after testing.

Fixes: 286de2729955 ("dpdk: Userspace Datapath: Introduce NAT Support.")
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Greg Rose <gvrose8192@gmail.com>
6 years agoredhat: make the rpm aware of the lock file
Aaron Conole [Tue, 13 Jun 2017 18:26:03 +0000 (14:26 -0400)]
redhat: make the rpm aware of the lock file

Currently, the db lockfile will cause the openvswitch directory to
linger after uninstall because the rpm database isn't aware that it
should be treated as part of the system.  This commit informs the rpmdb
properly as a 'ghost' so that when the package is uninstalled, it will
be removed automatically.  This means that if no extra files exist in
/etc/openvswitch, the whole directory will be removed from /etc/.

Acked-by: Flavio Leitner <fbl@sysclose.org>
Reviewed-by: Markos Chandras <mchandra@suse.de>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agosandbox: ovn rbac support for sandbox environment
Lance Richardson [Mon, 12 Jun 2017 22:42:39 +0000 (18:42 -0400)]
sandbox: ovn rbac support for sandbox environment

Enable OVN_Southbound RBAC by default in the sandbox environment,
provide a new option "--no-ovn-rbac" to disable it.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
6 years agotreewide: Avoid undefined behavior passing null in nonnull parameters.
Lance Richardson [Tue, 13 Jun 2017 16:57:38 +0000 (12:57 -0400)]
treewide: Avoid undefined behavior passing null in nonnull parameters.

Eliminate a number of instances of undefined behavior related to
passing NULL in parameters having "nonnull" annotations.

Found with gcc's undefined behavior sanitizer.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agohash: Remove conflicting hash_finish() prototype.
Ben Pfaff [Tue, 13 Jun 2017 15:30:02 +0000 (08:30 -0700)]
hash: Remove conflicting hash_finish() prototype.

Normally, hash_finish() is declared as:
static inline uint32_t hash_finish(uint32_t hash, uint32_t final)

When __SSE4_2__ && __x86_64__, it is declared as:
static inline uint32_t hash_finish(uint64_t hash, uint64_t final)

A recent commit added an unneeded prototype in the first form, which caused
an error due to the redeclaration of a different type when the second form
was actually used.  This removes the prototype, fixing the problem.

It may not be a great idea to have two different forms for this function,
but it's long standing and so I don't want to change it immediately without
proper consideration.

Reported-by: "Fischetti, Antonio" <antonio.fischetti@intel.com>
Fixes: 67702b79d845 ("hash: New helper functions for adding words in a buffer to a hash.")
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Darrell Ball <dlu998@gmail.com>
6 years agobyte-order: Fix undefined behavior of BYTES_TO_BE32.
Ben Pfaff [Tue, 13 Jun 2017 04:51:14 +0000 (21:51 -0700)]
byte-order: Fix undefined behavior of BYTES_TO_BE32.

A left shift that would produce a result that is not representable
by the type of the expression's result has "undefined behavior"
according to the C language standard. Avoid this by casting values
that could set the upper bit to unsigned types.

Also document and convert a macro to a function.

While we're at it, delete the unused macro BE16S_TO_BE32.

Found via gcc's undefined behavior sanitizer.

Reported-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Lance Richardson <lrichard@redhat.com>
6 years agoconntrack: Add hash_finish() to conn_key_hash().
Darrell Ball [Fri, 9 Jun 2017 22:30:44 +0000 (15:30 -0700)]
conntrack: Add hash_finish() to conn_key_hash().

The function conn_key_hash() is updated to include
a call to hash_finish() and also to make use of a
new hash abstraction - ct_endpoint_hash_add().

Fixes: a489b16854b5 ("conntrack: New userspace connection tracker.")
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoconntrack: Hash entire NAT data structure in nat_range_hash().
Darrell Ball [Fri, 9 Jun 2017 22:30:43 +0000 (15:30 -0700)]
conntrack: Hash entire NAT data structure in nat_range_hash().

Part of the hash input for nat_range_hash() was accidentally
omitted, so this fixes the problem.  Also, add a missing call to
hash_finish().

Fixes: 286de2729955 ("dpdk: Userspace Datapath: Introduce NAT Support.")
Co-authored-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agohash: New helper functions for adding words in a buffer to a hash.
Ben Pfaff [Fri, 9 Jun 2017 22:30:42 +0000 (15:30 -0700)]
hash: New helper functions for adding words in a buffer to a hash.

These will receive their first user (outside of hash.h) in the following
commit.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agotestsuite: exit gracefully if it fails.
Flavio Leitner [Fri, 9 Jun 2017 15:58:57 +0000 (12:58 -0300)]
testsuite: exit gracefully if it fails.

The daemon is killed leaving resources behind when a test fails.
This fixes to first signal the daemon to exit gracefully.

Fixes: 0f28164be02ac ("netdev-linux: make tap devices persistent")
Suggested-by: Joe Stringer <joe@ovn.org>
Co-authored-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
6 years agowindows-datapath: Temporary workaround checksum issue with NAT
Alin Gabriel Serdean [Fri, 9 Jun 2017 22:16:07 +0000 (15:16 -0700)]
windows-datapath: Temporary workaround checksum issue with NAT

There is a known bug with NAT where checksum computation is wrong on
the RX path if offload is enabled. This patch works around the problem
by always computing a software checksum and should be reverted once
we figure out the root cause of checksum error.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
6 years agodatapath-windows: NAT integration with conntrack
Yin Lin [Fri, 9 Jun 2017 22:16:06 +0000 (15:16 -0700)]
datapath-windows: NAT integration with conntrack

This patch integrates NAT module with existing conntrack module. NAT
action is now supported.

Signed-off-by: Yin Lin <linyi@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
6 years agodatapath-windows: Add NAT module in conntrack
Yin Lin [Fri, 9 Jun 2017 22:16:05 +0000 (15:16 -0700)]
datapath-windows: Add NAT module in conntrack

Signed-off-by: Yin Lin <linyi@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
6 years agodatapath-windows: Add support for NAT in conntrack
Anand Kumar [Fri, 9 Jun 2017 22:16:04 +0000 (15:16 -0700)]
datapath-windows: Add support for NAT in conntrack

Add support for parsing netlink attributes related to NAT
in conntrack.

Co-Authored-by: Yin Lin <linyi@vmware.com>
Co-Authored-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Anand Kumar <kumaranand@vmware.com>
Signed-off-by: Yin Lin <linyi@vmware.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
6 years agotreewide: Fix spelling of "prerequisites".
Ben Pfaff [Sat, 10 Jun 2017 02:47:50 +0000 (19:47 -0700)]
treewide: Fix spelling of "prerequisites".

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Greg Rose <gvrose8192@gmail.com>
6 years agoofp-actions: Properly interpret "output:in_port".
Ben Pfaff [Mon, 12 Jun 2017 15:35:48 +0000 (08:35 -0700)]
ofp-actions: Properly interpret "output:in_port".

It was being misinterpreted as output:NXM_OF_IN_PORT[].  This
interpretation is incorrect because of OpenFlow rules that say that only
the special form generated by output:in_port (or "in_port" on its own)
actually outputs to the input port.  The interpretation here was a no-op.

Fixes: 21b2fa617126 ("ofp-parse: Allow match field names in actions and brackets in matches.")
Reported-by: nickcooper-zhangtonghao <nic@opencloud.tech>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoofp-util: Initialize tunnel metadata for OpenFlow 1.0 matches.
Ben Pfaff [Fri, 9 Jun 2017 05:09:19 +0000 (22:09 -0700)]
ofp-util: Initialize tunnel metadata for OpenFlow 1.0 matches.

Found by valgrind.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Lance Richardson <lrichard@redhat.com>
Acked-by: Lance Richardson <lrichard@redhat.com>
6 years agodpdk: Deprecate vhost-user server ports.
Aaron Conole [Thu, 8 Jun 2017 20:41:32 +0000 (16:41 -0400)]
dpdk: Deprecate vhost-user server ports.

Since vhost-user server mode ports are the preferred mechanism for
interconnecting Open vSwitch with VMs when using DPDK, and since there
are currently no known use cases for vhost-user server mode ports apart
from version incompatibilities with QEMU, announce that server mode ports
are considered deprecated and will be removed in a future release.

Cc: Ciara Loftus <ciara.loftus@intel.com>
Cc: Kevin Traynor <ktraynor@redhat.com>
Suggested-by: Darrell Ball <dball@vmware.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agorstp: Add the 'ovs-appctl rstp/show' command.
nickcooper-zhangtonghao [Thu, 1 Jun 2017 03:38:16 +0000 (20:38 -0700)]
rstp: Add the 'ovs-appctl rstp/show' command.

The rstp/show command will help users and developers to
get more details about rstp. This patch works together with
the previous patches.

Signed-off-by: nickcooper-zhangtonghao <nic@opencloud.tech>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agorstp: Add internal functions without locks.
nickcooper-zhangtonghao [Thu, 1 Jun 2017 03:38:15 +0000 (20:38 -0700)]
rstp: Add internal functions without locks.

This patch adds some internal functions which
does not use the locks. This patch is used for
next patch.

Signed-off-by: nickcooper-zhangtonghao <nic@opencloud.tech>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agorstp: Add rstp port name for human reading.
nickcooper-zhangtonghao [Thu, 1 Jun 2017 03:38:14 +0000 (20:38 -0700)]
rstp: Add rstp port name for human reading.

This patch is useful to debug rstp subsystem and log the
port name instead of port number. This patch will also
be used to display rstp info for next patches.

Signed-off-by: nickcooper-zhangtonghao <nic@opencloud.tech>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovn-sbctl: support setting rbac role for remote connections
Lance Richardson [Wed, 31 May 2017 23:06:11 +0000 (19:06 -0400)]
ovn-sbctl: support setting rbac role for remote connections

Add support for specifying rbac "role" when setting remote
connection configuration in the southbound database.

Prior to this change, usage examples included:

    ovn-sbctl set-connection ptcp:6642
    ovn-sbctl set-connection pssl:6642 \
                             read-only ptcp:7777 \
                             read-write punix:/tmp.foo

With this change, in addition to the above:

    ovn-sbctl set-connection role=ovn-controller pssl:6642 \
                             read-only role= ptcp:7777 \
                             read-write punix:/tmp/foo

As with the "read-only"/"read-write" attributes, the specified
role is applied to all subsequent connections until changed.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovn: add rbac tables to ovn southbound schema
Lance Richardson [Wed, 31 May 2017 23:04:47 +0000 (19:04 -0400)]
ovn: add rbac tables to ovn southbound schema

Add rbac "roles" and "permissions" tables to ovn southbound
database schema, add support to ovn-northd for managing these
tables.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovsdb: add support for role-based access controls
Lance Richardson [Wed, 31 May 2017 23:04:32 +0000 (19:04 -0400)]
ovsdb: add support for role-based access controls

Add suport for ovsdb RBAC (role-based access control). This includes:

   - Support for "RBAC_Role" table. A db schema containing a table
     by this name will enable role-based access controls using
     this table for RBAC role configuration.

     The "RBAC_Role" table has one row per role, with each row having a
     "name" column (role name) and a "permissions" column (map of
     table name to UUID of row in separate permission table.) The
     permission table has one row per access control configuration,
     with the following columns:
          "name"          - name of table to which this row applies
          "authorization" - set of column names and column:key pairs
                            to be compared against client ID to
                            determine authorization status
          "insert_delete" - boolean, true if insertions and
                            authorized deletions are allowed.
          "update"        - Set of columns and column:key pairs for
                            which authorized updates are allowed.
   - Support for a new "role" column in the remote configuration
     table.
   - Logic for applying the RBAC role and permission tables, in
     combination with session role from the remote connection table
     and client id, to determine whether operations modifying database
     contents should be permitted.
   - Support for specifying RBAC role string as a command-line option
     to ovsdb-tool (Ben Pfaff).

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Co-authored-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agonetdev-dpdk: Show Rx checksum status when false.
Kevin Traynor [Thu, 8 Jun 2017 17:12:20 +0000 (18:12 +0100)]
netdev-dpdk: Show Rx checksum status when false.

Currently ovs-appctl dpctl/show only shows the Rx checksum offload
status when true. Change to also show the status when false.

CC: Sugesh Chandran <sugesh.chandran@intel.com>
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agodatapath-windows: Add original conntrack tuple to FlowKey
Sairam Venugopal [Fri, 2 Jun 2017 17:37:22 +0000 (10:37 -0700)]
datapath-windows: Add original conntrack tuple to FlowKey

Add the original tuple to Flow Key. In case of ICMP and UDP, default the
parent entry to NULL until related connections is supported.

Signed-off-by: Sairam Venugopal <vsairam@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
6 years agocheckpatch: Also allow .at files to have leading tabs.
Ben Pfaff [Tue, 6 Jun 2017 15:39:34 +0000 (08:39 -0700)]
checkpatch: Also allow .at files to have leading tabs.

Autotest .at files often have lines with samples of expected output from
various programs, which fairly often includes leading tabs, so this warning
causes false positives there.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Aaron Conole <aconole@redhat.com>
6 years agotestsuite: release resources when vswitch exits.
Flavio Leitner [Wed, 7 Jun 2017 20:58:10 +0000 (17:58 -0300)]
testsuite: release resources when vswitch exits.

This change the testsuite macro to release the resources
configured by ovs-vswitchd when exiting as it used to be.

Fixes: 0f28164be02ac ("netdev-linux: make tap devices persistent")
Fixes: fe13ccdca6a22 ("vswitchd: Add --cleanup option to the 'appctl
                       exit' command")

Reported-by: Eric Garver <e@erig.me>
Signed-off-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
6 years agotest-hash: Fix unaligned pointer value error.
Joe Stringer [Fri, 26 May 2017 21:11:31 +0000 (14:11 -0700)]
test-hash: Fix unaligned pointer value error.

Clang 4.0 complains:

../tests/test-hash.c:160:16: error: taking address of packed member 'b' of
class or structure 'offset_ovs_u128' may result in an unaligned pointer value
      [-Werror,-Waddress-of-packed-member]
        in0 = &in0_data.b;

Set the bit in the aligned u128 first then copy the contents into the
offset u128 so that we don't have to take the address of the non-aligned
u128 and pass it to set_bit128.

For the 256byte_hash, fix it up so that it's actually testing the 256B
hash inside a 32-bit offset u128 as well.

Suggested-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
6 years agodocs: Update dpdk vdev naming instructions.
Ciara Loftus [Tue, 6 Jun 2017 15:26:18 +0000 (16:26 +0100)]
docs: Update dpdk vdev naming instructions.

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Stephen Finucane <stephen@that.guru>
6 years agoovn-sb.xml: Update and improve documentation.
Ben Pfaff [Wed, 7 Jun 2017 19:38:38 +0000 (12:38 -0700)]
ovn-sb.xml: Update and improve documentation.

Some of the abbreviations at the head of this document, like LN and PN,
turn out to not be very useful, so expand them for clarity.

Some of the statements in this document are more about planning the design
than the current design.  Remove these for clarity.

Port_Binding rows used to all be about physical locations, except for
patch ports, but there are more kinds of rows now.  Elaborate for clarity.

Expand on the purpose of the Datapath_Binding table.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
6 years agoCopy external_ids from Logical_Switch_Port to SB database
Daniel Alvarez Sanchez [Tue, 6 Jun 2017 10:08:03 +0000 (10:08 +0000)]
Copy external_ids from Logical_Switch_Port to SB database

This patch makes ovn-northd copy all string-string pairs in
external_ids column of the Logical_Switch_Port table in Northbound
database to the equivalent column of the Port_Binding table in
Southbound database.

OpenStack Neutron will add some useful data to NB database that can be
later read by networking-ovn-metadata-agent without the need of
maintaining a connection to NB database. This data would include
the CIDR's of a port or the project and device ID's which are needed
when talking to Nova to request metadata.

Signed-off-by: Daniel Alvarez <dalvarez@redhat.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
6 years agoovn-sb.xml: Fix indentation.
Dong Jun [Tue, 6 Jun 2017 08:00:17 +0000 (16:00 +0800)]
ovn-sb.xml: Fix indentation.

Signed-off-by: Dong Jun <dongj@dtdream.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovn: ssl proto/cipher configuration in nb/sb db
Lance Richardson [Wed, 7 Jun 2017 17:35:20 +0000 (13:35 -0400)]
ovn: ssl proto/cipher configuration in nb/sb db

Add SSL protocol and cipher columns to SSL tables in northbound
and southbound databases. Start nb/sb ovsdb-server with command-
line options to use these columns. Add support to ovn-nbctl
and ovn-sbctl "set-ssl" commands for user-friendly management
of these settings.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoflow: Refactor ct_orig_tuple check in miniflow_extract().
Darrell Ball [Mon, 5 Jun 2017 13:34:33 +0000 (06:34 -0700)]
flow: Refactor ct_orig_tuple check in miniflow_extract().

The checks to populate ct_orig_tuple in miniflow_extract
include recirc_id being non-zero.  Now, ct_orig_tuple
is only populated if the packet has passed through the
connection tracker, which is a prerequisite for having
valid ct_orig_tuple information.  This is recognized by
having a non-zero ct_state.  This has an added benefit
of saving some processing time.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agodpdk: Move tcp_payload_length to include file.
Darrell Ball [Tue, 30 May 2017 21:21:33 +0000 (14:21 -0700)]
dpdk: Move tcp_payload_length to include file.

The function tcp_payload_length is moved to a private
include file to be used by other conntrack files.  A
sanity check is added for general use, although
previous usage was safe in that filtering is already
done by the time it is called.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agotests: Export PYTHONCOERCECLOCALE=0 for python3 tests
Timothy Redaelli [Mon, 5 Jun 2017 13:28:38 +0000 (15:28 +0200)]
tests: Export PYTHONCOERCECLOCALE=0 for python3 tests

This patch exports PYTHONCOERCECLOCALE=0 when you have Python3 tests
enabled.
This is needed since testsuite forces LC_ALL=C and Python 3, with PEP 538,
prints the following warning on stderr:

"Python runtime initialized with LC_CTYPE=C (a locale with default ASCII
encoding), which may cause Unicode compatibility problems. Using C.UTF-8,
C.utf8, or UTF-8 (if available) as alternative Unicode-compatible locales is
recommended."

AT_CHECK reports it as an error since stderr is not empty as it should be.

This patch is needed, at least, on Fedora 26 and Rawhide (backported PEP
538 on Python 3.6).
This will also be needed on any distribution with Python 3.7 (PEP 538).

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agostream: include ssl protocol/cipher options in run-time help
Lance Richardson [Wed, 7 Jun 2017 14:54:52 +0000 (10:54 -0400)]
stream: include ssl protocol/cipher options in run-time help

Include --ssl-protocols and --ssl-ciphers options in run-time
help output.

Sample output with this change:

PKI configuration (required to use SSL):
  -p, --private-key=FILE  file with private key
  -c, --certificate=FILE  file with certificate for private key
  -C, --ca-cert=FILE      file with peer CA certificate
  --bootstrap-ca-cert=FILE  file with peer CA certificate to read or create
SSL options:
  --ssl-protocols=PROTOS  list of SSL protocols to enable
  --ssl-ciphers=CIPHERS   list of SSL ciphers to enable

Output formatting options:

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agonetdev-linux: maintain original device's state
Flavio Leitner [Mon, 29 May 2017 19:40:23 +0000 (16:40 -0300)]
netdev-linux: maintain original device's state

It is important to maintain the original state when
the device already exists in the system.

Signed-off-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agonetdev-linux: make tap devices persistent.
Flavio Leitner [Mon, 29 May 2017 19:40:22 +0000 (16:40 -0300)]
netdev-linux: make tap devices persistent.

When using data path type "netdev", bridge port is a tun device
and when OVS restarts, that device and its network configuration
is lost.

This patch enables the tap device to persist instead.

Signed-off-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agoovs-router: fix refcnt leak when program terminates.
Flavio Leitner [Mon, 29 May 2017 19:40:21 +0000 (16:40 -0300)]
ovs-router: fix refcnt leak when program terminates.

Install a handler to flush routes and release devices when
the program is terminating.

Signed-off-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agodocs: Document dpdkr ports
Stephen Finucane [Fri, 26 May 2017 14:12:38 +0000 (15:12 +0100)]
docs: Document dpdkr ports

I has an idea what these were but that idea was somewhat incorrect and
out-of-date. Add a minimal guide to fill in these gaps, along with a
warning about how useless these things generally are now (yay,
vhost-user).

Signed-off-by: Stephen Finucane <stephen@that.guru>
Cc: Ciara Loftus <ciara.loftus@intel.com>
Cc: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
6 years agodocs: Clarify the superiority of dpdkvhostuserclient
Stephen Finucane [Fri, 26 May 2017 14:12:37 +0000 (15:12 +0100)]
docs: Clarify the superiority of dpdkvhostuserclient

Apparently dpdkvhostuser interfaces are inferior to dpdkvhostuserclient.
Explain why.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Cc: Ciara Loftus <ciara.loftus@intel.com>
Cc: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
6 years agoovn-controller: refactor and abstract ovs_idl registering
Han Zhou [Fri, 26 May 2017 00:26:46 +0000 (17:26 -0700)]
ovn-controller: refactor and abstract ovs_idl registering

Abstract as a function so that it can be used by other modules.

Signed-off-by: Han Zhou <zhouhan@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agobfd: Detect Multiplier configuration
Szucs Gabor [Tue, 6 Jun 2017 15:11:54 +0000 (17:11 +0200)]
bfd: Detect Multiplier configuration

Mult value (bfd.DetectMult in RFC5880) is hard-coded and equal to 3 in
current openvswitch. As a consequence remote and local mult is the same.

In this commit the mult (Detect Multiplier/bfd.DetectMult/Detect Mult)
can be set on each interface setting the mult=<value> in bfd Column
in Interface table of ovsdb database.
Example:
ovs-vsctl set Interface p1 bfd:mult=4
sets mult=4 on p1 interface

The modification based on RFC5880 June 2010.
The relevant paragraphs are:
4.1. Generic BFD Control Packet Format
6.8.4. Calculating the Detection Time
6.8.7. Transmitting BFD Control Packets
6.8.12. Detect Multiplier Change

The mult value is set to default 3 if it is not set in ovsdb. This
provides backward compatibility to previous openvswitch behaviour.
The RFC5880 says in 6.8.1 that DetectMult shall be a non-zero integer.
In RFC5880 4.1. "Detect Mult" has 8 bit length and is declared
as a 8 bit unsigned integer in bfd.c.
Consequently mult value shall be greater than 0 and less then 256.
In case of incorrect mult value is given in ovsdb the default value (3)
will be set and a message is logged into ovs-vswitchd.log on that.
Local or remote mult value change is also logged into ovs-vswitchd.log.

Since remote and local mult is not the same calculation of detect time
has been changed. Due to RFC5880 6.8.4 Detection Time is calculated using
mult value of the remote system.
Detection time is recalculated due to remote mult change.

The BFD packet transmission jitter is different in case of mult=1
due to RFC5880 6.8.7. The maximum interval of the transmitted bfd packet
is 90% of the transmission interval.

The value of remote mult is printed in the last line of the output of
ovs-appctl bfd/show command with label: Remote Detect Mult.

There is a feature in openvswitch connected with forwarding_if_rx that
is not the part of RFC5880. This feature also uses mult value but it is
not specified if local or remote since it was the
same in original code. The relevant description in code:
   /* When 'bfd->forwarding_if_rx' is set, at least one bfd control packet
     * is required to be received every 100 * bfd->cfg_min_rx.  If bfd
     * control packet is not received within this interval, even if data
     * packets are received, the bfd->forwarding will still be false. */

Due to lack of specification local mult value is used for calculation of
forwarding_if_rx_detect_time. This detect time is recalculated at mult
change if forwarding_if_rx is true and bfd is in UP state.

A new unit test has been added: "bfd - Edit the Detect Mult values"
The following cases are tested:
- Without setting mult the mult will be the default value (3).
- The setting of the lowest (1) and highest (255) valid mult value
  and the detection of remote mult value.
- The setting of out of range mult value (0, 256) in ovsdb results
  sets default value in ovs-vswitchd
- Clearing non default mult value from ovsdb results sets default
  value in ovs-vswitchd.

Signed-off-by: Gábor Szűcs <gabor.sz.cs@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agotests: Fix spelling error in test name.
Ben Pfaff [Fri, 2 Jun 2017 16:13:30 +0000 (09:13 -0700)]
tests: Fix spelling error in test name.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agodpdk: Update feature alert documentation.
Darrell Ball [Tue, 30 May 2017 17:49:33 +0000 (10:49 -0700)]
dpdk: Update feature alert documentation.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Daniele Di Proietto <diproiettod@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpdk: Enable NAT tests for userspace datapath.
Darrell Ball [Tue, 30 May 2017 17:49:32 +0000 (10:49 -0700)]
dpdk: Enable NAT tests for userspace datapath.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Daniele Di Proietto <diproiettod@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agotests: Add some system test fixes.
Darrell Ball [Tue, 30 May 2017 17:49:31 +0000 (10:49 -0700)]
tests: Add some system test fixes.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Daniele Di Proietto <diproiettod@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoSystem Tests: Enhance NAT tests.
Darrell Ball [Tue, 30 May 2017 17:49:30 +0000 (10:49 -0700)]
System Tests: Enhance NAT tests.

Two new tests are added and two other tests were
enhanced.  The use of tcpdump to verify checksums
is introduced.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Daniele Di Proietto <diproiettod@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpdk: Add orig tuple context recovery.
Darrell Ball [Tue, 30 May 2017 17:49:29 +0000 (10:49 -0700)]
dpdk: Add orig tuple context recovery.

This patch adds orig tuple checking and context
recovery; NAT interactions are factored in.
Orig tuple support exists to better handle policy
changes.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Acked-by: Daniele Di Proietto <diproiettod@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpdk: Add more ICMP Related NAT support.
Darrell Ball [Tue, 30 May 2017 17:49:28 +0000 (10:49 -0700)]
dpdk: Add more ICMP Related NAT support.

This patch includes more complete support
for icmp4 and icmp6 related NAT handling.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Acked-by: Daniele Di Proietto <diproiettod@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpdk: Userspace Datapath: Introduce NAT Support.
Darrell Ball [Tue, 30 May 2017 17:49:27 +0000 (10:49 -0700)]
dpdk: Userspace Datapath: Introduce NAT Support.

This patch introduces NAT support for the userspace datapath.
Most conntrack module changes are in this patch, with the
exception of icmp related handling and recent orig tuple
support.

The per packet scope of lookups for NAT and un_NAT is at
the bucket level rather than global. One hash table is
introduced to support create/delete handling. The create/delete
events may be further optimized, if the need becomes clear.

Some NAT options with limited utility (persistent, random) are
not supported yet, but will be supported in a later patch.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Daniele Di Proietto <diproiettod@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpdk: Remove batch sorting in userspace conntrack.
Darrell Ball [Tue, 30 May 2017 17:49:26 +0000 (10:49 -0700)]
dpdk: Remove batch sorting in userspace conntrack.

Packet batch sorting is removed for three reasons:

1) The following patches for NAT change the locking
    marshalling so batching loses benefit.

2) For real mixtures of flows either in hypervisors
   or gateways, the batch sorting won't provide benefit
   and will just be a tax.

3) Code clarity.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Daniele Di Proietto <diproiettod@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpdk: Parse NAT netlink for userspace datapath.
Darrell Ball [Tue, 30 May 2017 17:49:25 +0000 (10:49 -0700)]
dpdk: Parse NAT netlink for userspace datapath.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Daniele Di Proietto <diproiettod@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agouserspace: add vxlan gpe support to vport
Georg Schmuecking [Fri, 2 Jun 2017 16:16:26 +0000 (16:16 +0000)]
userspace: add vxlan gpe support to vport

This patch is based on the "datapath: enable vxlangpe creation in compat mode"
from Yi Yang. It introduces an extension option "gpe" to the vxlan port in the
netdev-dpdk datapath. Description of vxlan gpe protocoll was added to header
file lib/packets.h. In the vxlan specific methods the different packet are
introduced and handled.

Added VXLAN GPE tunnel push test.

Signed-off-by: Yi Yang <yi.y.yang at intel.com>
Signed-off-by: Georg Schmuecking <georg.schmuecking@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agouserspace: L3 tunnel support for GRE and LISP
Jan Scheurich [Fri, 2 Jun 2017 16:16:21 +0000 (16:16 +0000)]
userspace: L3 tunnel support for GRE and LISP

Add a boolean "layer3" configuration option for tunnel vports.
The layer3 option defaults to false for all ports except LISP.
GRE ports accept both true and false for "layer3".

A tunnel vport configured with layer3=true receives L3 packets.
which are then converted to Ethernet packets by pushing a dummy
Ethernet heder at the ingress of the OpenFlow pipeline. The
Ethernet header of a packet is stripped before sending to a
layer3 tunnel vport.

Presently a single GRE vport cannot carry both L2 and L3 packets.
But it is possible to create two GRE vports representing the same
GRE tunel, one with layer3=false, the other with layer3=true.
L2 packet from the tunnel are received on the first vport, L3
packets on the second. The controller must send packets to the
layer3 GRE vport to tunnel them without their Ethernet header.

Units tests have been added to check the L3 tunnel handling.

LISP tunnels are not yet supported by the netdev userspace datapath.

Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agouserspace: Switching of L3 packets in L2 pipeline
Jan Scheurich [Fri, 2 Jun 2017 16:16:17 +0000 (16:16 +0000)]
userspace: Switching of L3 packets in L2 pipeline

Ports have a new layer3 attribute if they send/receive L3 packets.

The packet_type included in structs dp_packet and flow is considered in
ofproto-dpif. The classical L2 match fields (dl_src, dl_dst, dl_type, and
vlan_tci, vlan_vid, vlan_pcp) now have Ethernet as pre-requisite.

A dummy ethernet header is pushed to L3 packets received from L3 ports
before the the pipeline processing starts. The ethernet header is popped
before sending a packet to a L3 port.

For datapath ports that can receive L2 or L3 packets, the packet_type
becomes part of the flow key for datapath flows and is handled
appropriately in dpif-netdev.

In the 'else' branch in flow_put_on_pmd() function, the additional check
flow_equal(&match.flow, &netdev_flow->flow) was removed, as a) the dpcls
lookup is sufficient to uniquely identify a flow and b) it caused false
negatives because the flow in netdev->flow may not properly masked.

In dpif_netdev_flow_put() we now use the same method for constructing the
netdev_flow_key as the one used when adding the flow to the dplcs to make sure
these always match. The function netdev_flow_key_from_flow() used so far was
not only inefficient but sometimes caused mismatches and subsequent flow
update failures.

The kernel datapath does not support the packet_type match field.
Instead it encodes the packet type implictly by the presence or absence of
the Ethernet attribute in the flow key and mask.
This patch filters the PACKET_TYPE attribute out of netlink flow key and
mask to be sent to the kernel datapath.

Signed-off-by: Lorand Jakab <lojakab@cisco.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoofproto: Use shash_find_and_delete() in ofport_destroy__().
Ben Pfaff [Sat, 27 May 2017 05:53:19 +0000 (22:53 -0700)]
ofproto: Use shash_find_and_delete() in ofport_destroy__().

This is shorter and slightly safer than combining calls to shash_find()
and shash_delete().

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762983&defectInstanceId=4305289&mergedDefectId=179850
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agopatch: Check the right variable for null.
Ben Pfaff [Sat, 27 May 2017 05:55:49 +0000 (22:55 -0700)]
patch: Check the right variable for null.

This function tried to check 'iface_peer' for null, but it actually
checked its always-nonnull 'peer' argument instead.  This fixes the
problem.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14763064&defectInstanceId=4305294&mergedDefectId=179852
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agoextract-ofp-errors: Avoid unintentional sign extension in generated code.
Ben Pfaff [Tue, 30 May 2017 14:39:44 +0000 (07:39 -0700)]
extract-ofp-errors: Avoid unintentional sign extension in generated code.

Code generated by this program includes constructs like this:

    switch (((uint64_t) vendor << 32) | (type << 16) | code)

with variables uint32_t vendor, uint16_t type, uint16_t code.  By C rules,
"type << 16" has type "int", which means that it will be sign-extended to
64 bits when ORed with uint64_t.  Thus, if 'type' has bit 15 set, then
the overall result will have all of its top 32 bits set, which is not
the desired result.

This commit fixes the problem.

No actual error types used in OVS or OpenFlow have bit 15 set, so this
does not fix a user-visible problem.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762955&defectInstanceId=4304798&mergedDefectId=180406
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agotest-cmap: Avoid shift by full width of type in find_batch().
Ben Pfaff [Sat, 27 May 2017 04:50:36 +0000 (21:50 -0700)]
test-cmap: Avoid shift by full width of type in find_batch().

In C, it is undefined to shift an N-bit value by N.  This fixes the
problem in find_batch() for the case where i == 0.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14763098&defectInstanceId=4304031&mergedDefectId=68209
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agoflow: Fix buffer overread in flow_hash_symmetric_l3l4().
Ben Pfaff [Fri, 2 Jun 2017 03:24:37 +0000 (20:24 -0700)]
flow: Fix buffer overread in flow_hash_symmetric_l3l4().

IPv6 addresses have 2 64-bit parts, but this code thought they have 4.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762918&defectInstanceId=4304099&mergedDefectId=179866
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agoofp-print: Avoid array overread in print_table_instruction_features().
Ben Pfaff [Sat, 27 May 2017 02:59:47 +0000 (19:59 -0700)]
ofp-print: Avoid array overread in print_table_instruction_features().

If a switch claimed to support an instruction that OVS does not know about,
then print_table_instruction_features() would read past the end of the
array of instruction names.  This fixes the problem.

None of the other uses of print_table_instruction_features() appear to have
the same problem.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762675&defectInstanceId=4305296&mergedDefectId=179859
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agoofp-util: Mask config value as intended in ofputil_decode_port_mod().
Ben Pfaff [Sat, 27 May 2017 03:36:17 +0000 (20:36 -0700)]
ofp-util: Mask config value as intended in ofputil_decode_port_mod().

The code in ofputil_decode_port_mod() was originally meant to mask
the returned 'config' value against 'mask'.  That is, only bits that are
marked in 'mask' as to be modified can be set to 1-bits in the returned
'config' value; it doesn't really entirely make sense otherwise.  The
actual code to do this was dead, though.  This fixes that problem.

In a quick skim of callers, I wasn't able to see an actual user-visible
bug that this fixes.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762682&defectInstanceId=4304822&mergedDefectId=180422
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agodpif-netlink: Fix multiple-free and fd leak on error path.
Ben Pfaff [Tue, 30 May 2017 14:38:56 +0000 (07:38 -0700)]
dpif-netlink: Fix multiple-free and fd leak on error path.

This function attempts to open a bunch of new handlers.  If it fails, it
attempts to close all the handlers that have already been opened.
Unfortunately, the loop to close the opened handlers used the wrong array
index: 'i' instead of 'j'.  This fixes the problem.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762827&defectInstanceId=4305351&mergedDefectId=180429
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agoofp-util: Remove dead code from ofputil_encode_get_async_reply().
Ben Pfaff [Sat, 27 May 2017 03:30:53 +0000 (20:30 -0700)]
ofp-util: Remove dead code from ofputil_encode_get_async_reply().

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762682&defectInstanceId=4304823&mergedDefectId=180423
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agodpif-netdev: Fix use-after-free error in reconfigure_datapath().
Ben Pfaff [Fri, 26 May 2017 22:50:16 +0000 (15:50 -0700)]
dpif-netdev: Fix use-after-free error in reconfigure_datapath().

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762915&defectInstanceId=4305352&mergedDefectId=180430
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agotest-conntrack: Close pcap file at end of test_pcap().
Ben Pfaff [Fri, 26 May 2017 23:09:35 +0000 (16:09 -0700)]
test-conntrack: Close pcap file at end of test_pcap().

Seems wise, even if not strictly required.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14763099&defectInstanceId=4305325&mergedDefectId=180413&fileStart=251&fileEnd=269
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agoovs-ofctl: Close pcap file at end of ofctl_ofp_parse_pcap().
Ben Pfaff [Fri, 26 May 2017 23:03:54 +0000 (16:03 -0700)]
ovs-ofctl: Close pcap file at end of ofctl_ofp_parse_pcap().

Seem wise even if not mandatory.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14763047&defectInstanceId=4305314&mergedDefectId=180420
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agobridge: Fix memory leak in bridge_aa_update_trunks().
Ben Pfaff [Fri, 26 May 2017 23:11:40 +0000 (16:11 -0700)]
bridge: Fix memory leak in bridge_aa_update_trunks().

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14763131&defectInstanceId=4305313&mergedDefectId=180411
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agotest-packets: Check that ipv6_parse_masked() is successful.
Ben Pfaff [Fri, 26 May 2017 23:13:56 +0000 (16:13 -0700)]
test-packets: Check that ipv6_parse_masked() is successful.

Otherwise it returns an allocated string that we should print and free.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14763114&defectInstanceId=4305332&mergedDefectId=180408
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agoactions: Fix memory leak on error path in parse_ct_lb_action().
Ben Pfaff [Fri, 26 May 2017 23:20:14 +0000 (16:20 -0700)]
actions: Fix memory leak on error path in parse_ct_lb_action().

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14763031&defectInstanceId=4305318&mergedDefectId=180399
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agoofp-parse: Fix memory leak on error path in parse_ofp_group_mod_file().
Ben Pfaff [Fri, 26 May 2017 23:25:14 +0000 (16:25 -0700)]
ofp-parse: Fix memory leak on error path in parse_ofp_group_mod_file().

Found by Coverity.

Reported-by: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762655&defectInstanceId=4305334&mergedDefectId=180394
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
7 years agocheckpatch: Also exempt Makefile.am from leading whitespace checks.
Ben Pfaff [Thu, 1 Jun 2017 14:36:24 +0000 (07:36 -0700)]
checkpatch: Also exempt Makefile.am from leading whitespace checks.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
7 years agonetdev: Fix netdev_open() to adhere to class type if given
Eelco Chaudron [Thu, 1 Jun 2017 12:38:09 +0000 (14:38 +0200)]
netdev: Fix netdev_open() to adhere to class type if given

When trying to configure a system port as type=internal it could start
an infinite port creation loop. When this happens you will see the
following log messages:

2017-06-01T09:00:17.900Z|02813|dpif|WARN|system@ovs-system: failed to add ve01_1 as port: File exists
2017-06-01T09:00:17.900Z|02814|bridge|WARN|could not add network device ve01_1 to ofproto (File exists)
2017-06-01T09:00:17.907Z|02815|bridge|INFO|bridge bzb: added interface ve01_1 on port 2
2017-06-01T09:00:17.909Z|02816|bridge|INFO|bridge bzb: deleted interface ve01_1 on port 2
2017-06-01T09:00:17.914Z|02817|dpif|WARN|system@ovs-system: failed to add ve01_1 as port: File exists
2017-06-01T09:00:17.914Z|02818|bridge|WARN|could not add network device ve01_1 to ofproto (File exists)
2017-06-01T09:00:17.921Z|02819|bridge|INFO|bridge bzb: added interface ve01_1 on port 3
2017-06-01T09:00:17.923Z|02820|bridge|INFO|bridge bzb: deleted interface ve01_1 on port 3
2017-06-01T09:00:17.929Z|02821|dpif|WARN|system@ovs-system: failed to add ve01_1 as port: File exists
2017-06-01T09:00:17.929Z|02822|bridge|WARN|could not add network device ve01_1 to ofproto (File exists)
2017-06-01T09:00:17.936Z|02823|bridge|INFO|bridge bzb: added interface ve01_1 on port 4
...
...

This is how to replicate it:

  ip link add name ve01_1 type veth peer name ve01_2
  ovs-vsctl add-br bzb
  ovs-vsctl add-port bzb ve01_1
  ovs-vsctl set interface ve01_1 type=internal
  ip link set dev ve01_1 up
  ip link set dev ve01_2 up

When changing the type to internal, the async configuration logic get
triggered and because the type has changed it will delete the
interface and the ofproto port. Next it will call iface_do_create() to
re-create the interface as internal. Because we just deleted the
interface netdev_open() will try to recreate it as internal.

However this will fail with EEXIST as a system interface already
exists withe the name.

Up till here all is fine...

Now some ipv6 route change comes along for the ve01_1 interface, and
the route infrastructure will call netdev_open(). This will create the
interface of type system.

Next the configuration verify process gets triggered due to
if_notifier_changed() being true. We now retry the above, but because
the interface exists (although in the system class) it will use it,
and create the interface successfully.

This triggers another if notification, causing yet another config
update, and because the system != internal reconfiguration happens and
it start from the top...

So the fix as presented below is causing netdev_open() only to return
the existing device for the class type requested (if the type is
specified).

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agocheckpatch: Fix typo for use as filter.
Ben Pfaff [Thu, 1 Jun 2017 14:40:01 +0000 (07:40 -0700)]
checkpatch: Fix typo for use as filter.

ovs_checkpatch_parse() takes 2 arguments, not sys.exit().  Oops.

Fixes: 95bd35d3db19 ("checkpatch: Implement -f option more usefully.")
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
7 years agocheckpatch: Omit some checks on comment lines.
Ben Pfaff [Tue, 30 May 2017 21:22:54 +0000 (14:22 -0700)]
checkpatch: Omit some checks on comment lines.

Comments are more freeform than code, so this patch tries to ignore many
checks on comment lines.  It assumes that any line that begins with "/*"
or "* " is a comment line.  (Without a following space, "*" might be
something like "*x = 1;".)

Suggested-by: Joe Stringer <joe@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
7 years agoReplace most uses of and references to "ifconfig" by "ip".
Ben Pfaff [Thu, 1 Jun 2017 14:21:41 +0000 (07:21 -0700)]
Replace most uses of and references to "ifconfig" by "ip".

It's becoming more common that OSes include "ip" but not "ifconfig", so
it's best to avoid using the latter.  This commit removes most references
to "ifconfig" and replaces them by "ip".  It also adds a build-time check
to make it harder to introduce new uses of "ifconfig".

There are important differences between "ifconfig" and "ip":

- An "ifconfig" command that sets an IP address also brings the interface
  up, but a similar "ip addr add" command does not, so it is often necessary
  (or at least precautionary) to add an "ip link set <dev> up" command.

- "ifconfig" can infer a netmask from an IP adddress, but "ip" always
  assumes /32 if none is given.

- "ifconfig" with address 0.0.0.0 removes any configured IP address, but
  "ip addr add" does not, so "ifconfig <dev> 0.0.0.0" must be replaced by
  "ip addr del" or "ip addr flush".

Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agowindows: Set service status when stop is issued
Alin Serdean [Fri, 19 May 2017 21:23:47 +0000 (21:23 +0000)]
windows: Set service status when stop is issued

If the service manager issued a stop service, the control handler
registered by the running daemon should report that service changed
state.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agonetdev-dpdk: Use uint8_t for port_id.
Ilya Maximets [Fri, 19 May 2017 13:37:32 +0000 (16:37 +0300)]
netdev-dpdk: Use uint8_t for port_id.

Currently, signed integer is used for 'port_id' variable and
'-1' as identifier of bad or uninitialized 'port_id'.

This inconsistent with dpdk library and, also, in few cases,
leads to passing '-1' to dpdk functions where uint8_t expected.

Such behaviour doesn't produce any issues, but it's better to
use same type as in dpdk library for consistency.
Introduced 'dpdk_port_t' typedef for better maintainability.

Also, magic number '-1' replaced with DPDK_ETH_PORT_ID_INVALID
macro.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
7 years agonetdev-dpdk: Fix device leak on port deletion.
Ilya Maximets [Fri, 19 May 2017 13:37:31 +0000 (16:37 +0300)]
netdev-dpdk: Fix device leak on port deletion.

Currently, once created device in dpdk will exist forever
even after del-port operation untill we manually call
'ovs-appctl netdev-dpdk/detach <name>', where <name> is not
the port's name but the name of dpdk eth device or pci address.

Few issues with current implementation:

1. Different API for usual (system) and DPDK devices.
   (We have to call 'ovs-appctl netdev-dpdk/detach' each
    time after 'del-port' to actually free the device)
   This is a big issue mostly for virtual DPDK devices.

2. Follows from 1:
   For DPDK devices 'del-port' leads just to
   'rte_eth_dev_stop' and subsequent 'add-port' will
   just start the already existing device. Such behaviour
   will not reset the device to initial state as it could
   be expected. For example: virtual pcap pmd will continue
   reading input file instead of reading it from the beginning.

3. Follows from 2:
   After execution of the following commands 'port1' will be
   configured with the 'old-options' while 'ovs-vsctl show'
   will show us 'new-options' in dpdk-devargs field:

     ovs-vsctl add-port port1 -- set interface port1 type=dpdk \
               options:dpdk-devargs=<eth_pmd_name1>,<old-options>
     ovs-vsctl del-port port1
     ovs-vsctl add-port port1 -- set interface port1 type=dpdk \
               options:dpdk-devargs=<eth_pmd_name1>,<new-options>

4. Follows from 1:
   Not detached device consumes 'port_id'. Since we have very
   limited number of 'port_id's (32 in common case) this may
   lead to quick exhausting of id pool and inability to add any
   other port.

To avoid above issues we need to detach all the attached devices on
port destruction.
appctl 'netdev-dpdk/detach' removed because not needed anymore.

We need to use internal 'attached' variable to track ports on
which rte_eth_dev_attach() was called and returned successfully
to avoid closing and detaching devices that do not support hotplug or
by any other reason attached using the 'dpdk-extra' cmdline options.

CC: Ciara Loftus <ciara.loftus@intel.com>
Fixes: 55e075e65ef9 ("netdev-dpdk: Arbitrary 'dpdk' port naming")
Fixes: 69876ed78611 ("netdev-dpdk: Add support for virtual DPDK PMDs (vdevs)")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Billy O'Mahony <billy.o.mahony@intel.com>
7 years agonetdev-dpdk: Fix double attaching of virtual devices.
Ilya Maximets [Fri, 19 May 2017 13:37:30 +0000 (16:37 +0300)]
netdev-dpdk: Fix double attaching of virtual devices.

'devargs' for virtual devices contains not only name but
also a list of arguments like this:

'net_pcap0,rx_pcap=file_rx.pcap,tx_pcap=file_tx.pcap'
or
'eth_af_packet0,iface=eth0'

We must cut off the arguments from this string before calling
'rte_eth_dev_get_port_by_name()' to avoid double attaching of
the same device.

CC: Ciara Loftus <ciara.loftus@intel.com>
Fixes: 69876ed78611 ("netdev-dpdk: Add support for virtual DPDK PMDs (vdevs)")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Billy O'Mahony <billy.o.mahony@intel.com>
Acked-by: Billy O'Mahony <billy.o.mahony@intel.com>
7 years agoSupport accepting and displaying port names in OVS tools.
Ben Pfaff [Wed, 31 May 2017 23:06:12 +0000 (16:06 -0700)]
Support accepting and displaying port names in OVS tools.

Until now, most ovs-ofctl commands have not accepted names for ports, only
numbers, and have not been able to display port names either.  It's a lot
easier for users if they can use and see meaningful names instead of
arbitrary numbers.  This commit adds that support.

For backward compatibility, only interactive ovs-ofctl commands by default
display port names; to display them in scripts, use the new --names
option.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Aaron Conole <aconole@redhat.com>
7 years agostp: Add link-state checking support for stp ports.
nickcooper-zhangtonghao [Fri, 19 May 2017 07:20:43 +0000 (00:20 -0700)]
stp: Add link-state checking support for stp ports.

When bridge stp enabled, we can enable the stp ports
despite ports are down. When initializing, this patch checks
link-state of ports and enable or disable them according
to their link-state. This patch also allow user to enable
and disable a port when bridge stp is running. If a stp
port is in disable state, it can forward packets. If its
link is down and this patch sets it to disable, there is
no L2 loop.

Signed-off-by: nickcooper-zhangtonghao <nic@opencloud.tech>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agorstp: Increment the rstp port num counter.
nickcooper-zhangtonghao [Fri, 19 May 2017 07:20:42 +0000 (00:20 -0700)]
rstp: Increment the rstp port num counter.

This counter is supposed to prevent having too many RSTP ports, but nothing
ever incremented it.

Signed-off-by: nickcooper-zhangtonghao <nic@opencloud.tech>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovn-controller: Fix log conditions for unexpected openflow messages.
Han Zhou [Wed, 17 May 2017 23:13:55 +0000 (16:13 -0700)]
ovn-controller: Fix log conditions for unexpected openflow messages.

Currently in pinctrl.c and ofctrl.c there are similar logic to log
ignored messages, which is somehow inaccurate and confusing. For example,
OFPTYPE_PACKET_IN is handled only in pinctrl.c but in ofctrl.c it
is listed as expected input and not logged as "ignored" messages, while
it is in fact unexpected and ignored there. This patch clearup the
unnecessary "if" conditions and logs all messages that are not
expected/handled honestly, so that there will be logs for debugging
if such abnormal case really happens.

Signed-off-by: Han Zhou <zhouhan@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovn-ctl: Fix help message for option ovn-controller-priority
Han Zhou [Wed, 17 May 2017 18:12:25 +0000 (11:12 -0700)]
ovn-ctl: Fix help message for option ovn-controller-priority

Signed-off-by: Han Zhou <zhouhan@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
7 years agorhel: install firewalld ovn files with chmod 644 instead of 755
Timothy Redaelli [Mon, 29 May 2017 15:37:26 +0000 (17:37 +0200)]
rhel: install firewalld ovn files with chmod 644 instead of 755

Fixes: 55f36be59122 ("rhel: Firewall service files for OVN.")
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Miguel Angel Ajo <majopela@redhat.com>
7 years agoovn-controller: Fix a wrong comment.
Han Zhou [Tue, 16 May 2017 18:21:22 +0000 (11:21 -0700)]
ovn-controller: Fix a wrong comment.

Flows are sent to switch by ofctrl_put() instead of ofctrl_run(), so
fix the comment which was misleading.

Signed-off-by: Han Zhou <zhouhan@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoofp-util: Fix tun_metadata processing in packet-out
Yi-Hung Wei [Mon, 15 May 2017 17:04:59 +0000 (10:04 -0700)]
ofp-util: Fix tun_metadata processing in packet-out

Pass tun_table to ofputil_handle_packet_out() to correctly decode tunnel
metadata in packet-out messages.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoofp-parse: Parse pipeline fields in OF1.5 packet-out
Yi-Hung Wei [Mon, 15 May 2017 17:04:58 +0000 (10:04 -0700)]
ofp-parse: Parse pipeline fields in OF1.5 packet-out

This patch adds support for parsing the pipeline match fields of
OpenFlow 1.5 packet-out messages. With this patch, we can use ovs-ofctl
to specify pipeline fileds for a packet-out message.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoofproto: Add pipeline fields support for OF 1.5 packet-out
Yi-Hung Wei [Mon, 15 May 2017 17:04:57 +0000 (10:04 -0700)]
ofproto: Add pipeline fields support for OF 1.5 packet-out

This patch decodes pipeline fields from a packet-out message, and populates
the pipeline fields into datapath. Error OFPERR_OFPBRC_PIPELINE_FIELDS_ONLY
is returned if the match field of a packet-out messages contains any
non pipeline fields. Currently, the supported pipeline fields
are as following.

* metadata fields:
    - in_port, in_port_oxm

* tunnel fields:
    - tun_id, tun_src, tun_dst, tun_ipv6_src, tun_ipv6_dst
    - tun_gbp_id, tun_gpb_flags, tun_flags
    - tun_metadata0 - tun_metadata63

* register fields:
    - metadata
    - reg0 - reg-15, xreg0 - xreg7, xxreg0 - xxreg3

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoofp-util: Add OpenFlow 1.5 packet-out support
Yi-Hung Wei [Mon, 15 May 2017 17:04:56 +0000 (10:04 -0700)]
ofp-util: Add OpenFlow 1.5 packet-out support

This patch implements the encoding and decoding of the new packet-out
format defined in OpenFlow 1.5. Test cases are provided to verify the
encoding and decoding.

This patch is based on [1] and [2].

[1] https://github.com/jean2/openvswitch/commits/jean/ext-427
[2] https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/331032.html

Signed-off-by: Jean Tourrilhes <jt@labs.hpe.com>
Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoofp-util: Add flow metadata to ofputil_packet_out
Yi-Hung Wei [Mon, 15 May 2017 17:04:55 +0000 (10:04 -0700)]
ofp-util: Add flow metadata to ofputil_packet_out

This patch adds flow metadata to ofputil_packet_out. It does not make any
functional change. The flow metadata will be useful to support new packet-out
message format in OpenFlow 1.5.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoAUTHORS: Add Yunjian Wang.
Ben Pfaff [Wed, 31 May 2017 19:01:20 +0000 (12:01 -0700)]
AUTHORS: Add Yunjian Wang.

Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agonetflow: Fix memory leak in netflow_unref.
Yunjian Wang [Mon, 22 May 2017 04:55:00 +0000 (12:55 +0800)]
netflow: Fix memory leak in netflow_unref.

The memory leak was triggered each time on calling netflow_unref() with
containing netflow_flows. And flows need to be removed and destroyed.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agometa-flow: Remove dead condition in mf_set().
Ben Pfaff [Sat, 27 May 2017 05:09:35 +0000 (22:09 -0700)]
meta-flow: Remove dead condition in mf_set().

mf_set() always takes a nonnull mask, but the MFF_CT_LABEL case checked
whether it was nonnull.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762941&defectInstanceId=4304057&mergedDefectId=179568
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
7 years agophysical: Tolerate missing distributed-port key for chassisredirect ports.
Ben Pfaff [Sat, 27 May 2017 06:03:20 +0000 (23:03 -0700)]
physical: Tolerate missing distributed-port key for chassisredirect ports.

Until now, the code here assumed that a "distributed-port" key existed,
and dereferenced a null pointer if it did not.  This commit avoids that
problem.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14763078&defectInstanceId=4305288&mergedDefectId=179857
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>