cascardo/ovs.git
9 years agodatapath-windows: Rename switch context's nameHashArray and vport's nameLink login...
Alin Serdean [Thu, 9 Oct 2014 17:46:56 +0000 (17:46 +0000)]
datapath-windows: Rename switch context's nameHashArray and vport's nameLink login register

The field nameLink of the OVS_VPORT_ENTRY is the link within the
OVS_SWITCH_CONTEXT's hash array of vports nameHashArray, hashed by the
ovsName field of the OVS_VPORT_ENTRY.

Later on, the friendly name of the hyper-v switch port will need to be
set from userspace using WMI. This will require that the hyper-v switch
port friendly name be set to the exact string value as the ovs
(datapath) port name set from netlink command vport add.

The vport will need to differentiate between the ovs (datapath) port
name and hyper-v switch port friendly name, because they may differ in
erroneous scenarios, or state differences between the hyper-v switch
port and the ovs (datapath) port. This may happen if the vport was
created by the netlink command vport add, but the VM disconnected (i.e.
the hyper-v switch port was later deleted).

Storing another field in vport, "portFriendlyName" would normally
make the current switchContext->nameHashArray and vport->nameLink
confusing since the "name"-s may be understood to mean the hyper-v
switch port friendly name, or the hyper-v switch port name, when it
actually refers to the ovs (datapath) port name.

Hence, the variable nameHashArray is renamed to ovsPortNameHashArray,
while the nameLink is renamed to ovsPortNameLink. This change will make
a clearer connection between these and the vport field "ovsName" to
which they revolve around.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Co-authored-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Tested-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Rename OvsGetVportNo into OvsComputeVportNo and make public
Alin Serdean [Thu, 9 Oct 2014 17:46:56 +0000 (17:46 +0000)]
datapath-windows: Rename OvsGetVportNo into OvsComputeVportNo and make public

OvsGetVportNo computes a new port number. Therefore, OvsComputeVportNo
is a more clear name for what the function does. Reading OvsGetVportNo
may give the false impression that it returns the port number of an
existing vport.

Also, since the responsibility of assigning dp port numbers no longer
falls on the hyper-v switch port handlers side, but on the netlink vport
commands side (vport add), we will need to use this compute port number
function from outside Vport.c. Therefore, this function declaration is
moved from Vport.c to Vport.h, and becomes public.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Co-authored-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Tested-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Define OVS_DPPORT_NUMBER_INVALID
Alin Serdean [Thu, 9 Oct 2014 17:46:55 +0000 (17:46 +0000)]
datapath-windows: Define OVS_DPPORT_NUMBER_INVALID

The fields externalVport and internalVport of the OVS_SWITCH_CONTEXT
struct are currently defined as PVOID. However, all over the code they
are used as POVS_VPORT_ENTRY. In order to improve clarity and reduce the
need for useless casts to POVS_VPORT_ENTRY, this patch changes the type
from PVOID to POVS_VPORT_ENTRY.

This patch does not cleanup the code that already uses casts to
POVS_VPORT_ENTRY. This cleanup can be done later on as well.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Co-authored-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Tested-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Update OVS_SWITCH_CONTEXT: external and internal port
Alin Serdean [Thu, 9 Oct 2014 17:46:55 +0000 (17:46 +0000)]
datapath-windows: Update OVS_SWITCH_CONTEXT: external and internal port

The fields externalVport and internalVport of the OVS_SWITCH_CONTEXT
struct are currently defined as PVOID. However, all over the code they
are used as POVS_VPORT_ENTRY. In order to improve clarity and reduce the
need for useless casts to POVS_VPORT_ENTRY, this patch changes the type
from PVOID to POVS_VPORT_ENTRY.

This patch does not cleanup the code that already uses casts to
POVS_VPORT_ENTRY. This cleanup can be done later on as well.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Co-authored-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Tested-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: We don't need to keep validation ports in ovs
Alin Serdean [Thu, 9 Oct 2014 17:46:55 +0000 (17:46 +0000)]
datapath-windows: We don't need to keep validation ports in ovs

Validation ports are used internally by the hyper-v switch to validate
and verify settings for the real hyper-v switch ports that will be
connected to the VNic. The validation ports are of no use to us - we
must skip handling them, and return STATUS_SUCCESS as the OID result.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Co-authored-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Tested-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Rename hyper-v switch port and nic handlers
Alin Serdean [Thu, 9 Oct 2014 17:46:54 +0000 (17:46 +0000)]
datapath-windows: Rename hyper-v switch port and nic handlers

Functions such as OvsCreatePort are vague in regard to who creates it or
when. It wasn't a problem thus far, since the vports were created,
updated and destroyed from one place only (hyper-v switch part). But
now, with the netlink implementation of the vport commands, a part of
the vport is constructed by the netlink vport add, and the other part
is constructed by the hyper-v switch nic and port handlers.

This patch renames the hyper-v switch nic and port handlers, so that
they are now prefixed by "Hv" instead of "Ovs", in order to clarify
which of the functions are nic or port handlers. This will make more
clear the usages from netlink vport commands side and from hyper-v
switch side. It will also make more obvious which nic and port
functions are helper functions.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Co-authored-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Tested-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Remove the old IOCTL vport functions.
Alin Serdean [Thu, 9 Oct 2014 17:46:54 +0000 (17:46 +0000)]
datapath-windows: Remove the old IOCTL vport functions.

The old IOCTL vport functions (using the non-netlink device) are no
longer needed. They should be removed.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Co-authored-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Tested-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoAUTHORS: Update my author entry.
Kyle Mestery [Wed, 8 Oct 2014 21:46:52 +0000 (21:46 +0000)]
AUTHORS: Update my author entry.

Update the email address for myself in the AUTHORS file.

Signed-off-by: Kyle Mestery <mestery@mestery.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agonetdev-dpif: Add metadata to dpif-packet.
Pravin B Shelar [Sat, 4 Oct 2014 03:23:58 +0000 (20:23 -0700)]
netdev-dpif: Add metadata to dpif-packet.

Today dpif-netdev has single metadat for given batch, since one
batch belongs to one port, but soon packets fro single tunnel ports
can belong to different ports, so we need to have per packet metadata.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoovs-bugtool: Add fdb output for all bridges
Andy Zhou [Thu, 9 Oct 2014 00:15:42 +0000 (17:15 -0700)]
ovs-bugtool: Add fdb output for all bridges

Fdb entries can provide useful information. Collect them in bugtool.

Signed-off-by: Andy Zhou <azhou@nicira.com>
9 years agoovs-vswitchd: Fix high cpu utilization when acquire idl lock fails.
Alex Wang [Thu, 9 Oct 2014 08:23:37 +0000 (08:23 +0000)]
ovs-vswitchd: Fix high cpu utilization when acquire idl lock fails.

