]> git.proxmox.com Git - mirror_ovs.git/log
mirror_ovs.git
7 years agodebian: Add six dependency to python-openvswitch.
Joe Stringer [Tue, 26 Jul 2016 19:34:16 +0000 (12:34 -0700)]
debian: Add six dependency to python-openvswitch.

python-openvswitch uses the python "six" library, add a dependency for
this to the debian package.

VMware-BZ: #1700259
Reported-by: Devang Doshi <ddoshi@vmware.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agonetdev-provider: fix comments for netdev_rxq_recv
Mark Kavanagh [Tue, 26 Jul 2016 13:19:17 +0000 (14:19 +0100)]
netdev-provider: fix comments for netdev_rxq_recv

Commit 64839cf43 applies batch objects to netdev-providers, but
some comments were not updated accordingly. Fix these:
   - replace 'pkts' with 'batch'
   - replace '*cnt' with 'batch->count'
   - replace MAX_RX_BATCH with NETDEV_MAX_BURST
   - remove superfluous whitespace

Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
Acked-by: William Tu <u9012063@gmail.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agoovsdb-client: Fix memory leak reported by Valgrind.
William Tu [Wed, 27 Jul 2016 03:24:57 +0000 (20:24 -0700)]
ovsdb-client: Fix memory leak reported by Valgrind.

Testcase 1857: ovsdb-monitor.at:538 monitor-cond-change reports the
following definitely memory leak:
    ovsdb_schema_create (ovsdb.c:34)
    ovsdb_schema_from_json (ovsdb.c:196)
    fetch_schema (ovsdb-client.c:385)
    do_monitor_cond (ovsdb-client.c:1112)

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agotest-ovsdb: Fix memory leak reported by Valgrind.
William Tu [Wed, 27 Jul 2016 03:12:36 +0000 (20:12 -0700)]
test-ovsdb: Fix memory leak reported by Valgrind.

Valgrind testcase 1967: simple idl, conditional, modify as delete due
to condition - C reports the following leak:
    json_array_create_empty (json.c:185)
    json_parser_push_array (json.c:1234)
    json_parser_input (json.c:1328)
    json_lex_input (json.c:945)
    json_parser_feed (json.c:1103)
    json_from_string (json.c:1025)
    parse_json (test-ovsdb.c:227)
    update_conditions (test-ovsdb.c:2324)
    do_idl (test-ovsdb.c:2389)
    ovs_cmdl_run_command (command-line.c:121)
    main (test-ovsdb.c:73)

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agopython: Send old values of the updated cols in notify for update2
Numan Siddique [Tue, 26 Jul 2016 17:58:14 +0000 (23:28 +0530)]
python: Send old values of the updated cols in notify for update2

When python IDL calls the "notify" function after processing the "update2"
message from ovsdb-server, it is suppose to send the old values of the
updated columns as the last parameter. But the recent commit "897c8064"
sends the updated values. This breaks the behaviour.
This patch fixes this issue. It also updates the description of
the 'updates' param of the notify function to make it more clear.

Fixes: 897c8064 ("python: move Python idl to work with monitor_cond")
Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agonetdev: do not allow devices to be opened with conflicting types
Thadeu Lima de Souza Cascardo [Wed, 27 Jul 2016 15:06:45 +0000 (12:06 -0300)]
netdev: do not allow devices to be opened with conflicting types

When a device is already opened, netdev_open should verify that the types match,
or else return an error.

Otherwise, users might expect to open a device with a certain type and get a
handle belonging to a different type.

This also prevents certain conflicting configurations that would have a port of
a certain type in the database and one of a different type on the system.

For example, when adding an interface with a type other than system, and there
is already a system interface with the same name, as the routing table will hold
a reference to that system interface, some conflicts will arise. The netdev will
be opened with the incorrect type and that will make vswitchd remove it, but
adding it again will fail as it already exists. Failing earlier prevents some
vswitchd loops in reconfiguring the interface.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agodpif-netdev: use the open_type when creating the local port
Thadeu Lima de Souza Cascardo [Wed, 27 Jul 2016 15:06:44 +0000 (12:06 -0300)]
dpif-netdev: use the open_type when creating the local port

Instead of using the internal type, use the port_open_type when creating the
local port. That makes sure that whenever dpif_port_query is used, the netdev
open_type is returned instead of the "internal" type.

For other ports, that is already the case, as the netdev type is used when
creating the dp_netdev_port.

That changes the output of dpctl when showing the local port, and also when
trying to change its type. So, corresponding tests are fixed.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agonetdev-vport: don't use system type when opening netdev
Thadeu Lima de Souza Cascardo [Wed, 27 Jul 2016 15:06:43 +0000 (12:06 -0300)]
netdev-vport: don't use system type when opening netdev

tunnel_check_status_change__ calls netdev_open with type system. Using NULL
instead will default to system in case the device is not opened yet, and allow a
different type in case it's already opened.

Any type should be fine, as netdev_get_carrier will work with any of them.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agoin-band: don't use system type when opening netdev
Thadeu Lima de Souza Cascardo [Wed, 27 Jul 2016 15:06:42 +0000 (12:06 -0300)]
in-band: don't use system type when opening netdev

A netdev might be already opened with a different type and that can be used
instead. The system type is already the default type that will be used when
there is no netdev opened and the type is not specified.

And as long as the opened netdev supports the required operations, it doesn't
matter its type.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agoin-band: use open_type when opening internal device
Thadeu Lima de Souza Cascardo [Wed, 27 Jul 2016 15:06:41 +0000 (12:06 -0300)]
in-band: use open_type when opening internal device

in-band code will open a device that it expects to be the main internal port of
the bridge. However, it's possible that the correct type is a different one. For
dpif-netdev, it might be a tap device, or a dummy device for dummy datapaths.
ofproto_port_open_type will give the correct type.

While this doesn't cause any problems right now, as the needed type would be
opened already, a later patch assumes netdev with different types cannot be
opened.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agoFAQ: Add contents section and enable internal links.
Bhanuprakash Bodireddy [Wed, 27 Jul 2016 21:16:17 +0000 (22:16 +0100)]
FAQ: Add contents section and enable internal links.

Add contents section to FAQ and enable internal links in doc for pretty
printing on GitHub.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agomove ovn/lib/<lex|actions|expr>.h to include/ovn
Aaron Rosen [Mon, 25 Jul 2016 22:04:32 +0000 (15:04 -0700)]
move ovn/lib/<lex|actions|expr>.h to include/ovn

This patch is done to enable in tree building of the ovn-utils python
wrapper.  This is similar to what was done in commit
ee89ea7b477bb4fd05137de03b2e8443807ed9f4 (json: Move from lib to
include/openvswitch.).

Signed-off-by: Aaron Rosen <aaronorosen@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agophysical: Persist tunnels from one ovn-controller loop to the next.
Ryan Moats [Mon, 25 Jul 2016 16:28:52 +0000 (16:28 +0000)]
physical: Persist tunnels from one ovn-controller loop to the next.

While commit ab39371d68842b7e4000cc5d8718e6fc04e92795
(ovn-controller: Handle physical changes correctly) addressed
unit test failures, it did so at the cost of performance: [1]
notes that ovn-controller cpu usage is now pegged at 100%.

Root cause of this is that while the storage for tunnels is
persisted, their creation is not (which the above changed
incorrectly assumed was the case).  This patch persists
tunneled data across invocations of physical_run.  A side
effect is that renaming of localfvif_map_changed variable
to physical_map_changed and extending its scope to include
tunnel changes.

[1] http://openvswitch.org/pipermail/dev/2016-July/076058.html

Fixes: ab39371d6884 ("ovn-controller: Handle physical changes correctly")
Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
Acked-by: Flavio Fernandes <flavio@flaviof.com>
Tested-by: Flavio Fernandes <flavio@flaviof.com>
Acked-by: Liran Schour <lirans@il.ibm.com>
Tested-by: Liran Schour <lirans@il.ibm.com>
Acked-by: Hui Kang <kangh@us.ibm.com>
Tested-by: Hui Kang <kangh@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovsdb: Fix memory leak in replication logic
Andy Zhou [Tue, 26 Jul 2016 02:23:02 +0000 (19:23 -0700)]
ovsdb: Fix memory leak in replication logic

Release the memory of reply message of the initial "monitor" request.

Reported-at: http://openvswitch.org/pipermail/dev/2016-July/076075.html
Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
7 years agoovsdb: Properly close replication rpc connection
Andy Zhou [Tue, 26 Jul 2016 02:22:03 +0000 (19:22 -0700)]
ovsdb: Properly close replication rpc connection

This patch removes rpc related memory leak reported below.

Reported-at: http://openvswitch.org/pipermail/dev/2016-July/076075.html
Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
7 years agoovsdb: Fix memory leak reported by valgrind.
Liran Schour [Mon, 25 Jul 2016 08:00:29 +0000 (11:00 +0300)]
ovsdb: Fix memory leak reported by valgrind.

