cascardo/ovs.git
10 years agogitignore: Add ovsdbmonitor.
Gurucharan Shetty [Wed, 14 Aug 2013 09:11:04 +0000 (09:11 +0000)]
gitignore: Add ovsdbmonitor.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
10 years agoflow: Enable matching on new field 'pkt_mark'.
Jesse Gross [Tue, 6 Aug 2013 19:57:16 +0000 (12:57 -0700)]
flow: Enable matching on new field 'pkt_mark'.

The Linux kernel datapath enables matching and setting the skb mark
but this functionality is currently used only internally by
ovs-vswitchd. This exposes it through NXM to enable external
controllers to interact with other kernel subsystems. Although this
is simply exporting the skb mark, the intention is that this is a
platform independent mechanism to access some system metadata and
therefore may have different implementations on various systems.

Bug #17855

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agotunnel: Clear IPSEC_MARK on input rather than output.
Jesse Gross [Tue, 6 Aug 2013 19:57:15 +0000 (12:57 -0700)]
tunnel: Clear IPSEC_MARK on input rather than output.

Currently we remove the IPSEC_MARK flag from all packets that are
egressing on non-tunnel ports. However, this behavior is confusing
if we allow OpenFlow controllers to match and set the pkt_mark field
because the tunnel behavior applies even on non-tunnel ports.

This instead clears the mark on tunnel input which should have the
same effect for tunnel ports. However, on non-tunnel traffic (or
even for traffic entering on a tunnel port but leaving on a non-
tunnel port) it allows the mark to pass through without change.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agotunnel: Consolidate action code for tunnel port receive.
Jesse Gross [Tue, 6 Aug 2013 19:57:14 +0000 (12:57 -0700)]
tunnel: Consolidate action code for tunnel port receive.

There are a couple of operations that are related to receiving a
packet on a tunnel port but that affect the actions and therefore
need to be performed on the output path. This adds a new hook to
do this and consolidates the existing code there.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agoflow: Rename skb_mark to pkt_mark.
Jesse Gross [Tue, 6 Aug 2013 19:57:13 +0000 (12:57 -0700)]
flow: Rename skb_mark to pkt_mark.

The skb_mark field is currently only available with the Linux datapath
and is only used internally. However, it is desirable to expose this
through OpenFlow and when it is exposed ideally it would not be system-
specific. In preparation for this, skb_mark is rename to pkt_mark in
internal data structures for consistency.

This does not rename the Linux interfaces because doing so would break
the API. It would not necessarily be desirable to do anyways since in
Linux-specific code it is clearer to use the actual name rather than a
generic one. This can lead to confusion in some places, however, because
we do not always strictly separate generic and platform dependent code
(one example is actions). This seems inevitable though at this point if
the lower and upper layers have different names (as they must given the
above requirements).

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agodebian: Fix build with old versions of dpkg-buildflags.
Ben Pfaff [Tue, 13 Aug 2013 19:54:35 +0000 (12:54 -0700)]
debian: Fix build with old versions of dpkg-buildflags.

dpkg-buildflags has not always supported --export=configure, but commit
6c2d4c8780 (debian: Apply hardening options to build.) used it
unconditionally, causing the build to fail on old Debian distributions.
This fixes the problem.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agotests: Fix threading race in "ofproto-dpif megaflow - learning" test.
Ben Pfaff [Tue, 13 Aug 2013 19:37:50 +0000 (12:37 -0700)]
tests: Fix threading race in "ofproto-dpif megaflow - learning" test.

Threaded ofproto-dpif uses a queue to pass packets from the forwarding
threads to the main thread for (mega)flow setup and for learning.  When
learning occurs, causing revalidations, this races against flow setup, so
that sometimes a datapath (mega)flow does get set up for a packet that
causes learning and sometimes it doesn't.  This caused this test to
sometimes fail because one megaflow or the other that was expected to be
set up was not.

This commit fixes the problem by sending a second packet in each flow.
These additional packets don't cause any additional changes to the flow
table but they do cause flows to be set up, fixing the problem.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agotests: Fix problems in "learning action - self-modifying flow" test.
Ben Pfaff [Tue, 13 Aug 2013 18:22:26 +0000 (11:22 -0700)]
tests: Fix problems in "learning action - self-modifying flow" test.

This test had two problems.  First, it had a bizarre dependency on stats
that were not up-to-date: the "ovs-ofctl dump-flows" assumed that only
the first one of ten packets sent through the switch had been accounted
to OpenFlow flow statistics.  Adding a 1-second time warp fixed this
problem by ensuring that all ten packets were accounted.  (That's why this
patch updates the expected output of "ovs-ofctl dump-flows".)

Second, multithreading has made packet processing less predictable in
general.  This commit adds 10-ms time warps after sending each packet,
which seems to make the test reliable for me.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agobfd: Delete trailing whitespace in 'bfd/show' output.
Alex Wang [Tue, 13 Aug 2013 17:02:41 +0000 (10:02 -0700)]
bfd: Delete trailing whitespace in 'bfd/show' output.

This commit chops off the trailing whitespace in the 'flag' field
of 'bfd/show' output.  This is for the string matching in bfd
unit test.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoovs-thread: Use mutex instead of its address in thread-safety annotation.
Ben Pfaff [Mon, 12 Aug 2013 22:52:42 +0000 (15:52 -0700)]
ovs-thread: Use mutex instead of its address in thread-safety annotation.

