ofproto-dpif: Add table-miss flow tests

Cc: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif: Differentiate between different miss types in packet in

Replace the generated_by_table_miss field of struct ofproto_packet_in
with a miss_type field.

The generated_by_table_miss field allowed packet-in messages generated
by table-miss rules to be differentiated. This differentiation
is still provided for by miss_type being set to OFPROTO_PACKET_IN_MISS_FLOW.

This patch allows further differentiation by setting miss_type
to OFPROTO_PACKET_IN_MISS_WITHOUT_FLOW if the packet-in message
is generated by a table-miss which is not handled by a table-miss rule.

This is in preparation for OpenFlow 1.3 version-specific
handling of the default action for such misses.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto: Allow the use of the OpenFlow 1.4 protocol

This defines the version number for OpenFlow 1.4 so that the switch
can actually use it. The ovsdb schema is also modified.

Signed-off-by: Alexandru Copot <alex.mihai.c@gmail.com>
Cc: Daniel Baluta <dbaluta@ixiacom.com>
[blp@nicira.com adjusted code in cases where 1.3 and 1.4 are the same]
Signed-off-by: Ben Pfaff <blp@nicira.com>
Disable OF1.4 in ovs-vswitchd and ovs-ofctl without specially enabling.

When the OF1.4 is made safe, so that receiving an unimplemented message
cannot crash the switch, this commit should be reverted.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-actions: New function ovs_instruction_type_from_inst_type().

Signed-off-by: Alexander Wu <alexander.wu@huawei.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-actions: Complete ofp13_action_type.

Signed-off-by: Alexander Wu <alexander.wu@huawei.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
bitmap: Make bitmap_scan() able to scan for 0-bits or 1-bits.

An upcoming commit will make use of this feature.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-util: Implement OFPMP_TABLE_FEATURES decoding and printing.

Signed-off-by: Alexander Wu <alexander.wu@huawei.com>
Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath: Fix output of SCTP mask.

The 'output' argument of the ovs_nla_put_flow() is the one from which
the bits are written to the netlink attributes.  For SCTP we
accidentally used the bits from the 'swkey' instead.  This caused the
mask attributes to include the bits from the actual flow key instead
of the mask.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
datapath: Use TCP flags in the flow key for stats.

We already extract the TCP flags for the key, might as well use that
for stats.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
ofp-util: Fix inconsistencies in table features type.

'metadata_match' and 'metadata_write' fields are defined as ovs_be64,
but sometimes used and referred to as uint64_t.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
datapath: Compact sw_flow_key.

Minimize padding in sw_flow_key and move 'tp' top the main struct.
These changes simplify code when accessing the transport port numbers
and the tcp flags, and makes the sw_flow_key 8 bytes smaller on 64-bit
systems (128->120 bytes).  These changes also make the keys for IPv4
packets to fit in one cache line.

There is a valid concern for safety of packing the struct
ovs_key_ipv4_tunnel, as it would be possible to take the address of
the tun_id member as a __be64 * which could result in unaligned access
in some systems. However:

- sw_flow_key itself is 64-bit aligned, so the tun_id within is always
  64-bit aligned.
- We never make arrays of ovs_key_ipv4_tunnel (which would force every
  second tun_key to be misaligned).
- We never take the address of the tun_id in to a __be64 *.
- Whereever we use struct ovs_key_ipv4_tunnel outside the sw_flow_key,
  it is in stack (on tunnel input functions), where compiler has full
  control of the alignment.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
packets: packet metadata from flow function instead of macro.

Commit 03fbdf8d9c80a (lib/flow: Retain ODPP_NONE on flow_extract())
replaced packet metadata initialization function by a macro.
Visual studio does not like nested structure initialization that
is done in that macro.

This commit replaces the macro by a function.

CC: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>