sliver-openvswitch.git
10 years agocomply with new ofpbuf interface
Giuseppe Lettieri [Fri, 11 Apr 2014 08:11:22 +0000 (10:11 +0200)]
comply with new ofpbuf interface

10 years agoMerge branch 'mainstream'
Giuseppe Lettieri [Thu, 10 Apr 2014 15:28:24 +0000 (17:28 +0200)]
Merge branch 'mainstream'

10 years agoSubmittingPatches: Rename to CONTRIBUTING.
Joe Stringer [Thu, 10 Apr 2014 04:57:51 +0000 (16:57 +1200)]
SubmittingPatches: Rename to CONTRIBUTING.

This makes the GitHub interface aware of the contribution guidelines,
so it will be displayed to contributors when they submit issues or pull
requests.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoMerge branch 'mainstream'
Giuseppe Lettieri [Thu, 10 Apr 2014 15:20:49 +0000 (17:20 +0200)]
Merge branch 'mainstream'

Conflicts:
lib/dpif-netdev.c
lib/netdev.c

10 years agovlandev: Fix an obvious predicate logic crash bug.
ZhengLingyun [Thu, 10 Apr 2014 15:07:05 +0000 (08:07 -0700)]
vlandev: Fix an obvious predicate logic crash bug.

Signed-off-by: ZhengLingyun <konghuarukhr@163.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif.at: Update MPLS test names.
Joe Stringer [Thu, 10 Apr 2014 04:56:12 +0000 (16:56 +1200)]
ofproto-dpif.at: Update MPLS test names.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agolearn.at: Fix a shell syntax
YAMAMOTO Takashi [Thu, 10 Apr 2014 00:32:36 +0000 (09:32 +0900)]
learn.at: Fix a shell syntax

Fix a botch in commit 7f12bdcc.
("learn.at: Fix a race in "self-modifying flow with idle_timeout" test")

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agonetdev-bsd: Update for recent ofpbuf api changes
YAMAMOTO Takashi [Wed, 9 Apr 2014 03:43:49 +0000 (12:43 +0900)]
netdev-bsd: Update for recent ofpbuf api changes

Leftovers from commit commit 1f317cb5.
("ofpbuf: Introduce access api for base, data and size.")

This fixes regressons introduced by commit 3f976e12.
("lib/ofpbuf: Rename private fields to discourage direct use.")

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agotests/ofproto-dpif: Use vlog to test dpif behaviour.
Joe Stringer [Wed, 9 Apr 2014 23:14:07 +0000 (11:14 +1200)]
tests/ofproto-dpif: Use vlog to test dpif behaviour.

Previously we made heavy use of the 'ovs-appctl dpif/dump-flows' command
to verify that flows were being installed into the datapath correctly.
However this is sensitive to timing, particularly when the behaviour of
revalidator threads is modified. A common race condition involves flows
being revalidated and deleted before the test script gets a chance to
connect to ovs-vswitchd and dump the datapath flows.

This patch reworks the tests to make use of the vlog facility for dpif,
checking for flow installation and flow dump messages. Most tests are
converted to check for flow installation, which should reduce these race
conditions significantly. For tests that require packet counts, these
will continue to check for flow_dump messages. Race conditions for these
should be reduced but not eliminated.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto/xlate: Fix set field unwildcarding.
Jarno Rajahalme [Wed, 9 Apr 2014 18:13:57 +0000 (11:13 -0700)]
ofproto/xlate: Fix set field unwildcarding.

If the field does not exist, nothing is set.  However, we must
unwildcard the bits we used to make the decision, and we need not
unwildcard the field and it's prerequisities, if nothing is set.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoTests: Fix ofproto/trace and expose megaflows when having a set action.
Jarno Rajahalme [Wed, 9 Apr 2014 18:13:57 +0000 (11:13 -0700)]
Tests: Fix ofproto/trace and expose megaflows when having a set action.

ofproto/trace incorrectly reported the megaflow based on the modified
flow, rather than the original flow key.  Now the original flow key is
stored before any modifications and is used for reporting the megaflow.

Also, flow reporting is suppressed only for resubmit flows, so that
the final flow will be printed if it is different from the incoming
flow key.

Test for the megaflow key and mask with flows having set actions.
This helps in verifying the correctness of operation with masked set
actions in the following patches.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto: Fix wildcard masking with nw_tos.
Jarno Rajahalme [Wed, 9 Apr 2014 18:13:57 +0000 (11:13 -0700)]
ofproto: Fix wildcard masking with nw_tos.

Later patches rely on the DSCP and ECN masks to be properly set when
the fields are read.  Also, avoid reading nw_tos if tunnel's inner
packet is not IP.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agolib/ofp-actions: Silently discard set ip ecn/ttl actions on OpenFlow10.
Jarno Rajahalme [Wed, 9 Apr 2014 18:13:57 +0000 (11:13 -0700)]
lib/ofp-actions: Silently discard set ip ecn/ttl actions on OpenFlow10.

It is better to not abort().

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agodpif-netdev: Use existing flow for computing dp hash
Andy Zhou [Tue, 8 Apr 2014 20:26:46 +0000 (13:26 -0700)]
dpif-netdev: Use existing flow for computing dp hash

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agodpif-netdev: preserve packet metadata fields across recirculation
Andy Zhou [Tue, 8 Apr 2014 18:32:57 +0000 (11:32 -0700)]
dpif-netdev: preserve packet metadata fields across recirculation

If the actions executed during recirculation changed metadata fields,
then any actions after the recirculation returns would see those new
values. Now, all metadata are saved and restored across a recirculation.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agobridge: improve vlan mode related error messages when adding port
Thomas Graf [Wed, 9 Apr 2014 15:19:17 +0000 (17:19 +0200)]
bridge: improve vlan mode related error messages when adding port

Inform about fallback to trunk mode and convert errors to warnings
when we are not failing.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agodpif: Wildcard bond output port with recirculation
Andy Zhou [Tue, 8 Apr 2014 04:49:07 +0000 (21:49 -0700)]
dpif: Wildcard bond output port with recirculation

This patch took advantage of the recirculation infrastructure
introduced in commit adcf00ba35a0, allowing megaflows to be generated
when the flow output to bond ports.

