Use updated dl_type when checking actions that use fields

Update handling of the following actions to use the dl_type set by MPLS
push and pop actions if it differs from the original dl_type. This is
consistent with the existing checking of load actions and allows
their existing checks to enforce dl_type pre-requisites correctly.

	output_reg
	bundle
	reg_move
	stack_push
	stack_pop
	learn
	multipath

In order to avoid the verbosity of updating the flow for each applicable
action the update is treated as a common case and performed in
ofpact_check().  This was suggested by Jesse Gross.

Cc: Jesse Gross <jesse@nicira.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Jesse Gross <jesse@nicira.com>
OpenFlow-level flow-based tunneling support.

Adds tun_src and tun_dst match and set capabilities via new NXM fields
NXM_NX_TUN_IPV4_SRC and NXM_NX_TUN_IPV4_DST.  This allows management of
large number of tunnels via the flow tables, without requiring the tunnels
to be pre-configured.

Flow-based tunnels can be configured with options remote_ip=flow and
local_ip=flow.  local_ip=flow requires remote_ip=flow.  When set, the
tunnel remote IP address and/or local IP address is set from the flow,
instead of the tunnel configuration.

Example:

$ ovs-vsctl add-port br0 gre -- set Interface gre ofport_request=1 type=gre options:remote_ip=flow options:key=flow
$ ovs-ofctl add-flow br0 "in_port=LOCAL actions=set_tunnel:1,set_field:192.168.0.1->tun_dst,output:1"
$ ovs-ofctl add-flow br0 "in_port=1 tun_src=192.168.0.1 tun_id=1 actions=LOCAL"

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
netdev: Factor restoring flags into new "struct netdev_saved_flags".

This gets rid of the only per-instance data in "struct netdev", which
will make it possible to merge "struct netdev_dev" into "struct netdev" in
a later commit.

Ed Maste wrote the netdev-bsd changes in this commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Co-authored-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Ed Maste <emaste@freebsd.org>
Tested-by: Ed Maste <emaste@freebsd.org>
netdev-bsd: Adjust argument line wrapping

This file presumably started out life as a copy of netdev-linux.c, and
some indentation was not updated after s/linux/bsd/.

Signed-off-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Ben Pfaff <blp@nicira.com>
meta-flow: Simplify mf_from_ofp_port_string()

ofputil_port_from_string() does all the work already.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
netdev: Add new "struct netdev_rx" for capturing packets from a netdev.

Separating packet capture from "struct netdev" means that there is no
remaining per-"struct netdev" state, which will allow us to get rid of
"struct netdev_dev" (by renaming it "struct netdev").

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
Rename superclass members to 'up'.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
netdev: Get rid of netdev_dev.

The distinction between struct netdev_dev and struct netdev has always
been confusing.  Now that previous commits have eliminated all interesting
state from struct netdev, this commit deletes it and renames struct
netdev_dev to take its place.  Now the situation makes much more sense and
I won't have to continue making embarrassed explanations in the future.

Good riddance.

Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath: Check for positive packet length in vport_send().

When sending a packet, a positive length indicates success and a
negative length indicates failure. However, the check for success
looked for non-zero values which catches both of these cases. This
can result in incorrect stats and leak memory on failure.

Introduced by commit be7cd27e44258bdb3c4e7dd8fd7389b5db56d55a (datapath:
Unify vport error stats handling.).

CC: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
ofproto-dpif: Make fin_timeout work when governor kicks in.

The xlate_actions() call in handle_flow_miss_without_facet() didn't
implement fin_timeout properly because tcp_flags wasn't getting set.

I have not tested that this fixes the problem, but it seems "obviously
correct".

Bug #16506.
Reported-by: Ying Chen <yingchen@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
datapath: Fix compilation with Linux kernel 3.7.

Definition of __sum16 and __wsum is moved to uapi header.
Following patch adds check in config script for second possible
header.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
netdev-linux: Skip NETDEV_UP test in netdev_linux_set_etheraddr() for taps.

netdev_turn_flags_off() does nothing if the flags that one turns off are
already off.

Reported-by: Ethan Jackson <ethan@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>