Destroy shash on destroy of session's condition structure.
Reported here: http://openvswitch.org/pipermail/dev/2016-July/075968.html

Signed-off-by: Liran Schour <lirans@il.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
7 years agoovs-router: Ignore IPv6 source addresses for IPv4 routes.
Thadeu Lima de Souza Cascardo [Sun, 24 Jul 2016 16:07:26 +0000 (13:07 -0300)]
ovs-router: Ignore IPv6 source addresses for IPv4 routes.

Though this should not happen when we have another address on the device that is
IPv4 mapped, we should prevent adding a routing entry to IPv4 with an IPv6
source address.

This entry has been observed when the addresses list was out of date.

Cached: 172.16.10.1/32 dev br3 SRC fe80::c4d0:14ff:feb1:b54b
Cached: 172.16.10.0/24 dev br3 SRC fe80::c4d0:14ff:feb1:b54b

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoutilities/ovs-ctl.in: Allow non-monitoring daemons
Aaron Conole [Mon, 25 Jul 2016 18:03:51 +0000 (14:03 -0400)]
utilities/ovs-ctl.in: Allow non-monitoring daemons

This commit allows the ovs-ctl command to spawn daemons without the
internal process monitor.  This is useful when integrating with,
ex. systemd, which provides its own monitoring facilities.

Signed-off-by: Aaron Conole <aconole@redhat.com>
Reviewed-by: Markos Chandras <mchandras@suse.de>
Acked-by: Ben Pfaff <blp@ovn.org>
Acked-by: Flavio Fernandes <flavio@flaviof.com>
Acked-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpif-netdev: Introduce pmd-rxq-affinity.
Ilya Maximets [Wed, 27 Jul 2016 14:44:44 +0000 (17:44 +0300)]
dpif-netdev: Introduce pmd-rxq-affinity.

New 'other_config:pmd-rxq-affinity' field for Interface table to
perform manual pinning of RX queues to desired cores.

This functionality is required to achieve maximum performance because
all kinds of ports have different cost of rx/tx operations and
only user can know about expected workload on different ports.

Example:
# ./bin/ovs-vsctl set interface dpdk0 options:n_rxq=4 \
                  other_config:pmd-rxq-affinity="0:3,1:7,3:8"
Queue #0 pinned to core 3;
Queue #1 pinned to core 7;
Queue #2 not pinned.
Queue #3 pinned to core 8;

It's decided to automatically isolate cores that have rxq explicitly
assigned to them because it's useful to keep constant polling rate on
some performance critical ports while adding/deleting other ports
without explicit pinning of all ports.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agodpif-netdev: Add reconfiguration request to dp_netdev.
Ilya Maximets [Wed, 27 Jul 2016 14:44:43 +0000 (17:44 +0300)]
dpif-netdev: Add reconfiguration request to dp_netdev.

Next patches will add new conditions when reconfiguration will be
required. It'll be simpler to have common way to request reconfiguration.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agobridge: Pass interface's configuration to datapath.
Ilya Maximets [Wed, 27 Jul 2016 14:44:42 +0000 (17:44 +0300)]
bridge: Pass interface's configuration to datapath.

This commit adds functionality to pass value of 'other_config' column
of 'Interface' table to datapath.

This may be used to pass not directly connected with netdev options and
configure behaviour of the datapath for different ports.
For example: pinning of rx queues to polling threads in dpif-netdev.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agodpif-netdev: XPS (Transmit Packet Steering) implementation.
Ilya Maximets [Wed, 27 Jul 2016 14:44:41 +0000 (17:44 +0300)]
dpif-netdev: XPS (Transmit Packet Steering) implementation.

If CPU number in pmd-cpu-mask is not divisible by the number of queues and
in a few more complex situations there may be unfair distribution of TX
queue-ids between PMD threads.

For example, if we have 2 ports with 4 queues and 6 CPUs in pmd-cpu-mask
such distribution is possible:
<------------------------------------------------------------------------>
pmd thread numa_id 0 core_id 13:
        port: vhost-user1       queue-id: 1
        port: dpdk0     queue-id: 3
pmd thread numa_id 0 core_id 14:
        port: vhost-user1       queue-id: 2
pmd thread numa_id 0 core_id 16:
        port: dpdk0     queue-id: 0
pmd thread numa_id 0 core_id 17:
        port: dpdk0     queue-id: 1
pmd thread numa_id 0 core_id 12:
        port: vhost-user1       queue-id: 0
        port: dpdk0     queue-id: 2
pmd thread numa_id 0 core_id 15:
        port: vhost-user1       queue-id: 3
<------------------------------------------------------------------------>

As we can see above dpdk0 port polled by threads on cores:
12, 13, 16 and 17.

By design of dpif-netdev, there is only one TX queue-id assigned to each
pmd thread. This queue-id's are sequential similar to core-id's. And
thread will send packets to queue with exact this queue-id regardless
of port.

In previous example:

pmd thread on core 12 will send packets to tx queue 0
pmd thread on core 13 will send packets to tx queue 1
...
pmd thread on core 17 will send packets to tx queue 5

So, for dpdk0 port after truncating in netdev-dpdk:

core 12 --> TX queue-id 0 % 4 == 0
core 13 --> TX queue-id 1 % 4 == 1
core 16 --> TX queue-id 4 % 4 == 0
core 17 --> TX queue-id 5 % 4 == 1

As a result only 2 of 4 queues used.

To fix this issue some kind of XPS implemented in following way:

* TX queue-ids are allocated dynamically.
* When PMD thread first time tries to send packets to new port
  it allocates less used TX queue for this port.
* PMD threads periodically performes revalidation of
  allocated TX queue-ids. If queue wasn't used in last
  XPS_TIMEOUT_MS milliseconds it will be freed while revalidation.
        * XPS is not working if we have enough TX queues.

Reported-by: Zhihong Wang <zhihong.wang@intel.com>
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agoINSTALL.md: Update configure section for built-in intrinsics.
Bhanuprakash Bodireddy [Wed, 27 Jul 2016 18:31:11 +0000 (19:31 +0100)]
INSTALL.md: Update configure section for built-in intrinsics.

Built-in CRC32 intrinsics can be used for efficient hash computation on
processors with SSE4.2 support.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoINSTALL.RHEL: Update missing hyperlink for Fedora install guide.
Bhanuprakash Bodireddy [Wed, 27 Jul 2016 18:31:10 +0000 (19:31 +0100)]
INSTALL.RHEL: Update missing hyperlink for Fedora install guide.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoINSTALL.md: Update missing hyperlink for Windows install guide.
Bhanuprakash Bodireddy [Wed, 27 Jul 2016 18:31:09 +0000 (19:31 +0100)]
INSTALL.md: Update missing hyperlink for Windows install guide.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agorelease-process.md: Document OVS release process and propose a schedule.
Ben Pfaff [Fri, 22 Jul 2016 19:39:44 +0000 (12:39 -0700)]
release-process.md: Document OVS release process and propose a schedule.

This document has two different kinds of text:

   - The first sections of the document, "Release Strategy" and "Release
     Numbering", describe what we've already been doing for most of the
     history of Open vSwitch.  If there is anything surprising in them,
     then it's because our process has not been transparent enough, and not
     because we're making a change.

   - The final section of the document, "Release Scheduling", is a proposal
     for current and future releases.  We have not had a regular release
     schedule in the past, but it seems important to have one in the
     future, so this section requires review and feedback from everyone in
     the community.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
7 years agoovn-nbctl: Improve usage message.
Ben Pfaff [Wed, 27 Jul 2016 05:43:07 +0000 (22:43 -0700)]
ovn-nbctl: Improve usage message.

The most important change here is to delete misspelled "the".

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Numan Siddique <nusiddiq@redhat.com>
7 years agoovn: Make it possible for CMS to detect when the OVN system is up-to-date.
Ben Pfaff [Sun, 24 Jul 2016 20:14:59 +0000 (13:14 -0700)]
ovn: Make it possible for CMS to detect when the OVN system is up-to-date.

Until now, there has been no reliable for the CMS (or ovn-nbctl, or
anything else) to detect when changes made to the northbound configuration
have been passed through to the southbound database or to the hypervisors.
This commit adds this feature to the system, by adding sequence numbers
to the northbound and southbound databases and adding code in ovn-nbctl,
ovn-northd, and ovn-controller to keep those sequence numbers up-to-date.

The biggest user-visible change from this commit is new a new option
--wait to ovn-nbctl.  With --wait=sb, ovn-nbctl now waits for ovn-northd
to update the southbound database; with --wait=hv, it waits for the
changes to make their way to Open vSwitch on every hypervisor.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
7 years agotravis: Update datapath target kernel list.
Pravin B Shelar [Mon, 18 Jul 2016 02:24:09 +0000 (19:24 -0700)]
travis: Update datapath target kernel list.

