datapath: Fix ovs_dp_cmd_msg_size()

commit c58cc9a460fd158e5250e59902e96ac677dc115f (datapath: Allow user space to
announce ability to accept unaligned Netlink messages) introduced
OVS_DP_ATTR_USER_FEATURES netlink attribute in datapath responses,
but the attribute size was not taken into account in ovs_dp_cmd_msg_size().

Signed-off-by: Daniele Di Proietto <daniele.di.proietto@gmail.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
datapath: use const in some local vars and casts

In few functions, const formal parameters are assigned or cast to
non-const.
These changes suppress warnings if compiled with -Wcast-qual.

Signed-off-by: Daniele Di Proietto <daniele.di.proietto@gmail.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
netlink: Rename 'dump->seq' to 'dump->nl_seq'

An upcoming patch will introduce another, completely unrelated seq to
'struct nl_dump'. Giving this one a better name should reduce confusion.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
netdev-dummy: Add support for active stream

The dummy ports thus far only support passive connections. It can
listen for multiple incoming connection requests but not make active
connections. This patch adds support of active stream, so that a
dummy port can be configured with either passive or active connections.

The net result is that dummy ports can now connect to each other,
without being patch ports. This feature will be useful in adding test
cases of future commits.

Signed-off-by: Andy Zhou <azhou@nicira.com>
ofproto: Handle negative number of threads.

As of now, setting other_config:n-handler-threads to a negative
value causes ovs-vswitchd to crash.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
syslog: Add LOG_LOCALX definitions.

LOG_LOCAL0 is used in lib/vlog.c.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
syslog: Provide stub functions for openlog and syslog.

One option to implement openlog and syslog functionality in Windows
is to use windows event logger. But it looks like it involves changing
registry settings and in general looks complicated.

For the time being, do nothing for syslog. All the information needed for
debugging will be present through the 'file' option anyways.

We can start OVS daemons on Windows with "-vfile:info -vsyslog:off".

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
daemon: Cleanup some functions.

Some functions are unused and some functions can be
declared as static.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovs-dev.py: Only build the Linux datapath with GCC.

In practice, Linux kernel modules are only built with GCC, so it
doesn't make much sense to spend time compiling them with clang.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
getopt_long: Copy over the implementation from netbsd.

Windows does not have a getopt_long function. This commit
copies over the getopt_long implementation from netbsd with
some minor modifications and is used only on Windows platform.

Modifications on top of the version in NetBSD repo.
* Remove header files not available in Visual Studio.
* Remove some unwanted #defines.
* Add Open vSwitch specific header files like config.h, vlog.h, util.h
* Add the following #define's
define __UNCONST(a)    ((void *)(unsigned long)(const void *)(a))
define _DIAGASSERT(q) ovs_assert(q)
define warnx VLOG_WARN
* Add extern declaration in getopt.h for optarg, optind.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
util: A generic function to convert error to string for windows.

More users will be added in an upcoming commit.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
upcall: Avoid divide-by-zero calculating flow limit

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
ofproto-dpif-upcall: Hardcode max_idle to 1500ms.

Before this patch, OVS tried to guess an optimal max idle time for
datapath flows based on the number of datapath flows relative to the
limit.  This caused instability because the limit was based on the
dump duration which was affected by the max idle time.  This patch
chooses instead to hardcode the max idle time to 1.5s except in
extreme case where the datapath flow limit is exceeded.  1.5s was
chosen to ensure pings occurring at once per second stay cached in the
datapath.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
bridge: Set ofport column in every database transaction.

Database transactions can occasionally fail due to concurrent changes in
the database.  When that happens, the next transaction should repeat the
changes that ovs-vswitchd tried to make the first time (adjusted for the
changes to the database).

The code to report the OpenFlow port number in use didn't do that.  It set
the ofport field once when it created the port and never set it again, even
if the transaction to set it failed.  This commit fixes the problem.

Bug #23047.
Reported-by: Suganya Ramachandran <suganyar@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
BUILD.Windows: Clarify on the correct linker.

This has tripped a couple of people.

The workaround in cccl does not actually work. So get rid of it and
clarify in documentation.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
BUILD.Windows: Add documentation to handle the libtool change.

With the recent change to libtool, the default behavior is to use
MinGW's 'ld'. Set the LD variable to direct it to Visual Studio's
linker.

The wordings for the documentation is copied from INSTALL.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
cccl: Handle library paths for one shot compilation.

When one wishes to compile and link a program with an
external library in one shot, additional
option "-link" is expected after all the other options. For example,

$ cl -I/c/OpenSSL-Win32/include 3.c -link -LIBPATH:"C:/OpenSSL-Win32/lib"

This is needed in an upcoming commit to compile conftest.c in autoconf.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath: Fix ovs_flow_free() ovs-lock assert.

ovs_flow_free() is not called under ovs-lock during packet
execute path (ovs_packet_cmd_execute()). Since packet execute
does not touch flow->mask, there is no need to take that
lock either. So move assert in case where flow->mask is checked.

Found by code inspection.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
configure: Identify OpenSSL libraries in Windows.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
socket-util: Remove unused functions.

A Windows porter mentioned to me that these functions caused special
trouble in the Windows port.  However, they are no longer used, so we
might as well remove them.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>