When ovs-vswitchd fails to acquire the ovsdb idl lock (either due to
contention or due to invalid database path), ovs-vswitchd will spin
on the global connectivity sequence number and consume 100% cpu.
This is in that the local copy is different to the global sequence
number and never updated when ovsdb idl is not locked.

To fix this issue, this commit makes ovs-vswitchd not checking the
global connectivity sequence number in that situation.

Reported-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agorhel7: Fix rpm install failure.
Alex Wang [Thu, 9 Oct 2014 07:02:07 +0000 (00:02 -0700)]
rhel7: Fix rpm install failure.

When trying to install the kernel module rpm built for RHEL7,
the install failed with following conflicts:

  # rpm -i kmod-openvswitch-2.3.1-1.el7.x86_64.rpm
    file /lib/modules/3.10.0-123.8.1.el7.x86_64/modules.devname
    from install of kmod-openvswitch-2.3.1-1.el7.x86_64 conflicts
    with file from package kernel-3.10.0-123.8.1.el7.x86_64

    file /lib/modules/3.10.0-123.8.1.el7.x86_64/modules.softdep
    from install of kmod-openvswitch-2.3.1-1.el7.x86_64 conflicts
    with file from package kernel-3.10.0-123.8.1.el7.x86_64

Similar issue has already been reported and solved here:

    https://bugzilla.redhat.com/show_bug.cgi?id=1003267

This commit applies the solution in the link to ovs.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Gurucharan Shetty <gshetty@nicira.com>
9 years agodatapath-windows: Update OvsGetExtInfoIoctl() to the new vport add workflow
Nithin Raju [Tue, 7 Oct 2014 01:05:39 +0000 (18:05 -0700)]
datapath-windows: Update OvsGetExtInfoIoctl() to the new vport add workflow

I applied the patches for the new vport add workflow that is out for
review, and found that some of the existing code in OvsGetExtInfoIoctl()
needs to be updated. In this patch, we add a CPP called
USE_NEW_VPORT_ADD_WORKFLOW and add the fixes under
USE_NEW_VPORT_ADD_WORKFLOW == 1. The current value is set to 0, since
the vport add code is not checked in yet.

Sending out this patch to unblock the vport add code when it gets checked
in. There are other fixes also required, but they are being addressed as
part of the review comments for vport-add.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
9 years agodatapath-windows: Add support for OVS_DP_CMD_NEW Netlink command.
Nithin Raju [Wed, 8 Oct 2014 21:21:50 +0000 (14:21 -0700)]
datapath-windows: Add support for OVS_DP_CMD_NEW Netlink command.

In this change, we add support for the 'OVS_DP_CMD_NEW' netlink command
in the kernel. We don't really support creation of a new datapath. If
the name of the userspace is the same as the single datapath we support,
we return EEXIST.

This code is required to bootstrap ovs-vswitchd which makes the
following sequence of calls:
open_dpif_backer() -> dpif_create_and_open() -> dpif_create()

We also rename HandleDpTransaction() to HandleDpTransactionCommon().

Signed-off-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
9 years agounaligned: Make get_unaligned_be64() compatible on GCC and non-GCC.
Ben Pfaff [Thu, 9 Oct 2014 05:13:31 +0000 (22:13 -0700)]
unaligned: Make get_unaligned_be64() compatible on GCC and non-GCC.

Until now, with GCC, get_unaligned_be64() had an interface that accepted
a "ovs_be64 *", and with other compilers its accepted any
pointer-to-64-bit type, but not void *.  This commit fixes the problem,
making the interface the same in both cases.

This fixes a build error on MSVC:

    lib/nx-match.c(320) : error C2100: illegal indirection
    lib/nx-match.c(320) : error C2034: 'build_assert_failed' : type of bit
        field too small for number of bits
    lib/nx-match.c(320) : error C2296: '%' : illegal, left operand has
        type 'void *'
    lib/nx-match.c(320) : error C2198: 'ntohll' : too few arguments for call

