]> git.proxmox.com Git - ovs.git/log
ovs.git
7 years agoPrepare for 2.8.0.
Ben Pfaff [Tue, 1 Aug 2017 17:09:52 +0000 (10:09 -0700)]
Prepare for 2.8.0.

Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovsdb-server: Document clarification for some bad wording in RFC 7047.
Ben Pfaff [Thu, 27 Jul 2017 23:20:24 +0000 (16:20 -0700)]
ovsdb-server: Document clarification for some bad wording in RFC 7047.

Reported-by: Harish Kanakaraju <hkanakaraju@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
7 years agodebian.rst: Clarify that "dpkg" needs manual help with dependencies.
Ben Pfaff [Mon, 29 May 2017 18:40:51 +0000 (11:40 -0700)]
debian.rst: Clarify that "dpkg" needs manual help with dependencies.

Reported-by: Mircea Ulinic <ping@mirceaulinic.net>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
7 years agotests: fix wrapped comment
Lance Richardson [Fri, 4 Aug 2017 14:15:37 +0000 (10:15 -0400)]
tests: fix wrapped comment

Add missing '#' to comment line.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
7 years agotests: avoid non-posix options to wc
Lance Richardson [Fri, 4 Aug 2017 14:26:02 +0000 (10:26 -0400)]
tests: avoid non-posix options to wc

The '--lines' option for the wc command is a GNU extension and is not
recognized by some implemenations. Use the POSIX 1003.1 '-l' option
instead.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
7 years agoAUTHORS: Add Jorge Arturo Sauma Vargas and fix a misspelling.
Ben Pfaff [Thu, 3 Aug 2017 21:55:55 +0000 (14:55 -0700)]
AUTHORS: Add Jorge Arturo Sauma Vargas and fix a misspelling.

Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovn-controller: use idl indexes for logical datapath
Lance Richardson [Thu, 3 Aug 2017 18:20:32 +0000 (14:20 -0400)]
ovn-controller: use idl indexes for logical datapath

Use IDL index to iterate over all logical ports in a given logical
datapath, avoiding the overhead of creating/destroying an indexing
data structure in each iteration of the ovn-controller main loop.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovn-controller: use idl indexes for logical port table
Lance Richardson [Thu, 3 Aug 2017 18:20:28 +0000 (14:20 -0400)]
ovn-controller: use idl indexes for logical port table

Use IDL index for logical port table lookups, avoiding the overhead
of creating/destroying an index hmap for each iteration of the
ovn-controller main loop.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovn-controller: use idl index for multicast group table
Lance Richardson [Thu, 3 Aug 2017 18:20:23 +0000 (14:20 -0400)]
ovn-controller: use idl index for multicast group table

Use IDL index for multicast group table lookups, avoiding the overhead
of creating/destroying an index hmap for each iteration of the
ovn-controller main loop.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovsdb-idl: Autogenerated functions for compound indexes
Lance Richardson [Thu, 3 Aug 2017 18:20:19 +0000 (14:20 -0400)]
ovsdb-idl: Autogenerated functions for compound indexes

Generates and fills in the default comparators for columns with
type int, real, string. Also creates the macros that allow
iteration over the contents of the index, and perform
queries.

Signed-off-by: Arnoldo Lutz Guevara <arnoldo.lutz.guevara@hpe.com>
Signed-off-by: Esteban Rodriguez Betancourt <estebarb@hpe.com>
Co-authored-by: Arnoldo Lutz Guevara <arnoldo.lutz.guevara@hpe.com>
Co-authored-by: Esteban Rodriguez Betancourt <estebarb@hpe.com>
Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovsdb-idl: idl compound indexes implementation
Lance Richardson [Thu, 3 Aug 2017 18:20:15 +0000 (14:20 -0400)]
ovsdb-idl: idl compound indexes implementation

This patch adds support for the creation of multicolumn indexes
in the C IDL to enable for efficient search and retrieval of database
rows by key.

Signed-off-by: Esteban Rodriguez Betancourt <estebarb@hpe.com>
Co-authored-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agolib: skiplist implementation
Lance Richardson [Thu, 3 Aug 2017 18:20:11 +0000 (14:20 -0400)]
lib: skiplist implementation

Skiplist implementation intended for use in the IDL compound indexes
feature.

Signed-off-by: Esteban Rodriguez Betancourt <estebarb@hpe.com>
Co-authored-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovsdb-idl: compound indexes design document
Lance Richardson [Thu, 3 Aug 2017 18:20:05 +0000 (14:20 -0400)]
ovsdb-idl: compound indexes design document

In the work made in our projects, it was found the need to have a faster
access to the rows contained in tables in the replica, as well to have
the possibility to loop over a subset of rows that meet some specified
criteria.
Those needs lead us to design and implement a functionality that
satisfies those requirements, so an implementation of special indexes were
done.
In order to keep the OVSDB server implementation unmodified and avoid
extra load of processing, the indexes are created as part of the IDL.
The indexes are created as part of the initialization of the replica request
and are maintained automatically when there are changes in the replica.

This document explains the design rationale of the compound indexes feature.

Signed-off-by: Javier Albornoz <javier.albornoz@hpe.com>
Signed-off-by: Esteban Rodriguez Betancourt <estebarb@hpe.com>
Signed-off-by: Jorge Arturo Sauma Vargas <jorge.sauma@hpe.com>
Co-authored-by: Javier Albornoz <javier.albornoz@hpe.com>
Co-authored-by: Esteban Rodriguez Betancourt <estebarb@hpe.com>
Co-authored-by: Jorge Arturo Sauma Vargas <jorge.sauma@hpe.com>
Co-aughored-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodatapath-windows: Fix conntrack lookups for reversed keys
Sairam Venugopal [Tue, 1 Aug 2017 22:01:44 +0000 (15:01 -0700)]
datapath-windows: Fix conntrack lookups for reversed keys

The conntrack table needs to be queried for entries in either directions
to determine if the packet is in forward direction or reply direction.

The current behavior ends up reversing the incoming packet's 5-Tuple for
every entry in the loop instead of doing it only once.

Testing Done:
- Verified that ICMP requests are no longer treated as replies
in Conntrack.

Co-authored-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Anand Kumar <kumaranand@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
7 years agobridge: Avoid read of uninitialized data configuring Auto-Attach.
Ben Pfaff [Thu, 6 Jul 2017 21:33:42 +0000 (14:33 -0700)]
bridge: Avoid read of uninitialized data configuring Auto-Attach.