CodingStyle says that this is preferred.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agosparse: Remove support for thread-safety annotations.
Ben Pfaff [Mon, 12 Aug 2013 22:49:25 +0000 (15:49 -0700)]
sparse: Remove support for thread-safety annotations.

The Clang support for thread-safety annotations is much more effective
than "sparse" support.  I found that I was unable to make the annotations
warning-free under sparse.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agoofproto-dpif-upcall: Fix sparse warning.
Ben Pfaff [Mon, 12 Aug 2013 22:43:36 +0000 (15:43 -0700)]
ofproto-dpif-upcall: Fix sparse warning.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agoovs-ofctl: Avoid groff warning due to too-long line.
Ben Pfaff [Mon, 12 Aug 2013 22:11:35 +0000 (15:11 -0700)]
ovs-ofctl: Avoid groff warning due to too-long line.

Avoids these warnings from groff:

<standard input>:1037: warning [p 14, 6.0i]: cannot adjust line
<standard input>:1037: warning [p 14, 6.2i]: can't break line

Found by lintian.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agodebian: Apply hardening options to build.
Ben Pfaff [Mon, 12 Aug 2013 22:10:39 +0000 (15:10 -0700)]
debian: Apply hardening options to build.

Debian now encourages building every program with various GCC hardening
options.  This commit implements that recommendation for Open vSwitch.

See https://wiki.debian.org/Hardening for details.

Found by lintian.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto: Include classifier wildcards in trace output.
Jesse Gross [Mon, 5 Aug 2013 23:00:03 +0000 (16:00 -0700)]
ofproto: Include classifier wildcards in trace output.

When tracing a flow, it shows the "relevant fields" that were used
to determine the results. However, this currently only includes fields
that are used for computing the actions but not the flow lookup. This
can be confusing so this patch includes the wildcards from the classifer
lookup as well.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto: make oftable_remove_rule__ release evict lock
YAMAMOTO Takashi [Mon, 12 Aug 2013 23:00:05 +0000 (08:00 +0900)]
ofproto: make oftable_remove_rule__ release evict lock

according to the OVS_RELEASES annotation, oftable_remove_rule__ is
expected to release rule->evict lock.  make it actually do so.

this fixes pthread_rwlock_destroy failures observed on NetBSD,
where destroying a held lock, which is specwise undefined behaviour,
actually fails.  i guess it doesn't fail on linux but it's better
not to rely on an undefined behavior.

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agodatapath: Do not set dev->master for XEN.
Pravin B Shelar [Mon, 12 Aug 2013 17:12:27 +0000 (10:12 -0700)]
datapath: Do not set dev->master for XEN.

XEN dom0 networking assumes dev->master is bond device
and it tries to access bond private structure from dev->master
ptr on receive path. This causes panic.
Following patch removes compat code that is setting master
device.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Bug #18920

10 years agonetdev-bsd: ioctl "cmd" is unsigned long, not int
YAMAMOTO Takashi [Mon, 12 Aug 2013 22:20:22 +0000 (07:20 +0900)]
netdev-bsd: ioctl "cmd" is unsigned long, not int

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif-upcall: don't forget to initialize mutexes
YAMAMOTO Takashi [Mon, 12 Aug 2013 22:20:21 +0000 (07:20 +0900)]
ofproto-dpif-upcall: don't forget to initialize mutexes

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoband: Fix error in bond_choose_output_slave() function.
Alex Wang [Mon, 12 Aug 2013 21:14:52 +0000 (14:14 -0700)]
band: Fix error in bond_choose_output_slave() function.

This commit fixes the error introduced by commit 4a1b8f30e59 (bond:
Stop using tags.). The error is caused by mistakenly returning 'slave'
where 'slave->aux' should be returned.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoseq: Add some comments.
Ben Pfaff [Mon, 12 Aug 2013 20:45:01 +0000 (13:45 -0700)]
seq: Add some comments.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agonetdev-dummy: Include all dummy classes in iterations.
Ben Pfaff [Mon, 12 Aug 2013 19:49:23 +0000 (12:49 -0700)]
netdev-dummy: Include all dummy classes in iterations.

Commit 86f1d0326bd0 (netdev-dummy: Use netdev_get_devices() instead of a
local shash.) caused netdev-dummy functions that iterate over all dummy
devices to iterate only over the ones that have class 'dummy_class'.  This
seemed to obviously include all the ones that we want, but in fact
when ovs-vswitch is invoked with --enable-dummy=override, there are more
dummy classes than just dummy_class, which this new form of iteration
skipped over, with various negative consequences that showed up in some
testing.

This commit switches netdev-dummy back to internally tracking its own
dummy devices.  It fixes the tests for me.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agobond.c: Fix a typo.
Alex Wang [Mon, 12 Aug 2013 19:01:46 +0000 (12:01 -0700)]
bond.c: Fix a typo.

This commit fixes a typo in "lib/bond.c" which causes the high CPU
utilization after adding bond.  The bug was introduced in commit
4a1b8f30e59 (bond: Stop using tags.).

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agodatapath: Use parallel_ops genl.
Pravin B Shelar [Thu, 1 Aug 2013 22:36:06 +0000 (15:36 -0700)]
datapath: Use parallel_ops genl.

OVS locking was recently changed to have private OVS lock which
simplified overall locking.  Therefore there is no need to have
another global genl lock to protect OVS data structures.  Following
patch uses of parallel_ops genl family for OVS.  This also allows
more granual OVS locking using ovs_mutex for protecting OVS data
structures, which gives more concurrencey.  E.g multiple genl
operations OVS_PACKET_CMD_EXECUTE can run in parallel, etc.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
10 years agodatapath: Support for Linux kernel 3.10
Pravin B Shelar [Fri, 2 Aug 2013 18:38:51 +0000 (11:38 -0700)]
datapath: Support for Linux kernel 3.10