It might appear that this patch changes get_unaligned_u64() but in fact
it onloy moves it earlier in the file (since it is now called from the
non-GCC fork of the #if).

Reported-by: Alin Serdean <aserdean@cloudbasesolutions.com>
Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agocccl: Ignore -fno-strict-aliasing.
Alin Serdean [Thu, 9 Oct 2014 03:35:10 +0000 (03:35 +0000)]
cccl: Ignore -fno-strict-aliasing.

Add a case for the gcc flag fno-strict-aliasing into cccl
Under MSVC  Strict aliasing is off by default.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoofp-actions: Support experimenter OXMs in Nicira extensions.
Ben Pfaff [Fri, 12 Sep 2014 05:09:03 +0000 (22:09 -0700)]
ofp-actions: Support experimenter OXMs in Nicira extensions.

Some of the Nicira extension actions include fixed-size 32-bit members that
designate NXM fields.  These actions can't accommodate 64-bit experimenter
OXMs, so we need to figure out some kind of solution.  This commit does
that, in different ways for different actions.

For some actions, I did not think it was worthwhile to worry about
experimenter OXM, so I just disabled use of them.  This is what I did for
bundle, learn, and multipath actions.

Other actions could be gracefully reinterpreted to support experimenter
OXM.  This is true of reg_move, which use NXM headers only at the end of
the action and such that using an experimenter OXM would make the action
longer (which unambigously signals to older OVS that the action is an
error, which is desired behavior since older OVS cannot interpret this
action).  The stack push and pop actions are also in this category.

reg_load was the most frustrating case.  In OpenFlow 1.5 we had already
eliminated this action in favor of OF1.5+ set_field.  In other OpenFlow
versions, though, reg_load is more powerful than set_field because it
can modify partial fields.  This commit therefore adds a new variant of
reg_load, called reg_load2, which is simply OF1.5+ set_field with a Nicira
extension header on it.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agotests: Add test of double set-field in output action list.
Jean Tourrilhes [Wed, 24 Sep 2014 23:47:13 +0000 (16:47 -0700)]
tests: Add test of double set-field in output action list.

ONF-JIRA: EXT-314
Signed-off-by: Jean Tourrilhes <jt@hpl.hp.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoofp-actions: Correct test for OFPVID_PRESENT bit in set_field action.
Ben Pfaff [Wed, 8 Oct 2014 23:19:57 +0000 (16:19 -0700)]
ofp-actions: Correct test for OFPVID_PRESENT bit in set_field action.

Reported-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agonx-match: Add support for experimenter OXM.
Ben Pfaff [Wed, 8 Oct 2014 22:41:00 +0000 (15:41 -0700)]
nx-match: Add support for experimenter OXM.

OpenFlow 1.2+ defines a means for vendors to define vendor-specific OXM
fields, called "experimenter OXM".  These OXM fields are expressed with a
64-bit OXM header instead of the 32-bit header used for standard OXM (and
NXM).  Until now, OVS has not implemented experimenter OXM, and indeed we
have had little need to do so because of a pair of special 32-bit OXM classes
grandfathered to OVS as part of the OpenFlow 1.2 standardization process.

However, I want to prototype a feature for OpenFlow 1.5 that uses an
experimenter OXM as part of the prototype, so to do this OVS needs to
support experimenter OXM.  This commit adds that support.

Most of this commit is a fairly straightforward change: it extends the type
used for OXM/NXM from 32 to 64 bits and adds code to encode and decode the
longer headers when necessary.  Some other changes are necessary because
experimenter OXMs have a funny idea of the division between "header" and
"body": the extra 32 bits for experimenter OXMs are counted as part of the body
rather than the header according to the OpenFlow standard (even though this
does not entirely make sense), so arithmetic in various places has to be
adjusted, which is the reason for the new functions nxm_experimenter_len(),
nxm_payload_len(), and nxm_header_len().

Another change that calls for explanation is the new function mf_nxm_header()
that has been split from mf_oxm_header().  This function is used in actions
where the space for an NXM or OXM header is fixed so that there is no room
for a 64-bit experimenter type.  An upcoming commit will add new variations
of these actions that can support experimenter OXM.

Testing experimenter OXM is tricky because I do not know of any in
widespread use.  Two ONF proposals use experimenter OXMs: EXT-256 and
EXT-233.  EXT-256 is not suitable to implement for testing because its use
of experimenter OXM is wrong and will be changed.  EXT-233 is not suitable
to implement for testing because it requires adding a new field to struct
flow and I am not yet convinced that that field and the feature that it
supports is worth having in Open vSwitch.  Thus, this commit assigns an
experimenter OXM code point to an existing OVS field that is currently
restricted from use by controllers, "dp_hash", and uses that for testing.
Because controllers cannot use it, this leaves future versions of OVS free
to drop the support for the experimenter OXM for this field without causing
backward compatibility problems.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoutil: Make hexits_value() support 64-bit integers too.
Ben Pfaff [Tue, 30 Sep 2014 19:45:50 +0000 (12:45 -0700)]
util: Make hexits_value() support 64-bit integers too.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
9 years agonx-match: Speak of 'class' instead of 'vendor' for OXM/NXM.
Ben Pfaff [Wed, 10 Sep 2014 18:15:20 +0000 (11:15 -0700)]
nx-match: Speak of 'class' instead of 'vendor' for OXM/NXM.

OXM renamed the 'vendor' field from NXM to the 'class', and uses the term
"experimenter", which OVS usually renders as "vendor" for historical
reasons, as part of the extended 64-bit OXMs.  To reduce confusion, this
commit adopts the OXM terminology for class.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
9 years agotests: Add test for masked set_field action.
Jean Tourrilhes [Wed, 24 Sep 2014 23:46:52 +0000 (16:46 -0700)]
tests: Add test for masked set_field action.

ONF-JIRA: EXT-314
Signed-off-by: Jean Tourrilhes <jt@hpl.hp.com>
9 years agonx-match: Use nx_put_header() internally for encoding flow matches.
Ben Pfaff [Wed, 1 Oct 2014 00:26:28 +0000 (17:26 -0700)]
nx-match: Use nx_put_header() internally for encoding flow matches.

This will make it easier to support 64-bit OXM experimenter fields.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoofp-actions: Support OF1.5 (draft) masked Set-Field, merge with reg_load.
Ben Pfaff [Tue, 7 Oct 2014 23:49:50 +0000 (16:49 -0700)]
ofp-actions: Support OF1.5 (draft) masked Set-Field, merge with reg_load.

OpenFlow 1.5 (draft) extends the OFPAT_SET_FIELD action originally
introduced in OpenFlow 1.2 so that it can set not just entire fields but
any subset of bits within a field as well.  This commit adds support for
that feature when OpenFlow 1.5 is used.

With this feature, OFPAT_SET_FIELD becomes a superset of NXAST_REG_LOAD.
Thus, this commit merges the implementations of the two actions into a
single ofpact_set_field.

ONF-JIRA: EXT-314
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
9 years agotests: Check that port status MODIFY messages are generated.
Jean Tourrilhes [Thu, 19 Jun 2014 01:05:44 +0000 (18:05 -0700)]
tests: Check that port status MODIFY messages are generated.

ONF-JIRA: EXT-338
Signed-off-by: Jean Tourrilhes <jt@hpl.hp.com>
9 years agolib/netdev-windows.c: nuke the init function.
Nithin Raju [Wed, 8 Oct 2014 18:53:25 +0000 (11:53 -0700)]
lib/netdev-windows.c: nuke the init function.

The init function is not allowed to call into the kernel datapath
while running unit tests since the kernel datapath is not loaded.
Instead of making the function dummy, it is better to not have it
at all.

Reported-by: Gurucharan Shetty <gshetty@nicira.com>
Signed-off-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
9 years agoovs-vsctl: Allow modifying "immutable" columns if we just created the row.
Ben Pfaff [Fri, 26 Sep 2014 23:00:44 +0000 (16:00 -0700)]
ovs-vsctl: Allow modifying "immutable" columns if we just created the row.

OVSDB has the concept of "immutable" columns, which are columns whose
values are fixed once a row is inserted.  Until now, ovs-vsctl has not
allowed these columns to be modified at all.  However, this is a little too
strict, because these columns can be set to any value at the time that the
row is inserted.  This commit relaxes the ovs-vsctl requirement, then, to
allow an immutable column's value to be modified if its row has been
inserted within this transaction.

Requested-by: Mukesh Hira <mhira@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoovs-ofctl: Document protocol-specific forms as preferred over tp_src/tp_dst.
Ben Pfaff [Tue, 7 Oct 2014 20:16:42 +0000 (13:16 -0700)]
ovs-ofctl: Document protocol-specific forms as preferred over tp_src/tp_dst.

The generic form doesn't work in "learn" actions.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Reported-by: Alex Wang <alexw@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
9 years agoAdd meta-flow.inc nx-match.inc to lib/.gitignore
Alin Serdean [Wed, 8 Oct 2014 17:50:47 +0000 (17:50 +0000)]
Add meta-flow.inc nx-match.inc to lib/.gitignore

Add the following files:
meta-flow.inc
nx-match.inc
to lib/.gitignore

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoUpdate the WMI Script handling Hyper-V friendly port names
Lucian Petrut [Wed, 8 Oct 2014 17:05:02 +0000 (20:05 +0300)]
Update the WMI Script handling Hyper-V friendly port names

This patch ensures that the friendly port name has no more than 16 characters
and also if it is not in use.

The method which checks the WMI jobs has been updated in order to provide
relevant error codes/descriptions.

Methods retrieving the according VM and VM network adapter mapped to an OVS
port have been added as well. They are called:
Get-VMNetworkAdapterByOVSPort
Get-VMByOVSPort

Example of usage:
 2 import-module .\OVS.psm1
 3 $vnic = Get-VMNetworkAdapter test_2_1
 4 $vnic[0] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1
 5 $vnic[1] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1
 6 $vnic[0] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-2
 7 $vnic[1] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1
 8 Get-VMNetworkAdapterByOVSPort ovs-port-1
 9 Get-VMByOVSPort ovs-port-2

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agovswitch.ovsschema: Correct schema version number.
Ben Pfaff [Tue, 7 Oct 2014 23:54:04 +0000 (16:54 -0700)]
vswitch.ovsschema: Correct schema version number.

Commit 3e5aeeb581faf7 (bridge: Keep bond active slave selection across OVS
restart) updated the OVS schema number from 7.9.0 to 8.0.0.  However,
the major version number should only be incremented for incompatible schema
changes, ones that are likely to break software that interacts with the
schema.  The change in question only added a column to a table, so it is
not an incompatible change.  Therefore, this commit changes the schema
version number to 7.10.0, indicating a compatible change.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
9 years agoofp-actions: Better support OXM in Copy-Field action.
Ben Pfaff [Tue, 30 Sep 2014 21:05:14 +0000 (14:05 -0700)]
ofp-actions: Better support OXM in Copy-Field action.

The OpenFlow 1.5 (draft) Copy-Field action has two OXM headers, one after
the other.  Until now, Open vSwitch has implemented these as a pair of
ovs_be32 members, which meant that only 32-bit OXM could be supported.  This
commit changes the implementation to use nx_pull_header(), which means that
in the future when that function supports 64-bit experimenter OXMs,
Copy-Field will automatically get that support too.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
9 years agonx-match: Move all knowledge of OXM/NXM here.
Ben Pfaff [Wed, 17 Sep 2014 05:13:44 +0000 (22:13 -0700)]
nx-match: Move all knowledge of OXM/NXM here.

This improves the general abstraction of OXM/NXM by eliminating direct
knowledge of it from the meta-flow code and other places.

Some function renaming might be called for; for example, mf_oxm_header()
may not be the best name now that the function is implemented within
nx-match.  However, these renamings would make this commit larger and
harder to review, so I'm postponing them.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
9 years agoovs-ofctl: Encode cookies in OXM-compliant manner.
Ben Pfaff [Fri, 5 Sep 2014 00:02:35 +0000 (17:02 -0700)]
ovs-ofctl: Encode cookies in OXM-compliant manner.

NXM/OXM are only supposed to put 1-bits in a value if the corresponding bit
in the mask is a 1-bit, but in the case of cookie matching, e.g.
    ovs-ofctl del-flows br0 cookie=0x3/0x1
ovs-ofctl would encode a bad OXM.  This fixes the problem.

(The test "ofproto - del flows based on cookie mask" in the OVS testsuite
tickles this bug.)

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
9 years agoutil: New function bitwise_scan().
Ben Pfaff [Wed, 3 Sep 2014 00:16:51 +0000 (17:16 -0700)]
util: New function bitwise_scan().

This will acquire its first user in an upcoming commit.

This implementation is not optimized at all but it doesn't matter for the
purpose for which I intend to initially use it.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
9 years agometa-flow: Autogenerate mf_field data structures.
Ben Pfaff [Tue, 7 Oct 2014 22:24:11 +0000 (15:24 -0700)]
meta-flow: Autogenerate mf_field data structures.

This is a first step toward improving the abstraction of OXM and NXM in the
tree.  As an immediate improvement, this commit removes all of the
definitions of the OXM and NXM constants from the top-level header files,
because they are no longer used anywhere.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agolib/bitmap: Faster bitmap functions.
Jarno Rajahalme [Tue, 7 Oct 2014 21:35:04 +0000 (14:35 -0700)]
lib/bitmap: Faster bitmap functions.

Replace bitwise loops with a single operation, inline all bitmap
functions.  Inlining allows the compiler to remove unnecessary code
due to some parameters being compile-time constants.

Before:

$ tests/ovstest test-bitmap benchmark 1000000
bitmap equal:    341 ms
bitmap scan:   8089 ms

After:

$ tests/ovstest test-bitmap benchmark 1000000
bitmap equal:    152 ms
bitmap scan:    146 ms

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Co-authored-by: Kmindg <kmindg@gmail.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agoflow: Clean up MINIFLOW_FOR_EACH_IN_MAP.
Ben Pfaff [Tue, 7 Oct 2014 19:59:14 +0000 (12:59 -0700)]
flow: Clean up MINIFLOW_FOR_EACH_IN_MAP.

It seemed awkward to have declarations outside the for loop.

This may also be a little faster because it avoids some calls to
count_1bits().  The idea for that change is due to Jarno Rajahalme
<jrajahalme@nicira.com>.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoBFD: Decreasing minimal transmit and receive interval
Niels van Adrichem [Tue, 7 Oct 2014 15:04:13 +0000 (15:04 +0000)]
BFD: Decreasing minimal transmit and receive interval

I found the BFD transmit interval was lowerbounded by the default value
without warning, although documentation does not consider a lowerbound.

Testing has been performed with transmit and receive intervals as low as 1
ms, and although CPU overhead was effected (especially with multiple BFD
sessions such as 6 and higher), it worked well.

Signed-off-by: Niels van Adrichem <n.l.m.vanadrichem@tudelft.nl>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodpif-netdev: reduce netdev_flow_key size
Daniele Di Proietto [Sat, 20 Sep 2014 07:30:02 +0000 (07:30 +0000)]
dpif-netdev: reduce netdev_flow_key size

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoutil: Use MSVC compiler intrinsic for clz and ctz.
Gurucharan Shetty [Fri, 3 Oct 2014 19:00:11 +0000 (12:00 -0700)]
util: Use MSVC compiler intrinsic for clz and ctz.

Using the compiler intrinsic shows approximately around 25% speed
up with some classifier specific unit tests.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agoofpbuf: Correct the comment for ofpbuf_trim().
Wang Sheng-Hui [Sat, 4 Oct 2014 03:28:43 +0000 (11:28 +0800)]
ofpbuf: Correct the comment for ofpbuf_trim().

Headroom and tailroom both are removed.

Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoofpbuf: Correct comment for ofpbuf_reserve_with_tailroom().
Wang Sheng-Hui [Sat, 4 Oct 2014 02:11:25 +0000 (10:11 +0800)]
ofpbuf: Correct comment for ofpbuf_reserve_with_tailroom().

Correct the old comment like ofpbuf_reserve() to describe the expected
behavior of ofpbuf_reserve_with_tailroom().

Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoofpbuf: Correct comments for ofpbuf_tail and ofpbuf_end().
Wang Sheng-Hui [Sat, 4 Oct 2014 01:22:23 +0000 (09:22 +0800)]
ofpbuf: Correct comments for ofpbuf_tail and ofpbuf_end().

The return type of ofpbuf_tail() and ofpbuf_end() is pointer, not byte.

Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: implementation of netdev commands
Nithin Raju [Mon, 6 Oct 2014 20:07:23 +0000 (13:07 -0700)]
datapath-windows: implementation of netdev commands

validation:
- Vport dump works now without printing any errors. I didn't go so far
as to test if vport add works.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Some fixes in vport get code
Nithin Raju [Mon, 6 Oct 2014 20:07:22 +0000 (13:07 -0700)]
datapath-windows: Some fixes in vport get code

In this patch, we make some fixes in the vport get code as well as
elevating some utility functions from static to non-static.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Add stub handlers for netdev commands
Nithin Raju [Mon, 6 Oct 2014 20:07:21 +0000 (13:07 -0700)]
datapath-windows: Add stub handlers for netdev commands

In this patch, we add stub handlers for the netdev commands.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agonetdev-windows: add code to query netdev information
Nithin Raju [Mon, 6 Oct 2014 20:07:20 +0000 (13:07 -0700)]
netdev-windows: add code to query netdev information

Primary goals of netdev-windows.c are:
1) To query the 'network device' information of a vport such as MTU, etc.
2) Monitor changes to the 'network device' information such as link
status.

