cascardo/ovs.git
8 years agoovn-nbctl: Move ovn-nbctl to utilities directory.
Alex Wang [Tue, 4 Aug 2015 18:31:22 +0000 (11:31 -0700)]
ovn-nbctl: Move ovn-nbctl to utilities directory.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
8 years agoovn-sb: Remove the "Gateway" table from the ovn-sb schema.
Alex Wang [Fri, 7 Aug 2015 22:55:32 +0000 (15:55 -0700)]
ovn-sb: Remove the "Gateway" table from the ovn-sb schema.

In a gateway like the VTEP L2 gateway, physical vlans belonging to
the same logical network form a "logical switch".  Each logical switch
has a dedicated tunnel key and will keep records of all MACs learned
from the owned vlans.  So user can just send packet to a "logical
switch" and the gateway will figure out the output port and vlan tag
automatically.

Therefore, it is really not necessary to keep record of the vlan map
for each gateway physical port in the OVN_Southbound database using
"gateway_ports" and to map each vlan to a unique ovn logical port.
Instead, we should simply map each logical switch to a ovn logical
port.

Thusly, this commit removes the "Gateway" table from the OVN_Southbound
database.  In the "Chassis" table, the "gateway_ports" column is replaced
by "vtep_logical_switches" column which stores all vtep logical switch
names.  The use of this column will be documented in later commit.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
8 years agoovn-controller: Fix flows between two local ports.
Justin Pettit [Fri, 7 Aug 2015 22:03:19 +0000 (15:03 -0700)]
ovn-controller: Fix flows between two local ports.

A flow was missing from the remote output table that causes local
packets to be resubmitted to the local ouptut table.

Reported-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
8 years agoVagrantfile: Add test_ovs_system_userspace provision.
Daniele Di Proietto [Fri, 7 Aug 2015 18:40:37 +0000 (19:40 +0100)]
Vagrantfile: Add test_ovs_system_userspace provision.

Add 'test_ovs_system_userspace' provision.  Command:
        # vagrant provision --provision-with=test_ovs_system_userspace

will run "make check-system-userspace" in the vagrant launched VM.

It may be more convenient to run this tests inside a vm rather than in
the host, because they interact with system networking.

Suggested-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
8 years agotests: Add system-userspace-testsuite.
Daniele Di Proietto [Fri, 7 Aug 2015 18:40:36 +0000 (19:40 +0100)]
tests: Add system-userspace-testsuite.

The new system-userspace-testsuite, which can be launched via
`make check-system-userspace`, reuses the kmod tests on the userspace
datapath.