Changes are mostly related API changes in vlan, GRE
restructuring.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
Acked-by: Jesse Gross <jesse@nicira.com>
10 years agoofproto-dpif: Implement multi-threaded miss handling.
Ethan Jackson [Tue, 25 Jun 2013 21:45:43 +0000 (14:45 -0700)]
ofproto-dpif: Implement multi-threaded miss handling.

This patch factors flow miss handling into its own module,
ofproto-dpif-upcall which can utilize multiple threads to process
misses.  For some important benchmarks, this change improves Open
vSwitch flow setup performance by roughly 50x (that's 50 times not
50%) in my testing.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif: Lock rules to prevent eviction.
Ethan Jackson [Wed, 17 Jul 2013 23:14:02 +0000 (16:14 -0700)]
ofproto-dpif: Lock rules to prevent eviction.

This patch uses a read-write lock to prevent rules from being evicted
while they're used by child threads.  It also changes the prototypes
of the various rule lookup functions so that the thread safety
analysis can be used to ensure that the locking is handled properly.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agonetdev: Clean up on "construct" error in netdev_open().
Ben Pfaff [Sun, 11 Aug 2013 03:46:21 +0000 (20:46 -0700)]
netdev: Clean up on "construct" error in netdev_open().

Reported-by: ZhengLingyun <konghuarukhr@163.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agodpif-netdev: Avoid races on queue and port changes using seq objects.
Ben Pfaff [Wed, 7 Aug 2013 20:29:54 +0000 (13:29 -0700)]
dpif-netdev: Avoid races on queue and port changes using seq objects.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoseq: New module for race-free, pollable, thread-safe sequence number.
Ben Pfaff [Tue, 6 Aug 2013 16:39:10 +0000 (09:39 -0700)]
seq: New module for race-free, pollable, thread-safe sequence number.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agonetdev-linux: Avoid deadlock in netdev_linux_update_flags() for taps.
Ben Pfaff [Sun, 11 Aug 2013 03:42:50 +0000 (20:42 -0700)]
netdev-linux: Avoid deadlock in netdev_linux_update_flags() for taps.

netdev_linux_set_etheraddr() would attempt to recursively acquire
netdev->mutex via netdev_linux_update_flags() for tap devices.

Reported-by: ZhengLingyun <konghuarukhr@163.com>
Tested-by: ZhengLingyun <konghuarukhr@163.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agonetdev-linux: Fix netdev leak in corner case.
Ben Pfaff [Sat, 10 Aug 2013 16:02:24 +0000 (09:02 -0700)]
netdev-linux: Fix netdev leak in corner case.

Reported-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agonetdev: Make netdev access thread-safe.
Ben Pfaff [Sat, 10 Aug 2013 04:34:02 +0000 (21:34 -0700)]
netdev: Make netdev access thread-safe.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agonetdev-linux: Use dedicated netlink notification socket.
Ben Pfaff [Sat, 10 Aug 2013 04:29:03 +0000 (21:29 -0700)]
netdev-linux: Use dedicated netlink notification socket.

The rtnetlink_link asynchronous netlink notifications seem somewhat
troublesome in a threaded environment.  It seems more straightforward
to have netdev-linux fend for itself.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agonetdev-vport: Make netdev_vport_patch_peer() return a malloc()'d string.
Ben Pfaff [Wed, 31 Jul 2013 21:09:30 +0000 (14:09 -0700)]
netdev-vport: Make netdev_vport_patch_peer() return a malloc()'d string.

When threading comes into the picture there arises the possibility of a
race between netdev_vport_patch_peer()'s caller using the returned string
and another caller changing the peer.  It is safer to return a copy.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agonetdev: Adopt four-step alloc/construct/destruct/dealloc lifecycle.
Ben Pfaff [Sat, 10 Aug 2013 04:21:38 +0000 (21:21 -0700)]
netdev: Adopt four-step alloc/construct/destruct/dealloc lifecycle.

This is the same lifecycle used in the ofproto provider interface.
Compared to the previous netdev provider interface, it has the
advantage that the netdev top layer can control when any given
netdev becomes visible to the outside world.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agonetdev-bsd: Make use of AF_LINK socket thread-safe in NetBSD.
Ben Pfaff [Thu, 8 Aug 2013 06:48:59 +0000 (23:48 -0700)]
netdev-bsd: Make use of AF_LINK socket thread-safe in NetBSD.

Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
CC: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
10 years agonetdev-linux, netdev-bsd: Make access to AF_INET socket thread-safe.
Ben Pfaff [Sat, 10 Aug 2013 04:14:23 +0000 (21:14 -0700)]
netdev-linux, netdev-bsd: Make access to AF_INET socket thread-safe.

The only uses of 'af_inet_sock', in both drivers, were ioctls, so it seemed
like a good abstraction to write a function that just does such an ioctl,
and to factor out shared code into socket-util.

Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
10 years agonetdev-dummy: Use netdev_get_devices() instead of a local shash.
Ben Pfaff [Thu, 25 Jul 2013 23:11:52 +0000 (16:11 -0700)]
netdev-dummy: Use netdev_get_devices() instead of a local shash.