Reported-by: "qintao (F)" <qintao5@huawei.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2017-April/044309.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
7 years agoovs-ofctl: Avoid unnecessary flow replacement in "replace-flows" command.
Ben Pfaff [Thu, 6 Jul 2017 23:40:30 +0000 (16:40 -0700)]
ovs-ofctl: Avoid unnecessary flow replacement in "replace-flows" command.

The ovs-ofctl "diff-flows" and "replace-flows" command compare the flows
in two flow tables.  Until now, the "replace-flows" command has considered
certain almost meaningless differences related to the version of OpenFlow
used to add a flow as significant, which caused it to replace a flow by an
identical-in-practice version, e.g. in the following, the "replace-flows"
command prints a FLOW_MOD that adds the flow that was already added
previously:

    $ cat > flows
    actions=resubmit(,1)
    $ ovs-vsctl add-br br0
    $ ovs-ofctl del-flows br0
    $ ovs-ofctl add-flows br0 flows
    $ ovs-ofctl -vvconn replace-flows br0 flows 2>&1 | grep FLOW_MOD

Re-adding an existing flow has some effects, for example, it resets the
flow's duration, so it's better to avoid it.

This commit fixes the problem using the same trick previously used for a
similar problem with the "diff-flows" command, which was fixed in commit
98f7f427bf8b ("ovs-ofctl: Avoid printing false differences on "ovs-ofctl
diff-flows".").

Reported-by: Kevin Lin <kevin@quilt.io>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
7 years agoofproto-dpif-xlate: Add OFPACT_ENCAP, OFPACT_DECAP to reversible_actions().
Ben Pfaff [Thu, 3 Aug 2017 20:19:20 +0000 (13:19 -0700)]
ofproto-dpif-xlate: Add OFPACT_ENCAP, OFPACT_DECAP to reversible_actions().

Fixes a broken build when building with --enable-Werror.

I guess that encap and decap are often reversible, but it's safe to
consider them irreversible.

Fixes: eee693934aac ("xlate: Emit datapath clone only when necessary.")
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
7 years agoovs-ovctl: Fix "OpenFlow versions" in ovs-ofctl -V
Timothy Redaelli [Thu, 27 Jul 2017 15:43:49 +0000 (17:43 +0200)]
ovs-ovctl: Fix "OpenFlow versions" in ovs-ofctl -V

Fix the output of "ovs-ofctl -V" to show OpenFlow 1.4 as max supported
versions since OpenFlow 1.4 was enabled by default in commit
8d3485791188 ("OpenFlow: Enable OpenFlow 1.4 by default.")

CC: Ben Pfaff <blp@ovn.org>
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agotnl-ports: Open tunnel type if device name has special prefix
Paul Blakey [Wed, 2 Aug 2017 11:17:29 +0000 (14:17 +0300)]
tnl-ports: Open tunnel type if device name has special prefix

There is a race between listening on route changes from route-table
netlink which then calls ovs_router_insert() where it adds the involved
netdev to the tnl-ports map (tnl_port_map_insert_ipdev()),
and netdev_open from from normal opening of the port.

tnl-ports open the netdev as type system (type == NULL) when it doesn't
exists before it is opened normally, e.g from dumping the ports
in dpctl.

This solves 'ovs-dpctl show' EExists error on vxlan ports as both
(dpctl/tnl-ports) will open the ports as vxlan type.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agotc: Correct convert ticks to msecs on parsing tc TM
Paul Blakey [Sun, 30 Jul 2017 05:01:52 +0000 (08:01 +0300)]
tc: Correct convert ticks to msecs on parsing tc TM

Use sysconf(_SC_CLK_TCK) to read run time "number of clock ticks per
second" and use that to convert ticks to msecs.
This is how iproute does the conversion when parsing tc filters.
The system call is done only once.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Acked-by: Joe Stringer <joe@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoodp-util: Support zero mask on ipv4 frag
Paul Blakey [Thu, 3 Aug 2017 13:27:07 +0000 (16:27 +0300)]
odp-util: Support zero mask on ipv4 frag

Don't print frag parsing error if mask is zero,
instead just don't print it.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoxlate: Emit datapath clone only when necessary.
Andy Zhou [Tue, 18 Jul 2017 05:30:01 +0000 (22:30 -0700)]
xlate: Emit datapath clone only when necessary.

Currently the open flow 'clone' action is always translated into
datapath clone. While this is valid translation, the datapath
'clone' action is more expensive and has more restrictions than
not using them.

This patch optimizing the open flow 'clone' translation. Whenever
the open flow actions within the 'clone' is reversible, i.e.
any datapath actions that modifies a packet can be reversed
by using another datapath action. Reversible actions can be
translated without emitting datapath clone.

This patch combines xlate_clone() and compose_clone() into
a single compose_clone() API, since the layering boundary is not
obvious.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agoxlate: Refactor compose_clone() API
Andy Zhou [Tue, 18 Jul 2017 00:39:11 +0000 (17:39 -0700)]
xlate: Refactor compose_clone() API

Create a new function that hides the details of netlink encoding
for the translated clone action.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agoofproto-dpif: Remove ofprto/tnl-push-pop command.
Andy Zhou [Fri, 14 Jul 2017 19:20:59 +0000 (12:20 -0700)]
ofproto-dpif: Remove ofprto/tnl-push-pop command.

Use dpif/set-dp-features command instead.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agoofproto-dpif: Remove dpif/disable-truncate command.
Andy Zhou [Fri, 14 Jul 2017 00:29:16 +0000 (17:29 -0700)]
ofproto-dpif: Remove dpif/disable-truncate command.

Use 'dpif/set-dp-features' command instead.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agoofproto-dpif: Remove dpif/disable-dp-clone command.
Andy Zhou [Thu, 13 Jul 2017 23:12:41 +0000 (16:12 -0700)]
ofproto-dpif: Remove dpif/disable-dp-clone command.

Use 'dpif/set-dp-features' command instead.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agoofproto-dpif: Add boottime support field.
Andy Zhou [Sat, 17 Jun 2017 06:39:31 +0000 (23:39 -0700)]
ofproto-dpif: Add boottime support field.

When changing support fields, it may be unsafe to set support level
beyond what datapath can support.

This patch introduce the notion of boot time support and
runtime support fields. Boot time support are set only
once during ofproto start up phase, and not changed during
runtime. The runtime support fields are the same as boot time
support fields at the startup time, but can be changed via
the 'ovs-appctl' command.  However, each change will
be checked against the corresponding boot time support field. Only
feature reduction from the boot time support is allowed.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agoofproto-dpif: A new command for changing dpif support fields
Andy Zhou [Sat, 17 Jun 2017 06:22:32 +0000 (23:22 -0700)]
ofproto-dpif: A new command for changing dpif support fields

