ovsdb: Fix error leak for negative timeout and invalid until case

Although the check for negative timeout is present, the error string
is overwritten if an invalid "until" is found right after. This leaks
an error string and results in not reporting the negative timeout back
to the user even though it is encountered first.

Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Add build of ovsext.sln using MSBuild

This commit adds to the automake build system the full build required
by the forwarding extension solution.

It will help a lot in the future CI to check the full build of the project.

To configure the forwarding extension to be built one could use the following:
./configure CC=./build-aux/cccl LD="`which link`" LIBS="-lws2_32" \
    --prefix="C:/openvswitch/usr" --localstatedir="C:/openvswitch/var" \
    --sysconfdir="C:/openvswitch/etc" --with-pthread="C:/pthread" \
    --with-vstudioddk="Win8.1 Release"

Documentation will be updated in another patch.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Saurabh Shah <ssaurabh@vmware.com>
CodingStyle: Relax restrictions on types of bit-fields.

C99 only requires compilers to support four types for bit-fields: signed
int, unsigned int, int, and _Bool.  "int" should not be used because it
is implementation-defined whether it is signed.  In practice, we have found
that compilers (in particular, GCC, Clang, and MSVC 2013) support any
integer type.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
netlink-socket: Use read/write ioctl instead of ReadFile/WriteFile.

The Windows datapath supports a READ/WRITE ioctl instead of ReadFile/WriteFile.
In this change, we update the following:
- WriteFile() in nl_sock_send__() to use DeviceIoControl(OVS_IOCTL_WRITE)
- ReadFile() in nl_sock_recv__() to use DeviceIoControl(OVS_IOCTL_READ)

The WriteFile() call in nl_sock_transact_multiple__() has not been touched
since it is not needed yet.

Main motive for this change is to be able to unblock the DP Dump workflow.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
datapath-windows: Rename files.

This patch includes the file renaming and accommodations needed for the file
renaming to build the forwarding extension for Hyper-V.

This patch is also a follow-up for the thread:
http://openvswitch.org/pipermail/dev/2014-August/044005.html

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Co-authored-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Changing hash used for selecting bucket in a group action

Current hash uses just the dl_dst field. This patch expands the hash  to
include all L2, L3 and L4 fields, allowing for more balanced selection.

Signed-off-by: Srini Seetharaman <srini.seetharaman@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
INSTALL: Describe steps to use/install continuous integration

Describe the steps required to setup use of travis-ci for any
GitHub ovs repository.

Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath: Always initialize fix_segment for GSO packet.

OVS tunnel compat code depends on this function pointer to
handle GSO packet. Currently we do not initialize for all
GRE GSO packets. Following patch fixes that.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
lib/ovs-atomic: Add missing macro argument parentheses.

Otherwise the dereference operator could target a portion of a ternary
expression, for example.

Also minor style fixes.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/ovs-atomic: Clarified comments on ovs_refcount_unref().

ovs_refcount_unref() needs to syncronize with the other instances of
itself rather than with ovs_refcount_ref().

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/ovs-atomic: Add helpers for relaxed atomic access.

When an atomic variable is not serving to synchronize threads about
the state of other (atomic or non-atomic) variables, no memory barrier
is needed with the atomic operation.  However, the default memory
order for an atomic operation is memory_order_seq_cst, which always
causes a system-wide locking of the memory bus and prevents both the
CPU and the compiler from reordering memory accesses accross the
atomic operation.  This can add considerable stalls as each atomic
operation (regardless of memory order) always includes a memory
access.

In most cases we can let the compiler reorder memory accesses to
minimize the time we spend waiting for the completion of the atomic
memory accesses by using the relaxed memory order.  This patch adds
helpers to make such accesses a little easier on the eye (and the
fingers :-), but does not try to hide them completely.

Following patches make use of these and remove all the (implied)
memory_order_seq_cst use from the OVS code base.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/ovs-atomic: Add atomic_count.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib: Use shorter form of relaxed atomic access.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/jsonrpc, lib/ofp-msgs, lib/ofp-parse: Use atomic_count.

Trivial ID counters do not synchronize anything, therefore can use
atomic_count.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/bfd: Used relaxed atomics and optimize bfd_should_process_flow().

The atomics here do not synchronize the state of any other variables,
so we can use atomic_count and relaxed atomics.

bfd_should_process_flow() is rearranged to set the megaflow mask bits
only if necessary, and to avoid the atomic operation on non-BFD
packets.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/cfm: Use relaxed atomics and optimize cfm_should_process_flow().

The atomics here do not synchronize the state of any other variables,
so we can use relaxed atomics.
    
cfm_should_process_flow() is rearranged to set the megaflow mask bits
only if necessary, and to avoid the atomic operation on non-CFM
packets.
    
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/dpif-linux: Use relaxed atomics for 'dump->status'.

'dump->status' does not syncronize the state of any other variable, so
we can use relaxed atomics on it.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/netdev: Do not use atomics when not needed.

All access to struct netdev_registered_class ref_cnt member was done
with netdev_class_mutex held, so it does not need to be an atomic
variable.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/netdev-dummy: Use relaxed atomics for a trivial counter.

Even though there is no need to optimize netdev-dummy, it might be
good to do this right, in case it serves as an inspiration for
something else later.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/netdev-linux: Use atomic_count for 'miimon_cnt'.

'miimon_cnt' and the actual device miimon configuration is only
loosely coupled, so we can use the relaxed atomic_count for it.

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