In this change, we implement only #1. #2 can also be implemented, but it
does not seem to be required for the purposes of implement
'ovs-dpctl.exe show'.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agonetdev-windows: New module.
Nithin Raju [Mon, 6 Oct 2014 20:07:19 +0000 (13:07 -0700)]
netdev-windows: New module.

In this patch, we add a lib/netdev-windows.c which mostly contains stub
code and in subsequent patches, would use the netlink interface to query
netdev information for a vport.

The code implements netdev functionality for "internal" and "system"
types of vports.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agonetlink-socket: add support for OVS_WIN_NETDEV_FAMILY
Nithin Raju [Mon, 6 Oct 2014 20:07:18 +0000 (13:07 -0700)]
netlink-socket: add support for OVS_WIN_NETDEV_FAMILY

In this patch, we add support for family ID lookup of
OVS_WIN_NETDEV_FAMILY.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoOvsDpInterfaceExt.h: add support for netlink family for netdev
Nithin Raju [Mon, 6 Oct 2014 20:07:17 +0000 (13:07 -0700)]
OvsDpInterfaceExt.h: add support for netlink family for netdev

In this patch, we define netlink family, attributes and commands
for query the 'network device' information of VPORTs, such as
MTU, Link status, etc.

I considered adding the netdev command to the OVS_WIN_CONTROL_FAMILY
itself, but the netdev attributes are not compatible with the existing
attributes for the events. I also considered adding new attributes to
the VPORT family, but we'll have to extend the standard datapath
interface for that.

