tests: Relax the requirement of bfd tests on timing.

Before this commit, the bfd related tests check the change of
states with very strict timing requirement.  This makes the tests
fragile, especially when ofproto-dpif-monitor module is moved to
its own thread.

Thusly, this commit relaxes the requirement on timing, making the
tests more reliable.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
ofproto-dpif-monitor: Run ofproto-dpif-monitor in a thread.

This commit moves the ofproto-dpif-monitor module into a
dedicated thread.  This helps eliminate the burden of main
thread having to wake up very frequently for periodic
interface monitoring (bfd, cfm).  Thusly, this commit greatly
increases the number of bfd/cfm sessions that can be supported
by ovs.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
heap: Change type of "priority" in "struct heap".

This commit changes the variable type of priority in "struct heap"
from uint32_t to uint64_t.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
bfd: Add bfd_wake_time() function.

This commit adds a new function "bfd_wake_time()" that returns the
next wakeup time associated with the "struct bfd".

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
cfm: Add cfm_wake_time() function.

This commit adds a new function "cfm_wake_time()" that returns the
next wakeup time associated with the "struct cfm".

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
ofproto-dpif-monitor: Use heap to order the mport wakeup time.

Before this commit, each time ofproto-dpif-monitor thread wakes up,
all monitored ports will be iterated over.  This adds a huge overhead
to the monitor thread.  This commit uses a heap to order the wakeup
time of monitored ports.  So each time the monitor thread is waken up,
it will only iterate those monitored ports that have timed out.

This commit greatly increases the number of monitored interfaces
openvswitch could support.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
ofp-actions: Fix some ofpbuf usage problems in write-actions code.

This code kept a pointer to data that might have been reallocated.

For longer term, "nested" variants of some ofpact functions
which using ofpbuf->l3 might be desirable.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-parse: Fix padding parsing write-actions.

For longer term, "nested" variants of some ofpact functions
which using ofpbuf->l3 might be desirable.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-actions: Consistently use helper function.

No functional changes.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-util: Fix a comment.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
nx-match: Fix comments.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ovs-dpctl: Add a 'filter' option to match wildcarded 'dump-flows'.

With mega-flows, many flows in the kernel datapath are wildcarded.
For someone that is debugging a system and wants to find a particular
flow and its actions, it is a little hard to zero-in on the flow
because some fields are wildcarded.

With the filter='$filter' option, we can now filter on the o/p
of 'ovs-dpctl dump-flows'.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
include/openflow: Move union ofp_action away from headers.

union ofp_action cannot remain in the OF 1.0 header as it is expanded
to include actions from later versions.  Also, it is not part of the
protocol interface and will be easier to update where it is actually
used.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ovsdb-doc: generate vswitch.[pic|gv] files only if dot tool is available

These are auto-generated files, so it would be better not to keep them
inside Open vSwitch repository.

Behaviour before this patch was that if dot tool was not present on
the system, then ovs-vswitchd.conf.db.5 would have used pre-generated
vswitch.pic file that was already checked in the git repository. After
this patch ovs-vswitchd.conf.db.5 will simply not have a dot diagram,
if dot was not present at the time when Open vSwitch was built.

Signed-off-by: Ansis Atteka <aatteka@nicira.com>
More accurate wildcarding and fragment handling.

This patch gets rid of the need for having explicit padding in struct
flow as new fields are being added.  flow_wildcards_init_exact(), which
used to set bits in both compiler generated and explicit padding, is
removed.  match_wc_init() is now used instead, which generates the mask
based on a given flow, setting bits only in fields which make sense.

Places where random bits were placed in struct flow have been changed to
only set random bits on fields that are significant in the given context.
This avoids setting padding bits.

- lib/flow:
  - Properly initialize struct flow also in places we used to zero out
    padding before.
  - Add flow_random_hash_fields() used for testing.
  - Remove flow_wildcards_init_exact() to avoid initializing
     masks where compiler generated padding has bits set.
- lib/match.c match_wc_init(): Wildcard transport layer fields for later
  fragments, remove match_init_exact(), which used
  flow_wildcards_init_exact().
- tests/test-flows.c: use match_wc_init() instead of match_init_exact()
- tests/flowgen.pl: generate more accurate packets and flows when
  fragmenting, mark unavailable fields as wildcarded.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ovsdb-dot: Include arrows by default.

When ovsdb-dot generates diagrams for use in the manpages, the dot2pic
postprocessor makes nicer output if the arrowheads are omitted (dot2pic
adds the arrowheads itself).  But for other uses that don't go through
the postprocessor, we generally want the arrowheads.  So this commit adds
an option.  On the principle that the default should be the least
surprising to a naive user, arrowheads are included by default.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
vtep: Initial checkin of vtep schema.

The hardware VTEP OVSDB schema specifies relations that a VTEP can use
to integrate physical ports into logical switches maintained by a
network virtualization controller such as NVP.

Co-authored-by: Ben Pfaff <blp@nicira.com>
Co-authored-by: Kenneth Duda <kduda@aristanetworks.com>
Co-authored-by: Justin Pettit <jpettit@nicira.com>
Signed-off-by: Bruce Davie <bdavie@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Kenneth Duda <kduda@aristanetworks.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
vtep: Add vtep-ctl command.

The vtep-ctl command provides a user interface to manipulate the VTEP
OVSDB schema.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
vtep: Initial checkin of ovs-vtep.

ovs-vtep is a VTEP emulator that uses Open vSwitch for forwarding.

Co-authored-by: Gurucharan Shetty <gshetty@nicira.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
vtep: Add Debian packaging.

Co-authored-by: David Yang <davidy@vmware.com>
Signed-off-by: David Yang <davidy@vmware.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>