datapath: Fix build failure on RHEL 6.4

Patch fixes following build failure:-

make[4]: Entering directory
`/usr/src/kernels/2.6.32-358.18.1.el6.x86_64'
  CC [M]  openvswitch/datapath/linux/actions.o
In file included from
openvswitch/datapath/linux/actions.c:21:
openvswitch/datapath/linux/compat/include/linux/skbuff.h:273:
error: redefinition of â€˜__skb_fill_page_descâ€™
include/linux/skbuff.h:1123: note: previous definition of
â€˜__skb_fill_page_descâ€™ was here
-----

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
unixctl: Make dpif/dump-flows fetch kernel flows.

Previously we used facets for ovs-appctl dpif/dump-flows commands.
This switches to fetching flows directly from the dpif.  This is
necessary because future patches remove facets and subfacet entirely.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto: Handle flow installation and eviction in upcall.

This patch moves flow installation and eviction from ofproto-dpif and
the main thread, into ofproto-dpif-upcall.  This performs
significantly better (approximately 2x TCP_CRR improvement), and
allows ovs-vswitchd to maintain significantly larger datapath flow
tables.  On top of that, it significantly simplifies the code,
retiring "struct facet" and friends.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
.gitignore: add /libtool

The ./configure script now generates a 'libtool' file in the top-level
directory.  Add it to .gitignore

Signed-off-by: Lorand Jakab <lojakab@cisco.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
tests/daemon-py.at: Skip if no python

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
tests/ofproto-dpif.at: Portability improvement

The output of "wc -l" have leading spaces on some platforms.
(NetBSD, OSX, ...)

This fixes a test failure introduced by commit e79a6c83.
("ofproto: Handle flow installation and eviction in upcall.")

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
tests/ofproto.at: Avoid stdout/stderr ordering assumptions

Stop assuming the order of outputs from separate streams.
(stdout and stderr)

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif-upcall: Reduce log level of "Spent unreasonably long" msg

This message can be caused by a time warp and make tests fail.

The message was introduced by commit e79a6c83.
("ofproto: Handle flow installation and eviction in upcall.")

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
tests/ofproto-dpif.at: Workaround a race

This test seems to assume only the first packets in flows
counted as 'miss'.  I don't see any code ensuring that.
The test would fail if the upcall handler for the flow doesn't
run fast enough.  Workaround the problem by giving 1 second
for the miss upcall.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
timeval: Workaround for threaded test failures

BFD tests have the code like the following.

    # wait for a while to stablize everything.
    for i in `seq 0 9`; do ovs-appctl time/warp 500; done

They no longer work as intended because BFD code is run in a
separate monitor thread these days.  The loop merely "warp"
the time by 5000.  The monitor thread should have been woken
at least once, but it's far from "wait for a while to stablize
everything."

This commit mitigates the problem by sleeping a little in the
appctl handler.  This is not ideal but makes BFD tests success
on my environment.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
tests/learn.at: Workaround a race

This test seems to assume that the switch completes
processing of the first packet before start processing
the second one.  I don't see any code ensuring that.
Workaround the problem by giving 1 second for the upcall.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/flow: Skip minimask value checks.

We allow zero 'values' in a miniflow for it to have the same map
as the corresponding minimask.  Minimasks themselves never have
zero data values, though.  Document this and optimize the code
accordingly.

v2:
- Made miniflow_get_map_in_range() to return data offset instead of
  a pointer via the last parameter.
- Simplified minimatch_hash_in_range() by removing pointer arithmetic.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofp-print: Print durations with at least three decimals.

Occasionally I run a command like this:
    watch -n.1 ovs-ofctl dump-flows br0
to see how flows change over time.  Until now, it has been more difficult
than necessary to spot real changes, because flows "jump around" as the
number of decimals printed for duration changes from moment to moment.
That is, you might see
    cookie=0x0, duration=4.566s, table=0, n_packets=0, ...
one moment, and then
    cookie=0x0, duration=4.8s, table=0, n_packets=0, ...
the next moment.  Shortening 4.8 to 4.800 shifts everything following it
two places to the left, creating a visual jump.

This commit avoids that problem by always printing at least three decimals
if we print any.  There can still be an occasional jump if a duration is
exactly on a second boundary, but that only happens 1/1000 of the time.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
ovs-check-dead-ifs: Flush buffer before calling execvp.

According to Python documentation here for execvp:
http://docs.python.org/2/library/os.html
"The current process is replaced immediately. Open file objects
and descriptors are not flushed, so if there may be data buffered
on these open files, you should flush them using sys.stdout.flush()
or os.fsync() before calling an exec* function.

Without the flush, we will miss the print statements before that
if we redirect the o/p to a file.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
linux: Report supported user features to the kernel

Following commit (''netlink: Do not enforce alignment of last Netlink
attribute''), signal the ability to receive unaligned Netlink messages
to the datapath to enable utilization of zerocopy optimizations.

Opening a datapath is now done by issueing a OVS_DP_CMD_SET in order
to overwrite previously set user features.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
datapath: Check for backported netdev_features_t.

This is apparently used by CentOS 6.5.

Reported-by: Phil Daws <uxbod@splatnix.net>
Reported-by: Edouard Bourguignon <madko@linuxed.net>
Signed-off-by: Jesse Gross <jesse@nicira.com>
bfd: Send FINAL immediately after receiving POLL.

Commit 307464a11 (ofproto-dpif-monitor: Use heap to order the mport
wakeup time.) makes bfd only send packet at specified periodic instant.
This fails to meet the RFC5880 requirement, which requires bfd send
FINAL immediately after receiving POLL.

This commit fixes the above issue by scheduling bfd to send FINAL
within 100 ms after receiving POLL.

Signed-off-by: Alex Wang <alexw@nicira.com>
datapath: Fix sparse warning on BUILD_BUG_ON_INVALID()

Sparse gives the following warnings when compile against Linux kernel
3.5:

 CHECK   /root/projs/ovs/openvswitch/datapath/linux/skbuff-openvswitch.c
 include/linux/mm.h:405:9: error: undefined identifier
 'BUILD_BUG_ON_INVALID'
 include/linux/mm.h:405:9: error: not a function <noident>

The same issue may also exist in kernel 3.6.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
datapath: bug.h missing from distfiles

commit 7c359202 introduced datapath/linux/compat/include/bug.h
but did not include it in datapath/linux/Modules.mk, which results
in the following build error:

> The distribution is missing the following files:
> datapath/linux/compat/include/linux/bug.h

Signed-off-by: Chris Luke <chris_luke@cable.comcast.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
ofpbuf: New function ofpbuf_shift().

An upcoming commit will add the first user.

Signed-off-by: Ben Pfaff <blp@nicira.com>