Without recirculation, it is necessary flows output to Bond ports
in balance_tcp mode to unmask all hash fields. With recirculation,
masking of hash fields is no longer required as kernel
now hashes each packet and redirects packets based on the hash value
using recirculation.

This patch removes the masking requirements when recirculation is
in use. Datapaths do not support recirculation are still supported,
but without the benefits of megaflow.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agodatapath: supply a dummy err_handler of gre_cisco_protocol to prevent kernel crash
Wei Zhang [Sat, 5 Apr 2014 23:17:35 +0000 (16:17 -0700)]
datapath: supply a dummy err_handler of gre_cisco_protocol to prevent kernel crash

When use gre vport, openvswitch register a gre_cisco_protocol but
does not supply a err_handler with it. The gre_cisco_err() in
net/ipv4/gre_demux.c expect err_handler be provided with the
gre_cisco_protocol implementation, and call ->err_handler() without
existence check, cause the kernel crash.

This patch provide a err_handler to fix this bug.

Signed-off-by: Wei Zhang <asuka.com@163.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
10 years agoovs-dev.py: Update repository location.
Ben Pfaff [Tue, 8 Apr 2014 23:56:21 +0000 (16:56 -0700)]
ovs-dev.py: Update repository location.

The Open vSwitch repository has moved to Github.

CC: Ethan Jackson <ethan@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
10 years agodatapath: Fix tracking of flags seen in TCP flows.
Ben Pfaff [Tue, 8 Apr 2014 22:39:18 +0000 (15:39 -0700)]
datapath: Fix tracking of flags seen in TCP flows.

Flow statistics need to take into account the TCP flags from the packet
currently being processed (in 'key'), not the TCP flags matched by the
flow found in the kernel flow table (in 'flow').

This bug made the Open vSwitch userspace fin_timeout action have no effect
in many cases.

Bug #1219516.
Reported-by: Len Gao <leng@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
10 years agolib/ofpbuf: Rename private fields to discourage direct use.
Jarno Rajahalme [Tue, 8 Apr 2014 15:36:33 +0000 (08:36 -0700)]
lib/ofpbuf: Rename private fields to discourage direct use.

Direct use of 'data', 'base', and 'size' will break DPDK builds.  Try
to wean us off the habit by renaming the fields.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
10 years agoofproto/ofproto-dpif: Use ofpbuf API to access 'data' and 'size'.
Jarno Rajahalme [Tue, 8 Apr 2014 15:54:42 +0000 (08:54 -0700)]
ofproto/ofproto-dpif: Use ofpbuf API to access 'data' and 'size'.

A recent commit reintroduced some direct use of the ofpbuf 'data' and
'size'.  Use the access API instead.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif.at: Fix a race in "idle_age and hard_age increase over time"
YAMAMOTO Takashi [Fri, 4 Apr 2014 11:13:30 +0000 (20:13 +0900)]
ofproto-dpif.at: Fix a race in "idle_age and hard_age increase over time"

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agolearn.at: Fix a race in "learn refreshes hard_age" test
YAMAMOTO Takashi [Fri, 4 Apr 2014 10:18:35 +0000 (19:18 +0900)]
learn.at: Fix a race in "learn refreshes hard_age" test

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agolearn.at: Fix a race in "self-modifying flow with hard_timeout"
YAMAMOTO Takashi [Fri, 4 Apr 2014 09:23:00 +0000 (18:23 +0900)]
learn.at: Fix a race in "self-modifying flow with hard_timeout"

Also, add a comment to explain the expected sequences.

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agoofproto-dpif.at: Fix races in "NetFlow flow expiration" tests
YAMAMOTO Takashi [Fri, 4 Apr 2014 08:46:01 +0000 (17:46 +0900)]
ofproto-dpif.at: Fix races in "NetFlow flow expiration" tests

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agoofproto-dpif.at: Fix a race in "flow stats" test
YAMAMOTO Takashi [Fri, 4 Apr 2014 08:36:05 +0000 (17:36 +0900)]
ofproto-dpif.at: Fix a race in "flow stats" test

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agoofproto-dpif.at: Fix a race in fin_timeout test
YAMAMOTO Takashi [Fri, 4 Apr 2014 08:30:05 +0000 (17:30 +0900)]
ofproto-dpif.at: Fix a race in fin_timeout test

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agoofproto-dpif.at: Fix some races in MPLS actions tests
YAMAMOTO Takashi [Fri, 4 Apr 2014 08:02:11 +0000 (17:02 +0900)]
ofproto-dpif.at: Fix some races in MPLS actions tests

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agolearn.at: Fix a race in "self-modifying flow with idle_timeout" test
YAMAMOTO Takashi [Fri, 4 Apr 2014 04:57:26 +0000 (13:57 +0900)]
learn.at: Fix a race in "self-modifying flow with idle_timeout" test

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agoofproto-dpif.at: Avoid races in table miss tests
YAMAMOTO Takashi [Fri, 4 Apr 2014 03:43:33 +0000 (12:43 +0900)]
ofproto-dpif.at: Avoid races in table miss tests

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agoofproto-dpif.at: Fix a race in "ofproto-dpif - controller"
YAMAMOTO Takashi [Fri, 4 Apr 2014 01:54:05 +0000 (10:54 +0900)]
ofproto-dpif.at: Fix a race in "ofproto-dpif - controller"

Simon Horman submitted the identical patch independently.

Acked-by: Ben Pfaff <blp@nicira.com>
Tested-by: Lori Jakab <lojakab@cisco.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agoofproto/bond: Implement bond megaflow using recirculation
Andy Zhou [Wed, 5 Mar 2014 23:27:31 +0000 (15:27 -0800)]
ofproto/bond: Implement bond megaflow using recirculation

Infrastructure to enable megaflow support for bond ports using
recirculation. This patch adds the following features:
* Generate RECIRC action when bond can benefit from recirculation.
* Populate post recirculation rules in a hidden table. Currently table 254.
* Uses post recirculation rules for bond rebalancing
* A recirculation implementation in dpif-netdev.

