datapath: Remove unused get_config vport op.

The get_config vport op is left over from old compatibility code,
it is neither used nor implemented any more.

Signed-off-by: Jesse Gross <jesse@nicira.com>
tunneling: Remove struct tnl_vport and tnl_ops.

After flow based tunneling, kernel tunneling is greatly simplified.
There is no need to have extra tunneling layer between vport and
particular protocol.
Following patch removes tunneling struct which make code easy to read.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
datapath: Unify vport error stats handling.

Following patch changes vport->send return type so that vport
layer can do error accounting.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
datapath: Move vport init to first port create.

vport->init and exit() functions are defined by gre and netdev vport
only and both can be moved to first port create.

Following patch does same, it moves vport init to respective vport
create and gets rid of vport->init() and vport->exit() functions.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
datapath: Kill VPORT_F_TUN_ID vport flag.

VPORT_F_TUN_ID is last remaining flag, once we remove it, flags
field from vport-ops can be removed.  Since it does not complicate
much code, we decided to remove this flag.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Allow master to build on Fedora with the recent threading changes

The recent threading changes have broken the build on Fedora,
and presumably other Red Hat based distributions. This adds an explicit
"-lpthread" to the linker command line and allows the latest master to build
on Fedora. I've also tested this on Ubuntu and it builds fine there.

Signed-off-by: Kyle Mestery <kmestery@cisco.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ed Maste <emaste@freebsd.org>
ovsdb-client: Avoid assertion with multiple databases.

When using ovsdb-client with an ovsdb-server with multiple databases, an
assertion could trigger due to them being returned in non-sorted order.
This commit changes the fetch_dbs() function to always return databases
in sorted order, since both callers are expecting that behavior.

Bug #16882

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Reported-by: Spiro Kourtessis <spiro@vmware.com>
ovsdb-client: Fix recently introduced svec_sort() bug.

Commit 66980be9 (ovsdb-client: Avoid assertion with multiple databases.)
passed in a pointer to an svec pointer, when it should have just been an
svec pointer.  This corrects the bug.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
ovs-ofctl: Fix bad info in comment on transact_multiple_noreply().

Cut-and-paste error I guess.

Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath: Free skb dropped by lisp_tnl_send().

vport->send functions must free the skbs they themselves report as
dropped (return 0).

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
bfd: Implement Bidirectional Forwarding Detection.

Traditionally, Open vSwitch has used a variant of 802.1ag "CFM" for
interface liveness detection.  This has served us well until now,
but has several serious drawbacks which have steadily become more
inconvenient.  First, the 802.1ag standard does not implement
several useful features forcing us to (optionally) break
compatibility.  Second, 802.1.ag is not particularly popular
outside of carrier grade networking equipment.  Third, 802.1ag is
simply quite awkward.

In an effort to solve the aforementioned problems, this patch
implements BFD which is ubiquitous, well designed, straight
forward, and implements required features in a standard way.  The
initial cut of the protocol focuses on getting the basics of the
specification correct, leaving performance optimizations, and
advanced features as future work.  The protocol should be
considered experimental pending future testing.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
ofproto-dpif: Avoid figuring out sFlow and IPFIX actions twice.

Not only is it easier to re-use the actions we already have, this avoids
potential problems due to the state that add_sflow_action() and
add_ipfix_action() look at having possibly been changed by
do_xlate_actions().  Currently those functions appear to look only at
the flow's 'in_port', which currently can't change.  However, an upcoming
commit will make it possible for actions to change the flow's 'in_port',
and in addition, with this change, one doesn't have to wonder whether these
functions might look at other state that translation might change.

Signed-off-by: Ben Pfaff <blp@nicira.com>
meta-flow: Make 'in_port' field writable.

OpenFlow says that an "output" action to a flow's input port is ordinarily
dropped, unless the flow explicitly outputs to OFPP_IN_PORT.  We've
occasionally been asked to implement some way to avoid this behavior in
cases where it is not easily known in advance whether a given port is the
input port (so that OFPP_IN_PORT is not easy to use).

