socket-util: Report fd of -1 on error in inet_open_active().

inet_open_active() is documented to report a fd of -1 when an error occurs.
All three of its callers rely on this, by checking only the fd to determine
whether there was an error.  This means that if the call to
set_nonblocking() or set_dscp() or connect() failed, then the callers would
try to use a fd that had already been closed, wreaking havoc.

This fixes a bug introduced in commit a4efa3fc5d (socket-util: Close socket
on failed dscp modification.)

Bug #13750.
Reported-by: Scott Hendricks <shendricks@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
datapath: Include OVS_KEY_ATTR_IPV4_TUNNEL in upstream range.

During development it was preferable to keep OVS_KEY_ATTR_IPV4_TUNNEL
in the non-upstream range of identifiers to avoid conflicts or
compatibility issues as it evolved.  However, since the intention is
to get it upstream, it makes sense to move it down now to avoid issues
with compatibility when upgrading.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
datapath: Don't write into IPV4_TUNNEL data when using TUN_ID.

When the IPV4_TUNNEL action is executed, a pointer in the skb is
directly assigned the address of the action, which is protected by
RCU.  If a TUN_ID action is later executed it will write into the
action, which is not allowed by RCU.  This avoids the problem by
making a copy of the data and writing into the copy.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
datapath: Don't allow flows installed with only TUN_ID.

Tunnel ports now always include full outer IP information, even if
userspace can't understand it.  Since our flows our exact match this
information must also be provided when setting up flows.  Since flows
with only OVS_KEY_ATTR_TUN_ID keys don't contain all of this information
they can never be hit and we should just reject them at setup time.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
datapath: Shorten flow tunneling flags.

The names for the flags used by flow based tunneling are pretty long.
This shortens them a little by removing the word FLOW, which is a
distinction that won't be meaningful in the near future.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
datapath: Allow GRE64 to use flow based tunneling.

There's no reason why GRE64 can't be configured using flow based
tunneling.  Since that's the direction we are moving, everything
should support that.  Once this special casing is removed, it's
possible to unify the tunnel parameter parsing code since both
GRE and CAPWAP are the same.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
tunnel: Zero keys if marked as not present.

If a key used to find a port then we mark it as being not present
(previously this was accomplished by setting it to zero).  However,
we also still pass the key to userspace which could lead to an
inconsistent state.  This also zeros out the key as before in order
to make our reported results consistent.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
datapath: ipv6_skip_exthdr() is now fully upstream.

OVS required some extensions to ipv6_skip_exthdr() which have
since been accepted upstream.  On kernels with these changes we can
now use the upstream version instead of our compatibility code.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
datapath: Move tun_key out of struct phy and union.

Tunneling metadata is important enough to move out of struct phy
and handled on its own.  This makes it somewhat easier to tell
how well the other structures are packed and also the name shorter.
This also drops the union since it's not needed quite yet.  We
can introduce it back when we have support for IPv6 tunneling.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
Merge branch 'master' of git://openvswitch.org/openvswitch into vxlan