When an upcoming commit introduces thread safety into the netdev API, this
allows netdev-dummy to avoid adding more internal locking by taking
advantage of netdev_get_devices() refcounting.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agodatapath: Fix typo in flow validation logic.
Jesse Gross [Fri, 9 Aug 2013 22:27:27 +0000 (15:27 -0700)]
datapath: Fix typo in flow validation logic.

A bit shift operation is using the value '11' instead of '1' as the
starting value. This only makes validation weaker than it should be
so unless userspace is trying to install an invalid flow there will
be no effect.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
10 years agoovs-bugtool: Add config files to the debug bundle.
Gurucharan Shetty [Mon, 22 Jul 2013 19:17:08 +0000 (12:17 -0700)]
ovs-bugtool: Add config files to the debug bundle.

The previously defined config files were never included in
the debug bundle. This will include them.

Also increase the max size for CAP_NETWORK_CONFIG to 5 MB.
A pre-compressed size of 5 MB does not amount to much after
compression for config files.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoovs-bugtool: Collect database through CAP_NETWORK_STATUS.
Gurucharan Shetty [Tue, 23 Jul 2013 21:53:11 +0000 (14:53 -0700)]
ovs-bugtool: Collect database through CAP_NETWORK_STATUS.

Currently the openvswitch database is being collected with
CAP_NETWORK_CONFIG which has a max size of 50 KB. This is
quite low as the database can easily be larger than 50 KB.

Move database collection to CAP_NETWORK_STATUS which does
not have a max size. If database size exceeds 10 MB, create
a compacted version of it and then collect it.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoCodingStyle: Add guide about using thread safety types and annotations.
Alex Wang [Thu, 8 Aug 2013 22:14:21 +0000 (15:14 -0700)]
CodingStyle: Add guide about using thread safety types and annotations.

This commit adds guide about using thread safety types and annotations
to CodingStyle file.

Signed-off-by: Alex Wang <alexw@nicira.com>
[blp@nicira.com edited the advice slightly]
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoclang: Pass objects, not their addresses, to thread-safety macros.
Alex Wang [Thu, 8 Aug 2013 22:14:20 +0000 (15:14 -0700)]
clang: Pass objects, not their addresses, to thread-safety macros.

This commit changes the code such that arguments to thread-safety
macros are not ampersanded.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoclang: Use OVS_REQUIRES() instead of OVS_REQ_WRLOCK() for plain mutex.
Alex Wang [Thu, 8 Aug 2013 22:14:19 +0000 (15:14 -0700)]
clang: Use OVS_REQUIRES() instead of OVS_REQ_WRLOCK() for plain mutex.

This commit changes the code to use OVS_REQUIRES() instead of
OVS_REQ_WRLOCK(), for plain mutex.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif-xlate: Avoid MAC learning write lock on fast path.
Ben Pfaff [Wed, 7 Aug 2013 03:35:29 +0000 (20:35 -0700)]
ofproto-dpif-xlate: Avoid MAC learning write lock on fast path.

Most of the trips through update_learning_table() do not actually change
the MAC learning table, but because some do the code there took the
MAC learning table's write lock.  This commit changes the common case to
take only the read lock, falling back to the write lock if a change was
actually necessary.

Ethan reported that this gave a 3.3x performance improvement in one test
case due to reduced lock contention.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agoclassifier: Make use of the classifier thread safe.
Ethan Jackson [Thu, 11 Jul 2013 21:19:11 +0000 (14:19 -0700)]
classifier: Make use of the classifier thread safe.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agocompiler: Add OVS_ACQ_BEFORE, OVS_ACQ_AFTER macros.
Ben Pfaff [Fri, 9 Aug 2013 18:18:34 +0000 (11:18 -0700)]
compiler: Add OVS_ACQ_BEFORE, OVS_ACQ_AFTER macros.

An upcoming patch will add the first uses.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agodatapath: Add 'ovs_' prefix to extern symbols.
Jesse Gross [Thu, 8 Aug 2013 02:47:59 +0000 (19:47 -0700)]
datapath: Add 'ovs_' prefix to extern symbols.

The external symbols in the OVS kernel module are prefixed with
'ovs_' with the exception of ipv4_tun_to/from_nlattr(). This adds
the prefix and makes the out of tree version consistent with
upstream.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agoofproto-dpif-xlate: Require a lock for reconfiguration.
Ethan Jackson [Sun, 21 Jul 2013 18:31:32 +0000 (11:31 -0700)]
ofproto-dpif-xlate: Require a lock for reconfiguration.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoovs-thread: Remove superfluous semicolons in macro definitions.
Ben Pfaff [Thu, 8 Aug 2013 22:53:28 +0000 (15:53 -0700)]
ovs-thread: Remove superfluous semicolons in macro definitions.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agoofproto-dpif: Hide rule_dpif_miss_rule().
Ethan Jackson [Fri, 26 Jul 2013 00:20:53 +0000 (17:20 -0700)]
ofproto-dpif: Hide rule_dpif_miss_rule().

It's simpler to hide it than to make it thread safe and ensure it
stays that way in the long term.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif: Lock the expirable list.
Ethan Jackson [Thu, 8 Aug 2013 00:41:17 +0000 (17:41 -0700)]
ofproto-dpif: Lock the expirable list.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto: Lock hard_timeout and idle_timeout of struct rule.
Ethan Jackson [Wed, 7 Aug 2013 20:06:49 +0000 (13:06 -0700)]
ofproto: Lock hard_timeout and idle_timeout of struct rule.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoovs-thread: New function xpthread_join().
Ethan Jackson [Tue, 6 Aug 2013 23:47:43 +0000 (16:47 -0700)]
ovs-thread: New function xpthread_join().

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif-xlate: Fix rare segfault on switch exit.
Ethan Jackson [Thu, 8 Aug 2013 18:08:03 +0000 (11:08 -0700)]
ofproto-dpif-xlate: Fix rare segfault on switch exit.