The goal of this patch is to be able to megaflow bond outputs and
thus greatly improve performance. However, this patch does not
actually improve the megaflow generation. It is left for a later commit.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoovsdb-server: Improve message for "add-db" of database already open.
Ben Pfaff [Tue, 25 Mar 2014 22:51:23 +0000 (15:51 -0700)]
ovsdb-server: Improve message for "add-db" of database already open.

Otherwise you get a fairly obscure message about a lockfile already being
locked.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
10 years agolockfile: Improve log message when a process tries to relock a file.
Ben Pfaff [Tue, 25 Mar 2014 22:50:14 +0000 (15:50 -0700)]
lockfile: Improve log message when a process tries to relock a file.

"Resource deadlock avoided" is a pretty obscure message.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
10 years agotests: Fix typo in ovsdb-server test.
Ben Pfaff [Fri, 4 Apr 2014 20:51:14 +0000 (13:51 -0700)]
tests: Fix typo in ovsdb-server test.

25 kB is about 25000 bytes, not 2500.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agotests: Remove problematic but questionably useful part of ovsdb-server test.
Ben Pfaff [Fri, 4 Apr 2014 20:37:33 +0000 (13:37 -0700)]
tests: Remove problematic but questionably useful part of ovsdb-server test.

The test "ovsdb-server combines updates on backlogged connections" first
checks that ovsdb-server can combine transactions, and then checks that
it can keep them separate.  The latter part is hard to force because it
requires making sure that the socket buffer never fills up, and it also
isn't a very useful test (it doesn't check for any kind of correctness).
Therefore, this commit removes it.

Reported-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofp-parse: Handle buffer resize when parsing actions
Simon Horman [Mon, 7 Apr 2014 16:43:04 +0000 (16:43 +0000)]
ofp-parse: Handle buffer resize when parsing actions

A call to ofpbuf_put() may cause the data of the passed to be resized and
its base address to change.  Thus the address returned by ofpbuf_put()
should be used as the base address rather than relying on the base address
prior to ofpbuf_put().

This avoids the following assertion in ofpact_update_len() from failing
when ofpbuf_put() causes a resize in parse_note(), parse_noargs_dec_ttl(),
parse_dec_ttl().

    ovs_assert(ofpact == ofpacts->frame);