In this patch, we fix the definition of 'OVS_WIN_CONTROL_ATTR_MAX' as
well.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Incorrect assumption of the IRQL
Sorin Vinturis [Mon, 6 Oct 2014 15:19:23 +0000 (15:19 +0000)]
datapath-windows: Incorrect assumption of the IRQL

Acquiring a spin lock raises the IRQL to DISPATCH_LEVEL. But
in many places of the code, while holding a spin lock, there
are useless checks for the current IRQL against DISPATCH_LEVEL.
Also, the dispatch flag is not correctly set when calling
NdisAcquireRWLockXXX() functions, which causes an extra check
of the current IRQL.

Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Reported-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/47
Acked-by: Nithin Raju <nithin@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agolib/cmap: cmap_find_batch().
Jarno Rajahalme [Wed, 24 Sep 2014 17:39:20 +0000 (10:39 -0700)]
lib/cmap: cmap_find_batch().

Batching the cmap find improves the memory behavior with large cmaps
and can make searches twice as fast:

$ tests/ovstest test-cmap benchmark 2000000 8 0.1 16
Benchmarking with n=2000000, 8 threads, 0.10% mutations, batch size 16:
cmap insert:    533 ms
cmap iterate:    57 ms
batch search:   146 ms
cmap destroy:   233 ms

cmap insert:    552 ms
cmap iterate:    56 ms
cmap search:    299 ms
cmap destroy:   229 ms

hmap insert:    222 ms
hmap iterate:   198 ms
hmap search:   2061 ms
hmap destroy:   209 ms

Batch size 1 has small performance penalty, but all other batch sizes
are faster than non-batched cmap_find().  The batch size 16 was
experimentally found better than 8 or 32, so now
classifier_lookup_miniflow_batch() performs the cmap find operations
in batches of 16.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agolib/cmap: split up cmap_find().
Jarno Rajahalme [Wed, 24 Sep 2014 17:39:20 +0000 (10:39 -0700)]
lib/cmap: split up cmap_find().

This makes the following patch easier and cleans up the code.

Explicit "inline" keywords seem necessary to prevent performance
regression on cmap_find() with GCC 4.7 -O2.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agolib/cmap: Use non-atomic access to hash.
Jarno Rajahalme [Wed, 24 Sep 2014 17:39:20 +0000 (10:39 -0700)]
lib/cmap: Use non-atomic access to hash.

We use the 'counter' as a "lock" providing acquire-release
semantics.  Therefore we can use normal, non-atomic access to the
memory accesses between the atomic accesses to 'counter'.  The
cmap_node.next needs to be RCU, so that can not be changed.

For the writer this is straightforward, as we first acquire-read the
counter and after all the changes we release-store the counter.  For
the reader this is a bit more complex, as we need to make sure the
last counter read is not reordered with the preceding read operations
on the bucket contents.

Also rearrange code to benefit from the fact that hash values are
unique in any bucket.

This patch seems to make cmap_insert() a bit faster.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agolib/cmap: More efficient cmap_find().
Jarno Rajahalme [Wed, 24 Sep 2014 17:39:20 +0000 (10:39 -0700)]
lib/cmap: More efficient cmap_find().

    These makes cmap_find 10% faster on GCC 4.7 (-O2 -g).

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agotests/test-cmap: Balance benchmarks between cmap and hmap.
Jarno Rajahalme [Wed, 24 Sep 2014 17:39:20 +0000 (10:39 -0700)]
tests/test-cmap: Balance benchmarks between cmap and hmap.

The test cases have been carefully crafted so that we do the same
amount of "overhead" operations in each case.  Earlier, with no
mutations, the number of random number generations was different for
hmap and cmap test cases.  hmap test was also missing an ignore() call.
Now the numbers look like this:

$ tests/ovstest test-cmap benchmark 2000000 8 0
Benchmarking with n=2000000, 8 threads, 0.00% mutations:
cmap insert:    597 ms
cmap iterate:    65 ms
cmap search:    299 ms
cmap destroy:   251 ms