Not all 'xport's have 'xbundle's, so this dereference is unsafe.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoovs-thread: New function ovsthread_id_self().
Ben Pfaff [Tue, 6 Aug 2013 21:57:19 +0000 (14:57 -0700)]
ovs-thread: New function ovsthread_id_self().

I foresee a need for possibly large numbers of instances of "struct
seq" (which is introduced in an upcoming patch).  Each struct seq
needs some per-thread data.  POSIX has pthread_key_t for this, but
the number of keys can be fairly limited, to as few as 128.  It is
reasonable to work around this by using a hash table indexed on the
current thread.  That only works if one can get a thread identifier
that is hashable (pthread_t is not).  This patch introduces a
hashable thread identifier.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoovs-thread: Add support for globally visible per-thread data.
Ben Pfaff [Tue, 6 Aug 2013 21:40:25 +0000 (14:40 -0700)]
ovs-thread: Add support for globally visible per-thread data.

DEFINE_PER_THREAD_DATA always declared its data item as "static", meaning
that it was only directly visible within a single translation unit.
This commit adds additional forms of per-thread data that allow the data
to be accessible from multiple translation units.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoovs-thread: New function xpthread_setspecific().
Ben Pfaff [Tue, 6 Aug 2013 21:30:01 +0000 (14:30 -0700)]
ovs-thread: New function xpthread_setspecific().

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif: Make packet_ins thread safe.
Ethan Jackson [Sat, 3 Aug 2013 17:04:57 +0000 (10:04 -0700)]
ofproto-dpif: Make packet_ins thread safe.

This patch makes packet_ins thread safe by handing responsibility for
them to ofproto-dpif.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agonetdev: Make netdev_from_name() take a reference to its returned netdev.
Ben Pfaff [Fri, 26 Jul 2013 00:05:46 +0000 (17:05 -0700)]
netdev: Make netdev_from_name() take a reference to its returned netdev.

This API change is necessary for thread safety, to be added in an upcoming
commit.  Otherwise, the client would not be able to safely use the returned
netdev because it could already have been destroyed.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agonetdev: Make netdev_get_devices() take a reference to each netdev.
Ben Pfaff [Thu, 25 Jul 2013 23:27:39 +0000 (16:27 -0700)]
netdev: Make netdev_get_devices() take a reference to each netdev.

This API change is necessary for thread safety, to be added in an upcoming
commit.  Otherwise, the client would not be able to actually use any of
the returned netdevs because they could already have been destroyed.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agonetdev-provider: Remove unused function netdev_assert_class().
Ben Pfaff [Sat, 27 Jul 2013 00:16:08 +0000 (17:16 -0700)]
netdev-provider: Remove unused function netdev_assert_class().

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agonetdev-bsd: Use xmemdup0() to simplify netdev_bsd_get_next_hop().
Ben Pfaff [Thu, 25 Jul 2013 22:38:29 +0000 (15:38 -0700)]
netdev-bsd: Use xmemdup0() to simplify netdev_bsd_get_next_hop().

Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
CC: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
10 years agonetdev-linux: Move variable declaration inward in netdev_linux_cache_cb().
Ben Pfaff [Fri, 26 Jul 2013 19:42:02 +0000 (12:42 -0700)]
netdev-linux: Move variable declaration inward in netdev_linux_cache_cb().

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agonetdev-linux: Remove useless member 'peer', which was always zero.
Ben Pfaff [Wed, 24 Jul 2013 17:44:42 +0000 (10:44 -0700)]
netdev-linux: Remove useless member 'peer', which was always zero.

Always, correct a comment on netdev_linux_get_features().

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agonetdev-linux: Remove unused struct netdev_linux member.
Ben Pfaff [Wed, 24 Jul 2013 17:37:37 +0000 (10:37 -0700)]
netdev-linux: Remove unused struct netdev_linux member.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agonetdev-linux: Remove pointless layers of indirection for tap devices.
Ben Pfaff [Fri, 26 Jul 2013 00:04:30 +0000 (17:04 -0700)]
netdev-linux: Remove pointless layers of indirection for tap devices.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agonetdev-linux: Remove unneeded struct forward declarations from header.
Ben Pfaff [Fri, 26 Jul 2013 18:20:09 +0000 (11:20 -0700)]
netdev-linux: Remove unneeded struct forward declarations from header.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agonetdev-vport: Use ovs_mutex rather than a raw pthread_mutex_t.
Ben Pfaff [Wed, 31 Jul 2013 21:15:05 +0000 (14:15 -0700)]
netdev-vport: Use ovs_mutex rather than a raw pthread_mutex_t.

I'd forgotten even to use the xpthread variants here.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
10 years agonetdev-bsd: Don't assume 'struct netdev' has offset 0.
Ben Pfaff [Fri, 2 Aug 2013 19:19:49 +0000 (12:19 -0700)]
netdev-bsd: Don't assume 'struct netdev' has offset 0.

The data items returned by netdev_get_devices() are "struct netdev *"s.
The code fixed up by this commit used them as "struct netdev_bsd *",
which happens to work because struct netdev happens to be at offset 0 in
each struct but it's better to do a proper cast in case someday
struct netdev gets moved to a nonzero offset.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agonetdev-bsd: Correctly handle IPv4 netmasks.
Ben Pfaff [Wed, 31 Jul 2013 22:22:12 +0000 (15:22 -0700)]
netdev-bsd: Correctly handle IPv4 netmasks.