Update kernel list to latest stable release.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
7 years agodatapath: Add support for kernel 4.6
Pravin B Shelar [Tue, 26 Jul 2016 01:40:05 +0000 (18:40 -0700)]
datapath: Add support for kernel 4.6

Most of patch iron out USE_UPSTREAM_TUNNEL case where datapath
directly use upstream tunneling modules.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
Acked-by: Amitabha Biswas <abiswas@us.ibm.com>
7 years agodatapath: compat: simplify ip_local_out().
Pravin B Shelar [Tue, 26 Jul 2016 20:37:46 +0000 (13:37 -0700)]
datapath: compat: simplify ip_local_out().

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
7 years agodatapath: compat: unset skb encapsulation bit
Pravin B Shelar [Tue, 26 Jul 2016 00:49:54 +0000 (17:49 -0700)]
datapath: compat: unset skb encapsulation bit

OVS compat layer can handle tunnel GSO packets. but it does
keep skb encapsulation on for packet handled in GSO. This can
confuse some NIC drivers. I have seen this issue on intel devices:

>>>  i40e 0000:42:00.0: TX driver issue detected, PF reset issued

Following patch resets this bit in case compat layer handles the packet.

VMware-BZ: 1698877
Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
7 years agodatapath: compat: fix udp checksum calculation
Pravin B Shelar [Tue, 26 Jul 2016 00:49:53 +0000 (17:49 -0700)]
datapath: compat: fix udp checksum calculation

In upstream linux kernel networking stack udp_set_csum() is called
with only udp header applied but in case of compat layer it can
be called with IP header. So following patch take the offset into
account.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
7 years agoovn-northd: Fix {}-enclosed constants for ND responder
Zong Kai LI [Tue, 26 Jul 2016 06:02:26 +0000 (14:02 +0800)]
ovn-northd: Fix {}-enclosed constants for ND responder

It missed comma as constant seperator in match string for ND responder.

Signed-off-by: Zong Kai LI <zealokii@gmail.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
7 years agoovn-northd: Add logical flows to support native DHCPv4
Numan Siddique [Tue, 26 Jul 2016 19:24:39 +0000 (00:54 +0530)]
ovn-northd: Add logical flows to support native DHCPv4

OVN implements a native DHCPv4 support which caters to the common
use case of providing an IP address to a booting instance by
providing stateless replies to DHCPv4 requests based on statically
configured address mappings. To do this it allows a short list of
DHCPv4 options to be configured and applied at each compute host
running ovn-controller.

A new table 'DHCP_Options' is added in OVN NB DB to store the DHCP
options. Logical ports refer to this table to configure the DHCPv4
options.

For each logical port configured with DHCPv4 Options following flows
are added
 - A logical flow which copies the DHCPv4 options to the DHCPv4
   request packets using the 'put_dhcp_opts' action and advances the
   packet to the next stage.

 - A logical flow which implements the DHCP reponder by sending
   the DHCPv4 reply back to the inport once the 'put_dhcp_opts' action
   is applied.

Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Co-authored-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Ramu Ramamurthy <ramu.ramamurthy@us.ibm.com>
Acked-by: Ramu Ramamurthy <ramu.ramamurthy@us.ibm.com>
7 years agorhel/openvswitch.spec: Add SELinux policy.
Joe Stringer [Mon, 25 Jul 2016 21:09:26 +0000 (14:09 -0700)]
rhel/openvswitch.spec: Add SELinux policy.

