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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
ovs-numa: Add ovs-numa.{c,h} for extracting and storing cpu
socket and cpu core info.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath-windows: check source port during tunnel Tx

In the Windows datapath, Tx tunneling functionality is implemented by checking
if the outport in the action is a tunnel port. If so, the packet is
encapsulated and sent out on the PIF bridge for as second flow lookup.
Basically, we don't use the hypervisor's IP stack to send out a packet, and
short circuit the path ourselves. On the PIF bridge, the source port of the
encapsulated packet is the VTEP port ie. the internal port.

If a Tunneling port is added to the PIF bridge (a possible misconfiguration),
where the VTEP(internal) port and the external port (physical NIC) also reside,
a flooding action can cause a loop, by re-injecting the packet on the same PIF
bridge which again floods to the tunnel port.

In this change, we break the loop by encapsulating packets only if they are
sent out by a VIF or if they originate from userspace ie. userspace generated.
We make use of the input port attribute in the packet execute ioctl.

This change is based off of the legacy datapath interface published in
OvsPub.h. This interface has a input port field in the packet execute ioctl.
I looked in dpif-linux.c that uses the netlink based datapath interface and
even in that case, we do add the the source port in:
    dpif_linux_encode_execute() -> odp_key_from_pkt_metadata().
So, this fix is applicable when we adopt the netlink based datapath interface
as well.

The Rx side of OvsDetectTunnelPkt() has only documentation updates. The fix is
on the Tx side.

Validation (using dpif-windows.c):
- Was able to perform VTEP <-> VTEP ping with the configuration posted in the
issue.
- Was able to perform VIF <-> VIF ping when the setup was configured correctly.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Reported-by: Alin Serdean <aserdean@cloudbasesolutions.com>
Tested-by: Alin Serdean <aserdean@cloudbasesolutions.com>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/20
Signed-off-by: Ben Pfaff <blp@nicira.com>
ovs-numa: Correct printf format specifiers.

list_size() yields a size_t, not uint64_t, and these types are different on
32-bit targets.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>