hmap insert:    243 ms
hmap iterate:   201 ms
hmap search:    299 ms
hmap destroy:   202 ms

So it seems search on cmap can be as fast as on hmap in the
single-threaded case.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agolib/cmap: Return number of nodes from functions modifying the cmap.
Jarno Rajahalme [Tue, 30 Sep 2014 19:37:52 +0000 (12:37 -0700)]
lib/cmap: Return number of nodes from functions modifying the cmap.

We already update the count field as the last step of these functions,
so returning the current count is very cheap.  Callers that care about
the count become a bit more efficient, as they avoid extra
non-inlineable function call.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agolib: Fix MPLS masking.
Jarno Rajahalme [Tue, 30 Sep 2014 20:34:43 +0000 (13:34 -0700)]
lib: Fix MPLS masking.

Previously we masked labels not present in the incoming packet.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agolib/meta-flow: Index correct MPLS lse in mf_is_all_wild().
Jarno Rajahalme [Mon, 6 Oct 2014 21:12:57 +0000 (14:12 -0700)]
lib/meta-flow: Index correct MPLS lse in mf_is_all_wild().

Should index the first lse for all parts of the lse (label, TC, BOS).

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agolib/match: Do not format undefined fields.
Jarno Rajahalme [Wed, 1 Oct 2014 22:35:45 +0000 (15:35 -0700)]
lib/match: Do not format undefined fields.

Add function flow_wildcards_init_for_packet() that can be used to set
sensible wildcards when megaflows are disabled.  Before this, we set
all the mask bits to ones, which caused printing tunnel, mpls, and/or
transport port fields even for packets for which it makes no sense.

This has the side effect of generating different megaflow masks for
different packet types, so there will be more than one kind of mask in
the datapath classifier.  This should not make practical difference,
as megaflows should not be disabled when performance is important.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agoopenvswitch.spec: Remove dependency with openvswitch-kmod.
Gurucharan Shetty [Mon, 6 Oct 2014 17:47:12 +0000 (10:47 -0700)]
openvswitch.spec: Remove dependency with openvswitch-kmod.

Upstream Linux has OVS kernel module that includes most (not all) of
the features that comes with the kernel module from openvswitch.org.
So, it is okay to relax the requirement for OVS userspace package
to depend on openvswitch-kmod package.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Flow get implementation.
Ankur Sharma [Fri, 3 Oct 2014 22:53:45 +0000 (15:53 -0700)]
datapath-windows: Flow get implementation.

In this patch we have implemented the flow get.

Signed-off-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Flow dump implementation.
Ankur Sharma [Fri, 3 Oct 2014 22:53:44 +0000 (15:53 -0700)]
datapath-windows: Flow dump implementation.

In this patch we have implemented the flow dump.

Signed-off-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Flow Dump handler
Ankur Sharma [Fri, 3 Oct 2014 22:53:43 +0000 (15:53 -0700)]
datapath-windows: Flow Dump handler

In this patch we have added basic changes for
handler registeration for FLOW_GET command.

Signed-off-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Added the API for getting unused space in nlbuf.
Ankur Sharma [Fri, 3 Oct 2014 22:53:42 +0000 (15:53 -0700)]
datapath-windows: Added the API for getting unused space in nlbuf.

Also, the boundary check in NlBufAt was a little weird.
Fixed the same.

Signed-off-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath-windows: Netlink additional APIs.
Ankur Sharma [Fri, 3 Oct 2014 22:53:41 +0000 (15:53 -0700)]
datapath-windows: Netlink additional APIs.

In this patch we have added following new APIs.

NlMsgAlignSize => Aligns the size of netlink message.
NlMsgSetSize => Sets the value of nlmsgLen.

Signed-off-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoovs-vswitchd.at: Port tests to run successfully on Windows.
Gurucharan Shetty [Mon, 6 Oct 2014 17:04:26 +0000 (10:04 -0700)]
ovs-vswitchd.at: Port tests to run successfully on Windows.

It is a little tricky to implement "$!" with unit tests on Windows.
This commit changes the tests so that it works both on Windows
and Linux.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
9 years agoovs-vswitchd: Add a missing headline in documentation.
Gurucharan Shetty [Mon, 6 Oct 2014 17:16:34 +0000 (10:16 -0700)]
ovs-vswitchd: Add a missing headline in documentation.

The logging options were shown as part of the "Public Key Infrastructure
Options". Correct it.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
9 years agoovs-vswitchd: Document the '--unixctl' option.
Gurucharan Shetty [Mon, 6 Oct 2014 17:14:21 +0000 (10:14 -0700)]
ovs-vswitchd: Document the '--unixctl' option.

The option is documented for ovsdb-server but not for ovs-vswitchd.
This commit adds the documentation for ovs-vswitchd too.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
9 years agobridge: Keep bond active slave selection across OVS restart
Andy Zhou [Sun, 5 Oct 2014 06:35:30 +0000 (23:35 -0700)]
bridge: Keep bond active slave selection across OVS restart

Whenever OVS restarts, it pseudo-randomly picks an interface
of a bond port to be the active slave. This can cause traffic
disruption in case the upstream switch does not support LACP, or
in case of multi-chassis switches that do not support mLACP.

This patch helps the situation by always record the last active
slave into ovsdb. When OVS restarts, the stored last active slave
has the highest priority to be selected again. In case this interface
is available, due to configuration changes or being offline, OVS then
consider other interfaces with the bond as it does today.

In a nutshell, this patch makes the active slave selection stickier
across OVS restart.

VMware-BZ:  1332235

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
9 years agodatapath: Add support for RHEL-7 / CentOS-7 kernel.
Pravin B Shelar [Tue, 30 Sep 2014 04:39:56 +0000 (21:39 -0700)]
datapath: Add support for RHEL-7 / CentOS-7 kernel.

This patch mostly is related to tunnel API where RHEL 7
kernel API are not in-sync with newer linux kernel API. So
extra checks are required to check for parameters of API.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jiri Benc <jbenc@redhat.com>
9 years agoovs-vswitchd.at: Add test for switch over to another ovs-vswitchd.
Alex Wang [Thu, 2 Oct 2014 02:44:47 +0000 (02:44 +0000)]
ovs-vswitchd.at: Add test for switch over to another ovs-vswitchd.

Test the switch over to inactive ovs-vswitchd process when user
kill the currently active ovs-vswitchd.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
9 years agonetlink-socket: User mode event read for Windows.
Eitan Eliahu [Wed, 1 Oct 2014 03:37:56 +0000 (20:37 -0700)]
netlink-socket: User mode event read for Windows.

User mode sends down three distinct Read ioctl commands for Events, Packet
Reads and Dumps. In case the Packet Read socket can not be distinguished a
Set function will be provided.