dpif support fields contain various datapath capabilities detected
by ofproto at start up time. Usually those fields are read-only,
not intended to be changed at runtime.

However in practice, when writing tests or running experiments, it
becomes necessary to set those fields to emulate different
datapath feature combinations.

Currently there are several separate commands that can be used
defeature individual support fields. This patch generalize those
implementations, provides a single command to change any support
fields. Later patches will remove those individual defeature
commands.

The new command also allow the support fields to be
changed multiple times. Currently defeature commands does not
allow the support level to be restored.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
7 years agonetdev-tc-offloads: Parse ip related fields only if eth type is ip
Paul Blakey [Thu, 3 Aug 2017 13:38:25 +0000 (16:38 +0300)]
netdev-tc-offloads: Parse ip related fields only if eth type is ip

There is no need to parse ip related fields if eth type is not ip.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agotc: Split IPs and transport layer ports unions in flower struct
Paul Blakey [Thu, 3 Aug 2017 13:38:24 +0000 (16:38 +0300)]
tc: Split IPs and transport layer ports unions in flower struct

Split dst/src_port and ipv4/ipv6 union so we can
distingush them easily for later features.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agotc: Refactor nl_msg_put_flower_options
Paul Blakey [Thu, 3 Aug 2017 13:38:23 +0000 (16:38 +0300)]
tc: Refactor nl_msg_put_flower_options

Refactor nl_msg_put_flower_options to be more readable.
This commit doesn't change functionality.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Acked-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovs-ctl: Remove a leftover restore_interfaces in restart
Timothy Redaelli [Wed, 26 Jul 2017 13:48:33 +0000 (15:48 +0200)]
ovs-ctl: Remove a leftover restore_interfaces in restart

Since commit c416eaf8c247 ("ovs-ctl: Remove code for upgrading from Open
vSwitch 1.9 and earlier.") the kernel configuration of the specified
network interfaces is not saved anymore for restart command so there is no
need to try to restore it.

CC: Ben Pfaff <blp@ovn.org>
Fixes: c416eaf8c247 ("ovs-ctl: Remove code for upgrading from Open vSwitch 1.9 and earlier.")
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agopackets: Reorganize the pkt_metadata structure.
Bhanuprakash Bodireddy [Tue, 25 Jul 2017 04:14:44 +0000 (05:14 +0100)]
packets: Reorganize the pkt_metadata structure.

pkt_metadata_init() is called for every packet in userspace datapath and
initializes few members in pkt_metadata. Before this the members that
needs to be initialized are prefetched using pkt_metadata_prefetch_init().

The above functions are critical to the userspace datapath performance
and should be in sync. Any changes to the pkt_metadata should also include
changes to metadata_init() and prefetch_init() if necessary.

This commit slightly refactors the pkt_metadata structure and introduces
cache line markers to catch any violations to the structure. Also only
prefetch the cachelines having the members that needs to be zeroed out.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoutil: Add PADDED_MEMBERS_CACHELINE_MARKER macro to mark cachelines.
Bhanuprakash Bodireddy [Tue, 25 Jul 2017 04:14:43 +0000 (05:14 +0100)]
util: Add PADDED_MEMBERS_CACHELINE_MARKER macro to mark cachelines.

PADDED_MEMBERS_CACHELINE_MARKER macro introduces a way to mark
cachelines.

This macro expands to an anonymous union containing cacheline marker,
members in nested anonymous structure, followed by array of bytes that
is multiple of UNIT bytes.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovs-router: Remove redundant headers.
Tonghao Zhang [Wed, 19 Jul 2017 03:44:14 +0000 (20:44 -0700)]
ovs-router: Remove redundant headers.

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agorhel: Use systemd Restart option for ovn-controllers.
Mark Michelson [Wed, 2 Aug 2017 18:43:04 +0000 (13:43 -0500)]
rhel: Use systemd Restart option for ovn-controllers.

This change stops the use of OVS's monitor for the ovn-controller and
ovn-controller-vtep systemd services. Instead, the services use the
systemd Restart option to restart the services automatically if they
fail.

This patch changes the ovn-controller service Type from "oneshot" to
"forking". The Restart option is incompatible with oneshot services. The
patch does not change the ovn-controller-vtep service type from
"simple", however.

Signed-off-by: Mark Michelson <mmichels@redhat.com>
Acked-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
7 years agonetdev-linux: Replace sendmsg with sendmmsg in netdev_linux_send
Zhenyu Gao [Wed, 2 Aug 2017 21:58:24 +0000 (14:58 -0700)]
netdev-linux: Replace sendmsg with sendmmsg in netdev_linux_send

Sendmmsg can reduce cpu cycles in sending packets to kernel.
Replace sendmsg with sendmmsg in function netdev_linux_send to send
batch packets if sendmmsg is available.

If kernel side doesn't support sendmmsg, will fallback to sendmsg.

    netserver
|------------|
|            |
|  container |
|----veth----|
          |
          |        |------------|
          |---veth-|   dpdk-ovs |      netperf
                   |            |  |--------------|
                   |----dpdk----|  | bare-metal   |
                         |         |--------------|
                         |              |
                         |              |
                        pnic-----------pnic

Netperf was consumed to test the performance:

1)cmd:netperf -H remote-container -t UDP_STREAM -l 60 -- -m 1400
result: netserver received 2383.21Mb(sendmsg)/2551.64Mb(sendmmsg)

2)cmd:netperf -H remote-container -t UDP_STREAM -l 60 -- -m 60
result: netserver received 109.72Mb(sendmsg)/115.18Mb(sendmmsg)

Sendmmsg show about 6% improvement in netperf UDP testing.

Signed-off-by: Zhenyu Gao <sysugaozhenyu@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodp-packet: New function dp_packet_get_send_len().
Ben Pfaff [Wed, 2 Aug 2017 21:58:23 +0000 (14:58 -0700)]
dp-packet: New function dp_packet_get_send_len().

This function is useful in a few places for representing the packet's
length minus the cutlen.

Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoofproto-dpif-ipfix: add support for per-flow drop counters
Przemyslaw Szczerbik [Fri, 28 Jul 2017 06:17:44 +0000 (07:17 +0100)]
ofproto-dpif-ipfix: add support for per-flow drop counters

Patch based on RFC 5102, section 5.10. It implements per-flow drop counters:
- droppedPacketDeltaCount
- droppedPacketTotalCount
- droppedOctetDeltaCount
- droppedOctetTotalCount