Commit 9b897c9125ef ("rhel: provide our own SELinux custom policy
package") added the SELinux policy to the fedora packaging as a
subpackage. This patch makes the corresponding change to
openvswitch.spec, so that users of that specfile can generate the
selinux policy package without having to build all of the fedora
packages.

VMware-BZ: #1692972
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
7 years agoselinux: Allow ovs-ctl force-reload-kmod.
Joe Stringer [Fri, 22 Jul 2016 21:10:51 +0000 (14:10 -0700)]
selinux: Allow ovs-ctl force-reload-kmod.

When invoking ovs-ctl force-reload-kmod via '/etc/init.d/openvswitch
force-reload-kmod', spurious errors would output related to 'hostname'
and 'ip', and the system's selinux audit log would complain about some
of the invocations such as those listed at the end of this commit message.

This patch loosens restrictions for openvswitch_t (used for ovs-ctl, as
well as all of the OVS daemons) to allow it to execute 'hostname' and
'ip' commands, and also to execute temporary files created as
openvswitch_tmp_t. This allows force-reload-kmod to run correctly.

Example audit logs:
type=AVC msg=audit(1468515192.912:16720): avc:  denied  { getattr } for
pid=11687 comm="ovs-ctl" path="/usr/bin/hostname" dev="dm-1"
ino=33557805 scontext=system_u:system_r:openvswitch_t:s0
tcontext=system_u:object_r:hostname_exec_t:s0 tclass=file

type=AVC msg=audit(1468519445.766:16829): avc:  denied  { getattr } for
pid=13920 comm="ovs-save" path="/usr/sbin/ip" dev="dm-1" ino=67572988
scontext=unconfined_u:system_r:openvswitch_t:s0
tcontext=system_u:object_r:ifconfig_exec_t:s0 tclass=file

type=AVC msg=audit(1468519445.890:16833): avc:  denied  { execute } for
pid=13849 comm="ovs-ctl" name="tmp.jdEGHntG3Z" dev="dm-1" ino=106876762
scontext=unconfined_u:system_r:openvswitch_t:s0
tcontext=unconfined_u:object_r:openvswitch_tmp_t:s0 tclass=file

VMware-BZ: #1692972
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
7 years agoMakefile.am: Add clang static analysis support
Bhanuprakash Bodireddy [Fri, 15 Jul 2016 18:43:24 +0000 (19:43 +0100)]
Makefile.am: Add clang static analysis support

Clang Static Analyzer is a source code analysis tool to find bugs. This
patch adds make target to trigger static analysis using below commands.

./boot.sh
For Clang: ./configure CC=clang --with-dpdk
For GCC: ./configure CC=gcc --with-dpdk CFLAGS="-std=gnu99"
make clang-analyze

Run 'scan-view <results dir>' command to examine the bug report.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Acked-By: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovn-northd: Combine two NAT loops into one.
Guru Shetty [Wed, 13 Jul 2016 11:20:36 +0000 (04:20 -0700)]
ovn-northd: Combine two NAT loops into one.

Signed-off-by: Gurucharan Shetty <guru@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agoovsdb: Weak references performance fix
Rodriguez Betancourt, Esteban [Wed, 13 Jul 2016 17:28:51 +0000 (17:28 +0000)]
ovsdb: Weak references performance fix

Prevents the cloning of rows with outgoing or incoming weak references when
those rows aren't being modified.

It improves the OVSDB Server performance when many rows with weak references
are involved in a transaction.

In the original code (dst_refs is created from scratch):

old->dst_refs = all the rows that weak referenced old

new->dst_refs = all the rows that weak referenced old and are still weak
+referencing new + rows in the transaction that weak referenced new

In the patch (dst_refs incrementally built):
Old->dst_refs = all the rows that weak referenced old

Ideally, but expansive to calculate:
New->dst_refs = old->dst_refs - "weak references removed within this TXN" +
+"weak references created within this TXN"

What this patch implements:
New->dst_refs = old->dst_refs - "weak references in old rows in TXN" + "weak
+references in new rows in TXN"

The resulting sets should be equal in both cases.

We do some more optimizations:

- If we know that the transactions must be successful at some point then,
  instead of cloning dst_refs we could just move the elements between
  the lists.

- At that point we lost the rollback feature, but we aren't going to need
  it anyway (note that we didn't really touch the src_refs part).

- The references in dst_refs must point to new instead than old.
  Previously we iterated over all the weak references in dst_refs
  to change that pointer, but using an UUID is easier, and prevents
  that iteration completely.

For some more commentary, see:
http://openvswitch.org/pipermail/dev/2016-July/074840.html

Signed-off-by: Esteban Rodriguez Betancourt <estebarb@hpe.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoflow: Verify that tot_len >= ip_len in miniflow_extract().
Ben Pfaff [Fri, 22 Jul 2016 23:43:50 +0000 (16:43 -0700)]
flow: Verify that tot_len >= ip_len in miniflow_extract().

miniflow_extract() uses the following quantities when it examines an IPv4
header:

    size, the number of bytes from the start of the IPv4 header onward
    ip_len, the number of bytes in the IPv4 header (from the IHL field)
    tot_len, same as size but taken from IPv4 header Total Length field

Until now, the code in miniflow_extract() verified these invariants:

    size >= 20 (minimum IP header length)
    ip_len >= 20 (ditto)
    ip_len <= size (to avoid reading past end of packet)
    tot_len <= size (ditto)
    size - tot_len <= 255 (because this is stored in a 1-byte variable
   internally and wouldn't normally be big)

It failed to verify the following, which is not implied by the conjunction
of the above:

    ip_len <= tot_len (e.g. that the IP header fits in the packet)

This means that the code was willing to read past the end of an IP
packet's declared length, up to the actual end of the packet including any
L2 padding.  For example, given:

    size = 44
    ip_len = 44
    tot_len = 40

miniflow_extract() would successfully verify all the constraints, then:

    * Trim off 4 bytes of tail padding (size - tot_len), reducing size to
      40 to match tot_len.
    * Pull 44 (ip_len) bytes of IP header, even though there are only 40
      bytes left.  This causes 'size' to wrap around to SIZE_MAX-4.

Given an IP protocol that OVS understands (such as TCP or UDP), this
integer wraparound could cause OVS to read past the end of the packet.
In turn, this could cause OVS to extract invalid port numbers, TCP flags,
or ICMPv4 or ICMPv6 or IGMP type and code from arbitrary heap data
past the end of a packet.

This bug has common hallmarks of a security vulnerability, but we do not
know of a way to exploit this bug to cause an Open vSwitch crash, or to
extract sensitive data from Open vSwitch address space to an attacker's
benefit.

We do not have a specific example, but it is reasonable to suspect that
this bug could allow an attacker in some circumstances to bypass ACLs
implemented via Open vSwitch flow tables.  However, any IP packet that
triggers this bug is invalid and should be rejected in an early stage of a
receiver's IP stack.  For the same reason, any IP packet that triggers this
bug will also be dropped by any IP router, so an attacker would have to
share the same L2 segment as the victim.  In conjunction with an IP stack
that has a similar bug, of course, this could cause some damage, but we do
not know of an IP stack with such a bug; neither Linux nor the OVS
userspace tunnel implementation appear to have such a bug.

Reported-by: Bhargava Shastry <bshastry@sec.t-labs.tu-berlin.de>
Reported-by: Kashyap Thimmaraju <Kashyap.Thimmaraju@sec.t-labs.tu-berlin.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
7 years agopython: Serial JSON via Python's json lib.
Terry Wilson [Tue, 26 Jul 2016 00:17:11 +0000 (19:17 -0500)]
python: Serial JSON via Python's json lib.

There is no particularly good reason to use our own Python JSON
serialization implementation when serialization can be done faster
with Python's built-in JSON library.

A few tests were changed due to Python's default JSON library
returning slightly more precise floating point numbers.

Signed-off-by: Terry Wilson <twilson@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoWindows: daemon-windows lockfile
Alin Serdean [Mon, 25 Jul 2016 21:58:10 +0000 (21:58 +0000)]
Windows: daemon-windows lockfile

_get_osfhandle returns an errno value not a GetLastErrorValue.
(https://msdn.microsoft.com/en-us/library/ks2530z6(v=vs.120).aspx)

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Paul Boca <pboca@cloudbasesolutions.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
7 years agodatapath: remove VLAN compat code from GSO
Thadeu Lima de Souza Cascardo [Thu, 21 Jul 2016 18:14:17 +0000 (11:14 -0700)]
datapath: remove VLAN compat code from GSO

This compatibility code was only needed for Linux 2.6.36 and older. With the
support for versions older than 3.10 dropped, this code is not needed anymore.

The style for checking for mpls was kept in case some other protocol type is
added in the future.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
7 years agodatapath: remove rtnl_delete_link support for older Linux
Thadeu Lima de Souza Cascardo [Thu, 21 Jul 2016 18:14:16 +0000 (11:14 -0700)]
datapath: remove rtnl_delete_link support for older Linux

The changes from upstream version of rtnl_delete_link were only there to support
Linux 2.6.33 or older. The removal of this support makes it identical to
upstream version as of 4.6.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
7 years agodatapath: remove rpl_ipv6_skip_exthdr
Thadeu Lima de Souza Cascardo [Thu, 21 Jul 2016 18:14:15 +0000 (11:14 -0700)]
datapath: remove rpl_ipv6_skip_exthdr

This backported functon was only used for Linux 3.2 or older. As we support only
Linux 3.10 or newer, there is no need for it anymore.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
7 years agodatapath: remove net namespace
Thadeu Lima de Souza Cascardo [Thu, 21 Jul 2016 18:14:14 +0000 (11:14 -0700)]
datapath: remove net namespace

The code that used that module was already removed when some support for Linux
older than 3.10 was removed.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
7 years agodatapath: remove flow_dissector
Thadeu Lima de Souza Cascardo [Thu, 21 Jul 2016 18:14:13 +0000 (11:14 -0700)]
datapath: remove flow_dissector

flow_dissector was only built for Linux 3.8 and older. There is no need for this
anymore, as anything older than 3.10 is no longer supported.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
7 years agodatapath: remove flex_array
Thadeu Lima de Souza Cascardo [Thu, 21 Jul 2016 18:14:12 +0000 (11:14 -0700)]
datapath: remove flex_array

flex_array is already present on Linux 3.10, so there is no need for its
backport anymore.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
7 years agoutil: Expose function nullable_string_is_equal.
Ilya Maximets [Fri, 15 Jul 2016 11:54:53 +0000 (14:54 +0300)]
util: Expose function nullable_string_is_equal.

Implementation of 'nullable_string_is_equal()' moved to util.c and
reused inside dpif-netdev.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agonetdev-dpdk: remove duplicated code in netdev_dpdk_get_status
xubinbin [Thu, 21 Jul 2016 13:52:29 +0000 (21:52 +0800)]
netdev-dpdk: remove duplicated code in netdev_dpdk_get_status

Put "driver_name" into "args" twice, that's meaninglessness.
So need to remove duplicated code.

Signed-off-by: Binbin Xu <xu.binbin1@zte.com.cn>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agonetdev-dpdk: Apply batch truncation API.
William Tu [Mon, 25 Jul 2016 15:14:24 +0000 (08:14 -0700)]
netdev-dpdk: Apply batch truncation API.

Instead of looping into each packet and check whether to truncate, the
patch moves it out of the loop and uses batch API.  If truncation is
not set, checking 'trunc' in 'struct dp_packet_batch' at per-batch basis
can skip the per-packet checking overhead.

Signed-off-by: William Tu <u9012063@gmail.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agopython: add set type for ovs.idl.data.Datum.from_python
Zong Kai LI [Thu, 21 Jul 2016 06:17:28 +0000 (14:17 +0800)]
python: add set type for ovs.idl.data.Datum.from_python

ovs.db.idl.Datum.from_python fails to handle set type value, while set
type is also a common iterable sequence, just like list and tuple.
No reason IDL caller must to turn set type parameters to list or tuple
type. Otherwise, they will fail to insert data, but get no exception.

Reported-at: https://bugs.launchpad.net/networking-ovn/+bug/1605573
Signed-off-by: Zong Kai LI <zealokii@gmail.com>
Acked-by: Richard Theis <rtheis@us.ibm.com>
Tested-by: Richard Theis <rtheis@us.ibm.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
7 years agowindows: Added lockf function and lock PID file
Paul Boca [Mon, 25 Jul 2016 12:50:33 +0000 (12:50 +0000)]
windows: Added lockf function and lock PID file

If the PID file isn't locked then appctl.py detects it as stale and
bails out without doing anything. Because of this lots of Python tests fail.
Also this protects the PID file from being overwritten.

I used only shared lock, in order to be compatible with Python tests,
which try to acquire the lock exclusively. On Windows if the exclusive lock
is used, than the read access is denied too for other instances of this file.

Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
7 years agoExplain initialization when using csum()
Ryan Moats [Sun, 24 Jul 2016 18:36:35 +0000 (18:36 +0000)]
Explain initialization when using csum()

The checksum method csum() requires its output location to be
intialized to zero when that output location is part of the
checksum.  Add comments to the various places where csum is
called documenting where the initialization has occurred.

Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agotests: Fix typo: s/OSVDB/OVSDB/.
Ben Pfaff [Fri, 22 Jul 2016 20:16:05 +0000 (13:16 -0700)]
tests: Fix typo: s/OSVDB/OVSDB/.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
7 years agoovs-ofctl: Fix font in manual.
Ben Pfaff [Fri, 22 Jul 2016 21:33:56 +0000 (14:33 -0700)]
ovs-ofctl: Fix font in manual.

Without this fix, the remainder of the paragraph appears in bold, which was
not intended.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
7 years agoTODO.md: Remove.
Ben Pfaff [Fri, 22 Jul 2016 20:18:09 +0000 (13:18 -0700)]
TODO.md: Remove.

No one has implemented a project from this list in years.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
7 years agoovn: Remove unnecessary conditional statements.
nickcooper-zhangtonghao [Sun, 24 Jul 2016 14:40:35 +0000 (07:40 -0700)]
ovn: Remove unnecessary conditional statements.

It is unnecessary to check ‘chassis_id’ again.

Signed-off-by: nickcooper-zhangtonghao <nickcooper-zhangtonghao@opencloud.tech>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agotest: change replication test to use unix domain socket
Andy Zhou [Wed, 20 Jul 2016 22:25:24 +0000 (15:25 -0700)]
test: change replication test to use unix domain socket

The ovsdb replication feature is not specific to the ovsdb socket types.
Switching the tests to use Unix domain socket simplifies the tests.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agoovn-controller: eliminate stall in ofctrl state machine
Lance Richardson [Fri, 8 Jul 2016 00:31:08 +0000 (20:31 -0400)]
ovn-controller: eliminate stall in ofctrl state machine

The "ovn -- 2 HVs, 3 LRs connected via LS, static routes"
test case currently exhibits frequent failures. These failures
occur because, at the time that the test packets are sent to
verify forwarding, no flows have been installed in the vswitch
for one of the hypervisors.

The state machine implemented by ofctrl_run() is intended to
iterate as long as progress is being made, either as long as
the state continues to change or as long as packets are being
received.  Unfortunately, the code had a bug: if receiving a
packet caused the state to change, it didn't call the state's
run function again to try to see if it would change the state.
This caused a real problem in the following case:

   1) The state is S_TLV_TABLE_MOD_SENT.
   2) An OFPTYPE_NXT_TLV_TABLE_REPLY message is received.
   3) No event (other than SB probe timer expiration) is expected
      that would unblock poll_block() in the main ovn-controller
      loop.

In such a case, ofctrl_run() would receive the packet and
advance the state, but not call the run function for the new
state, and then leave the state machine paused until the next
event (e.g. a timer event) occurred.

This commit fixes the problem by continuing to iterate the state
machine until the state remains the same and no packet is
received in the same iteration.  Without this fix, around 40
failures are seen out of 100 attempts, with this fix no failures
have been observed in several hundred attempts (using an earlier
version of this patch).

Signed-off-by: Lance Richardson <lrichard@redhat.com>
[blp@ovn.org refactored for clarity]
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Lance Richardson <lrichard@redhat.com>
7 years agoovs-lib: Keep internal interface ip during upgrade.
Daniele Di Proietto [Wed, 22 Jun 2016 02:27:30 +0000 (19:27 -0700)]
ovs-lib: Keep internal interface ip during upgrade.

Commit 9b5422a98f81("ovs-lib: Try to call exit before killing.")
introduced a problem where internal interfaces are destroyed and
recreated, losing their IP address.

Commit 9aad5a5a96ba("ovs-vswitchd: Preserve datapath ports across
graceful shutdown.") fixed the problem by changing ovs-vswitchd
to preserve the ports on `ovs-appctl exit`.  Unfortunately, this fix is
not enough during upgrade from <= 2.5.0, where an old ovs-vswitchd is
running (without the fix) and a new ovs-lib script is performing the
restart.

The problem seem to affect both RHEL and ubuntu.

This commit fixes the upgrade by looking at the running daemon
version and avoid using `ovs-appctl exit` if it's < 2.5.90.

Suggested-by: Gurucharan Shetty <guru@ovn.org>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Gurucharan Shetty <guru@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agojson: Move from lib to include/openvswitch.
Terry Wilson [Tue, 12 Jul 2016 21:37:34 +0000 (16:37 -0500)]
json: Move from lib to include/openvswitch.

To easily allow both in- and out-of-tree building of the Python
wrapper for the OVS JSON parser (e.g. w/ pip), move json.h to
include/openvswitch. This also requires moving lib/{hmap,shash}.h.

Both hmap.h and shash.h were #include-ing "util.h" even though the
headers themselves did not use anything from there, but rather from
include/openvswitch/util.h. Fixing that required including util.h
in several C files mostly due to OVS_NOT_REACHED and things like
xmalloc.

Signed-off-by: Terry Wilson <twilson@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovn-controller: Handle physical changes correctly
Ryan Moats [Fri, 22 Jul 2016 21:54:26 +0000 (21:54 +0000)]
ovn-controller: Handle physical changes correctly

[1] reported increased failure rates in certain tests
with incremental processing (the numbers are the number of failures
seen in 100 tests):

   2  ovn -- vtep: 3 HVs, 1 VIFs/HV, 1 GW, 1 LS
  10  ovn -- 2 HVs, 2 LS, 1 lport/LS, 2 peer LRs
  52  ovn -- 1 HV, 1 LS, 2 lport/LS, 1 LR
  45  ovn -- 1 HV, 2 LSs, 1 lport/LS, 1 LR
  23  ovn -- 2 HVs, 3 LS, 1 lport/LS, 2 peer LRs, static routes
  53  ovn -- 2 HVs, 3 LRs connected via LS, static routes
  32  ovn -- 2 HVs, 2 LRs connected via LS, gateway router
  50  ovn -- icmp_reply: 1 HVs, 2 LSs, 1 lport/LS, 1 LR

These failures were caused by a combination of problems in
handling physical changes:

  1. When a vif was removed, the localvif_to_ofport entry was not
     removed.
  2. When a physical change was detected, ovn-controller would wait
     a poll cycle before processing the logical flow table.

This patch set addresses both of these issues while simultaneously
cleaning up the code in physical.c.  A side effect is a modification
of where OF flows are dumped in the gateway router case that allowed
the root causes of this issue to be found.

With these changes, all of the above tests had a 100/100 success rate.

[1] http://openvswitch.org/pipermail/dev/2016-July/075803.html

Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agotests: Add ovsdb lock tests
Andy Zhou [Fri, 22 Jul 2016 20:59:03 +0000 (13:59 -0700)]
tests: Add ovsdb lock tests

Add more ovsdb lock tests.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agoovsdb: Add ovsdb-client options for testing lock
Andy Zhou [Fri, 22 Jul 2016 20:49:09 +0000 (13:49 -0700)]
ovsdb: Add ovsdb-client options for testing lock

RFC 7047 lock operation has been fully implemented in ovsdb-server
for a while, but it is not well covered in unit testing. This
patch adds options for the ovsdb-client tool to issue lock operations.
The next patch will make use those options.

Please see ovsdb-client(1) changes for more details.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agotests: Fix IPFIX test cases issue.
Benli Ye [Thu, 7 Jul 2016 15:17:48 +0000 (23:17 +0800)]
tests: Fix IPFIX test cases issue.

IPFIX statistics 'tx pkts' means the number of successfully
sending IPFIX packets, while 'tx errs' means sending error
IPFIX packets. These two parameters can be affected by whether
listening on port 4739 on local host. This case should be
solved entirely by introducing PARSE_LISTENING_PORT as sFlow,
but it depends on implementing IPFIX packet analysis and it
will take some time. Disable these field first, as IPFIX statistics
check are failed on Windows due to 'tx pkts' and 'tx errs' fields.
Windows marks all packets sending successfully, even if port 4739
on local host is not listened.

Remove XFAIL check for 'Flow IPFIX sanity check - tunnel set',
as this test had “UNEXPECTED PASS” on Windows.

More detail, please refer the following link.
https://www.mail-archive.com/dev@openvswitch.org/msg65229.html

Reported-by: Paul Boca <pboca@cloudbasesolutions.com>
Acked-by: Paul Boca <pboca@cloudbasesolutions.com>
Signed-off-by: Benli Ye <daniely@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agonetdev-dummy: fix crash with more than one passive connection
Lance Richardson [Wed, 6 Jul 2016 23:39:52 +0000 (19:39 -0400)]
netdev-dummy: fix crash with more than one passive connection

Investigation found that Some of the occasional failures in the
"ovn -- vtep: 3 HVs, 1 VIFs/HV, 1 GW, 1 LS" test case are caused
by ovs-vswitchd crashing with SIGSEGV. It turns out that the
crash occurrs when the number of netdev-dummy passive connections
transitions from 1 to 2.  When xrealloc() copies the array of
dummy_packet_stream structures from the original buffer to a
newly allocated one, the struct ovs_list txq member of the structure
becomes corrupt (e.g. if ovs_list_is_empty() would have returned
false before the copy, it will return true after the copy, which
will lead to a crash when the bogus packet buffer on the list is
dereferenced).

Fix by taking a hint from David Wheeler and adding a level of
indirection.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
[blp@ovn.org folded in an additional bug fix]
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovs-pki: Use SHA-512 instead of SHA-1 as message digest.
Ben Pfaff [Sat, 2 Jul 2016 01:05:40 +0000 (18:05 -0700)]
ovs-pki: Use SHA-512 instead of SHA-1 as message digest.

The upcoming OpenSSL 1.1.0 release disables use of SHA-1, which breaks the
OVS unit tests, which use SHA-1.  We last tried to switch to SHA-512 in
2014 with commit 9ff33ca75e9fcc ("ovs-pki: Use SHA-512 instead of MD5 as
message digest."), but we had to downgrade to SHA-1 in commit 4a1f9610682d
("ovs-pki: Use SHA-1 instead of SHA-512 as message digest.") because
XenServer did not support SHA-512.  It has been a few years, so let's try
again.

CC: 828478@bugs.debian.org
Reported-at: https://bugs.debian.org/828478
Reported-by: Kurt Roeckx <kurt@roeckx.be>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
7 years agotests: Make ovsdb test more robust and faster.
Jarno Rajahalme [Thu, 21 Jul 2016 13:22:18 +0000 (06:22 -0700)]
tests: Make ovsdb test more robust and faster.

Using sleep's is prone to runtime system dependent races, and indeed
this test started consistently failing on my dev VM after an unrelated
change to ovs-vswitchd.  Get git of the sleeps and explicitly wait for
the transaction on ovsdb1 to become visible on ovsdb2.

Also fix the name of the test.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
Tested-by: Joe Stringer <joe@ovn.org>
7 years agotests/ovs-monitor-ipsec: Remove --no-wait -vreconnect:emer from ovs-vsctl.
Daniele Di Proietto [Thu, 21 Jul 2016 21:05:11 +0000 (14:05 -0700)]
tests/ovs-monitor-ipsec: Remove --no-wait -vreconnect:emer from ovs-vsctl.

This fixes a sporadic failure of the testcase, where ovsdb-server.log
contains:

2016-07-21T21:08:22.279Z|00003|jsonrpc|WARN|unix: send error: Broken pipe
2016-07-21T21:08:22.279Z|00004|reconnect|WARN|unix: connection dropped (Broken pipe)

I'm not sure what was the purpose of the original "--no-wait
-vreconnect:emer", but the test seem to run fine without it.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Joe Stringer <joe@ovn.org>
7 years agoovn-controller: Fix potential null pointer dereferences.
Ben Pfaff [Wed, 20 Jul 2016 21:54:33 +0000 (14:54 -0700)]
ovn-controller: Fix potential null pointer dereferences.

Found by inspection.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
7 years agoovn-northd: Avoid redundant lookup of logical router port peer.
Ben Pfaff [Tue, 19 Jul 2016 16:03:21 +0000 (09:03 -0700)]
ovn-northd: Avoid redundant lookup of logical router port peer.

An ovn_port keeps track of its peer in its 'peer' member, but the code
updated by this commit instead did a redundant lookup of the peer.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Gurucharan Shetty <guru@ovn.org>
7 years agoovn-northd: Only peer router ports to other router ports.
Ben Pfaff [Tue, 19 Jul 2016 15:36:35 +0000 (08:36 -0700)]
ovn-northd: Only peer router ports to other router ports.

A router port's "peer", if set, must point to another router port, but the
code as written also accepted switch ports.  This caused problems when
switch ports were actually specified.

Reported-by: Gurucharan Shetty <guru@ovn.org>
Reported-at: http://openvswitch.org/pipermail/dev/2016-July/075524.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Gurucharan Shetty <guru@ovn.org>
7 years agonetdev-provider: Apply batch object to netdev provider.
William Tu [Tue, 19 Jul 2016 00:05:35 +0000 (17:05 -0700)]
netdev-provider: Apply batch object to netdev provider.

Commit 1895cc8dbb64 ("dpif-netdev: create batch object") introduces
batch process functions and 'struct dp_packet_batch' to associate with
batch-level metadata.  This patch applies the packet batch object to
the netdev provider interface (dummy, Linux, BSD, and DPDK) so that
batch APIs can be used in providers.  With batch metadata visible in
providers, optimizations can be introduced at per-batch level instead
of per-packet.

Tested-at: https://travis-ci.org/williamtu/ovs-travis/builds/145694197
Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agodebian: Fix OVS upgrade dependencies.
Joe Stringer [Fri, 17 Jun 2016 19:42:30 +0000 (12:42 -0700)]
debian: Fix OVS upgrade dependencies.

Commit 0dcc739e7a28 ("debian: Move ovs-lib to openvswitch-common.")
shifted a file between debian packages, but didn't update the
destination package annotations to indicate that it replaces a file
from earlier versions of the source package.

As a result, if one installs openvswitch-switch-2.5* (or earlier) and
then tries to upgrade to openvswitch-{switch,common}-2.5.90+, the
install of openvswitch-common will fail like the following:

dpkg: error processing archive
/tmp/openvswitch-common_2.5.90-1_amd64.deb (--install):
trying to overwrite '/usr/share/openvswitch/scripts/ovs-lib', which is
also in package openvswitch-switch 2.5.0-1

Fix the issue by adding "Replaces" and "Breaks" tags to the new
openvswitch-common section of debian/control.

Fixes: 0dcc739e7a28 ("debian: Move ovs-lib to openvswitch-common.")
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
7 years agodatapath-windows: Fix various Geneve bugs
Yin Lin [Thu, 14 Jul 2016 03:21:19 +0000 (20:21 -0700)]
datapath-windows: Fix various Geneve bugs

Signed-off-by: Yin Lin <linyi@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
7 years agosystem-traffic: Fix up FTP tests.
Joe Stringer [Tue, 19 Jul 2016 19:54:08 +0000 (12:54 -0700)]
system-traffic: Fix up FTP tests.

Prior to commit b87a5aacefe2 ("datapath: Fix cached ct with helper."),
we were relying on automatic helpers to ensure that FTP connections were
tracked correctly, regardless of the flows that existed in the datapath.
Now, we can drop the automatic helpers in the root namespace and still
have related connections work correctly. Also, the ALG should only be
specified when committing the connection. Update the rules.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
7 years agosystem-traffic: Remove unnecessary priorities.
Joe Stringer [Tue, 19 Jul 2016 19:54:07 +0000 (12:54 -0700)]
system-traffic: Remove unnecessary priorities.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
7 years agosystem-traffic: Update tests in flat tables.
Joe Stringer [Tue, 19 Jul 2016 19:54:06 +0000 (12:54 -0700)]
system-traffic: Update tests in flat tables.

A few of the earlier tests were written with all flows in a single flat
table. While this is a possible way to write your flows to use
connection tracking, it's easier to understand if the processing
proceeds forward from one table to the next. Update these tests.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
7 years agotunneling: get skb marking to work properly with tunnels
Ansis Atteka [Thu, 21 Jul 2016 11:49:40 +0000 (04:49 -0700)]
tunneling: get skb marking to work properly with tunnels

There are two issues that this patch fixes:
1. it was impossible to set skb mark at all through
   NXM_NX_PKT_MARK register for tunnel packets; AND
2. ipsec_xxx tunnels would not be marked with the default
   IPsec mark (broken by d23df9a87 "lib/odp: Use masked set
   actions.").

This patch also adds anti-regression tests to prevent such
breakages in the future.

Signed-off-by: Ansis Atteka <aatteka@ovn.org>
VMware-BZ: #1653178
Acked-by: Jarno Rajahalme <jarno@ovn.org>
7 years agoIPsec: refactor out some code in OVS_MONITOR_IPSEC_START macro
Ansis Atteka [Thu, 21 Jul 2016 11:49:40 +0000 (04:49 -0700)]
IPsec: refactor out some code in OVS_MONITOR_IPSEC_START macro

This OVS_MONITOR_IPSEC_START macro will be helpful in the next
patch where it will be used also from tests/tunnel.at file to test
that skb marking happens correctly.  Otherwise, without ovs-monitor-ipsec
running the ovs-vswitchd would refuse to configure ipsec_XXX tunnels.

Signed-off-by: Ansis Atteka <aatteka@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
7 years agoRename nbs/nbr port names to nbsp/nbrp.
Hui Kang [Tue, 19 Jul 2016 18:36:00 +0000 (14:36 -0400)]
Rename nbs/nbr port names to nbsp/nbrp.

These variables indicate ports in nb switches or routers.

Signed-off-by: Hui Kang <kangh@us.ibm.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
7 years agoovn: Apply ACL changes to existing connections.
Russell Bryant [Thu, 30 Jun 2016 20:14:05 +0000 (16:14 -0400)]
ovn: Apply ACL changes to existing connections.

Prior to this commit, once a connection had been committed to the
connection tracker, the connection would continue to be allowed, even
if the policy defined in the ACL table changed.  This patch changes
the implementation so that existing connections are affected by policy
changes.

The implementation is based on the suggested approach in this mailing
list thread:

    http://openvswitch.org/pipermail/dev/2016-February/065716.html

Instead of always allowing packets associated with an established
connection, we now put all packets in the request direction through
the flows generated based on OVN ACLs.  If a packet associated with an
established connection hits a "drop" ACL, that means we have
encountered a policy change and should drop packets associated with
this connection from now on.  We handle this by setting "ct_label" on
the associated connection tracking entry.

These changes also account for re-allowing a known connection after
ct_label had been set on it. This can happen if you delete an ACL and
then re-create it while connection state is still known.

The proposal on the mailing list also discussed the idea that
ovn-controller could periodically sweep the connection tracker and
delete entries with ct_label set.  That is not implemented in this
patch.  Instead, we rely on connections dying since we're dropping
its packets and then allowing the connection tracking entry to
eventually time out.  More proactively clearing them out could be a
future enhancement.

As a realistic example of how this works, consider this security policy
from an OpenStack+OVN development environment.

    +---------+-----------------------+
    | name    | security_group_rules  |
    +---------+-----------------------+
    | default | egress, IPv4          |
    |         | egress, IPv6          |
    |         | ingress, IPv4, 22/tcp |
    |         | ingress, IPv4, icmp   |
    +---------+-----------------------+

The OpenStack Neutron plugin creates ACLs that drop traffic by default
and higher priority ACLs for each type of traffic that is allowed.  In
this case, the ACLs for a port using the "default" security group are:

  from-lport  1002 (inport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip4) allow-related
  from-lport  1002 (inport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip6) allow-related
  from-lport  1001 (inport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip) drop
    to-lport  1002 (outport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip4 && icmp4) allow-related
    to-lport  1002 (outport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip4 && tcp && tcp.dst == 22) allow-related
    to-lport  1001 (outport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip) drop

which results in the following logical flows:

  table=3 (ls_in_pre_acl      ), priority=100  , match=(ip), action=(reg0[0] = 1; next;)
  table=3 (ls_in_pre_acl      ), priority=0    , match=(1), action=(next;)
  table=4 (ls_in_pre_lb       ), priority=0    , match=(1), action=(next;)
  table=5 (ls_in_pre_stateful ), priority=100  , match=(reg0[0] == 1), action=(ct_next;)
  table=5 (ls_in_pre_stateful ), priority=0    , match=(1), action=(next;)
  table=6 (ls_in_acl          ), priority=65535, match=(!ct.est && ct.rel && !ct.new && !ct.inv && ct_label[0] == 0), action=(next;)
  table=6 (ls_in_acl          ), priority=65535, match=(ct.est && !ct.rel && !ct.new && !ct.inv && ct.rpl && ct_label[0] == 0), action=(next;)
  table=6 (ls_in_acl          ), priority=65535, match=(ct.inv || (ct.est && ct.rpl && ct_label[0] == 1)), action=(drop;)
  table=6 (ls_in_acl          ), priority=65535, match=(nd), action=(next;)
  table=6 (ls_in_acl          ), priority=2002 , match=(!ct.new && ct.est && !ct.rpl && ct_label[0] == 0 && (inport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip4 && (ip4.dst == 255.255.255.255 || ip4.dst == 10.0.0.0/24) && udp && udp.src == 68 && udp.dst == 67)), action=(next;)
  table=6 (ls_in_acl          ), priority=2002 , match=(!ct.new && ct.est && !ct.rpl && ct_label[0] == 0 && (inport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip4)), action=(next;)
  table=6 (ls_in_acl          ), priority=2002 , match=(!ct.new && ct.est && !ct.rpl && ct_label[0] == 0 && (inport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip6)), action=(next;)
  table=6 (ls_in_acl          ), priority=2002 , match=(((ct.new && !ct.est) || (!ct.new && ct.est && !ct.rpl && ct_label[0] == 1)) && (inport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip4 && (ip4.dst == 255.255.255.255 || ip4.dst == 10.0.0.0/24) && udp && udp.src == 68 && udp.dst == 67)), action=(reg0[1] = 1; next;)
  table=6 (ls_in_acl          ), priority=2002 , match=(((ct.new && !ct.est) || (!ct.new && ct.est && !ct.rpl && ct_label[0] == 1)) && (inport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip4)), action=(reg0[1] = 1; next;)
  table=6 (ls_in_acl          ), priority=2002 , match=(((ct.new && !ct.est) || (!ct.new && ct.est && !ct.rpl && ct_label[0] == 1)) && (inport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip6)), action=(reg0[1] = 1; next;)
  table=6 (ls_in_acl          ), priority=2001 , match=((!ct.est || (ct.est && ct_label[0] == 1)) && (inport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip)), action=(drop;)
  table=6 (ls_in_acl          ), priority=2001 , match=(ct.est && ct_label[0] == 0 && (inport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip)), action=(ct_commit(ct_label=1/1);)
  table=6 (ls_in_acl          ), priority=1    , match=(ip && (!ct.est || (ct.est && ct_label[0] == 1))), action=(reg0[1] = 1; next;)
  table=6 (ls_in_acl          ), priority=0    , match=(1), action=(next;)
  table=7 (ls_in_lb           ), priority=0    , match=(1), action=(next;)
  table=8 (ls_in_stateful     ), priority=100  , match=(reg0[1] == 1), action=(ct_commit(ct_label=0/1); next;)
  table=8 (ls_in_stateful     ), priority=100  , match=(reg0[2] == 1), action=(ct_lb;)
  table=8 (ls_in_stateful     ), priority=0    , match=(1), action=(next;)

  table=0 (ls_out_pre_lb      ), priority=0    , match=(1), action=(next;)
  table=1 (ls_out_pre_acl     ), priority=110  , match=(ip && outport == "351f0012-0c13-4330-b471-b0d4719c5031"), action=(next;)
  table=1 (ls_out_pre_acl     ), priority=110  , match=(ip && outport == "4e0e294d-e54a-400c-a240-f121175904c2"), action=(next;)
  table=1 (ls_out_pre_acl     ), priority=110  , match=(nd), action=(next;)
  table=1 (ls_out_pre_acl     ), priority=100  , match=(ip), action=(reg0[0] = 1; next;)
  table=1 (ls_out_pre_acl     ), priority=0    , match=(1), action=(next;)
  table=2 (ls_out_pre_stateful), priority=100  , match=(reg0[0] == 1), action=(ct_next;)
  table=2 (ls_out_pre_stateful), priority=0    , match=(1), action=(next;)
  table=3 (ls_out_lb          ), priority=0    , match=(1), action=(next;)
  table=4 (ls_out_acl         ), priority=65535, match=(!ct.est && ct.rel && !ct.new && !ct.inv && ct_label[0] == 0), action=(next;)
  table=4 (ls_out_acl         ), priority=65535, match=(ct.est && !ct.rel && !ct.new && !ct.inv && ct.rpl && ct_label[0] == 0), action=(next;)
  table=4 (ls_out_acl         ), priority=65535, match=(ct.inv || (ct.est && ct.rpl && ct_label[0] == 1)), action=(drop;)
  table=4 (ls_out_acl         ), priority=65535, match=(nd), action=(next;)
  table=4 (ls_out_acl         ), priority=2002 , match=(!ct.new && ct.est && !ct.rpl && ct_label[0] == 0 && (outport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip4 && icmp4)), action=(next;)
  table=4 (ls_out_acl         ), priority=2002 , match=(!ct.new && ct.est && !ct.rpl && ct_label[0] == 0 && (outport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip4 && ip4.src == $as_ip4_85300131_274c_492c_a000_b1782315196d)), action=(next;)
  table=4 (ls_out_acl         ), priority=2002 , match=(!ct.new && ct.est && !ct.rpl && ct_label[0] == 0 && (outport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip4 && ip4.src == 10.0.0.0/24 && udp && udp.src == 67 && udp.dst == 68)), action=(next;)
  table=4 (ls_out_acl         ), priority=2002 , match=(!ct.new && ct.est && !ct.rpl && ct_label[0] == 0 && (outport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip6 && ip6.src == $as_ip6_85300131_274c_492c_a000_b1782315196d)), action=(next;)
  table=4 (ls_out_acl         ), priority=2002 , match=(((ct.new && !ct.est) || (!ct.new && ct.est && !ct.rpl && ct_label[0] == 1)) && (outport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip4 && icmp4)), action=(reg0[1] = 1; next;)
  table=4 (ls_out_acl         ), priority=2002 , match=(((ct.new && !ct.est) || (!ct.new && ct.est && !ct.rpl && ct_label[0] == 1)) && (outport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip4 && ip4.src == $as_ip4_85300131_274c_492c_a000_b1782315196d)), action=(reg0[1] = 1; next;)
  table=4 (ls_out_acl         ), priority=2002 , match=(((ct.new && !ct.est) || (!ct.new && ct.est && !ct.rpl && ct_label[0] == 1)) && (outport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip4 && ip4.src == 10.0.0.0/24 && udp && udp.src == 67 && udp.dst == 68)), action=(reg0[1] = 1; next;)
  table=4 (ls_out_acl         ), priority=2002 , match=(((ct.new && !ct.est) || (!ct.new && ct.est && !ct.rpl && ct_label[0] == 1)) && (outport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip6 && ip6.src == $as_ip6_85300131_274c_492c_a000_b1782315196d)), action=(reg0[1] = 1; next;)
  table=4 (ls_out_acl         ), priority=2001 , match=((!ct.est || (ct.est && ct_label[0] == 1)) && (outport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip)), action=(drop;)
  table=4 (ls_out_acl         ), priority=2001 , match=(ct.est && ct_label[0] == 0 && (outport == "23706cbe-98b6-4a8b-b78b-a8e12e6d773f" && ip)), action=(ct_commit(ct_label=1/1);)
  table=4 (ls_out_acl         ), priority=1    , match=(ip && (!ct.est || (ct.est && ct_label[0] == 1))), action=(reg0[1] = 1; next;)
  table=4 (ls_out_acl         ), priority=0    , match=(1), action=(next;)
  table=5 (ls_out_stateful    ), priority=100  , match=(reg0[1] == 1), action=(ct_commit(ct_label=0/1); next;)
  table=5 (ls_out_stateful    ), priority=100  , match=(reg0[2] == 1), action=(ct_lb;)
  table=5 (ls_out_stateful    ), priority=0    , match=(1), action=(next;)

One way I tested this by leaving ping running, ensuring that it was
blocked when the rule for ICMP was deleted, and then re-allowed when
the rule allowing ICMP was restored.  In this case, the ICMP
connection is still known by the connection tracker, but the flows
ensure that ct_label gets reset back to 0.

Reported-by: Xiao Li Xu <xiaolixu@cn.ibm.com>
Reported-at: https://bugs.launchpad.net/networking-ovn/+bug/1536080
Suggested-by: Justin Pettit <jpettit@ovn.org>
Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Han Zhou <zhouhan@gmail.com>
Acked-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
Tested-by: Babu Shanmugam <bschanmu@redhat.com>
7 years agopackets: Fix in6_is_lla() on systems without s6_addr32 defined.
Justin Pettit [Wed, 20 Jul 2016 06:01:29 +0000 (23:01 -0700)]
packets: Fix in6_is_lla() on systems without s6_addr32 defined.

Fixes: 6d1a4f16 ("packets: Add in6_is_lla() function.")
Reported-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agoovn-util: Add solicited node addresses to ipv6_netaddr.
Justin Pettit [Thu, 23 Jun 2016 01:20:08 +0000 (18:20 -0700)]
ovn-util: Add solicited node addresses to ipv6_netaddr.

Every IPv6 host has a link-local solicited node multicast address for
neighbor discovery.  This commit defines the solicited node address for
each IPv6 address added to a logical switch or router port.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agopackets: Add in6_is_lla() function.
Justin Pettit [Sun, 26 Jun 2016 05:22:02 +0000 (22:22 -0700)]
packets: Add in6_is_lla() function.

Checks whether the supplied IPv6 address is a link local address.

This will have a caller in a future commit.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agopackets: Define RSO flags.
Justin Pettit [Wed, 6 Jul 2016 23:27:57 +0000 (16:27 -0700)]
packets: Define RSO flags.

Use #define's as opposed to magic numbers.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agopackets: Rename "rco_flags" to "rso_flags".
Justin Pettit [Wed, 6 Jul 2016 23:19:40 +0000 (16:19 -0700)]
packets: Rename "rco_flags" to "rso_flags".

I presume the flags are supposed to map to neighbor discovery
advertisement "Router", "Solicited", and "Override" flags, which would
be "rso" instead of "rco".

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agopackets: Introduce xor and is_zero functions on IPv6 addresses.
Justin Pettit [Thu, 23 Jun 2016 01:17:07 +0000 (18:17 -0700)]
packets: Introduce xor and is_zero functions on IPv6 addresses.

These will have callers later.

This also rewrites ipv6_addr_bitand() to use newly defined macros.

Co-authored-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agoovn-northd: Ensure that flows are added to correct types of datapaths.
Ben Pfaff [Tue, 19 Jul 2016 16:07:13 +0000 (09:07 -0700)]
ovn-northd: Ensure that flows are added to correct types of datapaths.

A DP_TYPE_SWITCH_* flow should only be added to a logical switch datapath,
and a DP_TYPE_ROUTER_* flow should only be added to a logical router
datapath, but the code previously did not verify this and it caused a
problem in practice.

Suggested-by: Guru Shetty <guru@ovn.org>
Suggested-at: http://openvswitch.org/pipermail/dev/2016-July/075557.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agostream-unix: only use path-based socket names
Thadeu Lima de Souza Cascardo [Tue, 19 Jul 2016 20:05:51 +0000 (17:05 -0300)]
stream-unix: only use path-based socket names

FreeBSD returns a socklen of sockaddr_storage when doing an accept on an unix
STREAM socket. The current code will assume it means a sun_path larger than 0.

That breaks some tests like the one below which don't expect to find "unix::" on
the logs.

As a Linux abstract address would not have a more useful name either, it's
better to check that sun_path starts with a non-zero byte and return 0 length in
case it doesn't.

402: ovs-ofctl replace-flows with --bundle      FAILED (ovs-ofctl.at:2928)
2016-07-08T12:44:30.068Z|00020|vconn|DBG|unix:: sent (Success): OFPT_HELLO (OF1.6) (xid=0x1):

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovn-controller: Add incremental processing to lflow_run and physical_run
Ryan Moats [Mon, 18 Jul 2016 21:21:17 +0000 (16:21 -0500)]
ovn-controller: Add incremental processing to lflow_run and physical_run

This code changes to allow incremental processing of the
logical flow and physical binding tables whenver possible.

Note: flows created by physical_run for multicast_groups are
*NOT* handled incrementally due to to be solved issues
with GWs and local routers.

Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoofctrl: Refine treatment of duplicate flows in ofctrl_add_flow().
Ben Pfaff [Wed, 20 Jul 2016 00:02:55 +0000 (17:02 -0700)]
ofctrl: Refine treatment of duplicate flows in ofctrl_add_flow().

It's better to use the newer actions, in cases where the actions for
duplicate flows differ, because on balance they are more likely to be
correct.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
7 years agoovsdb: Add unixctl commands for OVSDB replication
Mario Cabrera [Tue, 19 Jul 2016 21:54:51 +0000 (14:54 -0700)]
ovsdb: Add unixctl commands for OVSDB replication

Set and get the server to replicate from:

    ovsdb-server/set-remote-ovsdb-server {server}
    ovsdb-server/get-remote-ovsdb-server

Set and get the replicated table blacklist:

    ovsdb-server/set-sync-excluded-tables {DB:table,...}
    ovsdb-server/get-sync-excluded-tables

Connect to the configured server and start replication:

    ovsdb-server/connect-remote-ovsdb-server

Disconnect from the remote server and stop replication, without dropping
the replicated data:

    ovsdb-server/disconnect-remote-ovsdb-server

Signed-off-by: Mario Cabrera <mario.cabrera@hpe.com>
Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
7 years agodatapath: Add support for kernel 4.5
Pravin B Shelar [Mon, 18 Jul 2016 02:24:07 +0000 (19:24 -0700)]
datapath: Add support for kernel 4.5

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
7 years agoovn-sbctl: eliminate a spurious test case error cause
Lance Richardson [Thu, 7 Jul 2016 21:30:01 +0000 (17:30 -0400)]
ovn-sbctl: eliminate a spurious test case error cause

The "ovn-sbctl" test fails occasionally due to log messages
similar to these:

  jsonrpc|WARN|unix: receive error: Connection reset by peer
  reconnect|WARN|unix: connection dropped (Connection reset by peer)

Since we're already ignoring "Broken pipe" messages in this test
case, and the difference between EPIPE and ECONNRESET on send
is simply a matter of whether the peer had unconsumed data
in its receive buffer when the peer socket was closed, it should
be OK to ignore "reset by peer" logs as well.

This same type of failure has been observed in ovs-nbctl and
ovn-vtep-controller tests, so fix it there as well.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
7 years agoovn-northd.8.xml: Remove outdated flow.
Russell Bryant [Fri, 15 Jul 2016 16:36:18 +0000 (12:36 -0400)]
ovn-northd.8.xml: Remove outdated flow.

This flow was a duplicate and was removed in a previous commit.  Update
the docs to reflect the removal.

Fixes: 6a9d35dde4a9 ("ovn-northd: Remove extraneous ip4 mulicast logical flow.")
Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
7 years agoovn: Add datapath column to the MAC_Binding table
Liran Schour [Mon, 18 Jul 2016 08:45:59 +0000 (11:45 +0300)]
ovn: Add datapath column to the MAC_Binding table

This will allow ovn-controller to conditionally monitor MAC_Binding table
according to datapath column.

Signed-off-by: Liran Schour <lirans@il.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agolib: add monitor_cond_change API to C IDL lib
Liran Schour [Mon, 18 Jul 2016 08:45:58 +0000 (11:45 +0300)]
lib: add monitor_cond_change API to C IDL lib

Add to IDL API that allows the user to add and remove clauses on a table's condition
iteratively. IDL maintain tables condition and send monitor_cond_change to the server
upon condition change.
Add tests for conditional monitoring to IDL.

Signed-off-by: Liran Schour <lirans@il.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>