This commit implements such a feature.  With this commit, one may write:
    actions=load:0->NXM_OF_IN_PORT[],output:123
which will output to port 123 regardless of whether it is the input port.
If the input port is important, then one may save and restore it on the
stack:
    actions=push:NXM_OF_IN_PORT[],load:0->NXM_OF_IN_PORT[],output:123,
            pop:NXM_OF_IN_PORT[]

(Sometimes I am asked whether "resubmit" changes the in_port and would
therefore interact badly with this feature.  It does not.   "resubmit" only
(optionally) changes the in_port used for the resubmit's flow table lookup.
It does not otherwise have any effect on in_port.)

Bug #14091.
CC: Jarno Rajahalme <jarno.rajahalme@nsn.com>
CC: Ronghua Zhang <rzhang@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ovs-pki: Reduce CA certificate validity to 10 years to fix 32-bit OpenSSL.

Before I applied this commit, when I generated CA certificate with OpenSSL
0.9.8o on my 32-bit Debian system, I got a certificate that expired
sometime in 1977.  This made all SSL-based tests fail with an invalid
certificate.

32-bit time_t only extends to 2038, so this must be a bug in OpenSSL.
This commit works around the problem by reducing the validity period of
certificates to 10 years.

CC: Gurucharan Shetty <gshetty@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Check actions prerequisites in parse_ofp_str()

Add a call to ofpacts_check() in parse_ofp_str() to check pre-requisites.
This is in preparation for removing special-case pre-requisite checking
of learn actions which is useful for the test-suite.

This patch also fixes two tests which this change revealed to be incorrect.

1. Open Flow 1.0 action which sets NXM_NX_IPV6_SRC
   without any pre-requisites

   This is not valid because there should be an IPv6 pre-requisite.

   This portion of the test has been removed as IPv6 pre-requisites are
   only valid when using OXM or NXM, however the test appears
   to be a (non-NXM) Open Flow 1.0 test.

   It has been replaced with a similar test of an action
   that sets the IPv4 source address.

2. Open Flow 1.2 action which sets NXM_NX_IPV6_SRC
   without any pre-requisites.

   This is not valid because there should be an IPv6 pre-requisite.

   This test has been corrected by adding IPv6 as a pre-requisite,
   which is valid for Open Flow 1.2 as it uses OXM.

Use of ofpacts_check() in parse_ofp_str() suggested by Ben Pfaff.

Cc: Ben Pfaff <blp@nicira.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Do not perform validation in learn_parse();

I believe this is consistent with the handling of all other action
parsing called from parse_named_action().

Verification of all actions, including learn actions, occurs separately
in ofpact_check__(). It also occurs via in a call to ofpacts_check()
in parse_ofp_str(),

This patch is larger than might otherwise be expected as the flow argument
of learn_parse() is now unused and thus removed.  This propagates up the
call-chain some way.

This implementation was suggested by Jesse Gross in response to an
enhancement I made to the validation performed during parsing learn actions
to allow it to correctly account for changes to the dl_type due to MPLS
push and pop actions.

Tests have also been updated to check for the less specific messages
generated by the call to ofpacts_check() in parse_ofp_str() which at the
suggestion of Ben Pfaff was added by a prior patch for this purpose.

Cc: Jesse Gross <jesse@nicira.com>
Cc: Ben Pfaff <blp@nicira.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Always check return value of strftime().

strftime() returns 0 and leaves the contents of the output buffer
unspecified if the output buffer is not big enough.  Thus, one should
check strftime()'s return value.  Until now, OVS has had a few invocations
of strftime() that did not check the return value.  This commit fixes
those.  I believe that the buffers were always large enough in each case,
but it's better to be safe.

Reported-by: Andy Zhou <azhou@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
NEWS: Modification of 'in_port' backported to 1.11.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Keep all of tunnel metadata in flow.

Do not clear tunnel metadata on tunnel input. This is used by a later patch.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif: Remove initial_vals.tunnel_ip_tos.

As tunnel metadata is no longer cleared on input, and the input
values are retained in 'ctx->flow' accross tunnel output actions,
there is no need to store the tunnel.ip_tos to initial_vals.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>