netdev_bsd_get_in4() did not set anything in its 'netmask' output argument
if the IPv4 address was cached, leaving it indeterminate.  It would also
mark the cache as valid even if there was an error retrieving the netmask.
This fixes both problems.

Found by inspection.

Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
10 years agonetdev-bsd: Fix fd leak on error path.
Ben Pfaff [Thu, 25 Jul 2013 21:41:12 +0000 (14:41 -0700)]
netdev-bsd: Fix fd leak on error path.

Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
10 years agonetdev-bsd: Fix typo in label name.
Ben Pfaff [Thu, 25 Jul 2013 21:14:09 +0000 (14:14 -0700)]
netdev-bsd: Fix typo in label name.

Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
10 years agonetdev-bsd: Fix memory leak on error path.
Ben Pfaff [Thu, 25 Jul 2013 21:03:32 +0000 (14:03 -0700)]
netdev-bsd: Fix memory leak on error path.

Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
10 years agobfd: Fix build on netbsd-6.
YAMAMOTO Takashi [Thu, 8 Aug 2013 00:33:24 +0000 (09:33 +0900)]
bfd: Fix build on netbsd-6.

ip.h requires in_systm.h here.

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoUpdate OPENFLOW-1.1+ to differentiate optional and required features
Simon Horman [Wed, 7 Aug 2013 00:28:00 +0000 (09:28 +0900)]
Update OPENFLOW-1.1+ to differentiate optional and required features

The purpose of this patch is primarily to provide details on which
unimplemented features are optional and which are required as this
may be of interest to those working on OpenFlow 1.1+ coverage.

This patch also:
* Clarifies the text of some entries which seemed difficult to understand
  for the authors of this patch.
* Adds entries for features that were missing from the existing list.
  N.B: It is entirely possible that there are still missing entries.
* Expands some entries into sub-entries where some portions of
  a feature are required and others are optional

Co-authored-by: Joe Stringer <joe@wand.net.nz>
Signed-off-by: Joe Stringer <joe@wand.net.nz>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoovs-ofctl: Add "ofp-parse" command for printing OpenFlow from a file.
Ben Pfaff [Tue, 6 Aug 2013 16:45:07 +0000 (09:45 -0700)]
ovs-ofctl: Add "ofp-parse" command for printing OpenFlow from a file.

Test provided by Alex Wang <alexw@nicira.com>.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoodp-util: Always export the priority and skb_mark netlink attributes.
Andy Zhou [Sat, 3 Aug 2013 19:23:15 +0000 (12:23 -0700)]
odp-util: Always export the priority and skb_mark netlink attributes.

The current Netlink protocol allows a default value of zero if either mark
or priority is not specified (this is part of the ABI).  Until now, when
userspace serializes either the value or mask, it looked at the value and
omitted the netlink attribute if it is zero.  This is a bug because an
exact match on zero turns into a wildcard of the field.

These two fields (plus input port and EtherType) are special because they
can be omitted whereas most other values are required to be fully
specified.  These protocol variations tend to cause bugs (as above) when we
evolve the protocol because an exception that makes sense in one context
might not be logical in another.  Since the default value for mark and
priority are merely shorthands, we can push the protocol in a more
consistent direction by ignoring the shortcut and always serializing the
values.  This is what this commits does.