Signed-off-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoodp-execute: Refactor odp_execute_{actions, sample}()
Daniele Di Proietto [Fri, 3 Oct 2014 22:04:15 +0000 (15:04 -0700)]
odp-execute: Refactor odp_execute_{actions, sample}()

Firstly, with this change, the 'more_actions' parameter is removed and
is integrated into 'steal'. Then, every function that receives a batch
of packets with 'steal' set to true is responsible for freeing the
packets. Finally, odp_execute_actions() and odp_execute_actions__()
can be be merged.

This also fixes a memory leak in odp_execute_sample(), when the
subactions are not executed

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoodp-execute: Fix memory leak on recirc action
Daniele Di Proietto [Fri, 3 Oct 2014 22:04:15 +0000 (15:04 -0700)]
odp-execute: Fix memory leak on recirc action

If odp_execute_actions() has been called with 'steal' set to true and
OVS_ACTION_ATTR_RECIRC as last action, it should allow dp_execute_cb()
to steal the packet.

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoodp-util: Parse recirc action in parse_odp_action()
Daniele Di Proietto [Fri, 3 Oct 2014 22:04:15 +0000 (15:04 -0700)]
odp-util: Parse recirc action in parse_odp_action()

This may be useful for debugging (with dpctl)

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agodpif-netdev: Destroy pmd_thread cmap at exit
Daniele Di Proietto [Fri, 3 Oct 2014 22:04:15 +0000 (15:04 -0700)]
dpif-netdev: Destroy pmd_thread cmap at exit

Found by valgrind

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agotimeval: Fix seq memory leak
Daniele Di Proietto [Fri, 3 Oct 2014 22:04:15 +0000 (15:04 -0700)]
timeval: Fix seq memory leak

'timewarp_seq' should be initialized only once, while init_clock() is
called multiple times (once for each clock instance).

Found by valgrind

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agodpif-netdev: fix dp_netdev_free()
Daniele Di Proietto [Fri, 3 Oct 2014 22:04:15 +0000 (15:04 -0700)]
dpif-netdev: fix dp_netdev_free()

dp_netdev_free() must free 'dp->upcall_rwlock', but when upcalls are
disabled (if the datapath is being freed upcalls should be disabled)
'dp->upcall_rwlock' is taken and freeing it causes an assertion to
fail.

This commit takes makes sure that the upcalls are disabled and
releases 'dp->upcall_rwlock' before freeing it. A simple testcase is
added to detect the failure.

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agodpif: Use OVS_FLOW_ATTR_PROBE.
Jarno Rajahalme [Fri, 12 Sep 2014 18:20:13 +0000 (11:20 -0700)]
dpif: Use OVS_FLOW_ATTR_PROBE.

Use the new OVS_FLOW_ATTR_PROBE flag when probing for datapath feature
support.  Suppress also dpif error logging when requested, as probe
failures are already logged at ofproto-dpif.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath: Add support for OVS_FLOW_ATTR_PROBE.
Jarno Rajahalme [Fri, 12 Sep 2014 18:20:13 +0000 (11:20 -0700)]
datapath: Add support for OVS_FLOW_ATTR_PROBE.

This new flag is useful for suppressing error logging while probing
for datapath features using flow commands.  For backwards
compatibility reasons the commands are executed normally, but error
logging is suppressed.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
9 years agobfd.at: Fix intermittent failure of test - flap_count.
Alex Wang [Thu, 2 Oct 2014 04:59:16 +0000 (21:59 -0700)]
bfd.at: Fix intermittent failure of test - flap_count.

ovs-vsctl commands like 'ovs-vsctl list Interface p1' use the
'monitor' RPC method, which causes ovsdb sending updates to
the command session when changes are committed to the monitored
table.  Since ovs-vsctl commands are short-lived, there is chance
that ovs-vsctl terminates the connection to ovsdb right before
ovsdb sends the update.  This race will cause the following
warning entries in ovsdb-server log:

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

The bfd:flap_count test is particularly prone to this race,
since the test aligns the statistics updates (every 5 seconds)
with the invocation of ovs-vsctl commands.

In the short term, this commit fixes the intermittent failure
by disabling the ovs-vswitchd statistics updates using a huge
update interval.

In the long run, we will research on making ovsdb not send
further updates to sessions like ovs-vsctl.

Signed-off-by: Alex Wang <alexw@nicira.com>
9 years agostream-tcp: Change the connection name for pwindows.
Gurucharan Shetty [Wed, 1 Oct 2014 17:38:23 +0000 (10:38 -0700)]
stream-tcp: Change the connection name for pwindows.

As of now, when someone passes a punix:foo/bar as a connection type
in Windows, we create a TCP server using 127.0.0.1 and save the kernel
assigned port number in the file foo/bar. The connection name
as obtained through pstream_get_name() would be ptcp:127.0.0.1:$PORT.
This was okay if pstream_get_name() was only used for logging
purposes. But netdev-dummy uses it to close active connections when the
passed name and created name are different. This causes transient
connection teardowns while using patch ports in Windows unit tests
causing occasional packet loss.

This commit sets the connection name to be punix:foo/bar instead
of ptcp:127.0.0.1:$PORT for pwindows.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agolib/ovs-atomic-i586: Faster 64-bit atomics on 32-bit builds with SSE.
Jarno Rajahalme [Thu, 2 Oct 2014 16:12:11 +0000 (09:12 -0700)]
lib/ovs-atomic-i586: Faster 64-bit atomics on 32-bit builds with SSE.

Aligned 64-bit memory accesses in i586 are atomic.  By using an SSE
register we can make such memory accesses in one instruction without
bus-locking.  Need to compile with -msse (or higher) to enable this
feature.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agodatapath: avoid hard coding OVS_VPORT_TYPE_GENEVE
Andy Zhou [Wed, 1 Oct 2014 07:29:19 +0000 (00:29 -0700)]
datapath: avoid hard coding OVS_VPORT_TYPE_GENEVE

OVS_VPORT_TYPE_GENEVE is currently hard coded to 6. This is not
necessary since slot 5 has not been taken yet. Drop the hard
coded value to before upstreaming GENEVE support to Linux kernel.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
9 years agocmap: ovsrcu postpone the cmap destroy.
Alex Wang [Wed, 1 Oct 2014 18:49:10 +0000 (11:49 -0700)]
cmap: ovsrcu postpone the cmap destroy.

Currently, the cmap_destroy() directly frees the cmap memory.
Some callers of cmap_destroy() (e.g. destroy_subtable()) still
allows other threads (e.g. pmd threads) accessing the cmap at
the same time (e.g. via classifier_lookup_miniflow_batch()),
which could cause segfault.

To fix the above issue, this commit use ovsrcu to postpone
the free of cmap memory.

