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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Change Travis CI notification email to ljakab@ac.upc.edu
userspace: add support for pop_eth and push_eth actions

These actions will allow L2->L3 and L3->L2 switching, and are supposed
to be added to flows installed in the datapath transparently by
ovs-vswitchd.

Signed-off-by: Lorand Jakab <lojakab@cisco.com>
userspace: add layer 3 flow and switching support

This commit relaxes the assumption that all packets have an Ethernet
header, and adds support for layer 3 flows.  For each packet received on
the Linux kernel datapath the l2 and l3 members of struct ofpbuf are
intialized appropriately, and some functions now expect this (notably
flow_extract()), in order to differentiate between layer 2 and layer 3
packets.  struct flow has now a new 'base_layer' member, because we
cannot assume that a flow has no Ethernet header when eth_src and
eth_dst are 0.  For layer 3 packets, the protocol type is still stored
in the eth_type member.

Switching L2->L3 and L3->L2 are both implemented by adding the pop_eth
and push_eth actions respectively when a transition is detected.  The
push_eth action puts 0s on both source and destination MACs.  These
addresses can be modified with mod_dl_dst and mod_dl_src actions.

Added new prerequisite MFP_ETHERNET for fields MFF_ETH_SRC, MFF_ETH_DST,
MFF_VLAN_TCI, MFF_DL_VLAN, MFF_VLAN_VID and MFF_DL_VLAN_PCP.

Signed-off-by: Lorand Jakab <lojakab@cisco.com>
datapath: add layer 3 flow/port support

Implementation of the pop_eth and push_eth actions in the kernel, and
layer 3 flow support.

Signed-off-by: Lorand Jakab <lojakab@cisco.com>
Address Jesse's comment #1