Signed-off-by: Andy Zhou <azhou@nicira.com>
[blp@nicira.com added Jesse's text to the commit message]
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agocfm: update remote opstate only when a CCM is received.
Paul Ingram [Sat, 3 Aug 2013 07:12:36 +0000 (07:12 +0000)]
cfm: update remote opstate only when a CCM is received.

The remote opstate for a CFM interface is presumed to be up unless a CCM is
received which signals opstate down. This means than an interface configured
for CFM demand mode may incorrectly appear to be opstate up if it has not
received a CCM within the last fault interval.

We should remember the last remote opstate for a CFM interface and only
change it when a CCM arrives signaling a change.

Bug #18806
Signed-off-by: Paul Ingram <pingram@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agobfd: Optimize BFD for Megaflows.
Gurucharan Shetty [Sat, 3 Aug 2013 13:46:26 +0000 (13:46 +0000)]
bfd: Optimize BFD for Megaflows.

The current situation is that whenever any packet enters the
userspace, bfd_should_process_flow() looks at the UDP destination
port to figure out whether that is a BFD packet. This means that
UDP destination port cannot be wildcarded for all the other flows
too.

To optimize BFD for megaflows, we introduce a new
'bfd:bfd_dst_mac' field in the database. Whenever this field is set
by a controller, it is assumed that all the BFD packets to/from
this interface will have the destination mac address set as the one
specified in the bfd:bfd_dst_mac field. If this field is set, we
first look at the destination mac address of a packet and if it
does not match the mac address set in bfd:bfd_dst_mac, we do not
process that packet as bfd. If the field does match, we go ahead
and look at the UDP destination port too.

Also, change the default BFD destination mac address to
"00:23:20:00:00:01".

Feature #18850.
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agoBFD: Populate ToS field in BFD packets.
Pavithra Ramesh [Sat, 20 Jul 2013 07:17:47 +0000 (07:17 +0000)]
BFD: Populate ToS field in BFD packets.

Signed-off-by: Pavithra Ramesh <paramesh@vmware.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agoBFD: Edit the unit test time/stop command
Pavithra Ramesh [Thu, 1 Aug 2013 09:55:22 +0000 (09:55 +0000)]
BFD: Edit the unit test time/stop command

Run the ovs-appctl time/stop command after OVS_VSWITCHD_START.
Also increase the wait time before checking if BFD session is up in
test 4.

Signed-off-by: Pavithra Ramesh <paramesh@vmware.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agoofproto-dpif-xlate: Take responsibility for ofproto_receive().
Ethan Jackson [Fri, 2 Aug 2013 19:43:03 +0000 (12:43 -0700)]
ofproto-dpif-xlate: Take responsibility for ofproto_receive().

ofproto_receive() is a slightly odd function which doesn't fit
perfectly in either ofproto-dpif or ofproto-dpif-xlate.  However, it's
much easier to reason about its thread safety in ofproto-dpif-xlate,
so this patch moves it there and renames it xlate_receive().

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif-xlate: Cleanup lookup functions.
Ethan Jackson [Sat, 3 Aug 2013 02:31:02 +0000 (19:31 -0700)]
ofproto-dpif-xlate: Cleanup lookup functions.

This patch allows the lookup functions to take NULL as an argument as
a convenience.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif: Make vlan splinters thread safe.
Ethan Jackson [Fri, 26 Jul 2013 00:42:24 +0000 (17:42 -0700)]
ofproto-dpif: Make vlan splinters thread safe.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif: Guard rule statistics with a mutex.
Ethan Jackson [Sat, 3 Aug 2013 20:13:26 +0000 (13:13 -0700)]
ofproto-dpif: Guard rule statistics with a mutex.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif-xlate: Maintain a pointer to struct dpif.
Ethan Jackson [Sat, 6 Jul 2013 18:46:48 +0000 (11:46 -0700)]
ofproto-dpif-xlate: Maintain a pointer to struct dpif.

This allows us to move some minor functionality from ofproto-dpif to
ofproto-dpif-xlate, where it's easier to ensure it's thread safe.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoodp-util: add verbose mode for displaying dp flow.
Andy Zhou [Sat, 3 Aug 2013 19:23:14 +0000 (12:23 -0700)]
odp-util: add verbose mode for displaying dp flow.

When verbose mode tuned on, all dp flow fields described by the netlink
attributes are displayed, including fully wildcarded attributes.
Otherwise, the fully wildcarded attributes are omitted for brevity.

Added -m option to "ovs-dpctl dump-flows" to enable verbose mode. It is
off by default.

Signed-off-by: Andy Zhou <azhou@nicira.com>
[blp@nicira.com added documentation]
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif-xlate: Don't trace on deep resubmit.
Ethan Jackson [Fri, 2 Aug 2013 03:52:01 +0000 (20:52 -0700)]
ofproto-dpif-xlate: Don't trace on deep resubmit.

While this code is useful for debugging, removing it allows us to hide
ofproto_trace() in ofproto-dpif. ofproto_trace() is a complex function
which could be difficult to make "obviously" thread safe.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif-xlate: Refactor stp_get_port() calls.
Ethan Jackson [Fri, 2 Aug 2013 21:55:31 +0000 (14:55 -0700)]
ofproto-dpif-xlate: Refactor stp_get_port() calls.

I had intended to fold this into a previous patch.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif: avoid losing track of kernel flows upon reinstallation
Andy Zhou [Sat, 3 Aug 2013 03:22:17 +0000 (20:22 -0700)]
ofproto-dpif: avoid losing track of kernel flows upon reinstallation

This commit fixes a problem whereby userspace can lose track of a
flow installed in the kernel, instead believing that the flow is
not installed.  The most visible consequence of this bug was a
message in the ovs-vswitchd log warning about an unexpected flow
in the kernel.  Other possible consequences included loss of
statistics and failure to updates actions when the OpenFlow flow
table changed.

The problem arose in the following scenario.  Suppose userspace
sets up a kernel flow due to an arriving packet.  Before kernel
flow setup completes, another packet for that flow arrives.  The
kernel sends the new packet to userspace after userspace has
completed processing the batch of packets that set up the flow.
Userspace then attempts to reinstall the kernel flow.  This fails
with EEXIST, so userspace then marked the flow as not-installed,
even though it was successfully installed before and remains
installed.  The next time userspace dumped the kernel flow
table to gather statistics, it would complain about an unexpected
flow and delete it.

In practice, we have seen these messages with netperf TCP_CRR tests and
UDP stream tests.

This patch fixes the problem by changing userspace so that, once
it successfully installs a flow in the kernel, it will not reinstall
it when it sees another packet for the flow in userspace.  This
has the downside that, if something goes wrong and a flow
disappears from the kernel (e.g. ovs-dpctl del-flows), then userspace
won't reinstall it (until it tries to delete it).  (This is in fact
the reason why until now userspace reinstalled flows it knew it
already installed.)

Some more background may be warranted.  There are two EEXIST error
cases:

       1. A subfacet was installed successfully in a previous (recent)
          batch.  Now we've attempted to reinstall exactly the same
          subfacet in this batch.

       2. A subfacet was installed successfully in a previous (recent)
          batch or earlier in the current batch.  We've attempted to
          install a subfacet for an overlapping megaflow.

Before megaflows, installation errors were ignored completely.
Since megaflows were introduced, they have been handled by
considering on any installation error that the given subfacet is
not installed.  This works well for case #2 but causes case #1 to
yield unexpected flows, as described at the top of the commit
message.

