cfm: Notify connectivity_seq on remote maintenance points change.

Commit f23d157c ("ofproto-dpif: Don't poll ports when nothing changes")
did not ensure the update of the row of remote maintenance points in ovsdb
when it changes.  This commit makes the update happen by notifying the
global connectivity_seq.

Bug #1192265

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/flow: Retain ODPP_NONE on flow_extract().

We used to map ODPP_NONE to port number 0, which is wrong, as
ODPP_NONE is a valid value of the flow's in_port.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
dpif-netdev: Use packet key to parse TCP flags.

The flow that created the netdev_flow might have wildcarded TCP flags,
or it may not be a TCP flow at all.  Fix this by using the freshly
extracted flow key to parse TCP flags.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib: Use tcp_flags from flow.

TCP flags are already extracted from the flow, no need to parse them
again.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/packets: Remove packet_get_tcp_flags().

This function has no more users, so remove it.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
CodingStyle: Allow designated initializers.

MSVC 2013 finally implements them, 14 years after they became part of C,
so we can use them in generic code now.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
socket-util: Fix an inverted use of LINUX

Fix a regression introduced by commit fce314cd.
("socket-util: Fix definition of LINUX.")

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
dpif: Change dpif API to allow multiple handler threads read upcall.

This commit changes the API in 'dpif-provider.h' to allow multiple
handler threads call dpif_recv() simultaneously.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
dpif-netdev: Implement the API functions to allow multiple handler
threads read upcall.

This commit implements the API functions to allow multiple handler
threads read upcall.

Also, this commit removes the handling priority of DPIF_UC_MISS
over DPIF_UC_ACTION.  So, both misses will be put to the same
queue.  The decision is based on the fact that a lot has changed
since the age when flow setup rate is most treasured and starving
all actions in the presence of any flow misses doesn't seem like
a sound balancing solution.

Thusly the current implementation will be put in testing and
investigation for better balancing solution will continue if
there is an issue.

Also note, the introduction and use of flow_hash_5tuple() will
put missed ICMP packets from same source but with different
type/code to different handler queues.  This may cause reordering
of these packets.  For now, we do not count this as a problem.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
cfm: Define old_cfm_fault as 'enum cfm_fault_reason'.

CFM fault variable type has been changed to 'enum cfm_fault_reason' for
long time.  However, inside cfm_run(), the old_cfm_fault is still defined
as boolean.  This commit fixes the issue.

Found by inspection.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
cfm: Add test for the update of CFM status to OVSDB.

Since daemons can use the cfm status from OVSDB, it is useful
to add a test to guarantee that the update is in time.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto: Honour Table Mod settings for table-miss handling

This reworks lookup of rules for both table 0 and table action translation.
The result is that Table Mod settings, which can alter the miss-behaviour
of tables, including table 0, on a per-table basis may be honoured.

Previous patches proposed by myself which build on earlier merged patches
by Andy Zhou implement the ofproto side of Table Mod. So with this patch
the feature should be complete.

Neither this patch, nor any other patches it builds on, alter the default
behaviour of Open vSwitch. And in particular the OpenFlow1.1 behaviour is
the default regardless of which OpenFlow version is negotiated between the
switch and the controller.

An implementation detail, which lends itself to future work, is the
handling of OFPTC_TABLE_MISS_CONTINUE. If a table has this behaviour set by
Table Mod and a miss occurs then a loop is created, skipping to the next
table. It is quite easy to create a situation where this loop covers ~255
tables which is very expensive as the lookup for each table involves taking
locks, amongst other things.

Cc: Andy Zhou <azhou@nicira.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
[blp@nicira.com updated comments and refactored]
Signed-off-by: Ben Pfaff <blp@nicira.com>
odp-util: Fix VLAN parsing behavior in parse_8021q_onward().

Anytime there is a VLAN the flow needs to properly reflect that.  Keeping
the TPID in dl_type never makes sense and will probably cause problems.
The existing code did the right thing in the common case but not in corner
cases where it returned ODP_FIT_TOO_MUCH or ODP_FIT_TOO_LITTLE (the cases
where it returned an error don't matter since nothing looks at the flow
in that case).

Found by inspection.

Signed-off-by: Ben Pfaff <blp@nicira.com>