The userspace datapath is already tested by the main testsuite (and
that's not going to change), but having also the
system-userspace-testsuite has the following advantages:

* More complicated tests are possible: real client and server
  applications can be used.
* The same tests run on both kernel and userspace datapath: this gives
  us an easy way to make sure that the behaviour is consistent (e.g.
  with the upcoming connection tracker integration)

The userspace datapath is able to use system network interfaces via an
AF_PACKET socket.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
8 years agotests: Introduce NS_EXEC and NS_CHECK_EXEC for system tests.
Daniele Di Proietto [Fri, 7 Aug 2015 18:40:35 +0000 (19:40 +0100)]
tests: Introduce NS_EXEC and NS_CHECK_EXEC for system tests.

Instead of repeating every time "ip netns exec ..." it is better to
introduce some macros.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
8 years agotests: Rename kmod-testsuite to system-kmod-testsuite.
Daniele Di Proietto [Fri, 7 Aug 2015 18:40:34 +0000 (19:40 +0100)]
tests: Rename kmod-testsuite to system-kmod-testsuite.

The name makes more sense, especially with the addition of a userspace
system testsuite.  No functional change in this commit.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
8 years agokmod-macros: Don't unload kmod in VSWITCHD_STOP.
Joe Stringer [Wed, 29 Jul 2015 23:28:59 +0000 (16:28 -0700)]
kmod-macros: Don't unload kmod in VSWITCHD_STOP.

We already queue the removal of the kernel module in OVS_VSWITCHD_START,
via an ON_EXIT() call. That command is executed in both the success and
failure cases, so it is unnecessary to unload the kernel module in
OVS_VSWITCHD_STOP.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
8 years agokmod-macros: Move some code to traffic-common-macros.
Daniele Di Proietto [Tue, 4 Aug 2015 18:00:16 +0000 (19:00 +0100)]
kmod-macros: Move some code to traffic-common-macros.

These macros will also be used by userspace datapath testing in
following commits. No functional change in this commit.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
8 years agotests: Rename kmod-traffic.at to traffic.at.
Daniele Di Proietto [Fri, 7 Aug 2015 18:08:56 +0000 (11:08 -0700)]
tests: Rename kmod-traffic.at to traffic.at.

The file will be part of two different testsuites: one for the kernel
datapath and another for the userspace datapath.  No functional change
in this commit.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
8 years agoINSTALL.DPDK.md: Add details of XL710 restrictions for DPDK
Ian Stokes [Thu, 6 Aug 2015 15:58:47 +0000 (16:58 +0100)]
INSTALL.DPDK.md: Add details of XL710 restrictions for DPDK

Currently there are restrictions regarding the use of the XL710 network
interface with OVS and DPDK. This patch details those restrictions in
INSTALL.DPDK.md.

Signed-off-by: Ian Stokes <ian.stokes@intel.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
8 years agonetdev-dpdk: Retry tx/rx queue setup until we don't get any failure.
Daniele Di Proietto [Thu, 16 Jul 2015 18:48:24 +0000 (19:48 +0100)]
netdev-dpdk: Retry tx/rx queue setup until we don't get any failure.

It has been observed that some DPDK device (e.g intel xl710) report an
high number of queues but make some of them available only for special
functions (SRIOV).  Therefore the queues will be counted in
rte_eth_dev_info_get(), but rte_eth_tx_queue_setup() will fail.

This commit works around the issue by retrying the device initialization
with a smaller number of queues, if a queue fails to setup.

Reported-by: Ian Stokes <ian.stokes@intel.com>
Tested-by: Ian Stokes <ian.stokes@intel.com>
Acked-by: Kevin Traynor <kevin.traynor@intel.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
8 years agodpif-netdev: Translate Geneve options per-flow, not per-packet.
Jesse Gross [Tue, 30 Jun 2015 01:01:59 +0000 (18:01 -0700)]
dpif-netdev: Translate Geneve options per-flow, not per-packet.

The kernel implementation of Geneve options stores the TLV option
data in the flow exactly as received, without any further parsing.
This is then translated to known options for the purposes of matching
on flow setup (which will then install a datapath flow in the form
the kernel is expecting).

The userspace implementation behaves a little bit differently - it
looks up known options as each packet is received. The reason for this
is there is a much tighter coupling between datapath and flow translation
and the representation is generally expected to be the same. This works
but it incurs work on a per-packet basis that could be done per-flow
instead.

This introduces a small translation step for Geneve packets between
datapath and flow lookup for the userspace datapath in order to
allow the same kind of processing that the kernel does. A side effect
of this is that unknown options are now shown when flows dumped via
ovs-appctl dpif/dump-flows, similar to the kernel.

There is a second benefit to this as well: for some operations it is
preferable to keep the options exactly as they were received on the wire,
which this enables. One example is that for packets that are executed from
ofproto-dpif-upcall to the datapath, this avoids the translation of
Geneve metadata. Since this conversion is potentially lossy (for unknown
options), keeping everything in the same format removes the possibility
of dropping options if the packet comes back up to userspace and the
Geneve option translation table has changed. To help with these types of
operations, most functions can understand both formats of data and seamlessly
do the right thing.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agodpif-netdev: Don't use metaflow to operate on userspace datapath fields.
Jesse Gross [Thu, 16 Jul 2015 16:05:33 +0000 (09:05 -0700)]
dpif-netdev: Don't use metaflow to operate on userspace datapath fields.

If ofproto-dpif installs a flow into the userspace datapath that doesn't
include a mask, we need to synthesize an exact match one. This is currently
done using the metaflow infrastructure, iterating over each field and
setting it to all ones.

There is a conceptual mismatch here because metaflow is operating on
OpenFlow fields, not datapath ones. Even though they are generally very
similar, there are subtle differences, which is why it is necessary to
fix up the input port mask.

With Geneve options, the mapping is much more complicated and so the
situation is worse. The first issue is that the metaflow to flow
mapping can change over time, so we would need to do more revalidation
to track this. In addition, an upcoming patch will completely disconnect
the option format between ofproto-dpif and dpif-netdev, so the values
written by metaflow don't make sense at all.

When megaflows are turned off, ofproto-dpif internally generates masks
using flow_wildcards_init_for_packet(). Since that's the same as what
we want to do here, we can just use that instead of metaflow.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agodatapath: Revert "datapath: Constify netlink structs."
Pravin B Shelar [Wed, 5 Aug 2015 01:07:27 +0000 (18:07 -0700)]
datapath: Revert "datapath: Constify netlink structs."

This reverts commit 2023bdcfc44c149a8e3b38dcde8f04f2ec3f8501.
This commit is causing segfaults when genl compat code is in use.

Compat code update genl_multicast_group and genl_family type objects.
Therefore these can not be const.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
8 years agodpif-netdev: fix race for queues between pmd threads.
Ilya Maximets [Tue, 4 Aug 2015 19:36:37 +0000 (12:36 -0700)]
dpif-netdev: fix race for queues between pmd threads.

Currently pmd threads select queues in pmd_load_queues() according to
get_n_pmd_threads_on_numa(). This behavior leads to race between pmds,
beacause dp_netdev_set_pmds_on_numa() starts them one by one and
current number of threads changes incrementally.

As a result we may have the following situation with 2 pmd threads:

* dp_netdev_set_pmds_on_numa()
* pmd12 thread started. Currently only 1 pmd thread exists.
dpif_netdev(pmd12)|INFO|Core 1 processing port 'port_1'
dpif_netdev(pmd12)|INFO|Core 1 processing port 'port_2'
* pmd14 thread started. 2 pmd threads exists.
dpif_netdev|INFO|Created 2 pmd threads on numa node 0
dpif_netdev(pmd14)|INFO|Core 2 processing port 'port_2'

We have:
core 1 --> port 1, port 2
core 2 --> port 2

Fix this by starting pmd threads only after all of them have
been configured.

Cc: Daniele Di Proietto <diproiettod at vmware.com>
Cc: Dyasly Sergey <s.dyasly at samsung.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Ilya Maximets <i.maximets at samsung.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
8 years agokmod-traffic: Expand sanity tests.
Joe Stringer [Wed, 29 Jul 2015 19:56:06 +0000 (12:56 -0700)]
kmod-traffic: Expand sanity tests.

The initial sanity test only checked IPv4 without IP fragments. This patch
adds additional tests using IPv6 and VLANs with IP fragments and expands
the existing test to be more strict.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
8 years agotreewide: Fix doubled "the".
Ben Pfaff [Mon, 3 Aug 2015 22:30:02 +0000 (15:30 -0700)]
treewide: Fix doubled "the".

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
8 years agoovs-ofctl: Refine documentation of Geneve option mapping.
Ben Pfaff [Mon, 3 Aug 2015 21:11:12 +0000 (14:11 -0700)]
ovs-ofctl: Refine documentation of Geneve option mapping.

The text didn't say how to actually match on them.  I took the liberty of
massaging the text a little further, too.

Suggested-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
8 years agoofproto-dpif: Use a regular ref instead of try_ref for rule translation.
Ben Pfaff [Sun, 2 Aug 2015 18:51:32 +0000 (11:51 -0700)]
ofproto-dpif: Use a regular ref instead of try_ref for rule translation.

Until now, flow translation has had to use try_ref to take a reference on
a rule, because a competing thread might have released the last reference
and done an RCU-postponed deletion.  Since classifier versioning was
introduced, however, the release of the last reference is itself
RCU-postponed, which means that it is always safe to take the reference
directly.

Changing try_ref to ref means that taking a reference can't fail, which
allows the caller to take a reference in cases where the need to take a
reference was previously passed along a call chain, which simplifies some
code.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoovn: Change strategy for tunnel keys.
Ben Pfaff [Mon, 3 Aug 2015 23:38:12 +0000 (16:38 -0700)]
ovn: Change strategy for tunnel keys.

Until now, OVN has used "flat" tunnel keys, in which the STT tunnel key or
Geneve VNI contains a logical port number.  Logical port numbers are unique
within an OVN deployment.

Flat tunnel keys have the advantage of simplicity.  However, for packets
that are destined to logical ports on multiple hypervisors, they require
sending one packet per destination logical port rather than one packet per
hypervisor.  They also make it hard to integrate with VXLAN-based hardware
switches, which use VNIs to designate logical networks instead of logical
ports.

This commit switches OVN to a different scheme.  In this scheme, in Geneve
the VNI designates a logical network and a Geneve option specifies the
logical input and output ports, which are now scoped within the logical
network rather than globally unique.  In STT, all three identifiers are
encoded in the tunnel key.

To allow for the reduced amount of traffic for packets destined to logical
ports on multiple hypervisors, this commit also introduces the concept
of a logical multicast group.  The membership of these groups can be set
using a new Multicast_Group table in the southbound database (and
ovn-northd does use it starting in this commit).

With multicast groups alone, it would be difficult to implement ACLs,
because an ACL might disallow only some of the packets being sent to
a remote hypervisor.  Thus, this commit also splits the OVN logical
pipeline into two pipelines: the "ingress" pipeline, which makes the
decision about the logical destination of a packet as a set of logical
ports or multicast groups, and the "egress" pipeline, which runs on the
destination hypervisor with the multicast group destination exploded into
individual ports and makes a final decision on whether to deliver the
packet.  The "egress" pipeline can efficiently apply ACLs.

Until now, the OVN logical and physical pipeline implementation was not
adequately documented.  This commit adds extensive documentation to
the OVN manpages to cover these issues.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agoofctrl: Negotiate OVN Geneve option.
Ben Pfaff [Mon, 3 Aug 2015 20:50:19 +0000 (13:50 -0700)]
ofctrl: Negotiate OVN Geneve option.

This won't really get used until the next commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agorule: Introduce MFF_LOG_DATAPATH macro for consistency.
Ben Pfaff [Sun, 19 Jul 2015 19:14:45 +0000 (12:14 -0700)]
rule: Introduce MFF_LOG_DATAPATH macro for consistency.

The other logical fields have their own macros, so the logical datapath
field might as well have one.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agoactions: Allow caller to specify output table.
Ben Pfaff [Sun, 19 Jul 2015 01:29:18 +0000 (18:29 -0700)]
actions: Allow caller to specify output table.

When an upcoming commit divides the pipeline up into ingress and egress
pipeline, it will become necessary to resubmit to different tables from
each of those pipelines to implement output.  This commit makes that
possible.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agoovn: Rename Pipeline table to Logical_Flow table.
Ben Pfaff [Mon, 3 Aug 2015 18:10:43 +0000 (11:10 -0700)]
ovn: Rename Pipeline table to Logical_Flow table.

The OVN pipeline is being split into two phases, which are most naturally
called "pipelines".  I kept getting very confused trying to call them
anything else, and in the end it seems to make more sense to just rename
the Pipeline table.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agoovn: Rename Binding table to Port_Binding.
Ben Pfaff [Thu, 30 Jul 2015 17:41:08 +0000 (10:41 -0700)]
ovn: Rename Binding table to Port_Binding.

An upcoming patch will add a Datapath_Binding table, so clarifying the
name seems useful.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agonroff: Add support for 'diagram' XML element for protocol headers.
Ben Pfaff [Wed, 29 Jul 2015 16:04:35 +0000 (09:04 -0700)]
nroff: Add support for 'diagram' XML element for protocol headers.

This will be used in documentation for an upcoming change, to document
how Geneve OVN options are encoded.

The code in this change is from a series (not yet submitted) that makes
much more extensive use of it for documenting protocol headers.

Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agosmap: New function smap_get_uuid().
Ben Pfaff [Sat, 18 Jul 2015 23:59:08 +0000 (16:59 -0700)]
smap: New function smap_get_uuid().

To be used in an upcoming commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agoovn-controller: Use controller_ctx just to pass around data.
Ben Pfaff [Sun, 19 Jul 2015 17:58:29 +0000 (10:58 -0700)]
ovn-controller: Use controller_ctx just to pass around data.

Until now, controller_ctx has been a store of common state (although
the amount of data stored in it has declined to just database state).
I think it's clearer if we just use it as a way to pass data to
functions.  This commit makes that change.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agoovn-controller: Slightly adjust pipeline init and destroy for consistency.
Ben Pfaff [Sun, 19 Jul 2015 17:33:26 +0000 (10:33 -0700)]
ovn-controller: Slightly adjust pipeline init and destroy for consistency.

This drops an unused parameter and groups the calls to these functions
with ofctrl_destroy() in each case.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agobridge: Reconfigure when system interfaces change.
Thadeu Lima de Souza Cascardo [Fri, 31 Jul 2015 17:35:02 +0000 (14:35 -0300)]
bridge: Reconfigure when system interfaces change.

Whenever system interfaces are removed, added or change state, reconfigure
bridge. This allows late interfaces to be added to the datapath when they are
added to the system after ovs-vswitchd is started.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agortbsd: support RTM_IFANNOUNCE messages
Thadeu Lima de Souza Cascardo [Fri, 31 Jul 2015 17:35:01 +0000 (14:35 -0300)]
rtbsd: support RTM_IFANNOUNCE messages

When devices are created, they are announced using RTM_IFANNOUNCE messages using
PF_ROUTE.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agodatapath: Fix STT protocol field for sampling packet.
Pravin B Shelar [Fri, 31 Jul 2015 03:51:15 +0000 (20:51 -0700)]
datapath: Fix STT protocol field for sampling packet.

Fixes typo in STT sampling code.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
8 years agoovn: Get/set lport type and options in ovn-nbctl.
Russell Bryant [Fri, 31 Jul 2015 17:14:43 +0000 (13:14 -0400)]
ovn: Get/set lport type and options in ovn-nbctl.

A recent patch added "type" and "options" columns to the Logical_Port
table in OVN_Northbound.  This patch allows you to get and set those
columns with ovn-nbctl.

ovn-nbctl should eventually get converted to use the common db-ctl
code that was recently added.  When that happens, these commands can
just be removed.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agoovn: Add type and options to logical port.
Russell Bryant [Fri, 31 Jul 2015 17:14:42 +0000 (13:14 -0400)]
ovn: Add type and options to logical port.

We have started discussing the use of the logical port abstraction in
OVN to represent special types of connections into an OVN logical
switch.  This patch proposes some schema updates to reflect these
special types of logical ports.  A logical port can have a "type" and
a set of options specific to that type.

Some examples of logical port types would be "vtep" for connectivity
to a VTEP gateway or "localnet" for a connection to a locally
accessible network via an ovs bridge.  Actualy support for these (or
other) types will come in later patches.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agosmap: Add smap_equal().
Russell Bryant [Fri, 31 Jul 2015 17:14:40 +0000 (13:14 -0400)]
smap: Add smap_equal().

Add a method to determine of two smaps are equal (have the exact same
set of key-value pairs).

Suggested-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agoofproto-dpif-xlate: Fix mirroring interaction with recirculation.
Ben Pfaff [Thu, 30 Jul 2015 05:13:26 +0000 (22:13 -0700)]
ofproto-dpif-xlate: Fix mirroring interaction with recirculation.

Before this commit, mirroring state was not preserved across recirculation,
which could result in a packet being mirrored to the same destination both
before and after recirculation.  This commit fixes the problem and adds a
test to avoid regression.

Found by inspection.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Add recirculation information to "ofproto/trace".
Ben Pfaff [Thu, 30 Jul 2015 05:03:31 +0000 (22:03 -0700)]
ofproto-dpif-xlate: Add recirculation information to "ofproto/trace".

This makes it possible to understand what happens recirculation-wise in
translation.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofp-actions: Add action "debug_recirc" for testing recirculation.
Ben Pfaff [Thu, 30 Jul 2015 05:02:41 +0000 (22:02 -0700)]
ofp-actions: Add action "debug_recirc" for testing recirculation.

It isn't otherwise useful and in fact hurts performance so it's disabled
without --enable-dummy.

An upcoming commit will make use of this.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-rid: Factor recirculation state out as new structure.
Ben Pfaff [Thu, 30 Jul 2015 03:32:12 +0000 (20:32 -0700)]
ofproto-dpif-rid: Factor recirculation state out as new structure.

This greatly reduces the number of arguments to many of the functions
involved in recirculation, which to my eye makes the code clearer.  It
will also make it easier to add new recirculation state in an upcoming
commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Rewrite mirroring to better fit flow translation.
Ben Pfaff [Thu, 30 Jul 2015 00:00:49 +0000 (17:00 -0700)]
ofproto-dpif-xlate: Rewrite mirroring to better fit flow translation.

Until now, mirroring has been implemented by accumulating, across the whole
translation process, a set of mirrors that should receive a mirrored
packet.  After translation was complete, mirroring restored the original
version of the packet and sent that version to the mirrors.

That implementation was ugly for multiple reasons.  First, it means that
we have to keep a copy of the original packet (or its headers, actually),
which is expensive.  Second, it doesn't really make sense to mirror a
version of a packet that is different from the one originally output.
Third, it interacted with recirculation; mirroring needed to happen only
after recirculation was complete, but this was never properly implemented,
so that (I think) mirroring never happened for packets that were
recirculated.

This commit changes how mirroring works.  Now, a packet is mirrored at the
point in translation when it becomes eligible for it: for mirrors based on
ingress port, this is at ingress; for mirrors based on egress port, this
is at egress.  (Duplicates are dropped.)  Mirroring happens on the version
of the packet as it exists when it becomes eligible.  Finally, since
mirroring happens immediately, it interacts better with recirculation
(it still isn't perfect, since duplicate mirroring will occur if a packet
is eligible for mirroring both before and after recirculation; this is
not difficult to fix and an upcoming commit later in this series will do so).

Finally, this commit removes more code from xlate_actions() than it adds,
which in my opinion makes it easier to understand.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Drop packets received from mirror output ports earlier.
Ben Pfaff [Wed, 29 Jul 2015 21:21:52 +0000 (14:21 -0700)]
ofproto-dpif-xlate: Drop packets received from mirror output ports earlier.

Packets should never be received on mirror output ports.  We drop them
when we do receive them.  But by putting them through the processing that
we did until now, we made it possible for MAC learning, etc. to happen
based on these packets.  This commit drops them earlier to prevent that.

Found by inspection.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Move initialization of 'in_port' closer to first use.
Ben Pfaff [Wed, 29 Jul 2015 21:20:16 +0000 (14:20 -0700)]
ofproto-dpif-xlate: Move initialization of 'in_port' closer to first use.

This seems to be a little clearer to me.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Move 'nf_output_iface' from xlate_out to xlate_ctx.
Ben Pfaff [Fri, 24 Jul 2015 16:35:58 +0000 (09:35 -0700)]
ofproto-dpif-xlate: Move 'nf_output_iface' from xlate_out to xlate_ctx.

This member is used internally during translation but none of the callers
used as an output of translation.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Remove multiple members from struct xlate_out.
Ben Pfaff [Fri, 24 Jul 2015 16:32:59 +0000 (09:32 -0700)]
ofproto-dpif-xlate: Remove multiple members from struct xlate_out.

Nothing used them.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Move 'mirrors' from xlate_out to xlate_ctx.
Ben Pfaff [Fri, 24 Jul 2015 00:08:14 +0000 (17:08 -0700)]
ofproto-dpif-xlate: Move 'mirrors' from xlate_out to xlate_ctx.

Nothing outside of ofproto-dpif-xlate.c referenced this member.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Set up 'base_flow' when we initialize 'ctx'.
Ben Pfaff [Fri, 24 Jul 2015 00:04:36 +0000 (17:04 -0700)]
ofproto-dpif-xlate: Set up 'base_flow' when we initialize 'ctx'.

The initialization of 'base_flow' was previously split into a few pieces,
and I think it's easier to understand if it's all in one place.

This also moves and rewrites the comment describing 'base_flow'.  I think
that the perspective of the new comment is a little more useful.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Clean up sFlow and IPFIX sampling code.
Ben Pfaff [Wed, 29 Jul 2015 22:24:05 +0000 (15:24 -0700)]
ofproto-dpif-xlate: Clean up sFlow and IPFIX sampling code.

This code was a twisty maze of tiny functions, but what it actually needed
to do was simple.  This makes it look that simple.

Among more stylistic changes, this removes 'user_cookie_offset' from
xlate_ctx.  This member was used to communicate between two sections of
code that are both in xlate_actions() and close together, so it's better to
simply use a local variable than to put it into a shared context structure.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Factor wildcard processing out of xlate_actions().
Ben Pfaff [Thu, 23 Jul 2015 21:43:26 +0000 (14:43 -0700)]
ofproto-dpif-xlate: Factor wildcard processing out of xlate_actions().

I think that this makes xlate_actions() easier to read.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agotunnel: Break tnl_xlate_init() into two separate functions.
Ben Pfaff [Wed, 29 Jul 2015 21:12:26 +0000 (14:12 -0700)]
tunnel: Break tnl_xlate_init() into two separate functions.

It seems to me that tnl_xlate_init() has two almost-separate tasks.  First,
it marks most of the 'wc' bits for tunnels.  Second, it checks and updates
ECN bits.  This commit breaks tnl_xlate_init() into two separate functions,
one for each of those tasks.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Simplify 'sample_actions_len' calculation.
Ben Pfaff [Thu, 23 Jul 2015 23:40:38 +0000 (16:40 -0700)]
ofproto-dpif-xlate: Simplify 'sample_actions_len' calculation.

It's always the size of 'odp_actions' following adding the sample actions.

This is a stylistic change that should not change behavior.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Move declaration of 'orig_flow' near its first use.
Ben Pfaff [Thu, 23 Jul 2015 23:38:19 +0000 (16:38 -0700)]
ofproto-dpif-xlate: Move declaration of 'orig_flow' near its first use.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Eliminate 'is_icmp' from xlate_actions().
Ben Pfaff [Thu, 23 Jul 2015 23:36:53 +0000 (16:36 -0700)]
ofproto-dpif-xlate: Eliminate 'is_icmp' from xlate_actions().

This is only used in one place and action processing can't change the
result, so only calculate it where it's needed.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Simplify invocation of process_special().
Ben Pfaff [Thu, 23 Jul 2015 20:39:38 +0000 (13:39 -0700)]
ofproto-dpif-xlate: Simplify invocation of process_special().

This takes advantage of common properties of the invocation of this
function in both callers (both supply the same 'flow' and 'packet',
although they write it differently) and avoids the need for a local
variable in each place.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Eliminate 'rule' local variable.
Ben Pfaff [Thu, 23 Jul 2015 20:31:04 +0000 (13:31 -0700)]
ofproto-dpif-xlate: Eliminate 'rule' local variable.

This variable was only used as a temporary within a small scope, so it
worked just as well to just use ctx.rule there instead.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofp-util: Fix group desc request encoding.
Minoru TAKAHASHI [Fri, 24 Jul 2015 04:31:58 +0000 (13:31 +0900)]
ofp-util: Fix group desc request encoding.

Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agoopenflow: Add OpenFlow1.5 group desc request.
Minoru TAKAHASHI [Fri, 17 Jul 2015 04:22:13 +0000 (13:22 +0900)]
openflow: Add OpenFlow1.5 group desc request.

Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agoofp-util: Fix port desc request encoding.
Minoru TAKAHASHI [Fri, 17 Jul 2015 05:10:33 +0000 (14:10 +0900)]
ofp-util: Fix port desc request encoding.

Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agoopenflow: Add OpenFlow1.5 port desc request.
Minoru TAKAHASHI [Fri, 17 Jul 2015 05:10:15 +0000 (14:10 +0900)]
openflow: Add OpenFlow1.5 port desc request.

Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agoofproto-dpif-xlate: Calculate 'ofpacts' in more restricted scope.
Ben Pfaff [Thu, 23 Jul 2015 20:01:57 +0000 (13:01 -0700)]
ofproto-dpif-xlate: Calculate 'ofpacts' in more restricted scope.

This moves the calculation of 'ofpacts' closer to its actual use, which
in my opinion makes the code easier to read.

This commit also expands the circumstances in which OVS omits sending
NetFlow records from those where there is exactly one OpenFlow action that
sends to controller, to those where any OpenFlow action sends to
controller.  I doubt that this is a big deal.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Make xlate_actions() caller supply action buffer.
Ben Pfaff [Fri, 31 Jul 2015 20:34:16 +0000 (13:34 -0700)]
ofproto-dpif-xlate: Make xlate_actions() caller supply action buffer.

Until now, struct xlate_out has embedded an ofpbuf for actions and a large
stub for it, which xlate_actions() filled in during the flow translation
process.  This commit removes the embedded ofpbuf and stub, instead putting a
pointer to an ofpbuf into struct xlate_in, for a caller to fill in with a
pointer to its own structure if desired.  (If none is supplied,
xlate_actions() uses an internal scratch buffer and destroys it before
returning.)

This commit eliminates the last large data structure from
struct xlate_out, making the initialization of an entire xlate_out at
the beginning of xlate_actions() now reasonable.  More members will be
eliminated in upcoming commits, but this is no longer essential.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Make xlate_actions() caller supply flow_wildcards.
Ben Pfaff [Fri, 31 Jul 2015 20:15:52 +0000 (13:15 -0700)]
ofproto-dpif-xlate: Make xlate_actions() caller supply flow_wildcards.

Until now, struct xlate_out has embedded a struct flow_wildcards, which
xlate_actions() filled in during the flow translation process (unless this
was disabled with xin->skip_wildcards, which in classifier microbenchmarks
saves significant time).  This commit removes the embedded flow_wildcards
and 'skip_wildcards', instead putting a pointer to a flow_wildcards into
struct xlate_in, for a caller to fill in with a pointer to its own
structure if desired.

One reason for this change is performance.  Until now, the userspace slow
path has done a full copy of a struct flow_wildcards for each upcall in
upcall_cb().  This commit eliminates that copy.  I don't know whether this
has a measurable performance impact; it may, because struct flow copies
had a noticeable cost in slow-path stress tests even when struct flow was
half its current size.

This commit also eliminates a large data structure from struct xlate_out,
reducing the cost of the initialization of that structure at the beginning
of xlate_actions().  However, there is more size reduction to come in
later commits.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif: Fix inaccurate wildcard output in ofproto/trace.
Ben Pfaff [Fri, 31 Jul 2015 20:33:16 +0000 (13:33 -0700)]
ofproto-dpif: Fix inaccurate wildcard output in ofproto/trace.

Until now, the ofproto/trace command has tried to accumulate wildcards
independently of flow translation.  This was unnecessary, and in a few
cases where flow translation drops wildcards, it meant that ofproto/trace
printed inaccurate wildcards (because it keep the wildcards that flow
translation dropped).

This updates a test case whose output is now more accurate.

Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agoofproto-dpif-xlate: Initialize 'ctx' all in one place.
Ben Pfaff [Thu, 23 Jul 2015 23:24:29 +0000 (16:24 -0700)]
ofproto-dpif-xlate: Initialize 'ctx' all in one place.

As I see it, this has two benefits.  First, by using an initializer
rather than a series of assignment statements, the reader can be
assured that everything in the structure is actually initialized.
Second, previously the initialization of 'ctx' was scattered in
a few places in this function, which made it a little harder to be
sure that any given member was not just initialized but actually
initialized before the statement that one was looking at.

It's also nice to get rid of the stub members in xlate_ctx, since
nothing outside of xlate_actions() itself needs direct access to
them.  (This is pretty much necessary if we're going to use an
initializer for struct xlate_ctx, because otherwise the compiler
would initialize the whole stub, which is too expensive.)

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofpbuf: New macro OFPBUF_STUB_INITIALIZER.
Ben Pfaff [Thu, 23 Jul 2015 23:28:50 +0000 (16:28 -0700)]
ofpbuf: New macro OFPBUF_STUB_INITIALIZER.

To be used in an upcoming commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agolist: New macro OVS_LIST_POISON for initializing a poisoned list.
Ben Pfaff [Fri, 31 Jul 2015 20:14:20 +0000 (13:14 -0700)]
list: New macro OVS_LIST_POISON for initializing a poisoned list.

To be used in an upcoming commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agoofproto-dpif-xlate: Initialize '*xout' all together at beginning.
Ben Pfaff [Thu, 30 Jul 2015 05:31:07 +0000 (22:31 -0700)]
ofproto-dpif-xlate: Initialize '*xout' all together at beginning.

To my mind, this is a good way to ensure that '*xout' gets initialized
properly in every execution.  By using an initializer rather than a
series of assignment statements, we can be assured that every member
gets initialized.

This commit makes xlate_actions() more expensive because struct
xlate_out is large and this assignment will initialize all of it due to
C rules.  Later commits will fix this up by removing all of the large
members, reducing xlate_out to only a few bytes total.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
8 years agotype-props: Suppress warnings in newer Clang and GCC.
Ben Pfaff [Fri, 31 Jul 2015 00:44:26 +0000 (17:44 -0700)]
type-props: Suppress warnings in newer Clang and GCC.

Until now, Clang 3.7+ and sufficiently new versions of GCC complained about
TYPE_MAXIMUM(int), etc., because it shifts a negative value.  This commit
fixes the problem.

This commit also gives these macros sensible definitions for _Bool, and
documents all of them.

Reported-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
8 years agoAUTHORS: Add Alexander Duyck.
Joe Stringer [Thu, 30 Jul 2015 23:54:25 +0000 (16:54 -0700)]
AUTHORS: Add Alexander Duyck.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
8 years agodatapath: Use eth_proto_is_802_3.
Alexander Duyck [Mon, 4 May 2015 21:34:05 +0000 (14:34 -0700)]
datapath: Use eth_proto_is_802_3.

Replace "ntohs(proto) >= ETH_P_802_3_MIN" w/ eth_proto_is_802_3(proto).

Backport of upstream commit 6713fc9b8fa33444aa000f0f31076f6a859ccb34:
"openvswitch: Use eth_proto_is_802_3"

Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
8 years agodatapath: Backport eth_proto_is_802_3().
Joe Stringer [Tue, 21 Jul 2015 22:12:32 +0000 (15:12 -0700)]
datapath: Backport eth_proto_is_802_3().

Backport of upstream commit 2c7a88c252bf3381958cf716f31b6b2e0f2f3fa7:
"etherdev: Fix sparse error, make test usable by other functions"

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
8 years agodatapath: Use skb_postpull_rcsum().
Joe Stringer [Thu, 16 Jul 2015 22:54:34 +0000 (15:54 -0700)]
datapath: Use skb_postpull_rcsum().

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
8 years agodatapath: Constify netlink structs.
Joe Stringer [Thu, 16 Jul 2015 22:49:01 +0000 (15:49 -0700)]
datapath: Constify netlink structs.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
8 years agodatapath: Whitespace fixes.
Joe Stringer [Thu, 16 Jul 2015 22:38:13 +0000 (15:38 -0700)]
datapath: Whitespace fixes.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
8 years agorhel: Add buildrequires for libtool and automake.
Flavio Leitner [Thu, 30 Jul 2015 18:16:30 +0000 (15:16 -0300)]
rhel: Add buildrequires for libtool and automake.

Those two packages are needed to build but they might not
be present in the system.

Signed-off-by: Flavio Leitner <fbl@redhat.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agoovn-controller: Honor external-ids:ovn-bridge changing.
Ben Pfaff [Thu, 30 Jul 2015 17:16:59 +0000 (10:16 -0700)]
ovn-controller: Honor external-ids:ovn-bridge changing.

Until now, if external-ids:ovn-bridge changed, ovn-controller ignored
the change.  With this commit, ovn-controller uses the new bridge.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agoovn-controller: Rename init functions that just register IDL columns.
Ben Pfaff [Sat, 18 Jul 2015 22:06:55 +0000 (15:06 -0700)]
ovn-controller: Rename init functions that just register IDL columns.

The generic *_init() names for these functions made it sounds like they
do something more than just register IDL columns, even though that's all
they do.  Also, the controller_ctx that was passed into each of them was
only used to get the IDL handle.  This commit renames them and changes
their parameter type to simplify and make all of this clearer.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agoovn-controller: Tolerate missing 'chassis_id'.
Ben Pfaff [Sat, 18 Jul 2015 23:15:47 +0000 (16:15 -0700)]
ovn-controller: Tolerate missing 'chassis_id'.

Until now, if the chassis id was missing, ovn-controller exited.  This
commit makes ovn-controller wait for it to return.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agoovn-controller: Tolerate missing integration bridge.
Ben Pfaff [Wed, 29 Jul 2015 16:02:09 +0000 (09:02 -0700)]
ovn-controller: Tolerate missing integration bridge.

Until now, if the integration bridge was missing, ovn-controller exited.
This commit makes it wait until the integration bridge is created.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agoovn-controller: Pass 'chassis_id' explicitly to functions that need it.
Ben Pfaff [Wed, 29 Jul 2015 15:48:26 +0000 (08:48 -0700)]
ovn-controller: Pass 'chassis_id' explicitly to functions that need it.

I found it otherwise difficult to see what code depended on this.  When
later commits make it possible for ovn-controller to handle changes in
chassis ID, this will become important (the code should determine the
current chassis ID before trying to use it).

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agoovn-controller: Factor encapsulation code out of chassis code.
Ben Pfaff [Sat, 18 Jul 2015 23:06:22 +0000 (16:06 -0700)]
ovn-controller: Factor encapsulation code out of chassis code.

These two pieces of code have different requirements and hardly anything in
common, and I found it easier to understand and reasonably modify the
overall structure of the program when they were separated.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
8 years agoFix treatment of OpenFlow 1.1+ bucket weights.
Ben Pfaff [Wed, 29 Jul 2015 05:01:24 +0000 (22:01 -0700)]
Fix treatment of OpenFlow 1.1+ bucket weights.

Until now, OVS has parsed all OF1.1+ group buckets that lack a weight
as having weight 1.  Unfortunately, OpenFlow says that only "select"
groups may have a nonzero weight, and requires reporting an error for
other kinds of groups that have a nonzero weight.  This commit fixes
the problem by parsing only select groups with a default weight of 1
and other groups with a default weight of 0.  It also adds the
OpenFlow-required check for nonzero weights for other kinds of groups.

This complies with OpenFlow 1.1 and later.  OF1.1 says in section 5.8:

    If a specified group type is invalid (ie: includes fields such as
    weight that are undefined for the specified group type) then the
    switch must refuse to add the group entry and must send an
    ofp_error_msg with OFPET_GROUP_MOD_FAILED type and
    OFPGMFC_INVALID_GROUP code.

Found by OFTest.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
8 years agoofp-actions: OFPP_ANY (aka OFPP_NONE) is not a valid output port.
Ben Pfaff [Wed, 29 Jul 2015 15:36:07 +0000 (08:36 -0700)]
ofp-actions: OFPP_ANY (aka OFPP_NONE) is not a valid output port.

This is implied by the list of ports that are valid for output in the
various versions of the OpenFlow specification.

Found by OFTest.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
8 years agoofproto: Ignore generation ID for role change to "equal".
Ben Pfaff [Mon, 25 May 2015 21:14:05 +0000 (14:14 -0700)]
ofproto: Ignore generation ID for role change to "equal".

The OpenFlow specification says that only role changes to slave or master
check the generation ID, so this is a bug fix.

OpenFlow 1.2 section A.3.9 phrases the requirement this way:

    Additionally, if the role value in the message is OFPCR_ROLE_MASTER
    or OFPCR_ROLE_SLAVE, the switch must validate generation_id to check
    for stale messages.

Found by OFTest.

Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agoovn: Fix broken build.
Ben Pfaff [Wed, 29 Jul 2015 01:53:02 +0000 (18:53 -0700)]
ovn: Fix broken build.

Fixes the following error:

    The following files are in git but not the distribution:
    ovn/OVN-GW-HA.md

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
8 years agoovn-controller: Avoid overlooking changes that occur during commit.
Ben Pfaff [Tue, 28 Jul 2015 20:41:34 +0000 (13:41 -0700)]
ovn-controller: Avoid overlooking changes that occur during commit.

A commit to the database takes multiple trips through the main loop.  In
that time, the database could change, but ovn-controller can't properly
react to the changes until the commit has succeeded or failed.  Since
commit f1fd765733 (ovn-controller: Avoid blocking to commit OVSDB
transactions), Open vSwitch has failed to properly re-check the contents
of the database following a successful commit.  That meant that it was
possible for ovn-controller to fail to react to a database change until
much later, if nothing else happened for some time.

Reported-by; Alex Wang <alexw@nicira.com>
Reported-at: http://openvswitch.org/pipermail/dev/2015-July/058176.html
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
8 years agodoc: Document proposed OVN Gateway HA design.
Ethan Jackson [Mon, 1 Jun 2015 20:43:23 +0000 (13:43 -0700)]
doc: Document proposed OVN Gateway HA design.

High availability for gateways in network virtualization deployments
is fairly difficult to get right.  There are a ton of options, most of
which are too complicated or perform badly.  To help solve this
problem, this patch proposes an HA design based on some of the lessons
learned building similar systems.  The hope is that it can be used as
a starting point for design discussions and an eventual
implementation.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
8 years agoopenflow: Add additional reserved space in struct nx_geneve_table_reply.
Jesse Gross [Tue, 28 Jul 2015 22:12:13 +0000 (15:12 -0700)]
openflow: Add additional reserved space in struct nx_geneve_table_reply.

It's possible to imagine that a switch might want to report additional
capabilities related to Geneve beyond just the number of options and
how much space they can consume. Some examples include additional
restrictions on parsing (if this command is used for non-OVS implementations
or OVS changes how it works) and per-packet actions that can't be done
generically (such as checksums or encryption). It's not yet clear if
these will be necessary or if OpenFlow is the right place to expose
them. However, it's easy to do now and there is very little cost so
it seems like a good idea to leave some additional reserved space.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
8 years agoovn-controller: Fix flow generation for container traffic.
Gurucharan Shetty [Fri, 24 Jul 2015 18:31:28 +0000 (11:31 -0700)]
ovn-controller: Fix flow generation for container traffic.

In table 64, when a vlan tag is set on a packet
destined to a container running inside a VM, we currently
don't revert it. This has an unintended consequence for
broadcast traffic when one endpoint of the braodcast
traffic is a plain VM (without containers running inside) where
the previously set tag would remain in the packets sent to the VM.

This commit fixes the above problem by popping the VLAN
and resetting the input port after outputting the packet
with a vlan tag to a container logical port.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
8 years agoofp-print: Abbreviate duplicated table features.
Ben Pfaff [Tue, 7 Jul 2015 05:15:40 +0000 (22:15 -0700)]
ofp-print: Abbreviate duplicated table features.

I spent some time recently looking at the results of "ovs-ofctl
dump-table-features".  It was really distressing because of the volume of
information.  Every table yielded well over 100 lines of output and for 253
(visible) tables that meant over 25,300 lines of output total, which is
basically unusable.

This commit cuts the volume of output greatly by eliminating most of the
duplication from one table to the next.  The command now prints the full
output only for table 0, and for each subsequent table prints only the
parts that differ.  That reduces the output volume for tables after the
first to only 9 lines each (one of which is blank), for a total of more
like 2,400 lines, which is still not short but reasonably manageable.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
8 years agodpdk: Fix detection of vhost_cuse in dpdk rte_config.h
Gary Mussar [Thu, 23 Jul 2015 17:48:53 +0000 (10:48 -0700)]
dpdk: Fix detection of vhost_cuse in dpdk rte_config.h

Dpdk allows users to create a config that includes other config files and
then override values.

Eg.
defconfig_x86_64-native_vhost_cuse-linuxapp-gcc:

CONFIG_RTE_BUILD_COMBINE_LIBS=y
CONFIG_RTE_BUILD_SHARED_LIB=n
CONFIG_RTE_LIBRTE_VHOST=y
CONFIG_RTE_LIBRTE_VHOST_USER=n

This allows you to have both a vhostuser and vhostcuse config in the same
source tree without the need to replicate everything in those config files
just to change a couple of settings. The resultant .config file has all of
the settings from the included files with the updated settings at the end.
The resultant rte_config.h contains multiple undefs and defines for the
overridden settings.

Eg.
  > grep RTE_LIBRTE_VHOST_USER x86_64-native_vhost_cuse-linuxapp-gcc/include/rte_config.h
  #undef RTE_LIBRTE_VHOST_USER
  #define RTE_LIBRTE_VHOST_USER 1
  #undef RTE_LIBRTE_VHOST_USER

The current mechanism to detect the RTE_LIBRTE_VHOST_USER setting merely
greps the rte_config.h file for the string "define RTE_LIBRTE_VHOST_USER 1"
rather than the final setting of RTE_LIBRTE_VHOST_USER. The following patch
changes this test to detect the final setting of RTE_LIBRTE_VHOST_USER.

Signed-off-by: Gary Mussar <gmussar@ciena.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com
8 years agoofctrl: Fix use of uninitialized hash value in ofctrl_add_flow().
Ben Pfaff [Tue, 28 Jul 2015 18:25:59 +0000 (11:25 -0700)]
ofctrl: Fix use of uninitialized hash value in ofctrl_add_flow().

When ofctrl_add_flow() called ovn_flow_lookup(), the latter used the hash
from the flow's hmap_node, but the former hadn't initialized it at that
point.  This commit fixes the problem.

Reported-by: Russell Bryant <rbryant@redhat.com>
Reported-at: http://openvswitch.org/pipermail/dev/2015-July/057851.html
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
8 years agoovn: Make column comparisons more generic.
Russell Bryant [Tue, 21 Jul 2015 16:59:13 +0000 (12:59 -0400)]
ovn: Make column comparisons more generic.

The logic in ovn-northd's parents_equal() and tags_equal() is useful
for other columns, so convert them into more generic functions that
can be reused.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
8 years agoovn-controller: Pass 'br_int' explicitly to functions that need it.
Ben Pfaff [Sat, 18 Jul 2015 19:32:20 +0000 (12:32 -0700)]
ovn-controller: Pass 'br_int' explicitly to functions that need it.

I found it hard otherwise to see what code depended on this.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
8 years agoovn-controller: Explicitly pass the flow table from function to function.
Ben Pfaff [Sat, 18 Jul 2015 19:25:16 +0000 (12:25 -0700)]
ovn-controller: Explicitly pass the flow table from function to function.

As I was working in ovn-controller, I found it hard to tell what code
produced and what code consumed the OpenFlow flow table, because it was
all implicit.  This commit makes the data structure an explicit variable
in the main loop, which makes it easier to see.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
8 years agoovn-controller: Avoid blocking to commit OVSDB transactions.
Ben Pfaff [Sun, 19 Jul 2015 17:56:57 +0000 (10:56 -0700)]
ovn-controller: Avoid blocking to commit OVSDB transactions.

Until now, ovn-controller has been full of loops that commit a transaction
to the OVS or OVN Southbound database.  These blocking loops delay other
work within ovn-controller.  They also make it unsafe to keep pointers to
database records within a single ovn-controller main loop, since calls
to ovsdb_idl_run() can cause IDL records to be destroyed.  This commit
drops all of the blocking calls, instead doing a single commit to the
databases at the end of each main loop.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
8 years agoovn-controller: Drop unnecessary checks for ovsdb_idl_is_alive().
Ben Pfaff [Mon, 13 Jul 2015 00:20:42 +0000 (17:20 -0700)]
ovn-controller: Drop unnecessary checks for ovsdb_idl_is_alive().

The IDLs as created by ovn-controller always retry failed connections,
which means that ovsdb_idl_is_alive() will always report that they are
alive.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
8 years agoovn-controller: Fix potential use-after-free in get_core_config().
Ben Pfaff [Tue, 28 Jul 2015 15:33:42 +0000 (08:33 -0700)]
ovn-controller: Fix potential use-after-free in get_core_config().

It's unsafe to hold a pointer to a row in the IDL across calls to
ovsdb_idl_run() for that IDL.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
8 years agonetdev-linux: Cache the result of previous reading of in4 address.
Alex Wang [Fri, 24 Jul 2015 21:28:42 +0000 (14:28 -0700)]
netdev-linux: Cache the result of previous reading of in4 address.

This commit makes netdev_linux_set_in4() cache the result of previous
reading of in4 address (successful or not).

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
8 years agonetdev-linux: Make netdev_linux_get_in6() conform to API definition.
Alex Wang [Thu, 23 Jul 2015 23:25:32 +0000 (16:25 -0700)]
netdev-linux: Make netdev_linux_get_in6() conform to API definition.

The get_in6() API defined in netdev-provider.h requires the return
of error values when the 'netdev' has no assigned IPv6 address or
the 'netdev' does not support IPv6.  However, the netdev_linux_get_in6()
implementation does not follow this (always return 0).  And this
causes the a bug in deleting vlan interfaces created for vlan
splinter.

This commit makes netdev_linux_get_in6() conform to the API definition
and returns the specified error value when failing to get IPv6 address.

VMware-BZ: #1485521
Reported-by: Ronald Lee <ronaldlee@vmware.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>