In order to determine if packet is going to be dropped, flow actions associated
with packet are read. If at least one of the following conditions is met,
packet is not marked as dropped.

 Packet has at least one:
 - OVS_ACTION_ATTR_OUTPUT action
 - OVS_ACTION_ATTR_CLONE action with nested OVS_ACTION_ATTR_OUTPUT action
 - OVS_ACTION_ATTR_SAMPLE action with nested OVS_ACTION_ATTR_OUTPUT action and
   sampling probability is set to 100%

Signed-off-by: Przemyslaw Szczerbik <przemyslawx.szczerbik@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodatapath-windows: Refactor OvsCreateNewNBLsFromMultipleNBs
Shashank Ram [Mon, 24 Jul 2017 22:31:38 +0000 (15:31 -0700)]
datapath-windows: Refactor OvsCreateNewNBLsFromMultipleNBs

Previously, the function would take the curNbl and nextNbl
as inputs, and modify the linked list, and merge the input
linked list with the newly generated newNbl list.

This is confusing for the caller, and the function has
unnecessary logic for merging linked lists that instead
the caller should take care of. This is because the
OvsCreateNewNBLsFromMultipleNBs() is a generic API
that can be used by other functions as well, and its
natural for different callers to have different needs.

This patch refactors the behavior of OvsCreateNewNBLsFromMultipleNBs
to take in the curNbl and lastNbl, and it returns
a linked list of NBLs and sets the HEAD and TAIL of the
new list obtained from the curNbl. If the caller wants
to chain a new linked list at the HEAD or TAIL, it
can make use of the curNbl and lastNbl to do so.

Signed-off-by: Shashank Ram <rams@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Anand Kumar <kumaranand@vmware.com>
7 years agoofproto-dpif-xlate: Always process IGMP packets in userspace.
Ben Pfaff [Tue, 11 Jul 2017 18:32:52 +0000 (11:32 -0700)]
ofproto-dpif-xlate: Always process IGMP packets in userspace.

Open vSwitch needs to always process IGMP packets in the userspace slow
path so that they can have their desired side effects.  However, userspace
was only applying SLOW_ACTION to IGMP packets in some cases, as opposed to
all cases, which meant that sometimes IGMP packets were ignored.  This
fixes that particular problem.

A problem remains: there is a mismatch between userspace support for IGMP
matching and kernel (lack of) support for IGMP matching.  This should
probably be handled better.  See the original report for more information.

Reported-by: Huanle Han <hanxueluo@gmail.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2017-July/335690.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoEliminate most shadowing for local variable names.
Ben Pfaff [Wed, 2 Aug 2017 22:03:06 +0000 (15:03 -0700)]
Eliminate most shadowing for local variable names.

Shadowing is when a variable with a given name in an inner scope hides a
different variable with the same name in a surrounding scope.  This is
generally undesirable because it can confuse programmers.  This commit
eliminates most of it.

Found with -Wshadow=local in GCC 7.  The repo is not really ready to enable
this option by default because of a few cases that are harder to fix, and
harmless, such as nested use of CMAP_FOR_EACH.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
7 years agoofproto-dpif-xlate: Eliminate duplicate read of xcfgp.
Ben Pfaff [Wed, 2 Aug 2017 15:36:07 +0000 (08:36 -0700)]
ofproto-dpif-xlate: Eliminate duplicate read of xcfgp.

This inner 'xcfg' shadowed the outer one and could have read a different
value if 'xcfgp' was changing, so this is possibly a bug fix.

Found by -Wshadow=local in GCC 7.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
7 years agohash: Add "fall through" annotations for 32-bit builds as well.
Ben Pfaff [Thu, 13 Jul 2017 17:15:42 +0000 (10:15 -0700)]
hash: Add "fall through" annotations for 32-bit builds as well.

