util: Add be32_prefix_mask().

Shifting a 32-bit entity by 32 bits is undefined behavior.  As we have 3
cases where we may hit this, it is a time to introduce a helper for
this.

VMware-BZ: #1355026
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Build: Add support for shared libraries and versioning.

These changes allow for the building of shared libraries by providing
the --enable-shared option to configure. In particular, lib/libopenvwitch.so,
lib/libsflow.so, ofproto/libofproto.so, and ovsdb/libovsdb.so will be built.
Original behavior of building static remains the same.

Additionally, versioning is introduced to each of the libraries objects
paving the way for APIs to be built around them. A detailed comment
outlining the rules for changing a version number is provided in
configure.ac. Note that at this time, the version number is set to
1.0.0, no API is specified yet, and there are no requirements to
maintain any sort of compatibility in any of the libraries.

Signed-off-by: Scott Mann <smann@noironetworks.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
travis: Add building of shared library to CI matrix.

Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath-windows: Add functionality to return OVSPortName given a VM

This commit adds functionality to return the ElementName of all the VNIC of a
given virtual machine name.

The function returns all the allocated ports including the ones which the OVS
port name was not set.

The default OVS port name that is set is the following:
"ElementName             : Dynamic Ethernet Switch Port".

Example of usage:
Import-Module OVS.psm1
Get-VMNetworkAdapterWithOvsPort test_ubuntu_1
$a = Get-VMNetworkAdapterWithOvsPort test_2_1
$a | findstr ElementName

Requested-by: Nithin Raju <nithin@vmware.com>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/51
Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Tested-by: Nithin Raju <nithin@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath-windows: Update port property.

Update Hyper-V port properties on NDIS property port set callback.
Driver update the port friendly name in its internal table.
Since the NIC Create callback won't be called after we need to maintain the
NIC and THE OVS states of the Vport.

Setting a new friendly name was tested in the following states:
[1] The port is disconnected
[2] The port is connected but not OVS user mode counter port
[3] The port is connected and an OCS port associated with it

Signed-off-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto: Test that group commands fail for OpenFlow 1.0

Groups are not supported by OpenFlow 1.0

Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
INSTALL.Windows: Add a TODO for QOS.

Also, remove the entry that talks about the need for atomic support
on Windows as that has already been added.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Acked-by: Nithin Raju <nithin@vmware.com>
tests: Skip a sflow test for Windows.

AT_XFAIL_IF cannot be used here because it lets the tests
run first and then say that the failure is expected. In this
particular test, the utilities simply hang blocking all
other tests. So use AT_SKIP_IF instead.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Acked-by: Nithin Raju <nithin@vmware.com>
ofp-util: Do not allow buckets for OFPGC15_REMOVE_BUCKET.

ONF-JIRA: EXT-350
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-util: Enhance error logging during encoding group mod messages.

In preparation for supporting (draft) OpenFlow 1.5
group mod commands enhance the error logging of them.

ONF-JIRA: EXT-350
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-util: Provide bucket list helper functions

This is in preparation for supporting the bucket commands of
(draft) Open Flow 1.5 group mod messages.

Also document ofputil_bucket_check_duplicate_id() for good measure.

ONF-JIRA: EXT-350
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-parse: Parse bucket commands of group mod.

(Draft) OpenFlow 1.5 adds bucket commands to group mod.
This patch allows parsing of them as a step towards supporting them.

ONF-JIRA: EXT-350
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib: Correctly pass collected AM_LDFLAGS to linker

AM_LDFLAGS is not automatically passed to individual library LDFLAGS
and must be passed in explicitly.

Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib: Document --enable-shared configure switch

Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
include: Use #include <.*> in public headers.

Required to make the headers installable.

Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib: Avoid using C++ keywords as variable names in header files.

Otherwise C++ programs can't #include the headers.

Signed-off-by: Amit Bose <bose@noironetworks.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
tunnel: Convert rwlock to fat-rwlock.

Tunnel lookup is done in slow path but DPDK tunneling
slow path is called in PMD context. Therefore it is
better to convert rwlock to fat rwlock.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Ben Pfaff <blp@nicira.com>
util: Introduce ovs_scan_len()

This is similar to ovs_scan but takes int pointer as extra
parameter, this pointer point to starting index of the string.
On successful scan this API stores number of characters
scanned.  This API is useful for parsing complex odp actions
e.g. tun_push action.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Fix misspellings of "OpenFlow".

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Flavio Leitner <fbl@redhat.com>
openvswitch: Userspace tunneling.

Following patch adds support for userspace tunneling. Tunneling
needs three more component first is routing table which is configured by
caching kernel routes and second is ARP cache which build automatically
by snooping arp. And third is tunnel protocol table which list all
listening protocols which is populated by vswitchd as tunnel ports
are added. GRE and VXLAN protocol support is added in this patch.

Tunneling works as follows:
On packet receive vswitchd check if this packet is targeted to tunnel
port. If it is then vswitchd inserts tunnel pop action which pops
header and sends packet to tunnel port.
On packet xmit rather than generating Set tunnel action it generate
tunnel push action which has tunnel header data. datapath can use
tunnel-push action data to generate header for each packet and
forward this packet to output port. Since tunnel-push action
contains most of packet header vswitchd needs to lookup routing
table and arp table to build this action.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Ben Pfaff <blp@nicira.com>