Reported-by: Ethan Jackson <ethan@nicira.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agoofproto: Do not postpone closing the mgmt socket
Daniele Di Proietto [Wed, 1 Oct 2014 18:54:09 +0000 (11:54 -0700)]
ofproto: Do not postpone closing the mgmt socket

When the bridge datapath_type is changed, ofproto is destroyed and immediately
recreated. This involves closing and reopening the mgmt socket. If the
destruction of the 'connmgr' is postponed, a race condition might happen, where
we first recreate the socket and then try to destroy it.

Reported-by: Daniel Badea <daniel.badea@windriver.com>
Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoconfigure: Disable strict aliasing.
Ben Pfaff [Wed, 1 Oct 2014 00:03:07 +0000 (17:03 -0700)]
configure: Disable strict aliasing.

The C standard allows compilers to do type-based alias analysis, which
means that the compiler is allowed to assume that pointers to objects of
different types are pointers to different objects.  For example, a compiler
may assume that "uint16_t *a" and "uint32_t *b" point to different and
nonoverlapping locations because the pointed-to types are different.  This
can lead to surprising "optimizations" with compilers that by default do
this kind of analysis, which includes GCC and Clang.

The one escape clause that the C standard gives us is that character types
must be assumed to alias any other object.  We've always tried to use this
escape clause to avoid problems with type-based alias analysis in the past.
I think that we should continue to try to do this in the future.  It's hard
to tell what compiler we might want to use in the future, and one never
knows what kind of control that compiler allows over alias analysis.

However, recently I helped another developer debug a nasty and confusing
issue, which turned out to be the result of a surprising compiler
optimization due to alias analysis.  I've seen enough of these that I don't
think it's worthwhile to risk more problems than we have to.  Thus, this
commit turns off type-based alias analysis in GCC and Clang.

Linus Torvalds thinks that type-base alias analysis is not sane, at least
as GCC implements it: https://lkml.org/lkml/2003/2/26/158

The GCC manual says that -Wstrict-aliasing is only effective without
-fno-strict-aliasing, otherwise I'd keep -Wstrict-aliasing also.

Indications are that MSVC doesn't do type-based alias analysis by default.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
9 years agoREADME: Adding github markup and travis-ci build status to github readme page.
Pritesh Kothari [Wed, 1 Oct 2014 06:23:46 +0000 (23:23 -0700)]
README: Adding github markup and travis-ci build status to github readme page.

Signed-off-by: Pritesh Kothari <pritesh.kothari@cisco.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agoovs-vswitchd.at: Fix "start additional ovs-vswitchd process" test
YAMAMOTO Takashi [Wed, 1 Oct 2014 05:00:36 +0000 (14:00 +0900)]
ovs-vswitchd.at: Fix "start additional ovs-vswitchd process" test

NetBSD implementation of wc command outputs extra whitespaces
like the following.  Tweak the test to success on such environments.

    % echo hoge|wc -l|hexdump -C
    00000000  20 20 20 20 20 20 20 31  0a                       |       1.|
    00000009
    %

The failing test was introduced by
commit 6bef3c7ca859f208239ca61ec3b25c09a3571553
("bridge: Fix high cpu utilization.")

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Acked-by: Joe Stringer <joestringer@nicira.com>
9 years agobridge: Fix high cpu utilization.
Alex Wang [Tue, 30 Sep 2014 20:46:22 +0000 (13:46 -0700)]
bridge: Fix high cpu utilization.

When there are more than one ovs-vswitchd processes started,
only one process is enabled.  The disabled processes should
just sleep.  However, a bug in ovs makes the disabled processes
keep waking up on global connectivity sequence number which is
never sync'ed.  Consequently, those processes use 100% cpu.

This commit fixes the bug by always sync up the connectivity
sequence number for disabled processes.

Reported-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
9 years agoCodingStyle: Mention our assumption about conversions to bool
YAMAMOTO Takashi [Mon, 29 Sep 2014 22:59:36 +0000 (07:59 +0900)]
CodingStyle: Mention our assumption about conversions to bool

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agoINSTALL.DPDK: Update DPDK related documentation.
Alex Wang [Fri, 26 Sep 2014 15:05:40 +0000 (15:05 +0000)]
INSTALL.DPDK: Update DPDK related documentation.

This commit updates the DPDK related documentation to reflect
the pmd thread multi-threading work.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Daniele Di Proietto <ddiproietto@vmware.com>
9 years agoovs-vswitchd: Better diagnose errors in DPDK command-line options.
Ben Pfaff [Tue, 30 Sep 2014 16:57:08 +0000 (09:57 -0700)]
ovs-vswitchd: Better diagnose errors in DPDK command-line options.

With DPDK compiled in, when the --dpdk option was given other than as the
first command-line argument, ovs-vswitchd silently ignored it.  Without
DPDK compiled in, when the --dpdk option was given anywhere, ovs-vswitchd
silently ignored it.  However, in each case any options following --dpdk
were not ignored, and since --dpdk is normally followed by additional
DPDK-specific options, this caused even more confusing trouble.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Daniele Di Proietto <ddiproietto@vmware.com>
Tested-by: Daniele Di Proietto <ddiproietto@vmware.com>
9 years agopstream-unix: Increase listen count to 64 in punix_open().
Lilijun [Tue, 30 Sep 2014 08:55:25 +0000 (16:55 +0800)]
pstream-unix: Increase listen count to 64 in punix_open().

In my test with openstack setup, ovs-ofctl executes failed when there are
many flow rules to be added by multiple threads.
The error like this:
ovs-ofctl: /var/run/openvswitch/br1.mgmt: failed to open socket (Protocol
error)

In the function listen(fd, 10) in punix_open(), the number 10 should be
modified to more bigger, such as 64 maybe a proper value.

Signed-off-by: Lilijun <jerry.lilijun@huawei.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
9 years agotests: Mention binomial coefficient in hash tests.
Joe Stringer [Fri, 26 Sep 2014 17:28:12 +0000 (17:28 +0000)]
tests: Mention binomial coefficient in hash tests.

This just makes it a bit easier for someone coming in fresh to do some
searches and figure out what the description means.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agorevalidator: Distinguish new and duplicate flows.
Joe Stringer [Fri, 26 Sep 2014 17:28:05 +0000 (17:28 +0000)]
revalidator: Distinguish new and duplicate flows.

We previously counted flows that have been installed during the current
dump as duplicates, rather than recognising them as new flows. This
patch separates the counters out for these two cases.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
9 years agonx-match: Encode dp_hash and recirc_id in OXM also.
Ben Pfaff [Fri, 12 Sep 2014 21:42:47 +0000 (14:42 -0700)]
nx-match: Encode dp_hash and recirc_id in OXM also.

dp_hash and recirc_id are specific to OVS, but that doesn't mean that we
shouldn't encode them into flow matches when OXM is used in OpenFlow 1.2
and later.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>