Commit 73c7216a5329 ("Fix some -Wimplicit-fallthrough warnings building with
GCC 7") missed a few fall through annotations that only appear in 32-bit
builds.  This commit adds them.

CC: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
7 years agonetdev: Fix netdev_open() to track and recreate classless interfaces
Eelco Chaudron [Fri, 14 Jul 2017 12:33:27 +0000 (14:33 +0200)]
netdev: Fix netdev_open() to track and recreate classless interfaces

Due to commit 67ac844 an existing issue with OVS persisten ports
surfaced. If we revert the commit we no longer get the error, and
basic traffic will flow. However the wrong netdev class is used, hence
the wrong callbacks get called.

The main issue is with netdev_open() being called with type = NULL
before the interface is actually configured in the system. This patch
tracks these "auto" generated interfaces, and once netdev_open() gets
called with a valid type, re-configures (re-create) it.

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovn-controller: Monitor port bindings of parent ports.
wangqianyu [Wed, 2 Aug 2017 20:36:29 +0000 (13:36 -0700)]
ovn-controller: Monitor port bindings of parent ports.

Neutron configure a trunk-sub port. The parent-port and sub-port located
in different network. there is a vm attached to parent port. And no vm
attached to the network of sub-port in the same chassis. In this
situation, the ovn-controller can not get the configuration info of
sub-port.

The reason is that ovn-controller does not monitor the port-binding with
parent.

This patch fix this bug.

Signed-off-by: wangqianyu <wang.qianyu@zte.com.cn>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agolacp: enable bond slave immediately after lacp attach
Huanle Han [Wed, 12 Jul 2017 14:35:58 +0000 (22:35 +0800)]
lacp: enable bond slave immediately after lacp attach

There is a long interval (5~20 seconds) between lacp slave attach
and bond slave enable. During the interval, ovs drop all received
packets from that slave because bond_check_admissibility() check
fails. The root cause is that connectivity_seq is not changed
after lacp update and lacp status is not populated into port->may_enable
by port_run() immediately.

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agovlog: reopen log file in monitor process
Huanle Han [Wed, 2 Aug 2017 14:08:15 +0000 (10:08 -0400)]
vlog: reopen log file in monitor process

ovs daemon process will reopen file after every log rotate.
However, it doesn't happen to monitor process. That is to say,
fd of log file in monitor proces always point to oldest disk file,
which is deleted after log rotate. Once daemon process restarts
from a crash, it inherits parent's fds, including the deleted log file.

This commit reopens log file in monitor process everytime it
wakes up from waitpid.

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodatapath-windows: Fix shared variables which use Interlocked functions
Alin Serdean [Fri, 14 Jul 2017 04:40:58 +0000 (04:40 +0000)]
datapath-windows: Fix shared variables which use Interlocked functions

Instead of assigning a value directly to the variable use `InterlockedAdd`
with 0.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add annotation for OvsIpFragmentEntryCleaner
Alin Serdean [Fri, 14 Jul 2017 04:40:58 +0000 (04:40 +0000)]
datapath-windows: Add annotation for OvsIpFragmentEntryCleaner

Make the function `OvsIpFragmentEntryCleaner` aware it is a kstart_routine.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add annotation for OvsCtRelatedEntryCleaner
Alin Serdean [Fri, 14 Jul 2017 04:40:57 +0000 (04:40 +0000)]
datapath-windows: Add annotation for OvsCtRelatedEntryCleaner

Make the function `OvsCtRelatedEntryCleaner` aware it is a kstart_routine.

Also, the function is not compliant with the coding standard.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Treat TCP_HDR_LEN static analysis warnings
Alin Serdean [Fri, 14 Jul 2017 04:40:57 +0000 (04:40 +0000)]
datapath-windows: Treat TCP_HDR_LEN static analysis warnings

Using the shift operator in macros makes the static analyzer on WDK 8.1 confused.

Switch to multiplication when trying to get the data offset of the TCP header.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Check return status when using APIs
Alin Serdean [Fri, 14 Jul 2017 04:40:57 +0000 (04:40 +0000)]
datapath-windows: Check return status when using APIs

Check the return status of `ConvertInterfaceLuidToAlias` and `RtlStringCbLengthW`
and treat them accordingly.

Also remove unneeded initialization for `interfaceName`.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: fix excessive stack usage in iphelper
Alin Serdean [Fri, 14 Jul 2017 04:40:57 +0000 (04:40 +0000)]
datapath-windows: fix excessive stack usage in iphelper

`OvsGetOrResolveIPNeigh` uses a stack over 1024 bytes.

Switch one parameter to be a pointer.

Found using WDK 8.1 static code analysis.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add dummy parameter for NotifyRouteChange2
Alin Serdean [Fri, 14 Jul 2017 04:40:56 +0000 (04:40 +0000)]
datapath-windows: Add dummy parameter for NotifyRouteChange2

Add a dummy parameter when using `NotifyRouteChange2` to keep static
static analysis happy.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Suppress warning in jhash
Alin Serdean [Fri, 14 Jul 2017 04:40:56 +0000 (04:40 +0000)]
datapath-windows: Suppress warning in jhash

Suppress overflow warning to keep static code analysis happy.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Fix possible NULL deference in OvsFullCopyNBL
Alin Serdean [Fri, 14 Jul 2017 04:40:56 +0000 (04:40 +0000)]
datapath-windows: Fix possible NULL deference in OvsFullCopyNBL

Check if the first net buffer exists before trying to copy it.

Found using WDK 10 static code analysis.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add assert in OvsPartialCopyNBL
Alin Serdean [Fri, 14 Jul 2017 04:40:56 +0000 (04:40 +0000)]
datapath-windows: Add assert in OvsPartialCopyNBL

`srcNb` should never be NULL since it was copied over from another nbl.
Add an assertion just in case and to keep static analysis happy.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Use annotations instead for macros
Alin Serdean [Fri, 14 Jul 2017 04:40:56 +0000 (04:40 +0000)]
datapath-windows: Use annotations instead for macros

We can safely use function annotations to instead of defining out own macros.
Nuke implementation of `OVS_VERIFY_IRQL_LE` and OVS_VERIFY_IRQL (unused).

Add function annotations to the functions which were using OVS_VERIFY_IRQL_LE`.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Fix misspelling in comment.
Alin Serdean [Fri, 14 Jul 2017 04:40:55 +0000 (04:40 +0000)]
datapath-windows: Fix misspelling in comment.

Found by inspection.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add annotations for OvsAcquirePidHashLock
Alin Serdean [Fri, 14 Jul 2017 04:40:55 +0000 (04:40 +0000)]
datapath-windows: Add annotations for OvsAcquirePidHashLock

Add annotations to the function ` OvsAcquirePidHashLock`.
We make it aware that it raises the dispatch level, where it saves the
dispatch level and it acquires a lock.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add annotations for OvsReleasePidHashLock
Alin Serdean [Fri, 14 Jul 2017 04:40:55 +0000 (04:40 +0000)]
datapath-windows: Add annotations for OvsReleasePidHashLock

Add function annotations for ` OvsReleasePidHashLock`.
We make it aware that it requires a certain dispatch level, that it
restores the dispatch level, that it requires a lock held and releases
a lock.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add annotations for OvsReleaseEventQueueLock
Alin Serdean [Fri, 14 Jul 2017 04:40:55 +0000 (04:40 +0000)]
datapath-windows: Add annotations for OvsReleaseEventQueueLock

Add function annotations for ` OvsReleaseEventQueueLock`.
We make it aware that it requires a certain dispatch level, that it
restores the dispatch level, that it requires a lock held and releases
a lock.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add function annotations for OvsAcquireEventQueueLock
Alin Serdean [Fri, 14 Jul 2017 04:40:55 +0000 (04:40 +0000)]
datapath-windows: Add function annotations for OvsAcquireEventQueueLock

The function should be aware that it raises the dispatch level, saves the
dispatch level and acquires a lock.

This patch adds annotation for that.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add function annotations for OvsCancelIrpDatapath
Alin Serdean [Fri, 14 Jul 2017 04:40:55 +0000 (04:40 +0000)]
datapath-windows: Add function annotations for OvsCancelIrpDatapath

The function should be aware that it is cancel routine.

This patch adds annotation for that.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add function annotations for OvsTunnelFilterCancelIrp
Alin Serdean [Fri, 14 Jul 2017 04:40:54 +0000 (04:40 +0000)]
datapath-windows: Add function annotations for OvsTunnelFilterCancelIrp

The function should be aware that it is cancel routine.

This patch adds annotation for that.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add function annotations for OvsCancelIrp
Alin Serdean [Fri, 14 Jul 2017 04:40:54 +0000 (04:40 +0000)]
datapath-windows: Add function annotations for OvsCancelIrp

The function should be aware that it is cancel routine.

This patch adds annotation for that.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add function annotations for OvsReleaseDatapath
Alin Serdean [Fri, 14 Jul 2017 04:40:54 +0000 (04:40 +0000)]
datapath-windows: Add function annotations for OvsReleaseDatapath

The function should be aware that it requires a certain dispatch level,
restores the dispatch level, requires lock held and releases a lock.

This patch adds annotation for that.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add function annotations for OvsAcquireDatapathWrite
Alin Serdean [Fri, 14 Jul 2017 04:40:54 +0000 (04:40 +0000)]
datapath-windows: Add function annotations for OvsAcquireDatapathWrite

The function should be aware that it raises the dispatch level, saves the
dispatch level and acquires a lock.

This patch adds annotation for that.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add function annotations for OvsAcquireDatapathRead
Alin Serdean [Fri, 14 Jul 2017 04:40:54 +0000 (04:40 +0000)]
datapath-windows: Add function annotations for OvsAcquireDatapathRead

The function should be aware that it raises the dispatch level, saves the
dispatch level and acquires a lock.

This patch adds annotation for that.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Remove function declarations from Tunnel.c
Alin Serdean [Fri, 14 Jul 2017 04:40:54 +0000 (04:40 +0000)]
datapath-windows: Remove function declarations from Tunnel.c

`OvsAcquireDatapathRead`, `OvsAcquireDatapathWrite`, `OvsReleaseDatapath`
are defined and implemented in Switch.h which is already included.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add annotations for OvsReleaseCtrlLock
Alin Serdean [Fri, 14 Jul 2017 04:40:54 +0000 (04:40 +0000)]
datapath-windows: Add annotations for OvsReleaseCtrlLock

Add function annotations for `OvsReleaseCtrlLock`.
We make it aware that it requires a certain dispatch level, that it
restores the dispatch level, that it requires a lock held and release
a lock.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add annotations for OvsAcquireCtrlLock
Alin Serdean [Fri, 14 Jul 2017 04:40:53 +0000 (04:40 +0000)]
datapath-windows: Add annotations for OvsAcquireCtrlLock

Add annotations to the function `OvsAcquireCtrlLock`.
We make it aware that it raises the dispatch level, where it saves the
dispatch level and it acquires a lock.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add an assert in recirculation
Alin Serdean [Fri, 14 Jul 2017 04:40:53 +0000 (04:40 +0000)]
datapath-windows: Add an assert in recirculation

`ovsFwdCtx.switchContext` can't be null since it is passed from actions.
Add an assert to keep the static analyzer happy.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Fix possible NULL dereference in BufferMgmt
Alin Serdean [Fri, 14 Jul 2017 04:40:53 +0000 (04:40 +0000)]
datapath-windows: Fix possible NULL dereference in BufferMgmt

The mdl can be NULL.

Found using WDK 10 static code analysis.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Suppress PAGED_CODE warnings
Alin Serdean [Fri, 14 Jul 2017 04:40:53 +0000 (04:40 +0000)]
datapath-windows: Suppress PAGED_CODE warnings

Suppress static code analysis around PAGED_CODE(). The macro is useful only in
checked builds.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Add asserts to Stt
Alin Serdean [Fri, 14 Jul 2017 04:40:53 +0000 (04:40 +0000)]
datapath-windows: Add asserts to Stt

Unfortunately the WDK 10 static code analysis can't see this one clearly.

Add an ASSERT to silence the warning.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Fix code alignment in Stt
Alin Serdean [Fri, 14 Jul 2017 04:40:52 +0000 (04:40 +0000)]
datapath-windows: Fix code alignment in Stt

Found by inspection.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: interfaceName overflow in IpHelper
Alin Serdean [Fri, 14 Jul 2017 04:40:52 +0000 (04:40 +0000)]
datapath-windows: interfaceName overflow in IpHelper

Bump the size of interfaceName so an overflow cannot occur when using
`ConvertInterfaceLuidToAlias`.

Found using WDK 10 static code analysis.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Remove annotations in Switch.c
Alin Serdean [Fri, 14 Jul 2017 04:40:52 +0000 (04:40 +0000)]
datapath-windows: Remove annotations in Switch.c

There are no annotations defined for `OvsExtDetach` and `OvsExtRestart`.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agodatapath-windows: Use non-executable memory when allocating memory
Alin Serdean [Fri, 14 Jul 2017 04:40:52 +0000 (04:40 +0000)]
datapath-windows: Use non-executable memory when allocating memory

Use non-executable memory when using ExAllocatePoolWithTagPriority.

Found using WDK 10 static code analysis.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
7 years agotests: Extend PTAP unit tests with decap action
Zoltan Balogh [Wed, 2 Aug 2017 08:04:13 +0000 (16:04 +0800)]
tests: Extend PTAP unit tests with decap action

  - Checking decap() prerequisits.
  - Encap/decap VLAN tagged Ethernet frames.
  - Send L3 packet over patch port.
  - Output L2/L3 packet to ports with different packet_type properties.

Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Suggested-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoOF support and translation of generic encap and decap
Jan Scheurich [Wed, 2 Aug 2017 08:04:12 +0000 (16:04 +0800)]
OF support and translation of generic encap and decap

This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.

CLI syntax for encap action with properties:
  encap(<header>)
  encap(<header>(<prop>=<value>,<tlv>(<class>,<type>,<value>),...))

For example:
  encap(ethernet)
  encap(nsh(md_type=1))
  encap(nsh(md_type=2,tlv(0x1000,10,0x12345678),tlv(0x2000,20,0xfedcba9876543210)))

CLI syntax for decap action:
  decap()
  decap(packet_type(ns=<pt_ns>,type=<pt_type>))

For example:
  decap()
  decap(packet_type(ns=0,type=0xfffe))
  decap(packet_type(ns=1,type=0x894f))

The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).

This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.

In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.

The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.

Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.

Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovn-northd: Add native active-standby HA.
Russell Bryant [Tue, 1 Aug 2017 16:15:04 +0000 (12:15 -0400)]
ovn-northd: Add native active-standby HA.

Add native support for active-standby HA in ovn-northd by having each
instance attempt to acquire an OVSDB lock.  Only the instance of
ovn-northd that currently holds the lock will make active changes to
the OVN databases.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Han Zhou <zhouhan@gmail.com>
Tested-by: Numan Siddique <nusiddiq@redhat.com>
Acked-by: Numan Siddique <nusiddiq@redhat.com>
7 years agodpif-netdev: Reorder elements in dp_netdev_port structure.
Bhanuprakash Bodireddy [Wed, 2 Aug 2017 03:13:38 +0000 (20:13 -0700)]
dpif-netdev: Reorder elements in dp_netdev_port structure.

By reordering the elements in dp_netdev_port structure, pad bytes can be
reduced there by saving a cache line. Marginal performance improvement
is also observed with this change.

Before: structure size: 136, holes: 7, sum padbytes:7, cachelines:3
After : structure size: 128, holes: 6, sum padbytes:0, cachelines:2

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Tested-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpctl: Add new 'ct-bkts' command.
Antonio Fischetti [Wed, 2 Aug 2017 03:12:03 +0000 (20:12 -0700)]
dpctl: Add new 'ct-bkts' command.

With the command:
 ovs-appctl dpctl/ct-bkts
shows the number of connections per bucket.

By using a threshold:
 ovs-appctl dpctl/ct-bkts gt=N
for each bucket shows the number of connections when they
are greater than N.

Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Co-authored-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoconntrack : Use Rx checksum offload feature on DPDK ports for conntrack.
Sugesh Chandran [Wed, 2 Aug 2017 01:51:14 +0000 (18:51 -0700)]
conntrack : Use Rx checksum offload feature on DPDK ports for conntrack.

Avoiding checksum validation in conntrack module if it is already verified
in DPDK physical NIC ports.

Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
Co-authored-by: Darrell Ball <dball@vmware.com>
Signed-off-by: Darrell Ball <dball@vmware.com>
Acked-by: Antonio Fishetti <antonio.fischetti@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodp-packet : Update DPDK rx checksum validation functions.
Sugesh Chandran [Wed, 2 Aug 2017 00:36:33 +0000 (17:36 -0700)]
dp-packet : Update DPDK rx checksum validation functions.

DPDK ports use masks while reporting rx checksum flags. OVS should use these
mask along with reported checksum flag while validating the good checksum.

Added two new functions to validate bad checksum reported by DPDK NIC port.
These two functions will be used in the following patch for enabling rx checksum
offload in conntrack module.

Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
Co-authored-by: Darrell Ball <dball@vmware.com>
Signed-off-by: Darrell Ball <dball@vmware.com>
Acked-by: Antonio Fishetti <antonio.fischetti@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agopackets: Do not initialize ct_orig_tuple.
Daniele Di Proietto [Wed, 2 Aug 2017 00:26:28 +0000 (17:26 -0700)]
packets: Do not initialize ct_orig_tuple.

Commit "odp: Support conntrack orig tuple key." introduced new fields
in struct 'pkt_metadata'.  pkt_metadata_init() is called for every
packet in the userspace datapath.  When testing a simple single
flow case with DPDK, we observe a lower throughput after the above
commit (it was 14.88 Mpps before, it is 13 Mpps after).

This patch skips initializing ct_orig_tuple in pkt_metadata_init().
It should be enough to initialize ct_state, because nobody should look
at ct_orig_tuple unless ct_state is != 0.

It's discussed at:
https://mail.openvswitch.org/pipermail/ovs-dev/2017-May/332419.html

Fixes: daf4d3c18da4("odp: Support conntrack orig tuple key.")
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Co-authored-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpdk: Fix device cleanup.
Darrell Ball [Wed, 2 Aug 2017 00:04:29 +0000 (17:04 -0700)]
dpdk: Fix device cleanup.

Commit 5dcde09c80a8 was introduced to make detaching more
automatic without using an additional command beyond
ovs-vsctl del-port <br> <port>.

Sometimes, since commit 5dcde09c80a8, dpdk devices are
not detached when del-port is issued; command example:

sudo ovs-vsctl del-port br0 dpdk1

This can happen when vswitchd is (re)started with an existing
database and devices are already bound to dpdk.

A minimal recipe to reproduce the issue is:

1/ Starting with

darrell@prmh-nsx-perf-server125:~$ sudo ovs-vsctl show
1c50d8ee-b17f-4fac-a595-03b0da8c8275
    Bridge "br0"
        Port "br0"
            Interface "br0"
                type: internal
        Port "dpdk1"
            Interface "dpdk1"
                type: dpdk
                options: {dpdk-devargs="0000:04:00.1"}
        Port "dpdk0"
            Interface "dpdk0"
                type: dpdk
                options: {dpdk-devargs="0000:04:00.0"}

darrell@prmh-nsx-perf-server125:~$ /usr/src/dpdk-16.11/tools/dpdk-devbind.py --status

Network devices using DPDK-compatible driver

============================================
0000:04:00.0 'Ethernet Controller 10-Gigabit X540-AT2' drv=uio_pci_generic unused=ixgbe,vfio-pci
0000:04:00.1 'Ethernet Controller 10-Gigabit X540-AT2' drv=uio_pci_generic unused=ixgbe,vfio-pci

2/ restart vswitchd

3/ run
 sudo ovs-vsctl del-port br0 dpdk1

and find the interface is NOT detached; there is
no info log ‘Device '0000:04:00.1' detached’.

A more verbose discussion is here:
https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/333462.html
along with another possible solution.

Since we are nearing the end of a release, a safe approach is needed,
at this time.
One approach is to revert 5dcde09c80a8.  This patch does not do that
but reinstates the command ovs-appctl netdev-dpdk/detach to handle
cases when del-port will not work.

To detach the device, run the reinstated command
ovs-appctl netdev-dpdk/detach 0000:04:00.1
Observe console output
‘Device '0000:04:00.1' has been detached’

Fixes: 5dcde09c80a8 ("netdev-dpdk: Fix device leak on port deletion.")
CC: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Acked-by: Fischetti, Antonio <antonio.fischetti@intel.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoUpdate relevant artifacts to add support for DPDK 17.05.1.
Michal Weglicki [Tue, 1 Aug 2017 23:14:10 +0000 (16:14 -0700)]
Update relevant artifacts to add support for DPDK 17.05.1.

Upgrading to DPDK 17.05.1 stable release adds new
significant features relevant to OVS, including,
but not limited to:
- tun/tap PMD,
- VFIO hotplug support,
- Generic flow API.

Following changes are applied:
- netdev-dpdk: Changes required by DPDK API modifications.
- doc: Because of DPDK API changes, backward compatibility
  with previous DPDK releases will be broken, thus all
  relevant documentation entries are updated.
- .travis: DPDK version change from 16.11.1 to 17.05.1.
- rhel/openvswitch-fedora.spec.in: DPDK version change
  from 16.11 to 17.05.1

Signed-off-by: Michal Weglicki <michalx.weglicki@intel.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Acked-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
Tested-by: Ian Stokes <ian.stokes@intel.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agonetdev-dpdk: use rte_eth_dev_set_mtu.
Mark Kavanagh [Tue, 1 Aug 2017 22:03:08 +0000 (15:03 -0700)]
netdev-dpdk: use rte_eth_dev_set_mtu.

DPDK provides an API to set the MTU of compatible physical devices -
rte_eth_dev_set_mtu(). Prior to DPDK v16.07 however, this API was not
implemented in some DPDK PMDs (i40e, specifically). To allow the use
of jumbo frames with affected NICs in OvS-DPDK, MTU configuration was
achieved by setting the jumbo frame flag, and corresponding maximum
permitted Rx frame size, in an rte_eth_conf structure for the NIC
port, and subsequently invoking rte_eth_dev_configure() with that
configuration.

However, that method does not set the MTU field of the underlying DPDK
structure (rte_eth_dev) for the corresponding physical device;
consequently, rte_eth_dev_get_mtu() reports the incorrect MTU for an
OvS-DPDK phy device with non-standard MTU.

Resolve this issue by invoking rte_eth_dev_set_mtu() when setting up
or modifying the MTU of a DPDK phy port.

Fixes: 0072e93 ("netdev-dpdk: add support for jumbo frames")
Reported-by: Aaron Conole <aconole@redhat.com>
Reported-by: Vipin Varghese <vipin.varghese@intel.com>
Reviewed-by: Aaron Conole <aconole@redhat.com>
Acked-by: Sugesh Chandran <sugesh.chandran@intel.com>
Tested-by: Sugesh Chandran <sugesh.chandran@intel.com>
Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpif-netdev: Assign ports to pmds on non-local numa node.
Billy O'Mahony [Tue, 1 Aug 2017 21:38:43 +0000 (14:38 -0700)]
dpif-netdev: Assign ports to pmds on non-local numa node.

Previously if there is no available (non-isolated) pmd on the numa node
for a port then the port is not polled at all. This can result in a
non-operational system until such time as nics are physically
repositioned. It is preferable to operate with a pmd on the 'wrong' numa
node albeit with lower performance. Local pmds are still chosen when
available.

Signed-off-by: Billy O'Mahony <billy.o.mahony@intel.com>
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Co-authored-by: Ilya Maximets <i.maximets@samsung.com>
Tested-by: Ian Stokes <ian.stokes@intel.com>
Acked-by: Ian Stokes <ian.stokes@intel.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpif-netdev: Don't uninit emc on reload.
Ilya Maximets [Tue, 1 Aug 2017 21:22:17 +0000 (14:22 -0700)]
dpif-netdev: Don't uninit emc on reload.

There are many reasons for reloading of pmd threads:
* reconfiguration of one of the ports.
* Adjusting of static_tx_qid.
* Adding new tx/rx ports.

In many cases EMC is still useful after reload and uninit
will only lead to unnecessary upcalls/classifier lookups.

Such behaviour slows down the datapath. Uninit itself slows
down the reload path. All this factors leads to additional
unexpected latencies/drops on events not directly connected
to current PMD thread.

Lets not uninitialize emc cache on reload path.
'emc_cache_slow_sweep()' and replacements should free all
the old/unwanted entries.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Cian Ferriter <cian.ferriter@intel.com>
Tested-by: Cian Ferriter <cian.ferriter@intel.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agodpif-netdev: Incremental addition/deletion of PMD threads.
Ilya Maximets [Tue, 1 Aug 2017 20:46:33 +0000 (13:46 -0700)]
dpif-netdev: Incremental addition/deletion of PMD threads.

Currently, change of 'pmd-cpu-mask' is very heavy operation.
It requires destroying of all the PMD threads and creating
them back. After that, all the threads will sleep until
ports' redistribution finished.

This patch adds ability to not stop the datapath while
adjusting number/placement of PMD threads. All not affected
threads will forward traffic without any additional latencies.

id-pool created for static tx queue ids to keep them sequential
in a flexible way. non-PMD thread will always have
static_tx_qid = 0 as it was before.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Tested-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
Acked-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
7 years agoovn: Fix the failing "2335: ovn -- ACL logging" test case
Numan Siddique [Wed, 2 Aug 2017 14:20:57 +0000 (19:50 +0530)]
ovn: Fix the failing "2335: ovn -- ACL logging" test case

The test case is failing mainly because of timing issue. Looking into the
ovn-controller.log it is evident that the last packet injected just before the
AT_CHECK, is still not processed by ovn-controller.

Fixes: d383eed59589 ("ovn: Add support for ACL logging.")
Suggested-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
7 years agodpif-netlink: Fix log level for error message
Roi Dayan [Sun, 30 Jul 2017 04:58:17 +0000 (07:58 +0300)]
dpif-netlink: Fix log level for error message

Since it's an error but also will always occur in older kernels
log the message with level warning instead of info.

Signed-off-by: Roi Dayan <roid@mellanox.com>
Acked-by: Eric Garver <e@erig.me>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodpif-netlink-rtnl: Fix false errors on interfaces without tunnel config
Roi Dayan [Thu, 27 Jul 2017 11:40:02 +0000 (14:40 +0300)]
dpif-netlink-rtnl: Fix false errors on interfaces without tunnel config

When we skip adding a port using rtnetlink and not because of an error we
need to return EOPNOTSUPP to avoid logging an error message.

Fixes: 2fd3d5eda508 ("dpif-netlink-rtnl: Support layer3 GRE")
Signed-off-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Paul Blakey <paulb@mellanox.com>
Acked-by: Eric Garver <e@erig.me>
Acked-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agodpif-netlink-rtnl: Fix VXLAN port create for regular VXLAN
Eric Garver [Tue, 1 Aug 2017 22:47:18 +0000 (18:47 -0400)]
dpif-netlink-rtnl: Fix VXLAN port create for regular VXLAN

When VXLAN-GPE was introduced we added IFLA_VXLAN_GPE to the policy
parsing, but did not mark it as optional. The kernel only returns this
netlink attribute if it's actually configured.

This also adds a missing entry for IFLA_VXLAN_GBP. Apparently we have no
system-traffic test coverage there.

Fixes: c33c412fb139 ("dpif-netlink-rtnl: Support VXLAN-GPE")
Fixes: 825e45e0109f ("dpif-netlink-rtnl: Support VXLAN creation")
Reported-by: Joe Stringer <joe@ovn.org>
Signed-off-by: Eric Garver <e@erig.me>
Signed-off-by: Joe Stringer <joe@ovn.org>
7 years agoofpbuf: Fix parameter for const initializer.
Joe Stringer [Tue, 1 Aug 2017 00:16:11 +0000 (17:16 -0700)]
ofpbuf: Fix parameter for const initializer.

Clang 4.0 complains:

In file included from include/openvswitch/cxxtest.cc:11:0:
../include/openvswitch/ofpbuf.h: In function ‘ofpbuf ofpbuf_const_initializer(const void*, size_t)’:
../include/openvswitch/ofpbuf.h:107:5: warning: narrowing conversion of ‘size’ from ‘size_t {aka long unsigned int}’ to ‘uint32_t {aka unsigned int}’ inside { } [-Wnarrowing]
     };
     ^
../include/openvswitch/ofpbuf.h:107:5: warning: narrowing conversion of ‘size’ from ‘size_t {aka long unsigned int}’ to ‘uint32_t {aka unsigned int}’ inside { } [-Wnarrowing]

This is because the ofpbuf struct's "size" parameter is a uint32_t,
while ofpbuf_const_initializer() takes a size_t for the size. Fix this
function to take a uint32_t instead.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>