cascardo/ovs.git
9 years agoPrepare include headers
Alin Serdean [Wed, 13 Aug 2014 15:16:07 +0000 (15:16 +0000)]
Prepare include headers

Preparing the include headers needed to compile dpif-linux.c with MSVC.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoNo newline at end of file
Alin Serdean [Wed, 13 Aug 2014 15:15:21 +0000 (15:15 +0000)]
No newline at end of file

Adding newline at end of the following files: packet.h, uio.h.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath: Fix memory leak in ovs_vport_alloc() error path
Christoph Jaeger [Wed, 13 Aug 2014 03:25:07 +0000 (20:25 -0700)]
datapath: Fix memory leak in ovs_vport_alloc() error path

ovs_vport_alloc() bails out without freeing the memory 'vport' points
to.

Picked up by Coverity - CID 1230503.

Fixes: beb1c69a3 ("datapath: Allow each vport to have an array of
'port_id's.")
Signed-off-by: Christoph Jaeger <cj@linux.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
9 years agonetdev-dpdk: Keep calling rte_eth_tx_burst() until it returns 0
Daniele Di Proietto [Tue, 12 Aug 2014 17:43:36 +0000 (10:43 -0700)]
netdev-dpdk: Keep calling rte_eth_tx_burst() until it returns 0

rte_eth_tx_burst() _should_ transmit every packet that it is passed unless the
queue is full. Nontheless some implementation of rte_eth_tx_burst (e.g.
ixgbe_xmit_pkts_vec()) does not transmit more than a fixed number (32) of
packets at a time.

With this commit we assume that there's an error only if rte_eth_tx_burst
returns 0.

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
9 years agonetdev-dpdk: Move to DPDK 1.7.0
Daniele Di Proietto [Tue, 12 Aug 2014 17:43:35 +0000 (10:43 -0700)]
netdev-dpdk: Move to DPDK 1.7.0

With this commit we move our DPDK support to 1.7.0.
DPDK binaries (starting with dpdk 1.7.0) should be linked with --whole-archive
to include pmd drivers

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
9 years agodpif-netdev: Reintroduce ref_cnt for dp_netdev_flow
Daniele Di Proietto [Tue, 12 Aug 2014 00:25:50 +0000 (17:25 -0700)]
dpif-netdev: Reintroduce ref_cnt for dp_netdev_flow

struct dp_netdev_flow used to have a reference counter.
It has been replaced by RCU. Unfortunately RCU is not
enough if we plan to hold a reference to the dp_netdev_flow
for a long time. So this commit reintroduces reference
counting for struct dp_netdev_flow

Subsequent commits make use of it.

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
9 years agoofp-errors: Use EXT-444 extension error codes for properties in OF1.3.
Ben Pfaff [Mon, 11 Aug 2014 21:31:29 +0000 (14:31 -0700)]
ofp-errors: Use EXT-444 extension error codes for properties in OF1.3.

These error codes are proposed in the ONF extensibility working group as an
OpenFlow 1.3 extension.

Error codes are also proposed for the other three "bad property" error
codes, but those already have standardized OpenFlow 1.3 error codes and the
proposal says that implementations should use the standard ones.

ONF-JIRA: EXT-444.
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoMakefiles: Add ofp-actions.inc1 and ofp-actions.inc2 to gitignore.
Ben Pfaff [Tue, 12 Aug 2014 20:32:01 +0000 (13:32 -0700)]
Makefiles: Add ofp-actions.inc1 and ofp-actions.inc2 to gitignore.

Requested-by: Alin Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agolearning-switch: Make test-controller work with OpenFlow 1.3+.
Ben Pfaff [Wed, 16 Jul 2014 20:28:40 +0000 (13:28 -0700)]
learning-switch: Make test-controller work with OpenFlow 1.3+.

The controller setup in my personal test environment has been broken for a
while.  I figured that it wasn't anything important, though, because no one
else had reported similar problems.  Anyway, it turns out that enabling
OpenFlow 1.3 by default broke test-controller because OpenFlow 1.3 doesn't
send table misses to the controller by default.  This commit fixes the
problem.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
9 years agolib/netlink-protocol.h: Do not include headers for windows kernel build.
Ankur Sharma [Tue, 12 Aug 2014 18:36:27 +0000 (11:36 -0700)]
lib/netlink-protocol.h: Do not include headers for windows kernel build.

Added saurabh's fix to not to include some header files
in lib/netlink-protocol.h not needed by windows driver.

This is a temporary fix to make sure that windows driver can compile.

We are working in parallel on adding netlink support in windows driver
(https://github.com/openvswitch/ovs-issues/issues/18). With netlink support
changes we will get rid of the dependency on lib/netlink-protocol.h.

Testing:
1. Verified make distcheck on linux.
2. Verified that windows driver can compile now.
3. Verified that ping works over vxlan tunnel.

Signed-off-by: Ankur Sharma <ankursharma@vmware.com>
Co-authored-by: Saurabh Shah <ssaurabh@vmware.com>
Tested-by: Ankur Sharma <ankursharma@vmware.com>
Reported-by: Alin Serdean <aserdean@cloudbasesolutions.com>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/21
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoMakefiles: Clean lib/ofp-actions.inc1 and lib/ofp-actions.inc2.
Ben Pfaff [Tue, 12 Aug 2014 18:43:43 +0000 (11:43 -0700)]
Makefiles: Clean lib/ofp-actions.inc1 and lib/ofp-actions.inc2.

Fixes a failure with make distcheck.

Reported-by: Ankur Sharma <ankursharma@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoofp-actions: Make struct ofpact constant size across implementations.
Ben Pfaff [Tue, 12 Aug 2014 18:42:56 +0000 (11:42 -0700)]
ofp-actions: Make struct ofpact constant size across implementations.

Before commit c2d936a44fa6 (ofp-actions: Centralize all OpenFlow action
code for maintainability.), struct ofpact was 4 bytes with GCC and Clang,
and 12 bytes with other compilers.  That commit changed struct ofpact so
that it remained 4 bytes with GCC and Clang but shrank to 8 bytes on other
compilers.  An unexpected side effect of that change was that the size
of the pad[] array in struct ofpact_nest shrank to 0 bytes, because that
array padded to a multiple of 8 bytes.  MSVC does not support 0-element
arrays, so this caused a build failure.

This commit fixes the problem by changing struct ofpact so that it is 4
bytes with every compiler.

Reported-by: Alin Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Alin Serdean <aserdean@cloudbasesolutions.com>
9 years agodatapath: Update flow key before recirc
Andy Zhou [Mon, 11 Aug 2014 21:02:45 +0000 (14:02 -0700)]
datapath: Update flow key before recirc

When flow key becomes invalid due to push or pop actions, current
implementation leaves it as invalid, only rebuild the flow key used
for recirculation.

This works, but is less efficient in case of multiple recirc
actions. Each recirc action will have to re-extract
its own flow keys.

This patch update the original flow key as soon as the first recirc
action is encountered, avoiding expensive flow extract call for any
future recirc actions as long as the flow key remains valid.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
9 years agodpif-provider: Get rid of redundant operations.
Ben Pfaff [Tue, 15 Jul 2014 23:09:40 +0000 (16:09 -0700)]
dpif-provider: Get rid of redundant operations.

The dpif provider 'operate' call duplicates all of the features available
from the 'flow_put', 'flow_del', and 'execute' calls, yielding redundant
code in providers that support both mechanisms.  This change drops the
latter calls in favor of making every dpif provider support 'operate'.
The result is code that is overall less duplicative.

It might make sense to do the same with flow_get but so far 'operate'
doesn't support flow_get.

Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoPackaging: Add useful files for debian and rhel.
Pravin B Shelar [Mon, 11 Aug 2014 21:35:19 +0000 (14:35 -0700)]
Packaging: Add useful files for debian and rhel.

CC: Ben Pfaff <blp@nicira.com>
Signed-off-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agodpdk: Update documentation.
Pravin B Shelar [Thu, 7 Aug 2014 19:40:34 +0000 (12:40 -0700)]
dpdk: Update documentation.

Add usage info for ovs-vswitchd dpdk option. Update
INSTALL.DPDK file and man page.

Reported-by: Hari Sasank Bhamidipalli <hbhamidi@cisco.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Acked-by: Flavio Leitner <fbl@redhat.com>
9 years agoodp-netlink.h: Autogenerate a version of odp-netlink for windows kernel.
Ankur Sharma [Mon, 11 Aug 2014 18:43:22 +0000 (11:43 -0700)]
odp-netlink.h: Autogenerate a version of odp-netlink for windows kernel.

Autogenerated odp-netlink.h will not compile with windows kernel, as
it refers to some userspace files like openvswitch/types.h and
packets.h which hyperv extension does not access. Due to this the
windows datapath compilation is broken on tip of tree. This patch
intends to fix that.

In this patch we add a new sed script "extract-odp-netlink-windows-dp-h"
to create OvsDpInterface.h. It works on similar lines as
extract-odp-netlink-h, but avoids including the header files
which are not available for driver.

After this fix, a userspace build will be needed before windows
kernel datapath can be built.

Tested that hyperv extension could be built after building
the userspace. Verified vxlan tunnel based ping across
hypervisors. Verified that odp-netlink-windows-dp.h is not
built for linux platform. Ran 'make distcheck' to verify that
nothing is broken on linux.

Signed-off-by: Ankur Sharma <ankursharma@vmware.com>
Co-authored-by: Saurabh Shah <ssaurabh@vmware.com>
Tested-by: Ankur Sharma <ankursharma@vmware.com>
Reported-by: Alin Serdean <aserdean@cloudbasesolutions.com>
Reported-by: Nithin Raju <nithin@vmware.com>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/21
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoofp-actions: Use specific error code for oxm_hasmask=1 in Set-Field.
Ben Pfaff [Mon, 11 Aug 2014 21:13:53 +0000 (14:13 -0700)]
ofp-actions: Use specific error code for oxm_hasmask=1 in Set-Field.

Based on the OpenFlow 1.5 draft.

ONF-JIRA: EXT-425
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofp-actions: Avoid logging 64 times as many actions as actually provided.
Ben Pfaff [Mon, 11 Aug 2014 21:13:27 +0000 (14:13 -0700)]
ofp-actions: Avoid logging 64 times as many actions as actually provided.

The following commit adds a test.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofp-actions: Add support for OpenFlow 1.5 (draft) Copy-Field action.
Ben Pfaff [Thu, 7 Aug 2014 23:18:51 +0000 (16:18 -0700)]
ofp-actions: Add support for OpenFlow 1.5 (draft) Copy-Field action.

ONF-JIRA: EXT-320
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoovs-ofctl: Generalize action and instruction test commands.
Ben Pfaff [Thu, 7 Aug 2014 23:03:42 +0000 (16:03 -0700)]
ovs-ofctl: Generalize action and instruction test commands.

Until now, there were four of these commands: parse-ofp10-actions,
parse-ofp10-instructions, parse-ofp11-actions, parse-ofp11-instructions.
This is painful to add support for new OpenFlow versions and has a ton of
cut-and-paste code.  This commit generalizes the code to improve on both
of those points.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofp-actions: Centralize all OpenFlow action code for maintainability.
Ben Pfaff [Mon, 11 Aug 2014 19:50:36 +0000 (12:50 -0700)]
ofp-actions: Centralize all OpenFlow action code for maintainability.

Until now, knowledge about OpenFlow has been somewhat scattered around the
tree.  Some of it is in ofp-actions, some of it is in ofp-util, some in
separate files for individual actions, and most of the wire format
declarations are in include/openflow.  This commit centralizes all of that
in ofp-actions.

Encoding and decoding OpenFlow actions was previously broken up by OpenFlow
version.  This was OK with only OpenFlow 1.0 and 1.1, but each additional
version added a new wrapper around the existing ones, which started to
become hard to understand.  This commit merges all of the processing for
the different versions, to the extent that they are similar, making the
version differences clearer.

Previously, ofp-actions contained OpenFlow encoding and decoding, plus
ofpact formatting, but OpenFlow parsing was separated into ofp-parse, which
seems an odd division.  This commit moves the parsing code into ofp-actions
with the rest of the code.

Before this commit, the four main bits of code associated with a particular
ofpact--OpenFlow encoding and decoding, ofpact formatting and parsing--were
all found far away from each other.  This often made it hard to see what
was going on for a particular ofpact, since you had to search around to
many different pieces of code.  This commit reorganizes so that all of the
code for a given ofpact is in a single place.

As a code refactoring, this commit has little visible behavioral change.
The update to ofproto-dpif.at illustrates one minor bug fix as a side
effect: a flow that was added with the action "dec_ttl" (a standard
OpenFlow action) was previously formatted as "dec_ttl(0)" (using a Nicira
extension to specifically direct packets bounced to the controller because
of too-low TTL), but after this commit it is correctly formatted as
"dec_ttl".

The other visible effect is to drop support for the Nicira extension
dec_ttl action in OpenFlow 1.1 and later in favor of the equivalent
standard action.  It seems unlikely that anyone was really using the
Nicira extension in OF1.1 or later.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofp-actions: Pretend that OpenFlow 1.0 has instructions.
Ben Pfaff [Thu, 7 Aug 2014 23:09:07 +0000 (16:09 -0700)]
ofp-actions: Pretend that OpenFlow 1.0 has instructions.

This allows callers to be more uniform, because they don't have to pick
out whether they should parse actions or instructions based on the OpenFlow
version in use.  It also allows the Write-Metadata instruction emulation
in OpenFlow 1.0 to be treated just as in OpenFlow 1.1 in the sense that
it is allowed in contexts where instructions are allowed in OpenFlow 1.1
and not elsewhere.  (The changes in the tests reflect this more accurate
treatment.)

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofp-parse: Make string conversion functions available outside this file.
Ben Pfaff [Sat, 26 Jul 2014 00:21:14 +0000 (17:21 -0700)]
ofp-parse: Make string conversion functions available outside this file.

An upcoming commit will use them from ofp-actions.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoovs-ofctl: Fix error message in "parse-ofp10-actions" internal command.
Ben Pfaff [Wed, 6 Aug 2014 21:07:55 +0000 (14:07 -0700)]
ovs-ofctl: Fix error message in "parse-ofp10-actions" internal command.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoovs-ofctl: Un-document "apply_actions" because it does not exist.
Ben Pfaff [Sat, 26 Jul 2014 00:14:14 +0000 (17:14 -0700)]
ovs-ofctl: Un-document "apply_actions" because it does not exist.

"apply_actions" is assumed, any other instruction has to be specified
explicitly.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofproto: Implement OpenFlow 1.3+ table features request.
Ben Pfaff [Mon, 11 Aug 2014 19:42:35 +0000 (12:42 -0700)]
ofproto: Implement OpenFlow 1.3+ table features request.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofp-util: Fix table features decoding of match and mask.
Ben Pfaff [Mon, 4 Aug 2014 16:02:15 +0000 (09:02 -0700)]
ofp-util: Fix table features decoding of match and mask.

The call to parse_oxms() inside ofputil_decode_table_features() sets only
one bit in either 'match' or 'mask' for a given field that is matchable:
in 'mask' if the field is arbitrarily maskable or in 'match' otherwise.
The code at the end of ofputil_decode_table_features() mishandled this,
assuming that an arbitrarily matchable field would have that bit set in
both.  This meant that arbitrarily matchable fields were being
misinterpreted as not matchable at all.  This commit fixes the problem.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofp-util: Fix table features decoding of action and instruction fields.
Ben Pfaff [Sun, 3 Aug 2014 18:10:00 +0000 (11:10 -0700)]
ofp-util: Fix table features decoding of action and instruction fields.

Parsing of actions was wrong because OF1.3 says that non-experimenter
actions are 4 bytes and don't include padding.  This fixes the problem.

Parsing of instructions seems wrong too because OF1.3 says that
non-experimenter instructions are 4 bytes (though it is not explicit about
padding as it is for actions).  This fixes the problem there too.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofp-util: Fix table features decoding of multiple tables.
Ben Pfaff [Mon, 28 Jul 2014 18:46:36 +0000 (11:46 -0700)]
ofp-util: Fix table features decoding of multiple tables.

Table features replies can be packed back-to-back within a single
multipart reply.  The code here didn't properly parse properties when this
occurred.  This fixes the problem.

There is no test in the current tree that exercises this decoding, but an
upcoming commit that adds ofproto support for table-features requests will
add one.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofp-util: Abstract table miss configuration and fix related bugs.
Ben Pfaff [Mon, 11 Aug 2014 18:31:45 +0000 (11:31 -0700)]
ofp-util: Abstract table miss configuration and fix related bugs.

The ofproto implementation has had an abstraction layer on top of
OFPTC11_TABLE_MISS for a while.  This commit pushes that abstraction layer
farther down, into ofp-util.  This will be more useful in an upcoming
commit.

During the conversion I realized that the previous implementation was
not entirely correct.  In particular, the OpenFlow 1.3+ "table mod" was
still being treated as if it had table miss configuration bits, even
though it doesn't.  This commit fixes that issue and updates the tests.

OpenFlow 1.4 adds some more OFPTC_* flags that this new abstraction doesn't
yet support, but OVS didn't support those flags any better before this
commit, so abstracting those is left as future work.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofproto: Correctly report table miss configuration in table stats.
Ben Pfaff [Mon, 28 Jul 2014 18:08:36 +0000 (11:08 -0700)]
ofproto: Correctly report table miss configuration in table stats.

OFPTC11_TABLE_MISS_MASK isn't a valid value at all, let alone always the
value in use.  We should report the value actually in use, as this commit
does.

There is a remaining problem: the default table configuration is
OFPROTO_TABLE_MISS_DEFAULT, which doesn't correspond to any particular
OFPTC11_* value or, more precisely, corresponds to a different OFPTC11_*
value based on the OpenFlow version.  The following commit fixes that
problem.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofp-actions: Add instructions bitmaps and fix related bug.
Ben Pfaff [Mon, 11 Aug 2014 18:07:53 +0000 (11:07 -0700)]
ofp-actions: Add instructions bitmaps and fix related bug.

This will allow, later, to centralize all of the knowledge of instruction
encoding inside ofp-actions.

OFPIT11_ALL and OFPIT13_ALL are no longer used, so this commit removes
them.  Their definitions were wrong (they did not shift each bit into
position correctly), so this commit is also a small bug fix.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofp-actions: Add action bitmap abstraction.
Ben Pfaff [Mon, 11 Aug 2014 17:57:03 +0000 (10:57 -0700)]
ofp-actions: Add action bitmap abstraction.

Until now, sets of actions have been abstracted separately outside
ofp-actions, as enum ofputil_action_bitmap.  Drawing sets of actions into
ofp-actions, as done in this commit, makes for a better overall
abstraction of actions, with better consistency.

A big part of this commit is shifting from using ofp12_table_stats as if
it were an abstraction for OpenFlow table stats, toward using a new
struct ofputil_table_stats, which is what we generally do with other
OpenFlow structures and fits better with the rest of the code.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agodatapath/flow_netlink: Validate IPv6 flow key and mask values.
Jarno Rajahalme [Mon, 11 Aug 2014 15:38:58 +0000 (08:38 -0700)]
datapath/flow_netlink: Validate IPv6 flow key and mask values.

Reject flow label key and mask values with invalid bits set.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
9 years agodatapath/actions: Mark recalculate_csum as likely in set_ipv6_addr().
Jarno Rajahalme [Mon, 11 Aug 2014 15:38:58 +0000 (08:38 -0700)]
datapath/actions: Mark recalculate_csum as likely in set_ipv6_addr().

The â€˜recalculate_csum’ is almost always â€˜true’.  It is false only if
the ipv6 nexthdr is an extension header, and a routing header is
found.  For the majority of ipv6 packets this would not be the case,
so this can be marked as 'likely'.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
9 years agodatapath: Avoid NULL mask check while building mask
Pravin B Shelar [Fri, 8 Aug 2014 04:26:35 +0000 (21:26 -0700)]
datapath: Avoid NULL mask check while building mask

OVS does mask validation even if it does not need to convert
netlink mask attributes to mask structure.  ovs_nla_get_match()
caller can pass NULL mask structure pointer if the caller does
not need mask.  Therefore NULL check is required in SW_FLOW_KEY*
macros.  Following patch does not convert mask netlink attributes
if mask pointer is NULL, so we do not need these checks in
SW_FLOW_KEY* macro.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Andy Zhou <azhou@nicira.com>
9 years agodatapath: Optimize recirc action.
Pravin B Shelar [Thu, 7 Aug 2014 22:46:19 +0000 (15:46 -0700)]
datapath: Optimize recirc action.

OVS need to flow key for flow lookup in recic action. OVS
does key extract in recic action. Most of cases we could
use OVS_CB packet key directly and can avoid packet flow key
extract. SET action we can update flow-key along with packet
to keep it consistent. But there are some action like MPLS
pop which forces OVS to do flow-extract. In such cases we
can mark flow key as invalid so that subsequent recirc
action can do full flow extract.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
9 years agolib/flow: Update FLOW_WC_SEQ to skip assertions on miniflow_extract()
Daniele Di Proietto [Fri, 8 Aug 2014 17:15:57 +0000 (10:15 -0700)]
lib/flow: Update FLOW_WC_SEQ to skip assertions on miniflow_extract()

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agodatapath: Avoid using stack larger than 1024.
Pravin B Shelar [Fri, 8 Aug 2014 03:34:20 +0000 (20:34 -0700)]
datapath: Avoid using stack larger than 1024.

commit (datapath: Refactor action alloc and copy api) effectively
reverted 1d2a1b5f5252e4c6ce8bbf8d91ca27aba52496e6 (datapath: Factor out
allocation and verification of actions.). This results in following
warning:

CC [M]  /home/jesse/openvswitch/datapath/linux/datapath.o
/home/jesse/openvswitch/datapath/linux/datapath.c: In function
‘ovs_flow_cmd_set’:
/home/jesse/openvswitch/datapath/linux/datapath.c:1094:1: warning: the
frame size of 1256 bytes is larger than 1024 bytes
[-Wframe-larger-than=]
 }

Following patch introduced the factoring back.

CC: Jesse Gross <jesse@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
9 years agosocket-util-unix: Fix umask race in bind_unix_socket().
Ben Pfaff [Thu, 7 Aug 2014 23:25:05 +0000 (16:25 -0700)]
socket-util-unix: Fix umask race in bind_unix_socket().

The umask is a process-wide value, so bind_unix_socket() races with file
creation in other Open vSwitch threads.  This fixes the race.

The workaround for non-Linux systems is not ideal, but I do not know any
other general solution.  I tested the workaround only on Linux.

CC: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Flavio Leitner <fbl@redhat.com>
9 years agoofp-util: Remove prototypes for unimplemented functions.
Ben Pfaff [Thu, 7 Aug 2014 23:19:32 +0000 (16:19 -0700)]
ofp-util: Remove prototypes for unimplemented functions.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agodatapath: Refactor action alloc and copy api.
Pravin B Shelar [Thu, 7 Aug 2014 19:51:14 +0000 (12:51 -0700)]
datapath: Refactor action alloc and copy api.

There are two separate API to allocate and copy actions list. Anytime
OVS needs to copy action list, it needs to call both functions.
Following patch moves action allocation to copy function to avoid
code duplication.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agodatapath: Update comments about 'OVS_KEY_ATTR_8021Q'.
Justin Pettit [Wed, 6 Aug 2014 21:15:52 +0000 (14:15 -0700)]
datapath: Update comments about 'OVS_KEY_ATTR_8021Q'.

Commit fea393b1 (datapath: Describe policy for extending flow key,
implement needed changes.) changed the key 'OVS_KEY_ATTR_8021Q' to
'OVS_KEY_ATTR_VLAN' and the size of the attribute structure.  A couple
of comments were missed, so this commit updates them.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
9 years agodatapath: Use tun_info only for egress tunnel path.
Pravin B Shelar [Tue, 5 Aug 2014 20:49:57 +0000 (13:49 -0700)]
datapath: Use tun_info only for egress tunnel path.

Currently tun_info is used for passing tunnel information
on ingress and egress path, this cause confusion.  Following
patch removes its use on ingress path make it egress only parameter.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
9 years agodatapath: Optimize Flow mask cache hash collision case.
Pravin B Shelar [Tue, 5 Aug 2014 17:47:23 +0000 (10:47 -0700)]
datapath: Optimize Flow mask cache hash collision case.

In case hash collision on mask cache, OVS does extra flow lookup.
Following patch avoid it.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agodatapath: Avoid using wrong metadata for recic action.
Pravin B Shelar [Tue, 5 Aug 2014 20:43:45 +0000 (13:43 -0700)]
datapath: Avoid using wrong metadata for recic action.

Recirc action needs to extract flow key from packet, it uses tun_info
from OVS_CB for setting tunnel meta data in flow key. But tun_info
can be overwritten by tunnel send action. This would result in wrong
flow key for the recirculation.
Following patch copies flow-key meta data from OVS_CB packet key
itself thus avoids this bug.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
9 years agodatapath: refactor ovs flow extract API.
Pravin B Shelar [Tue, 29 Jul 2014 22:25:02 +0000 (15:25 -0700)]
datapath: refactor ovs flow extract API.

OVS flow extract is called on packet receive or packet
execute code path.  Following patch defines separate API
for extracting flow-key in packet execute code path.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
9 years agotest-atomic: Fix warnings for GCC4.9 and sparse
Daniele Di Proietto [Thu, 7 Aug 2014 01:35:11 +0000 (01:35 +0000)]
test-atomic: Fix warnings for GCC4.9 and sparse

There's no reason for the local variable 'old_count' to be atomic. In fact, if
it is atomic it triggers a GCC4.9 warning (Wunused-value)
The global variables 'a' and 'paux' could be static, according to sparse.

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agodatapath-windows: Update ovsext.sln to properly build under "Win8 Debug".
Alin Serdean [Wed, 6 Aug 2014 01:28:08 +0000 (01:28 +0000)]
datapath-windows: Update ovsext.sln to properly build under "Win8 Debug".

"Win8 Debug" solution configuration  currently builds in fact under
"Win8.1 Debug".

This patch updates the configuration to properly build under "Win8 Debug".

Reported-at: https://github.com/openvswitch/ovs-issues/issues/7
Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Nithin Raju <nithin@vmware.com>
9 years agodatapath: Correct comment about 'tun_info' member in ovs_skb_cb.
Justin Pettit [Mon, 4 Aug 2014 23:00:40 +0000 (16:00 -0700)]
datapath: Correct comment about 'tun_info' member in ovs_skb_cb.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
9 years agoclassifier: classifier_lookup_miniflow_batch() indicate failures.
Ethan Jackson [Mon, 28 Jul 2014 00:51:48 +0000 (17:51 -0700)]
classifier: classifier_lookup_miniflow_batch() indicate failures.

This patch causes classifier_lookup_miniflow_batch() to return a
boolean indicating whether any rules could not be successfully looked
up.  Used in future patches.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agodpif-netdev: Avoid useless flow copy in dp_netdev_flow_add().
Ethan Jackson [Mon, 28 Jul 2014 01:56:45 +0000 (18:56 -0700)]
dpif-netdev: Avoid useless flow copy in dp_netdev_flow_add().

This patch gives dp_netdev_flow_add() a match with which it can
initialize the classifier rule.  This prevents it from needing to copy
a flow and flow_wildcards into the match first.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agoovs-dev.py: Support check-valgrind in the Makefile.
Ethan Jackson [Sat, 2 Aug 2014 01:15:14 +0000 (18:15 -0700)]
ovs-dev.py: Support check-valgrind in the Makefile.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agostyle: Replace TODO with XXX.
Ethan Jackson [Mon, 28 Jul 2014 20:37:24 +0000 (13:37 -0700)]
style: Replace TODO with XXX.

In accordance with CodingStyle.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agolib/ovs-atomic: Native support for 32-bit 586 with GCC.
Jarno Rajahalme [Tue, 5 Aug 2014 20:51:19 +0000 (13:51 -0700)]
lib/ovs-atomic: Native support for 32-bit 586 with GCC.

XenServer runs OVS in dom0, which is a 32-bit VM.  As the build
environment lacks support for atomics, locked pthread atomics were
used with considerable performance hit.

This patch adds native support for ovs-atomic with 32-bit Pentium and
higher CPUs, when compiled with an older GCC.  We use inline asm with
the cmpxchg8b instruction, which was a new instruction to Intel
Pentium processors.  We do not expect anyone to run OVS on 486 or older
processor.

cmap benchmark before the patch on 32-bit XenServer build (uses
ovs-atomic-pthread):

$ tests/ovstest test-cmap benchmark 2000000 8 0.1
Benchmarking with n=2000000, 8 threads, 0.10% mutations:
cmap insert:   8835 ms
cmap iterate:   379 ms
cmap search:   6242 ms
cmap destroy:  1145 ms

After:

$ tests/ovstest test-cmap benchmark 2000000 8 0.1
Benchmarking with n=2000000, 8 threads, 0.10% mutations:
cmap insert:    711 ms
cmap iterate:    68 ms
cmap search:    353 ms
cmap destroy:   209 ms

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agolib/ovs-atomic: Native support for x86_64 with GCC.
Jarno Rajahalme [Tue, 5 Aug 2014 20:51:19 +0000 (13:51 -0700)]
lib/ovs-atomic: Native support for x86_64 with GCC.

Some supported XenServer build environments lack compiler support for
atomic operations.  This patch provides native support for x86_64 on
GCC, which covers possible future 64-bit builds on XenServer.

Since this implementation is faster than the existing support prior to
GCC 4.7, especially for cmap inserts, we use this with GCC < 4.7 on
x86_64.

Example numbers with "tests/test-cmap benchmark 2000000 8 0.1" on
quad-core hyperthreaded laptop, built with GCC 4.6 -O2:

Using ovs-atomic-pthreads on x86_64:

Benchmarking with n=2000000, 8 threads, 0.10% mutations:
cmap insert:   4725 ms
cmap iterate:   329 ms
cmap search:   5945 ms
cmap destroy:   911 ms

Using ovs-atomic-gcc4+ on x86_64:

Benchmarking with n=2000000, 8 threads, 0.10% mutations:
cmap insert:    845 ms
cmap iterate:    58 ms
cmap search:    308 ms
cmap destroy:   295 ms

With the native support provided by this patch:

Benchmarking with n=2000000, 8 threads, 0.10% mutations:
cmap insert:    530 ms
cmap iterate:    59 ms
cmap search:    305 ms
cmap destroy:   232 ms

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agotests/test-atomic: Cover more of the atomic API.
Jarno Rajahalme [Tue, 5 Aug 2014 20:51:19 +0000 (13:51 -0700)]
tests/test-atomic: Cover more of the atomic API.

This adds tests using all of the defined memory orders, as well as
simple two-thread test cases for the acquire-release and
consume-release patterns.

These new tests helped uncover a bug in the ovs-atomic-gcc4+
implementation, which was fixed in a preceding patch.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agolib/ovs-atomic-gcc4+: Use 'volatile' to enforce memory access.
Jarno Rajahalme [Tue, 5 Aug 2014 20:51:19 +0000 (13:51 -0700)]
lib/ovs-atomic-gcc4+: Use 'volatile' to enforce memory access.

Use 'volatile' to enforce a new memory access on each lockless atomic
store and read.  Without this a loop consisting of an atomic_read with
memory_order_relaxed would be simply optimized away.  Also, using
volatile is cheaper than adding a full compiler barrier (also) in that
case.

This use of a volatile cast mirrors the Linux kernel ACCESS_ONCE macro.

Without this change the more rigorous atomic test cases introduced in
a following patch will hang due to the atomic accesses being optimized
away.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agoovs-atomic: Fix GCC4+ atomic_flag.
Jarno Rajahalme [Tue, 5 Aug 2014 20:51:19 +0000 (13:51 -0700)]
ovs-atomic: Fix GCC4+ atomic_flag.

The default memory order for atomic_flag is documented to be
memory_order_seq_cst (as in C11), but the GCC4+ implementation only
used the GCC builtins, which provide acquire and release semantics
only.  Additional barriers are needed for in other cases.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agolib/ovs-atomic: Require memory_order be constant.
Jarno Rajahalme [Tue, 5 Aug 2014 20:51:19 +0000 (13:51 -0700)]
lib/ovs-atomic: Require memory_order be constant.

Compiler implementations may provide sub-optimal support for a
memory_order passed in as a run-time value (ref.
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html).

Document that OVS atomics require the memory order to be passed in as
a compile-time constant.

It should be noted, however, that when inlining is disabled (i.e.,
compiling without optimization) even compile-time constants may be
passed as run-time values to (non-inlined) functions.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agolib/ovs-atomic: Elaborate memory_order documentation.
Jarno Rajahalme [Tue, 5 Aug 2014 20:51:19 +0000 (13:51 -0700)]
lib/ovs-atomic: Elaborate memory_order documentation.

The definition of memory_order_relaxed included a compiler barrier,
while it is not necessary, and indeed the following text on
atomic_thread_fence and atomic_signal_fence contradicted that.

memory_order_consume and memory_order_acq_rel are also more thoroughly
described.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agoFix strict aliasing violations with GCC 4.1 and 4.4.
Jarno Rajahalme [Tue, 5 Aug 2014 20:51:19 +0000 (13:51 -0700)]
Fix strict aliasing violations with GCC 4.1 and 4.4.

The typical use of struct sockaddr_storage is flagged as a strict
aliasing violation by GCC 4.4.7.  Using an explicit union lets the
compiler know that accessing the same location via different types is
not an error.

GCC 4.1.2 had a similar complaint about a cast of ukey's key_buf to
nlattr.  After this patch there are no further warnings with the
XenServer build, so we could start treating warnings as errors in the
builds.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Rename solution name.
Samuel Ghinet [Tue, 5 Aug 2014 20:25:37 +0000 (20:25 +0000)]
datapath-windows: Rename solution name.

extensions.sln is the name of the MS sample solution.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Nithin Raju <nithin@vmware.com>
9 years agoINSTALL.Windows: Update build instructions to do 'make'.
Nithin Raju [Tue, 5 Aug 2014 23:30:31 +0000 (23:30 +0000)]
INSTALL.Windows: Update build instructions to do 'make'.

We no-longer need to build individual targets on Windows. This information
was lost when we committed the hyper-v changes to the repo.

Resurrecting that information in this change.

Also, added the testing instructions on how to setup a VLAN based network.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
9 years agotests: Turn off appctl poll_loop logging for long output.
Ben Pfaff [Tue, 29 Jul 2014 16:54:17 +0000 (09:54 -0700)]
tests: Turn off appctl poll_loop logging for long output.

One of the VMware internal autobuilder builds failed due to extraneous
logging in these tests of the form:

   2014-07-28T21:11:07Z|00001|poll_loop|INFO|wakeup due to [POLLIN] on fd 3
   (...) at lib/stream-fd-unix.c:124 (93% CPU usage)

I think this must be because these tests have tons of output and so on a
loaded machine it can take some CPU to pull it down.  We don't want to fail
for that reason, so disable this logging.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ansis Atteka <aatteka@nicira.com>
9 years agoovs-appctl: Add logging options.
Ben Pfaff [Mon, 4 Aug 2014 19:36:04 +0000 (12:36 -0700)]
ovs-appctl: Add logging options.

Normally I would also add documentation for the logging options to the
ovs-appctl manpage, but I am concerned that in this case it would actually
make the manpage confusing, because one of the main purposes of ovs-appctl
is to modify the log levels of *other* programs, and these options only
modify the log level of ovs-appctl itself, which is rarely useful.

The following commit will start using these logging options in a test.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ansis Atteka <aatteka@nicira.com>
9 years agodpctl: add ovs-appctl dpctl/* commands to talk to dpif-netdev
Daniele Di Proietto [Fri, 18 Jul 2014 00:26:00 +0000 (17:26 -0700)]
dpctl: add ovs-appctl dpctl/* commands to talk to dpif-netdev

This commit introduces multiple appctl commands (dpctl/*)

They are needed to interact with userspace datapaths (dpif-netdev), because the
ovs-dpctl command runs in a separate process and cannot see the userspace
datapaths inside vswitchd.

This change moves most of the code of utilities/ovs-dpctl.c in lib/dpctl.c.

Both the ovs-dpctl command and the ovs-appctl dpctl/* commands make calls to
lib/dpctl.c functions, to interact with datapaths.

The code from utilities/ovs-dpctl.c has been moved to lib/dpctl.c and has been
changed for different reasons:
   - An exit() call in the old code made perfectly sense. Now (since the code
     can be run inside vswitchd) it would terminate the daemon. Same reasoning
     can be applied to ovs_fatal_*() calls.
   - The lib/dpctl.c code _should_ not leak memory.
   - All the print* have been replaced with a function pointer provided by the
     caller, since this code can be run in the ovs-dpctl process (in which
     case we need to print to stdout) or in response to a unixctl request (and
     in this case we need to send everything through a socket, using JSON
     encapsulation).

The syntax is
   ovs-appctl dpctl/(COMMAND) [OPTIONS] [PARAMETERS]
while the ovs-dpctl syntax (which _should_ remain the same after this change)
is
   ovs-dpctl [OPTIONS] (COMMAND) [PARAMETERS]

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
[blp@nicira.com made stylistic and documentation changes]
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoofproto-dpif: Fix tests broken by previous commit.
Ben Pfaff [Mon, 4 Aug 2014 19:46:37 +0000 (12:46 -0700)]
ofproto-dpif: Fix tests broken by previous commit.

This fixes tests that were broken by commit a7d1bbdcfe (ofproto-dpif: Use
DPIF_FP_CREATE but not DPIF_FP_MODIFY.)

Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoofproto-dpif: fix an ovs crash when dpif_recv_set returns error
Andy Zhou [Sun, 3 Aug 2014 23:16:40 +0000 (16:16 -0700)]
ofproto-dpif: fix an ovs crash when dpif_recv_set returns error

When dpif_recv_set returns an error, close_dpif_backer gets called,
which in term calls recirc_id_pool_destroy, which can lead to a crash
since recirc_id_pool_create() was not called before this patch.

Reported-by: Mukesh Hira <mhira@vmware.com>
Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agoofproto-dpif: Use DPIF_FP_CREATE but not DPIF_FP_MODIFY.
Ben Pfaff [Sat, 2 Aug 2014 00:22:20 +0000 (17:22 -0700)]
ofproto-dpif: Use DPIF_FP_CREATE but not DPIF_FP_MODIFY.

A dpif reports EEXIST if a flow put operation that should create a new flow
instead attempts to modify an existing flow, or ENOENT if a flow put would
create a flow that overlaps some existing flow.  The latter does not always
indicate a bug in OVS userspace, because it can also mean that two
userspace OVS packet handler threads received packets that generated
the same megaflow for different microflows.  Until now, userspace has
logged this, which confuses users by making them suspect a bug.  We could
simply not log ENOENT in userspace, but that would suppress logging for
genuine bugs too.  Instead, this commit drops DPIF_FP_MODIFY from flow
put operations in ofproto-dpif, which transforms this particular
problem into EEXIST, which userspace already logs at "debug" level (see
flow_message_log_level()), effectively suppressing the logging in normal
circumstances.

It appears that in practice ofproto-dpif doesn't actually ever need to
modify flows in the datapath, only create and delete them, so this
shouldn't cause problems.

Suggested-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
9 years agoodp-netlink.h: Use 32-bit aligned 64-bit types.
Ben Pfaff [Fri, 13 Jun 2014 22:28:29 +0000 (15:28 -0700)]
odp-netlink.h: Use 32-bit aligned 64-bit types.

Open vSwitch userspace uses special types to indicate that a particular
object may not be naturally aligned.  Netlink is one source of such
problems: in Netlink, 64-bit integers are often aligned only on 32-bit
boundaries.  This commit changes the odp-netlink.h that is transformed from
<linux/openvswitch.h> to use these types to make it harder to accidentally
access a misaligned 64-bit member.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
9 years agoDo not seemingly #include Linux-specific headers on other platforms.
Ben Pfaff [Mon, 4 Aug 2014 18:11:40 +0000 (11:11 -0700)]
Do not seemingly #include Linux-specific headers on other platforms.

Until now, the OVS source tree has had a whole maze of header files that
make "#include <linux/openvswitch.h>" work OK regardless of platform, but
this confuses everyone new to the tree, at first glance, and is difficult
to understand at second glance too.

This commit renames include/linux/openvswitch.h to
datapath/linux/compat/include/linux/openvswitch.h without other change,
then modifies the userspace build to generate a header that makes sense in
portable Open vSwitch userspace from that header.

It then removes all the remaining include/linux/* files since they are now
unused.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
9 years agodatapath: do not use vport type to determine presence of Geneve attributes
Ansis Atteka [Tue, 29 Jul 2014 22:39:35 +0000 (15:39 -0700)]
datapath: do not use vport type to determine presence of Geneve attributes

This patch fixes following kernel crash that could happen, if geneve
vport was not added yet, but revalidator thread attempted to dump flows.
To reproduce:
1. switch tunnel type between geneve and gre in a loop; and
2. run ping.

BUG: unable to handle kernel NULL pointer dereference at 0000000000000048
IP: [<ffffffffa0385470>] ovs_nla_put_flow+0x3d0/0x7c0 [openvswitch]
PGD 3b32b067 PUD 3b2ef067 PMD 0
Oops: 0000 [#2] SMP
...
CPU: 0 PID: 6450 Comm: revalidator2 Tainted: GF     D    O
3.13.0-24-generic #46-Ubuntu
Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference
Platform, BIOS 6.00 07/02/2012
task: ffff88003b4aafe0 ti: ffff88003d314000 task.ti: ffff88003d314000
RIP: 0010:[<ffffffffa0385470>]  [<ffffffffa0385470>]
ovs_nla_put_flow+0x3d0/0x7c0 [openvswitch]
RSP: 0018:ffff88003d315a10  EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff88003a9a9960 RCX: 0000000000000000
RDX: 0000000000000002 RSI: ffffffffffffffc8 RDI: ffff88003babcb80
RBP: ffff88003d315a68 R08: 0000000000000000 R09: 0000000000000004
R10: ffff880039c23034 R11: 0000000000000008 R12: ffff88003a861600
R13: ffff88003a9a9960 R14: ffff88003babcb80 R15: qffff88003a861600
FS:  00007ff0f5d94700(0000) GS:ffff88003f600000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000048 CR3: 000000003b55b000 CR4: 00000000000007f0
Stack:
ffffffff81385093 0000000000000000 0000000000000000 0000000000000000
ffff880000000000 ffff88003d315a58 ffff880039c23014 ffff88003a9a97a0
ffff88003babcb80 ffff880039c23018 ffff88003a861600 ffff88003d315ad0
Call Trace:
[<ffffffff81385093>] ? __nla_reserve+0x43/0x50
[<ffffffffa037e683>] ovs_flow_cmd_fill_info+0x93/0x2b0 [openvswitch]
[<ffffffffa0387159>] ? ovs_flow_tbl_dump_next+0x49/0xc0 [openvswitch]
[<ffffffffa037e920>] ovs_flow_cmd_dump+0x80/0xd0 [openvswitch]
[<ffffffff81645004>] netlink_dump+0x84/0x240
[<ffffffff816458eb>] __netlink_dump_start+0x1ab/0x220
[<ffffffff816498d7>] genl_family_rcv_msg+0x337/0x370
[<ffffffffa037e8a0>] ? ovs_flow_cmd_fill_info+0x2b0/0x2b0 [openvswitch]
[<ffffffff811a2778>] ? __kmalloc_node_track_caller+0x58/0x1e0
[<ffffffff81649910>] ? genl_family_rcv_msg+0x370/0x370
[<ffffffff816499a1>] genl_rcv_msg+0x91/0xd0
[<ffffffff81647a29>] netlink_rcv_skb+0xa9/0xc0
[<ffffffff81647f28>] genl_rcv+0x28/0x40
[<ffffffff81647055>] netlink_unicast+0xd5/0x1b0
[<ffffffff8164742f>] netlink_sendmsg+0x2ff/0x740
[<ffffffff816024eb>] sock_sendmsg+0x8b/0xc0
[<ffffffff811bbaa1>] ? __sb_end_write+0x31/0x60
[<ffffffff811d42bf>] ? touch_atime+0x10f/0x140
[<ffffffff811c2471>] ? pipe_read+0x371/0x400
[<ffffffff81602691>] SYSC_sendto+0x121/0x1c0
[<ffffffff8109dd84>] ? vtime_account_user+0x54/0x60
[<ffffffff81020d35>] ? syscall_trace_enter+0x145/0x250
[<ffffffff8160319e>] SyS_sendto+0xe/0x10
[<ffffffff8172663f>] tracesys+0xe1/0xe6

Signed-Off-By: Ansis Atteka <aatteka@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
9 years agodatapath-windows: Fix crash when internal port is removed.
Eitan Eliahu [Sat, 2 Aug 2014 00:11:51 +0000 (17:11 -0700)]
datapath-windows: Fix crash when internal port is removed.

Avoids a BSOD when AllowManagementOS is set to false.

Reported-at: https://github.com/openvswitch/ovs/issues/13
Reported-by: Alin Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Eitan Eliahu <eliahue@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Nithin Raju <nithin@vmware.com>
9 years agobitmap: Add test for bitmap_equal and bitmap_scan
Kmindg [Thu, 31 Jul 2014 05:16:04 +0000 (13:16 +0800)]
bitmap: Add test for bitmap_equal and bitmap_scan

Suggested-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Kmindg <kmindg@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Add temporary files to gitignore.
Saurabh Shah [Wed, 30 Jul 2014 20:29:54 +0000 (20:29 +0000)]
datapath-windows: Add temporary files to gitignore.

Github Issue: #12

Reported-by: Alin Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Saurabh Shah <ssaurabh@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
9 years agodatapath: Remove unlikely() for WARN_ON() conditions
Thomas Graf [Thu, 31 Jul 2014 01:05:01 +0000 (18:05 -0700)]
datapath: Remove unlikely() for WARN_ON() conditions

No need for the unlikely(), WARN_ON() and BUG_ON() internally use
unlikely() on the condition.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
9 years agodatapath-windows: Rename the extension & vendor in the INF file.
Saurabh Shah [Wed, 30 Jul 2014 16:03:20 +0000 (09:03 -0700)]
datapath-windows: Rename the extension & vendor in the INF file.

Github issue: #14

Signed-off-by: Saurabh Shah <ssaurabh@vmware.com>
Reported-by: Alessandro Pilotti <apilotti@cloudbasesolutions.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
9 years agodatapath: Remove redundant key ref from upcall_info.
Pravin B Shelar [Tue, 29 Jul 2014 17:04:52 +0000 (10:04 -0700)]
datapath: Remove redundant key ref from upcall_info.

struct dp_upcall_info has pointer to pkt_key which is already
available in OVS_CB.  This also simplifies upcall handling
for gso packet.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
9 years agodatapath: Drop packets when interdev is not up
Chunhe Li [Wed, 30 Jul 2014 01:49:01 +0000 (09:49 +0800)]
datapath: Drop packets when interdev is not up

If the internal device is not up, it should drop received
packets. Sometimes it receive the broadcast or multicast
packets, and the ip protocol stack will casue more cpu
usage wasted.

Signed-off-by: Chunhe Li <lichunhe@huawei.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
9 years agoconnmgr: Make call to connmgr_wants_packet_in_on_miss() thread safe.
Alex Wang [Tue, 29 Jul 2014 17:50:07 +0000 (10:50 -0700)]
connmgr: Make call to connmgr_wants_packet_in_on_miss() thread safe.

connmgr_wants_packet_in_on_miss() is called by multiple threads
and thusly should be protected by the mutex.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
9 years agoconnmgr: Fix a typo.
Alex Wang [Tue, 29 Jul 2014 18:10:21 +0000 (11:10 -0700)]
connmgr: Fix a typo.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
9 years agotests: Add another test for extended registers.
Ben Pfaff [Tue, 29 Jul 2014 16:27:11 +0000 (09:27 -0700)]
tests: Add another test for extended registers.

ONF-JIRA: EXT-244
Suggested-by: Jean Tourrilhes <jt@hpl.hp.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jean Tourrilhes <jt@hpl.hp.com>
9 years agoAdd more files to the openvswitch library on MSVC
Alin Serdean [Tue, 29 Jul 2014 15:24:08 +0000 (15:24 +0000)]
Add more files to the openvswitch library on MSVC

Add netlink related files to the windows build.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agonetlink-socket: Adapt to Windows and MSVC.
Alin Serdean [Tue, 29 Jul 2014 15:23:28 +0000 (15:23 +0000)]
netlink-socket: Adapt to Windows and MSVC.

Add two functions set_sock_pid_in_kernel and portid_next. This will allow
the channel identification for the kernel extension to send back messages.

Replace send with WriteFile equivalent and ignore nl_sock_drain for the moment
under MSVC.

Replace sendmsg and recvmsg with ReadFile and WriteFile equivalents.

On MSVC put in handle instead of fd(sock->fd becomes sock->handle).

Creation of the netlink socket will be replaced by CreateFile equivalent.

Add MAX_STACK_LENGTH for MSVC.  This will be our maximum size for on-stack
copy buffer.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agonetlink-socket: Allow compiling on MSVC even without HAVE_NETLINK.
Alin Serdean [Tue, 29 Jul 2014 15:22:37 +0000 (15:22 +0000)]
netlink-socket: Allow compiling on MSVC even without HAVE_NETLINK.

Bypass the error compilation when compiling under MSVC.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agonetlink-protocol: Add more definitions.
Alin Serdean [Tue, 29 Jul 2014 15:22:03 +0000 (15:22 +0000)]
netlink-protocol: Add more definitions.

Add MAX_LINKS define needed for nl_pool.

Add NLM_F_CREATE and NLM_F_EXCL defines also.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoAdd defines, enums and headers for MSVC
Alin Serdean [Tue, 29 Jul 2014 15:21:16 +0000 (15:21 +0000)]
Add defines, enums and headers for MSVC

Add defines needed to compile netlink-socket.c and netlink.c.

Add a wrapper and the functionality behind it for syconf.

Add the newly created files to the noinst_HEADERS in windows/automake.mk

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agocmap: Merge CMAP_FOR_EACH_SAFE into CMAP_FOR_EACH.
Ben Pfaff [Tue, 29 Jul 2014 16:02:23 +0000 (09:02 -0700)]
cmap: Merge CMAP_FOR_EACH_SAFE into CMAP_FOR_EACH.

There isn't any significant downside to making cmap iteration "safe" all
the time, so this drops the _SAFE variant.

Similar changes to CMAP_CURSOR_FOR_EACH and CMAP_CURSOR_FOR_EACH_CONTINUE.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agonetlink-socket: Add conceptual documentation.
Ben Pfaff [Tue, 29 Jul 2014 15:59:40 +0000 (08:59 -0700)]
netlink-socket: Add conceptual documentation.

Based on a conversation with the VMware Hyper-V team earlier today.

This commit also changes a couple of functions that were only used with
netlink-socket.c into static functions.  I couldn't think of a reason for
code outside that file to use them.

Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath: Use currect rcu API in exact match flow lookup function.
Pravin B Shelar [Sat, 26 Jul 2014 03:34:48 +0000 (20:34 -0700)]
datapath: Use currect rcu API in exact match flow lookup function.

exact match cache lookup is always done under ovs lock. So
use ovsl_dereference() API for rcu access.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
9 years agoconnmgr: Only send role status messages to OpenFlow 1.4+ controllers.
Ben Pfaff [Tue, 22 Jul 2014 22:54:55 +0000 (15:54 -0700)]
connmgr: Only send role status messages to OpenFlow 1.4+ controllers.

Only OpenFlow 1.4 and later support role status messages, but this code
tried to send them to all controllers, which caused an assertion failure.

Also, add tests to check that role status messages work, and that they
don't cause trouble with OF1.2.

Reported-by: Anup Khadka <khadka.py@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
9 years agoconnmgr: Demote service controllers too in ofconn_set_role().
Ben Pfaff [Mon, 28 Jul 2014 17:17:56 +0000 (10:17 -0700)]
connmgr: Demote service controllers too in ofconn_set_role().

Service controllers can set their roles, so it's necessary to demote them
to slaves if another controller becomes master.  Unfortunately the
'controllers' hmap only contains primary controllers, so this was omitted.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
9 years agoovs-ofctl: Add --unixctl command line option.
Ben Pfaff [Mon, 28 Jul 2014 17:31:25 +0000 (10:31 -0700)]
ovs-ofctl: Add --unixctl command line option.

This matches the option offered by some other Open vSwitch daemons.  I
intend to use it in tests in an upcoming commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
9 years agodatapath-windows: Kernel module for HyperV.
Saurabh Shah [Mon, 28 Jul 2014 00:26:58 +0000 (17:26 -0700)]
datapath-windows: Kernel module for HyperV.

The kernel switch extension has support for bridged back forwarding & tunneling
over VXLAN. There is no Netlink integration as it is still being worked out.

Co-Authored-By: Ankur Sharma <ankursharma@vmware.com>
Signed-off-by: Ankur Sharma <ankursharma@vmware.com>
Co-Authored-By: Eitan Eliahu <eliahue@vmware.com>
Signed-off-by: Eitan Eliahu <eliahue@vmware.com>
Co-Authored-By: Guolin Yang <gyang@vmware.com>
Signed-off-by: Guolin Yang <gyang@vmware.com>
Co-Authored-By: Linda Sun <lsun@vmware.com>
Signed-off-by: Linda Sun <lsun@vmware.com>
Co-Authored-By: Nithin Raju <nithin@vmware.com>
Signed-off-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Saurabh Shah <ssaurabh@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agometa-flow: Add 64-bit registers.
Ben Pfaff [Mon, 28 Jul 2014 16:50:37 +0000 (09:50 -0700)]
meta-flow: Add 64-bit registers.

These 64-bit registers are intended to conform with the OpenFlow 1.5
draft specification.

EXT-244.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofproto-dpif-upcall: Fix sparse warnings.
Ben Pfaff [Sat, 26 Jul 2014 19:19:03 +0000 (12:19 -0700)]
ofproto-dpif-upcall: Fix sparse warnings.

Fixes these warnings from "sparse":

../ofproto/ofproto-dpif-upcall.c:761:1: warning: symbol 'free_upcall' was
    not declared. Should it be static?
../ofproto/ofproto-dpif-upcall.c:849:1: warning: symbol 'convert_upcall'
    was not declared. Should it be static?

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
9 years agoFix two memory leaks.
yinpeijun [Mon, 28 Jul 2014 07:21:17 +0000 (15:21 +0800)]
Fix two memory leaks.

Found by coverity.

Signed-off-by: yinpeijun <yinpeijun@huawei.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoRemove assumption that there are 64 or fewer fields.
Ben Pfaff [Sat, 26 Jul 2014 19:15:26 +0000 (12:15 -0700)]
Remove assumption that there are 64 or fewer fields.

An upcoming commit will increase the number of fields beyond 64.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>