This commit adds the wrinkle that we never try to reinstall
exactly the same subfacet that we know we installed successfully
earlier (and haven't deleted) unless its actions change.  This
ought to work just as well for case #2, and avoids the problem
with case #1.

Prepared with assistance from Ethan.

Signed-off-by: Andy Zhou <azhou@nicira.com>
[blp@nicira.com rewrote the commit message]
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif: Always un-wildcard fields that are being set.
Justin Pettit [Sat, 3 Aug 2013 04:17:31 +0000 (21:17 -0700)]
ofproto-dpif: Always un-wildcard fields that are being set.

The ODP library has an optimization to not set a header if the field was
not changed, regardless of whether an action to set the field was
present.  That library is also responsible for un-wildcarding fields
that are bieng modified.  This leads to a problem where a packet matches
a flow that updates a field, but that particular packet's field already
has that value.  As such, an overly loose megaflow will be generated
that doesn't match on that field and the actions won't update it.  A
second packet that should have the field set will match that flow and
will not be modified.

This commit changes the behavior to always un-wildcard fields that are
being modified.  Since the ODP library updates the entire header if a
field in it is modified, and all those fields will be un-wildcarded, the
generated flows may be different.  However, they should be correct.

Bug #18946.

Reported-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoasync-append: Refactor to avoid requiring enabling while single threaded.
Ben Pfaff [Sat, 3 Aug 2013 00:32:25 +0000 (17:32 -0700)]
async-append: Refactor to avoid requiring enabling while single threaded.

Until now, the async append interface has required async_append_enable()
to be called while the process was still single-threaded, with the
rationale being that async_append_enable() could race with
async_append_write() on some existing async_append object.  This was a
difficult problem when the async append interface was introduced, because
at the time Open vSwitch did not have any infrastructure for inter-thread
synchronization.

Now it is easy to solve, by introducing synchronization into the
async append module.  However, that's more or less wasted, because the
client is already required to serialize access to async append objects.
Moreover, vlog, the only existing client, needs to serialize access for
other reasons, so it wouldn't even be possible to just drop the client's
synchronization.

This commit therefore takes another approach.  It drops the
async_append_enable() interface entirely.  Now any existing async_append
object is always enabled.  The responsibility for "enabling", then, now
rests in whether the client creates and uses an async_append object, and
so vlog now takes care of that by itself.  Also, since vlog now has to
deal with sometimes having an async_append and sometimes not having one,
we might as well allow creating an async_append to fail, thereby slightly
simplifying the "no async I/O" implementation from "write synchronously"
to "always fail creating an async_append".

Reported-by: Shih-Hao Li <shihli@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif: Handle learn action flow mods asynchronously.
Ethan Jackson [Fri, 12 Jul 2013 00:17:00 +0000 (17:17 -0700)]
ofproto-dpif: Handle learn action flow mods asynchronously.

Once we have multiple threads running, having each execute flow mods
created by the learn action won't be tenable.  It essentially will
require us to make the core ofproto module thread safe, which is not
the direction we want to go.  This patch punts on the problem by
handing flow mods to ofproto-dpif to handle later.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif-xlate: Take control of the qdscp map.
Ethan Jackson [Sat, 6 Jul 2013 17:25:06 +0000 (10:25 -0700)]
ofproto-dpif-xlate: Take control of the qdscp map.

This will make locking easier in future patches.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif-xlate: Pull STP xlation into ofproto-dpif-xlate.
Ethan Jackson [Sat, 6 Jul 2013 16:31:35 +0000 (09:31 -0700)]
ofproto-dpif-xlate: Pull STP xlation into ofproto-dpif-xlate.

This patch pulls the STP xlation code into ofproto-dpif-xlate where it
will be easier to guard.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agotag: Retire the venerable tag library.
Ethan Jackson [Fri, 2 Aug 2013 00:07:08 +0000 (17:07 -0700)]
tag: Retire the venerable tag library.

This patch retires a venerable library whose inception dates before
the first patch of the current repository: tags.  They have served us
well, but their time has come for the reasons listed below.

1) They don't actually help much.
In theory, tags had been used to reduce revalidation necessary when
using bonds, mac-learning, and frequently changing flow tables.  With
bonds and mac-learning, things change happen so rarely that tagging
isn't worth it.  That leaves flow table changes. With the complex flow
tables in my testing, the revalidate_set gets so overwhelmed with
tags, that we end up revalidating every facet every time through the
run loop.  In other words, they tags are giving us no benefit.

2) They complicate the code.
This patch simplifies the code and removes a couple of rather ugly
kludges.

3) They complicated locking once threading hits.
Because of the calculate_flow_tag() function, the table_dpif structure
would require locking in a multi-threaded OVS.  Though this problem
isn't insurmountable, it's annoying and probably would cause lock
contention.

Of course, we could try to work around these problems with a more
advanced tagging infrastructure, but this moves in the opposite of the
direction we should be.  Ideally we'll have a more-or-less stateless
ofproto-dpif supporting a massive number of datapath flows.  Tags (or
facets for that matter) aren't going to work in this new world.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agobond: Stop using tags.
Ethan Jackson [Fri, 2 Aug 2013 01:23:13 +0000 (18:23 -0700)]
bond: Stop using tags.

This patch transitions bonding away from using tags as required by
future patches.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agomac-learning: Stop using tags.
Ethan Jackson [Fri, 2 Aug 2013 01:04:07 +0000 (18:04 -0700)]
mac-learning: Stop using tags.

This patch transitions mac learning away from using tags as required
by future patches.

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