This restores pointer updates removed by and resolves a regression
introduced by cf3b7538666cd1ef ("ofpbuf: Abstract 'l2' pointer and document
usage conventions.").

Test cases have also been added to exercise this buffer resize in
parse_note(), parse_noargs_dec_ttl(), parse_dec_ttl().

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
10 years agoofproto-dpif-upcall: Expire netflow flow when revalidate_ukey failed
YAMAMOTO Takashi [Tue, 1 Apr 2014 12:21:45 +0000 (21:21 +0900)]
ofproto-dpif-upcall: Expire netflow flow when revalidate_ukey failed

This fixes missing netflow flows in
"ofproto-dpif - NetFlow flow expiration" tests.

Acked-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agoovsdb-server.at: Update a comment
YAMAMOTO Takashi [Fri, 4 Apr 2014 02:49:00 +0000 (11:49 +0900)]
ovsdb-server.at: Update a comment

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agoofproto-dpif.at: Wait for the monitor's pidfile disappears where necessary
YAMAMOTO Takashi [Mon, 31 Mar 2014 06:11:19 +0000 (15:11 +0900)]
ofproto-dpif.at: Wait for the monitor's pidfile disappears where necessary

These tests invokes ovs-ofctl monitor twice or more.
Because "ovs-appctl -t ofctl exit" does not wait for the target
process exit, there are chances to see the pid file from the previous
incarnation.

OVS_APP_EXIT_AND_WAIT macro was provided by Ben Pfaff.

Acked-by: Ben Pfaff <blp@nicira.com>
Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agoofp-print: Fix misaligned data access in ofp_print_error_msg().
Ben Pfaff [Sat, 5 Apr 2014 02:26:22 +0000 (19:26 -0700)]
ofp-print: Fix misaligned data access in ofp_print_error_msg().

The body of an OpenFlow error message often contains an inner OpenFlow
message, and when it does, the inner message starts at an odd multiple of 4
bytes from the beginning of the outer message.  That means that, on RISC
systems, accessing the inner message directly causes a bus error.  This
commit fixes the problem in a way that should make it difficult to recur.

This fixes the failure of tests 643, 645, and 651 on sparc seen here:
https://buildd.debian.org/status/fetch.php?pkg=openvswitch&arch=sparc&ver=2.1.0%2Bgit20140325-1&stamp=1396438624

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
10 years agopackets: Fix misaligned data accesses for MPLS and SCTP fields.
Ben Pfaff [Sat, 5 Apr 2014 03:21:15 +0000 (20:21 -0700)]
packets: Fix misaligned data accesses for MPLS and SCTP fields.

The other 32-bit data fields in protocol headers were already using
ovs_16aligned_be32, but MPLS and SCTP had been overlooked.  This fixes
the failure of test 681 seen here:
https://buildd.debian.org/status/fetch.php?pkg=openvswitch&arch=sparc&ver=2.1.0%2Bgit20140325-1&stamp=1396438624

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
10 years agodpif-netdev: Unwildcard entire odp_port in dpif_netdev_mask_from_nlattrs().
Ben Pfaff [Sat, 5 Apr 2014 17:27:05 +0000 (10:27 -0700)]
dpif-netdev: Unwildcard entire odp_port in dpif_netdev_mask_from_nlattrs().

One case in the dpif_netdev_mask_from_nlattrs() function accidentally
wildcarded only a 16-bit subset of the mask's odp_port.  On little-endian
machines this subset was the lower bits, which happened to work out OK,
but on big-endian machines this subset was the upper bits, which doesn't
work and causes a test failure.  (The problem was actually visible in the
test expected results on little-endian machines, but we had not noticed.)

This commit unwildcards the whole field, fixing the problem, and updates
the test expected results to match.

This fixes the failure of test 732 seen here:
https://buildd.debian.org/status/fetch.php?pkg=openvswitch&arch=sparc&ver=2.1.0%2Bgit20140325-1&stamp=1396438624

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
10 years agoovsdb: Remove SPECS in favor of referring to RFC 7047.
Ben Pfaff [Fri, 4 Apr 2014 16:43:54 +0000 (09:43 -0700)]
ovsdb: Remove SPECS in favor of referring to RFC 7047.

Also, add some clarifications relative to RFC 7047 to ovsdb-server(1).

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
10 years agoflow: Rearrange struct flow for better megaflows.
Ethan Jackson [Fri, 4 Apr 2014 00:31:03 +0000 (17:31 -0700)]
flow: Rearrange struct flow for better megaflows.

Since the dp_hash will often be a hash of the 5 tuple, it makes sense
to put it with the L4 header so it hits in the last classifier lookup
stage.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agotest-reconnect: Fix a warning.
Alex Wang [Fri, 4 Apr 2014 16:58:28 +0000 (09:58 -0700)]
test-reconnect: Fix a warning.

This commit fixes the "return discards 'const' qualifier
from pointer target type" warning issued when compiling
test-reconnect.c.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofpbuf: fix struct comment
Lorand Jakab [Fri, 4 Apr 2014 08:09:52 +0000 (11:09 +0300)]
ofpbuf: fix struct comment

Signed-off-by: Lorand Jakab <lojakab@cisco.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoAvoid static declarations of arrays with unknown size.
Gurucharan Shetty [Thu, 3 Apr 2014 23:07:43 +0000 (16:07 -0700)]
Avoid static declarations of arrays with unknown size.

Visual studio does not like it.

This commit is similar to commit 3815d6c2c
(Avoid designated initializers and static decls of arrays
of unknown size.) but touches more files.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agojsonrpc: Return received JSON-RPC messages immediately in jsonrpc_recv().
Ben Pfaff [Thu, 3 Apr 2014 22:27:18 +0000 (15:27 -0700)]
jsonrpc: Return received JSON-RPC messages immediately in jsonrpc_recv().

Until now, jsonrpc_recv() used separate iterations of its loop to receive
data, feed it to the JSON-RPC parser, and return the received message.
This is unnecessarily complicated and can occasionally mean that the
jsonrpc object has received and parsed but not returned a message.  This
commit refactors the code to receive data, feed it to the parse, and
return the received message in a single iteration, and simplifies the code
in the process.

Reported-by: Chris Hydon <chydon@aristanetworks.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto: Support OF version-specific table-miss behaviours
Simon Horman [Wed, 2 Apr 2014 09:04:27 +0000 (18:04 +0900)]
ofproto: Support OF version-specific table-miss behaviours

OpenFlow 1.1 and 1.2 specify that if a table-miss occurs then the default
behaviour is to forward the packet the controller using a packet-in
message. And until this patch this is the default behaviour that Open
vSwitch uses for all OpenFlow versions.

OpenFlow1.3+ specifies that if a table-miss occurs then the default
behaviour is simply to drop the packet. This patch implements this
behaviour using the following logic:

If a table-miss occurs and the table-miss behaviour for the table
has not been set using a table_mod (in which case it is no longer
the default setting) then:

* Installing a facet in the datapath with a drop action in the
  if there are no pre-OF1.3 controllers connected which would receive
  an packet_in message.

  Note that this covers both the case where there are only OF1.3
  controllers and the case where there are no controllers at all.

* Otherwise sent a packet_in message to all pre-OF1.3 controllers.

  This covers both the case where there are only pre-OF1.3
  controllers and there are both pre-OF1.3 and OF1.3+ controllers.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoMerge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch
Giuseppe Lettieri [Tue, 1 Apr 2014 15:46:48 +0000 (17:46 +0200)]
Merge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch

10 years agorhel: Add Patch Port support to initscripts
Jason Kölker [Mon, 31 Mar 2014 23:34:14 +0000 (23:34 +0000)]
rhel: Add Patch Port support to initscripts

Allows setting up type=patch ports through sysconfig ifcfg-* files.

Signed-off-by: Jason Kölker <jason@koelker.net>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Flavio Leitner <fbl@redhat.com>
10 years agounit-test: merge test-heap into ovstest
Andy Zhou [Mon, 31 Mar 2014 01:20:07 +0000 (18:20 -0700)]
unit-test: merge test-heap into ovstest

Modify test-heap.c to use ovstest framework.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agounit-test: Add ovstest
Andy Zhou [Sat, 29 Mar 2014 01:13:00 +0000 (18:13 -0700)]
unit-test: Add ovstest

Changing one of the files in the Open vSwitch ``lib'' directory
causes 43 binaries to be relinked, which takes a lot of time even with
parallel ``make''.  31 of those binaries are in the ``tests''
directory.  ovs-test attemps to combine most of those binaries into a
single test program that just takes a subcommand name as its first
command-line argument.

The following patch makes use of this infrastructure.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agodebian: Depend on 'kmod' instead of module-init-tools.
Ben Pfaff [Mon, 31 Mar 2014 20:38:50 +0000 (13:38 -0700)]
debian: Depend on 'kmod' instead of module-init-tools.

CC: 733696@bugs.debian.org
Reported-by: md@Linux.IT (Marco d'Itri)
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
10 years agovswitchd: Add external_ids to Flow_Table table in database schema.
Ben Pfaff [Mon, 31 Mar 2014 20:34:52 +0000 (13:34 -0700)]
vswitchd: Add external_ids to Flow_Table table in database schema.

Every other table has an external_ids column, which can be useful to
controller writers for integration purposes, so add one to Flow_Table also.

Reported-by: Ariel Tubaltsev <atubaltsev@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
10 years agoutil: xleep for Windows.
Gurucharan Shetty [Fri, 28 Mar 2014 22:15:02 +0000 (15:15 -0700)]
util: xleep for Windows.

Windows does not have a sleep(seconds). But it does have
a Sleep(milliseconds). Sleep() in windows does not have a
return value. Since we are not using the return value for xsleep()
anywhere as of now, don't return any.

Introduced by commit 275eebb9 (utils: Introduce xsleep for RCU quiescent state)

CC: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
10 years agodatapath: Add support for kernels 3.13
Pravin Shelar [Wed, 2 Apr 2014 03:55:21 +0000 (20:55 -0700)]
datapath: Add support for kernels 3.13

Add support for building the in-tree kernel datapath for
Linux kernels up to 3.13. There were some changes in the
netlink area which required adding new compatibility code
for this layer. Also, some new per-cpu stats initialization
code was added.

Based on patch from Kyle Mestery.

Signed-off-by: Kyle Mestery <mestery@noironetworks.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Kyle Mestery <mestery@noironetworks.com>
10 years agobridge: don't bring up internal ports by default.
Flavio Leitner [Tue, 1 Apr 2014 21:05:20 +0000 (18:05 -0300)]
bridge: don't bring up internal ports by default.

It should be an administrator task to bring up devices as they
are configured properly.

Currently, Fedora is deleting the bridges when the interface is
brought down. Therefore, there is no bridge on the next boot and
the initscripts can apply the networking configuration properly
for a new bridge.

However, if the system didn't execute ifdown for some reason, the
bridge is left in the ovsdb and since internal ports are brought
up by default, there is no way for initscripts to known if the
adminitrator has already configured it or not.

This patch reverts commit bef071a5fdf8e2dd87677b04b3cf7a8f5094edcb
(bridge: Always "up" internal devices.).

Signed-off-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofpbuf: Abstract 'l2' pointer and document usage conventions.
Jarno Rajahalme [Wed, 2 Apr 2014 22:44:21 +0000 (15:44 -0700)]
ofpbuf: Abstract 'l2' pointer and document usage conventions.

Rename 'l2' to 'frame' and add new ofpbuf_set_frame() and ofpbuf_l2().
ofpbuf_set_frame() alse resets all the layer offsets.  ofpbuf_l2()
returns NULL if the packet has no Ethernet header, as indicated either
by unset l3 offset or NULL frame pointer.  Callers of ofpbuf_l2() are
supposed to check the return value, unless they can otherwise be sure
that the packet has a valid Ethernet header.

The recent commit 437d0d22 made some assumptions that were not valid
regarding the use of the 'l2' pointer in rconn module and by
compose_rarp().  This is now fixed as follows: rconn now relies on the
fact that once OpenFlow messages are given to rconn for transport, the
frame pointer is no longer needed to refer to the OpenFlow header; and
compose_rarp() now sets the frame pointer and offsets as expected.

In addition to storing network frames, ofpbufs are also used for
handling OpenFlow messages and action lists.  lib/ofpbuf.h now has a
comment documenting the current usage conventions and invariants.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofpbuf: Rename trivial _get_ functions without the "get".
Jarno Rajahalme [Thu, 3 Apr 2014 18:51:54 +0000 (11:51 -0700)]
ofpbuf: Rename trivial _get_ functions without the "get".

Code reads better without the "get", for example "ofpbuf_l3()"
v.s. "ofpbuf_get_l3()".  L4 payoad access functions still use the
"get" (e.g., "ofpbuf_get_tcp_payload()").

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
10 years agotests: add ovstest to .gitignore
Lorand Jakab [Thu, 3 Apr 2014 18:42:31 +0000 (21:42 +0300)]
tests: add ovstest to .gitignore

Signed-off-by: Lorand Jakab <lojakab@cisco.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agounit-test: Link 29 test programs into ovstest
Andy Zhou [Tue, 1 Apr 2014 07:47:01 +0000 (00:47 -0700)]
unit-test: Link 29 test programs into ovstest

Improve link speed by linking 29 test programs into ovstest.

On my machine, running the following command against a fully
built tree:

  $ touch lib/random.c; time make

Improve the overall build time from 7 seconds to 3.5 seconds.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agounit-test: Improve ovstest user interface
Andy Zhou [Mon, 31 Mar 2014 20:38:04 +0000 (13:38 -0700)]
unit-test: Improve ovstest user interface

Improve help output. Running without argument now exit with an error
message and an error code. Simplify OVSTEST_REGISTER() since not all
test programs uses sub_commands.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agojsonrpc-server: Combine notifications when connection becomes backlogged.
Ben Pfaff [Wed, 2 Apr 2014 15:43:17 +0000 (08:43 -0700)]
jsonrpc-server: Combine notifications when connection becomes backlogged.

Connections that queue up too much data, because they are monitoring a
table that is changing quickly and failing to keep up with the updates,
cause problems with buffer management.  Since commit 60533a405b2e
(jsonrpc-server: Disconnect connections that queue too much data.),
ovsdb-server has dealt with them by disconnecting the connection and
letting them start up again with a fresh copy of the database.  However,
this is not ideal because of situations where disconnection happens
repeatedly.  For example:

     - A manager toggles a column back and forth between two or more values
       quickly (in which case the data transmitted over the monitoring
       connections always increases quickly, without bound).

     - A manager repeatedly extends the contents of some column in some row
       (in which case the data transmitted over the monitoring connection
       grows with O(n**2) in the length of the string).

A better way to deal with this problem is to combine updates when they are
sent to the monitoring connection, if that connection is not keeping up.
In both the above cases, this reduces the data that must be sent to a
manageable amount.  This commit implements this new way.

Bug #1211786.
Bug #1221378.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agojsonrpc-server: Track monitor updates separately from sending them.
Ben Pfaff [Tue, 1 Apr 2014 23:26:47 +0000 (16:26 -0700)]
jsonrpc-server: Track monitor updates separately from sending them.

This will make combining monitor updates easier in the next commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agoRevert "json: New function json_serialized_length()."
Ben Pfaff [Wed, 2 Apr 2014 14:11:20 +0000 (07:11 -0700)]
Revert "json: New function json_serialized_length()."

This reverts commit 1600fa6853872e16130366351a2c14f6fa8b547c.

Connections that queue up too much data, because they are monitoring a
table that is changing quickly and failing to keep up with the updates,
cause problems with buffer management.  Since commit 60533a405b2e
(jsonrpc-server: Disconnect connections that queue too much data.),
ovsdb-server has dealt with them by disconnecting the connection and
letting them start up again with a fresh copy of the database.  However,
this is not ideal because of situations where disconnection happens
repeatedly.  For example:

     - A manager toggles a column back and forth between two or more values
       quickly (in which case the data transmitted over the monitoring
       connections always increases quickly, without bound).

     - A manager repeatedly extends the contents of some column in some row
       (in which case the data transmitted over the monitoring connection
       grows with O(n**2) in the length of the string).

A better way to deal with this problem is to combine updates when they are
sent to the monitoring connection, if that connection is not keeping up.
In both the above cases, this reduces the data that must be sent to a
manageable amount.  An upcoming patch implements this new way.  This commit
reverts part of the previous solution that disconnects backlogged
connections, since it is no longer useful.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agoRevert "ovsdb-data: New functions for predicting serialized length of data."
Ben Pfaff [Wed, 2 Apr 2014 14:10:40 +0000 (07:10 -0700)]
Revert "ovsdb-data: New functions for predicting serialized length of data."

This reverts commit 0ea7bec76d804a2c4efccd3dbdaa3e30cf536a5c.

Connections that queue up too much data, because they are monitoring a
table that is changing quickly and failing to keep up with the updates,
cause problems with buffer management.  Since commit 60533a405b2e
(jsonrpc-server: Disconnect connections that queue too much data.),
ovsdb-server has dealt with them by disconnecting the connection and
letting them start up again with a fresh copy of the database.  However,
this is not ideal because of situations where disconnection happens
repeatedly.  For example:

     - A manager toggles a column back and forth between two or more values
       quickly (in which case the data transmitted over the monitoring
       connections always increases quickly, without bound).

     - A manager repeatedly extends the contents of some column in some row
       (in which case the data transmitted over the monitoring connection
       grows with O(n**2) in the length of the string).

A better way to deal with this problem is to combine updates when they are
sent to the monitoring connection, if that connection is not keeping up.
In both the above cases, this reduces the data that must be sent to a
manageable amount.  An upcoming patch implements this new way.  This commit
reverts part of the previous solution that disconnects backlogged
connections, since it is no longer useful.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agoRevert "jsonrpc-server: Disconnect connections that queue too much data."
Ben Pfaff [Wed, 2 Apr 2014 14:09:47 +0000 (07:09 -0700)]
Revert "jsonrpc-server: Disconnect connections that queue too much data."

This reverts commit 60533a405b2eb77214b767767fe143c8645f82d5.

Connections that queue up too much data, because they are monitoring a
table that is changing quickly and failing to keep up with the updates,
cause problems with buffer management.  Since commit 60533a405b2e
(jsonrpc-server: Disconnect connections that queue too much data.),
ovsdb-server has dealt with them by disconnecting the connection and
letting them start up again with a fresh copy of the database.  However,
this is not ideal because of situations where disconnection happens
repeatedly.  For example:

     - A manager toggles a column back and forth between two or more values
       quickly (in which case the data transmitted over the monitoring
       connections always increases quickly, without bound).

     - A manager repeatedly extends the contents of some column in some row
       (in which case the data transmitted over the monitoring connection
       grows with O(n**2) in the length of the string).

A better way to deal with this problem is to combine updates when they are
sent to the monitoring connection, if that connection is not keeping up.
In both the above cases, this reduces the data that must be sent to a
manageable amount.  An upcoming patch implements this new way.  This commit
reverts part of the previous solution that disconnects backlogged
connections, since it is no longer useful.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agoRevert "jsonrpc-server: Add test for disconnecting connections with too long queues."
Ben Pfaff [Wed, 2 Apr 2014 21:22:25 +0000 (14:22 -0700)]
Revert "jsonrpc-server: Add test for disconnecting connections with too long queues."

This reverts commit 631583739f9aec55d4cbe25fb856143ccde48ab6.

Connections that queue up too much data, because they are monitoring a
table that is changing quickly and failing to keep up with the updates,
cause problems with buffer management.  Since commit 60533a405b2e
(jsonrpc-server: Disconnect connections that queue too much data.),
ovsdb-server has dealt with them by disconnecting the connection and
letting them start up again with a fresh copy of the database.  However,
this is not ideal because of situations where disconnection happens
repeatedly.  For example:

     - A manager toggles a column back and forth between two or more values
       quickly (in which case the data transmitted over the monitoring
       connections always increases quickly, without bound).

     - A manager repeatedly extends the contents of some column in some row
       (in which case the data transmitted over the monitoring connection
       grows with O(n**2) in the length of the string).

A better way to deal with this problem is to combine updates when they are
sent to the monitoring connection, if that connection is not keeping up.
In both the above cases, this reduces the data that must be sent to a
manageable amount.  An upcoming patch implements this new way.  This commit
reverts part of the previous solution that disconnects backlogged
connections, since it is no longer useful.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agoovsdb-server: Send update for _version for changes due to weak ref removal.
Ben Pfaff [Tue, 1 Apr 2014 21:33:24 +0000 (14:33 -0700)]
ovsdb-server: Send update for _version for changes due to weak ref removal.

When a row was deleted, and that caused the transaction manager to remove
a remaining weak reference to the row, and no other change had been made
to the row in that transaction, and a client was monitoring modifications
of the _version column in the row, then the monitor update for the column
did not include the old contents of the _version column, even though it
should have.  This commit fixes the problem.

Probably most clients only look at the new value of the column, if they
monitor _version at all, and this bug is really old, so it's probably
not a serious bug.

Found by inspection.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agoovsdb-client: Support all vlog options.
Ben Pfaff [Wed, 2 Apr 2014 22:03:41 +0000 (15:03 -0700)]
ovsdb-client: Support all vlog options.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agodebian: Allow kmod or module-init-tools for backward compatibility.
Ben Pfaff [Wed, 2 Apr 2014 21:54:51 +0000 (14:54 -0700)]
debian: Allow kmod or module-init-tools for backward compatibility.

Commit d473844693 (debian: Depend on 'kmod' instead of module-init-tools.)
switched from depending on module-init-tools to depending on kmod, which
is the new name of the appropriate package in Debian.  Unfortunately,
while kmod is the right name for the latest Debian distribution, it doesn't
have that name in old distributions and thus breaks the build on those.
This commit should work OK in either case, since it allows both names.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Gurucharan Shetty <gshetty@nicira.com>
10 years agonetdev-dpdk: Remove alloc from packet recv.
Pravin Shelar [Mon, 31 Mar 2014 20:17:24 +0000 (13:17 -0700)]
netdev-dpdk: Remove alloc from packet recv.

On DPDK packet recv, ovs is given pointer to mbuf which has
information about a packet, for example pointer to data and size.
By moving mbuf to ofpbuf we can let dpdk allocate ofpbuf and
pass that to ovs for processing the packet.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
10 years agoofpbuf: Add DPDK mbuf to ofpbuf.
Pravin Shelar [Tue, 1 Apr 2014 03:41:53 +0000 (20:41 -0700)]
ofpbuf: Add DPDK mbuf to ofpbuf.

Define data, base and size access APIs for DPDK.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
10 years agoofpbuf: Add ofpbuf_init_dpdk()
Pravin Shelar [Mon, 31 Mar 2014 20:22:39 +0000 (13:22 -0700)]
ofpbuf: Add ofpbuf_init_dpdk()

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
10 years agoofpbuf: Introduce access api for base, data and size.
Pravin Shelar [Sun, 30 Mar 2014 08:31:50 +0000 (01:31 -0700)]
ofpbuf: Introduce access api for base, data and size.

These functions will be used by later patches.  Following patch
does not change functionality.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
10 years agoofpbuf: Add private pointer for dpdk
Pravin Shelar [Mon, 31 Mar 2014 19:44:06 +0000 (12:44 -0700)]
ofpbuf: Add private pointer for dpdk

netdev-dpdk uses this pointer to store dpdk mbuf. This patch fixes
compilation error in dpdk.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
10 years agodatapath: Minimize ovs_flow_cmd_new|set critical sections.
Jarno Rajahalme [Wed, 2 Apr 2014 18:14:58 +0000 (11:14 -0700)]
datapath: Minimize ovs_flow_cmd_new|set critical sections.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
10 years agodatapath: Split ovs_flow_cmd_new_or_set().
Jarno Rajahalme [Wed, 2 Apr 2014 18:14:58 +0000 (11:14 -0700)]
datapath: Split ovs_flow_cmd_new_or_set().

Following patch will be easier to reason about with separate
ovs_flow_cmd_new() and ovs_flow_cmd_set() functions.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
10 years agodatapath: Minimize ovs_flow_cmd_del critical section.
Jarno Rajahalme [Wed, 2 Apr 2014 18:14:58 +0000 (11:14 -0700)]
datapath: Minimize ovs_flow_cmd_del critical section.

ovs_flow_cmd_del() now allocates reply (if needed) after the flow has
already been removed from the flow table.  If the reply allocation
fails, a netlink error is signaled with netlink_set_err(), as is
already done in ovs_flow_cmd_new_or_set() in the similar situation.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
10 years agodatapath: Reduce locking requirements.
Jarno Rajahalme [Wed, 2 Apr 2014 18:14:58 +0000 (11:14 -0700)]
datapath: Reduce locking requirements.

Reduce and clarify locking requirements for ovs_flow_cmd_alloc_info(),
ovs_flow_cmd_fill_info() and ovs_flow_cmd_build_info().

A datapath pointer is available only when holding a lock.  Change
ovs_flow_cmd_fill_info() and ovs_flow_cmd_build_info() to take a
dp_ifindex directly, rather than a datapath pointer that is then
(only) used to get the dp_ifindex.  This is useful, since the
dp_ifindex is available even when the datapath pointer is not, both
before and after taking a lock, which makes further critical section
reduction possible.

Make ovs_flow_cmd_alloc_info() take an 'acts' argument instead a
'flow' pointer.  This allows some future patches to do the allocation
before acquiring the flow pointer.

The locking requirements after this patch are:

ovs_flow_cmd_alloc_info(): May be called without locking, must not be
  called while holding the RCU read lock (due to memory allocation).
  If 'acts' belong to a flow in the flow table, however, then the
  caller must hold ovs_mutex.

ovs_flow_cmd_fill_info(): Either ovs_mutex or RCU read lock must be held.

ovs_flow_cmd_build_info(): This calls both of the above, so the caller
  must hold ovs_mutex.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
10 years agodatapath/flow: Fix ovs_flow_stats_get/clear RCU dereference.
Jarno Rajahalme [Wed, 2 Apr 2014 18:14:58 +0000 (11:14 -0700)]
datapath/flow: Fix ovs_flow_stats_get/clear RCU dereference.

For ovs_flow_stats_get() using ovsl_dereference() was wrong, since
flow dumps call this with RCU read lock.

ovs_flow_stats_clear() is always called with ovs_mutex, so can use
ovsl_dereference().

Also, make the ovs_flow_stats_get() 'flow' argument const to make
later patches cleaner.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
10 years agodatapath: Fix typo.
Jarno Rajahalme [Wed, 2 Apr 2014 18:14:58 +0000 (11:14 -0700)]
datapath: Fix typo.

Incorrect struct name was confusing, even though otherwise
inconsequental.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
10 years agovtep: Add IP address configuration for bfd.
Bruce Davie [Wed, 2 Apr 2014 16:11:48 +0000 (09:11 -0700)]
vtep: Add IP address configuration for bfd.

The OVS implementation of BFD allows configuration of the source and
destination IP addresses of BFD packets. This patch adds the same
configuration option to the VTEP schema.

Signed-off-by: Bruce Davie <bsd@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
10 years agoofproto.at: Fix races in rule eviciton tests
YAMAMOTO Takashi [Mon, 31 Mar 2014 05:04:35 +0000 (14:04 +0900)]
ofproto.at: Fix races in rule eviciton tests

Bump timeout differences, because timeouts different by 1s might end up
to have the same position in the heap as rule_eviction_priority() uses
1024ms as a unit.

Also, use time/stop to avoid relying on how long an add-flow would take.

These tests were introduced by commit 6d56c1f1.
("ofproto: Update rule's priority in eviction group.")

Acked-by: Ben Pfaff <blp@nicira.com>
Acked-by: Kmindg G <kmindg@gmail.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agoofproto-dpif: Fix races in MPLS tests
YAMAMOTO Takashi [Mon, 31 Mar 2014 03:31:46 +0000 (12:31 +0900)]
ofproto-dpif: Fix races in MPLS tests

Depending on how output buffers are flushed, there might
be still races.  But this at least makes the race windows smaller.

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agoofproto: Fix a race in pause and resume test
YAMAMOTO Takashi [Mon, 31 Mar 2014 03:22:20 +0000 (12:22 +0900)]
ofproto: Fix a race in pause and resume test

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agoofproto-dpif.at: Fix races in table-miss tests
YAMAMOTO Takashi [Mon, 31 Mar 2014 03:13:02 +0000 (12:13 +0900)]
ofproto-dpif.at: Fix races in table-miss tests

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
10 years agolib/ofpbuf: Compact
Jarno Rajahalme [Mon, 24 Mar 2014 16:17:01 +0000 (09:17 -0700)]
lib/ofpbuf: Compact

This patch shrinks the struct ofpbuf from 104 to 48 bytes on 64-bit
systems, or from 52 to 36 bytes on 32-bit systems (counting in the
'l7' removal from an earlier patch).  This may help contribute to
cache efficiency, and will speed up initializing, copying and
manipulating ofpbufs.  This is potentially important for the DPDK
datapath, but the rest of the code base may also see a little benefit.

Changes are:

- Remove 'l7' pointer (previous patch).
- Use offsets instead of layer pointers for l2_5, l3, and l4 using
  'l2' as basis.  Usually 'data' is the same as 'l2', but this is not
  always the case (e.g., when parsing or constructing a packet), so it
  can not be easily used as the offset basis.  Also, packet parsing is
  faster if we do not need to maintain the offsets each time we pull
  data from the ofpbuf.
- Use uint32_t for 'allocated' and 'size', as 2^32 is enough even for
  largest possible messages/packets.
- Use packed enum for 'source'.
- Rearrange to avoid unnecessary padding.
- Remove 'private_p', which was used only in two cases, both of which
  had the invariant ('l2' == 'data'), so we can temporarily use 'l2'
  as a private pointer.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agodatapath: Minimize dp and vport critical sections.
Jarno Rajahalme [Fri, 28 Mar 2014 20:44:23 +0000 (13:44 -0700)]
datapath: Minimize dp and vport critical sections.

Move most memory allocations away from the ovs_mutex critical
sections.  vport allocations still happen while the lock is taken, as
changing that would require major refactoring. Also, vports are
created very rarely so it should not matter.

Change ovs_dp_cmd_get() now only takes the rcu_read_lock(), rather
than ovs_lock(), as nothing need to be changed.  This was done by
ovs_vport_cmd_get() already.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
10 years agodatapath: Make flow mask removal symmetric.
Jarno Rajahalme [Sat, 29 Mar 2014 22:52:32 +0000 (15:52 -0700)]
datapath: Make flow mask removal symmetric.

Masks are inserted when flows are inserted to the table, so it is
logical to correspondingly remove masks when flows are removed from
the table, in ovs_flow_table_remove().

This allows ovs_flow_free() to be called without locking, which will
be used by later patches.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>Summary:
10 years agodatapath: Build flow cmd netlink reply only if needed.
Jarno Rajahalme [Sat, 29 Mar 2014 22:52:32 +0000 (15:52 -0700)]
datapath: Build flow cmd netlink reply only if needed.

Use netlink_has_listeners() and NLM_F_ECHO flag to determine if a
reply is needed or not for OVS_FLOW_CMD_NEW, OVS_FLOW_CMD_SET, or
OVS_FLOW_CMD_DEL.  Currently, OVS userspace does not request a reply
for OVS_FLOW_CMD_NEW, but usually does for OVS_FLOW_CMD_DEL, as stats
may have changed.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
10 years agorecirculation: Adjust ovs_key_attr ABI
Andy Zhou [Fri, 28 Mar 2014 20:36:28 +0000 (13:36 -0700)]
recirculation: Adjust ovs_key_attr ABI

Jesse helped to clarify how to maintain the ABI. Making the
adjustment accordingly and add some comments.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
10 years agodatapath: Use with RCU_INIT_POINTER(x, NULL) in vport-gre.c
Monam Agarwal [Fri, 28 Mar 2014 03:12:22 +0000 (20:12 -0700)]
datapath: Use with RCU_INIT_POINTER(x, NULL) in vport-gre.c

This patch replaces rcu_assign_pointer(x, NULL) with RCU_INIT_POINTER(x, NULL)

The rcu_assign_pointer() ensures that the initialization of a structure
is carried out before storing a pointer to that structure.
And in the case of the NULL pointer, there is no structure to initialize.
So, rcu_assign_pointer(p, NULL) can be safely converted to RCU_INIT_POINTER(p, NULL)

Signed-off-by: Monam Agarwal <monamagarwal123@gmail.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
10 years agosparse: workaround for a bug in sparse.
Pritesh Kothari [Fri, 28 Mar 2014 19:20:00 +0000 (12:20 -0700)]
sparse: workaround for a bug in sparse.

sparse emits the following warning:
lib/dpif-netdev.c:1755:15: warning: Initializer entry defined twice
lib/dpif-netdev.c:1755:15:   also defined here
due to a bug in sparse which doesn't like inlined functions which
expands a #define within it. This commit removes inline to make
sparse happy.

Signed-off-by: Pritesh Kothari <pritesh.kothari@cisco.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agosparse: fix the order of include paths to make sparse happy.
Pritesh Kothari [Fri, 28 Mar 2014 19:19:59 +0000 (12:19 -0700)]
sparse: fix the order of include paths to make sparse happy.

This fix restores the order of include path such that the local include/ comes
before the system /usr/include in the #include path. Thus by making sure that
include/linux/types.h and include/linux/openvswitch.h take precedence over the
similar files in /usr/include/ directory.

Signed-off-by: Pritesh Kothari <pritesh.kothari@cisco.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agorecirculation: Some cosmetic fixes
YAMAMOTO Takashi [Thu, 27 Mar 2014 14:38:57 +0000 (14:38 +0000)]
recirculation: Some cosmetic fixes

Wrap long lines, fix whitespaces, and fix a typo in a comment.
No functional changes are intended.

Cc: Andy Zhou <azhou@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Andy Zhou <azhou@nicira.com>
10 years agolib/packet.h: add hash_mac()
Andy Zhou [Fri, 28 Mar 2014 03:22:37 +0000 (20:22 -0700)]
lib/packet.h: add hash_mac()

Add hash_mac() and apply it when appropriate.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>