tests: Fix up "ofproto-dpif - ofproto-dpif-monitor 1".

Commit 1335a8d578b03e (tests: Fix race condition waiting for monitor
thread.) fixed a race condition in a test.  Commit 8ba0a5227f6 (ovs-thread:
Make caller provide thread name when creating a thread.) slightly changed
the output that the test checked, breaking the test.  However, I was used
to the test occasionally failing due to the race (not realizing that the
race had been fixed) so I applied the commit anyway.

This commit fixes the broken test.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
lib/ofp-actions: Update comment.

We recently renamed ofpbuf's 'l2' member as 'frame'.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
openvswitch.h: Note that 64 bit ints are 4-aligned.

In general, all Netlink 64-bit data may be 4-byte aligned, due to
netlink header and attributes being 4-aligned.

To avoid unaligned access the data should be copied out of the netlink
attribute before access.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
lib/odp-util: Remove extra parenthesis from sctp key output.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Reviewed-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
openvswitch.h: Clarify use of key attributes.

Key attributes relating to actual packet headers are ignored for
OVS_PACKET_CMD_EXECUTE as the header key attributes are retrieved
from the packet itself.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
ofproto-bond: do not allow recirculation when we failed to allocate recirc_id

When recirc pool is exhausted, a new bond won't be allocate a new
recirc_id. The bond->recirc_id will remain zero. This condition
should prevent the bond from use recirculation. This check was missing
before this patch.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif: restore bond rebalance for non-recirc bond

Bond rebalancing was disabled for bonds not using recirculation. The
patch fixes this bug.

While fixing the bug, the bond_rebalance() was also restructured
slightly to move bond related logic back into ofproto/bond.c

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
dpif-linux: Fix a bug in creating port.

Based on the policy of 'OVS_VPORT_ATTR_UPCALL_PID', if upcall should
not be sent to userspace (i.e. the number of handler threads is zero),
the netlink message for creating vport should be an one-element array of
value 0.  However, dpif_linux_port_add__() fails to obey it and generates
zero-payload netlink message which causes the netlink transaction failing
with ERANGE error.

This is particularly bad when the 'flow-restore-wait' is set during upgrade,
since number of handler threads is not set in dpif-linux module and ovs is
not able to add port in datapath until the 'flow-restore-wait' is disabled.
Connection may lose due to this bug.

This bug was introduced by commit 1579cf677fc (dpif-linux: Implement the
API functions to allow multiple handler threads read upcall.).

This commit fixes the bug by fixing the dpif_linux_port_add__() to generate
the correct netlink message when the number of handler threads is not set.

Bug #1239914.
Bug #1240598.
Bug #1240626.

Reported-by: Gurucharan Shetty <gshetty@nicira.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
netdev: Fix an use of uninitialized mutex.

Commit 05bf6d3c62e1d (ovs-thread: Add checking for mutex and
rwlock initialization.) helps find an use of uninitialized
mutex (netdev_class_mutex) during upgrade.  The assertion
check aborts the ovs.

This commit fixes the issue by adding the proper initialization.

Bug #1239914.
Bug #1240598.
Bug #1240626.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath: Move table destroy to dp-rcu callback.

Ths simplifies flow-table-destroy API.  This change is required
for following patches.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Thomas Graf <tgraf@redhat.com>
datapath: Add flow mask cache.

On every packet OVS needs to lookup flow-table with every mask
until it finds a match. The packet flow-key is first masked
with mask in the list and then the masked key is looked up in
flow-table.  Therefore number of masks can affect packet
processing performance.

Following patch adds mask index to mask cache from last
pakcet lookup in same flow.  Index of mask is stored in
this cache. This cache is searched by 5 tuple hash (skb rxhash).

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Thomas Graf <tgraf@redhat.com>
datapath: Convert mask list in mask array.

mask caches index of mask in mask_list.  On packet recv OVS
need to traverse mask-list to get cached mask.  Therefore array
is better for retrieving cached mask.  This also allows better
cache replacement algorithm by directly checking mask's existence.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Thomas Graf <tgraf@redhat.com>
ofp-version-opt: Fix spelling and capitalization.

"OpenFlow" is one word.
"Version" isn't a proper noun.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>