6 years agoSetting tag sliver-openvswitch-2.2.90-1 master sliver-openvswitch-2.2.90-1
Thierry Parmentelat [Wed, 16 Jul 2014 21:23:43 +0000 (23:23 +0200)]
Setting tag sliver-openvswitch-2.2.90-1
catching up with mainstream 2.2.90

6 years agooops
Thierry Parmentelat [Wed, 16 Jul 2014 21:23:20 +0000 (23:23 +0200)]

6 years agobump version number to 2.2.90
Thierry Parmentelat [Wed, 16 Jul 2014 21:21:36 +0000 (23:21 +0200)]
bump version number to 2.2.90

6 years agoMerge branch 'mainstream'
Giuseppe Lettieri [Sun, 4 May 2014 09:19:14 +0000 (11:19 +0200)]
Merge branch 'mainstream'

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

6 years agonetdev-linux: favor netlink stats for physical ports mainstream
Andy Zhou [Mon, 28 Apr 2014 22:46:30 +0000 (15:46 -0700)]
netdev-linux: favor netlink stats for physical ports

Currently physical ports stats are collected from kernel datapath.
However, those counter do not reflect actual wire packet counters
when GSO, TSO or GRO are enabled by the NIC. In the meantime, the
stats collected form routing stack does. While both stats are valid,
Reporting kernel netdev stats for packet counts and byte counts make
it easier to correlate those numbers with external measurements.

Signed-off-by: Andy Zhou <>
Acked-by: Ben Pfaff <>
6 years agonetdev-vport: Checks tunnel status change when route-table is reset.
Alex Wang [Thu, 1 May 2014 17:53:48 +0000 (10:53 -0700)]
netdev-vport: Checks tunnel status change when route-table is reset.

Commit 3e912ffcbb (netdev: Add 'change_seq' back to netdev.) added per-
netdev change number for indicating status change.  Future commits used
this change number to optimize the netdev status update to database.
However, the work also introduced the bug in the following scenario:

- assume interface eth0 has address, eth1 has adddress
- assume tunnel port p1 is set with remote_ip=
- after setup, 'ovs-vsctl list interface p1 status' should show the
- now if the address of eth1 is change to 0 via 'ifconfig eth1 0'.
- expectedly, after change, 'ovs-vsctl list interface p1 status' should
  show the 'tunnel_egress_iface="eth0"'

However, 'tunnel_egress_iface' will not be updated on current master.
This is in that, the 'netdev-vport' module corresponding to p1 does
not react to routing related changes.

To fix the bug, this commit adds a change sequence number in the route-
table module and makes netdev-vport check the sequence number for
tunnel status update.

Bug #1240626

Signed-off-by: Alex Wang <>
Acked-by: Ben Pfaff <>
6 years agobridge: Allow users to configure statistics update to OVSDB.
Alex Wang [Thu, 3 Apr 2014 20:27:22 +0000 (13:27 -0700)]
bridge: Allow users to configure statistics update to OVSDB.

This commit adds a new configuration "stats-update-interval" in
"other_config" of Open_Vswitch table.  So users can control the
statistics update frequency.  A possible use case is that, users
can lower the update frequency to reduce the cpu consumption of
the ovs-vswitchd thread.

The configured value should always be greater than or equal to
5000 ms.  And more frequent statistics update should be achieved
via OpenFlow.

Signed-off-by: Alex Wang <>
Acked-by: Joe Stringer <>
6 years agoofproto-dpif-monitor: Fix deadlock.
Alex Wang [Fri, 4 Apr 2014 01:31:13 +0000 (18:31 -0700)]
ofproto-dpif-monitor: Fix deadlock.

Commit 6b59b543 (ovs-thread: Use fair (but nonrecursive)
rwlocks on glibc.) changed the rwlocks to nonrecursive,
writer-biased lock.  It also made the following deadlock

Assume BFD is used on both end of a link.  Consider the
following events:
1. Handler at one end received the BFD control packet with
   POLL flag set while holding the read lock of 'xlate_rwlock'.
   Since a BFD control packet with FINAL flag set should be
   sent back immediately, it calls the
   ofproto_dpif_monitor_port_send_soon(), in which, it tries
   to grab the 'monitor_mutex'.
2. The main thread needs to configure the ofproto-dpif-xlate
   module.  It tries to grab the write lock of 'xlate_rwlock'
   and is blocked by event 1.
3. The monitor thread, after acquired the 'monitor_mutex',
   wants to acquire the read lock of 'xlate_rwlock'.

Since the rwlock is now writer-biased, the attempt of acquiring
read lock in event 3 will be blocked by event 2.  This will
subsequently cause the block of event 1, since monitor thread
is holding the 'monitor_mutex'.  So the deadlock happens.

This commit resolves the above issue by removing the requirement of
acquiring 'monitor_mutex' in ofproto_dpif_monitor_port_send_soon().

Signed-off-by: Alex Wang <>
Acked-by: Ben Pfaff <>
6 years agodatapath: Fix feature check for HAVE_RXHASH.
Jesse Gross [Fri, 2 May 2014 17:33:45 +0000 (10:33 -0700)]
datapath: Fix feature check for HAVE_RXHASH.

The check for HAVE_RXHASH use #if rather than #ifdef, which
provokes a warning when it isn't defined.

Signed-off-by: Jesse Gross <>
6 years agoAdd basic implementation for OpenFlow 1.4 bundles
Alexandru Copot [Fri, 2 May 2014 06:54:27 +0000 (09:54 +0300)]
Add basic implementation for OpenFlow 1.4 bundles

This is only the communication part of the bundles functionality.
The actual message pre-validation and commits are not implemented.

We also enable OF1.4 for all the tests.

Signed-off-by: Alexandru Copot <>
Cc: Daniel Baluta <>
[ made ofputil_decode_bundle_add() more obviously correct]
Signed-off-by: Ben Pfaff <>
6 years agoAUTHORS: Add Christian Stigen Larsen <>.
Ben Pfaff [Fri, 2 May 2014 15:10:05 +0000 (08:10 -0700)]
AUTHORS: Add Christian Stigen Larsen <>.

Signed-off-by: Ben Pfaff <>
6 years agovtep: clean up whitespace
Bruce Davie [Fri, 2 May 2014 01:37:24 +0000 (18:37 -0700)]
vtep: clean up whitespace

Signed-off-by: Bruce Davie <>
Signed-off-by: Ben Pfaff <>
6 years agoofproto-dpif: Add table_is_internal() helper
Simon Horman [Fri, 2 May 2014 08:41:33 +0000 (17:41 +0900)]
ofproto-dpif: Add table_is_internal() helper

This will be used by a subsequent patch to add support for
recirculation for MPLS.

Signed-off-by: Simon Horman <>
Signed-off-by: Ben Pfaff <>
6 years agoflow: Add mf_is_l3_or_higher()
Simon Horman [Fri, 2 May 2014 08:41:32 +0000 (17:41 +0900)]
flow: Add mf_is_l3_or_higher()

This is in preparation for using the same helper as part of support
for using recirculation in conjunction series of actions including
with MPLS actions that are currently not able to be translated.

In that scenario this helper will be used to test if load, move and
set_field actions require recirculation to occur.

Signed-off-by: Simon Horman <>
Signed-off-by: Ben Pfaff <>
6 years agodatapath: clear l4_rxhash in skb_clear_hash.
Pritesh Kothari [Thu, 1 May 2014 22:50:49 +0000 (15:50 -0700)]
datapath: clear l4_rxhash in skb_clear_hash.

Signed-off-by: Pritesh Kothari <>
Signed-off-by: Jesse Gross <>
6 years agodatapath: Add support for kernel 3.14.
Pritesh Kothari [Thu, 1 May 2014 22:50:48 +0000 (15:50 -0700)]
datapath: Add support for kernel 3.14.

Signed-off-by: Pritesh Kothari <>
Signed-off-by: Jesse Gross <>
6 years agodatapath: handle recirculation loop detection
Andy Zhou [Wed, 30 Apr 2014 23:13:27 +0000 (16:13 -0700)]
datapath: handle recirculation loop detection

Current datapath limits the number of times same packet can loop
through action execution to avoid blowing out the kernel stack.
Recirculation also adds to action execution count, but does not use
the same amount of stack compare to other services, such as IPsec.

This patch introduces the concept of stack cost. Recirculation has a
stack cost of 1 while other services have stack cost of 4. Datapath
packet process can accommodate packets that need both services and
recirculation as long as the total stack cost does not exceed the max
stack cost. Packets exceed the limit will be treated as looped packets
and dropped.

The max stack cost is set to allow up to 4 regular services, plus up
to 3 recirculation. The behavior of packets do not recirculate does
not change.

Signed-off-by: Andy Zhou <>
Acked-by: Jesse Gross <>
6 years agoofproto: Fix is_flow_deletion_pending() false positive.
Ethan Jackson [Thu, 1 May 2014 00:24:21 +0000 (17:24 -0700)]
ofproto: Fix is_flow_deletion_pending() false positive.

If one tries to install a rule that's identical to another rule in
another OpenFlow table which is being deleted, it's possible that
is_flow_deletion_pending() might confuse them and block the
installation.  This is such an edge case I doubt it has ever actually

Found by inspection.

Signed-off-by: Ethan Jackson <>
Acked-by: Ben Pfaff <>
6 years agoofproto: Fix potential leak during flow mods.
Ethan Jackson [Wed, 30 Apr 2014 21:52:28 +0000 (14:52 -0700)]
ofproto: Fix potential leak during flow mods.

This code created a cls_rule without destroying it.  Found by

Signed-off-by: Ethan Jackson <>
Acked-by: Jarno Rajahalme <>
6 years agoofproto-dpif: Make bonding balance test more robust
Simon Horman [Thu, 1 May 2014 16:40:17 +0000 (16:40 +0000)]
ofproto-dpif: Make bonding balance test more robust

It is my observation that when sending 91 packets to a mode=balance
bond interface with three underlying ports in some cases not all ports
receive at least 7 packets. This causes the test to fail.

It may be that failure indicates that the bonding code
needs improvement. But it seems to me that its more likely to
be a valid behaviour.

I have found that by sending 256 packets instead of 91 the test passes
more reliably: I am yet to see it fail.

Signed-off-by: Simon Horman <>
Signed-off-by: Andy Zhou <>
6 years agoovs-thread: Fix OVS_ADAPTIVE_MUTEX_INITIALIZER.
Ben Pfaff [Thu, 1 May 2014 15:46:45 +0000 (08:46 -0700)]

Commit 05bf6d3c62e1d (ovs-thread: Add checking for mutex and rwlock
initialization.) updated mutex and rwlock initializers to set the "where"
member to a nonnull value, but missed this one.  This commit fixes the

This does not cause real problems in practice because

Signed-off-by: Ben Pfaff <>
Acked-by: Jarno Rajahalme <>
6 years agoovs-ctl: Install manpage.
Ben Pfaff [Thu, 1 May 2014 15:10:20 +0000 (08:10 -0700)]
ovs-ctl: Install manpage.

It seems that it is useful to admins after all.

Reported-by: Brian Candler <>
Signed-off-by: Ben Pfaff <>
6 years agoMerge pull request #1 from spil-jasper/master
Ben Pfaff [Thu, 1 May 2014 14:40:35 +0000 (07:40 -0700)]
Merge pull request #1 from spil-jasper/master

Add BuildRequires to RHEL specfile

6 years agoofproto-dpif: Correct check_recirc comment
Simon Horman [Thu, 1 May 2014 08:34:20 +0000 (17:34 +0900)]
ofproto-dpif: Correct check_recirc comment

This is a proposed correction for what appears to be
an editing error.

Signed-off-by: Simon Horman <>
Signed-off-by: Ben Pfaff <>
6 years agoofp-print: Enable printing OF1.4 version
Alexandru Copot [Thu, 1 May 2014 10:22:20 +0000 (13:22 +0300)]
ofp-print: Enable printing OF1.4 version

Also fix some tests that can now properly print packets
with the new protocol version.

Signed-off-by: Alexandru Copot <>
Cc: Daniel Baluta <>
Signed-off-by: Ben Pfaff <>
6 years agoofproto-dpif: Move recirc members from struct xlate_out to struct xlate_ctx
Simon Horman [Thu, 1 May 2014 08:29:59 +0000 (17:29 +0900)]
ofproto-dpif: Move recirc members from struct xlate_out to struct xlate_ctx

There does not seem to be a reason to expose
recirc members in struct xlate_out to move them
to struct xlate_ctx.

Signed-off-by: Simon Horman <>
Signed-off-by: Ben Pfaff <>
6 years agoofproto-dpif-xlate: Fix in_port=controller case for NORMAL action
YAMAMOTO Takashi [Wed, 30 Apr 2014 01:10:12 +0000 (10:10 +0900)]
ofproto-dpif-xlate: Fix in_port=controller case for NORMAL action

The problem mentioned by Simon Horman in the following mail.

Cc: Simon Horman <>
Acked-by: Ben Pfaff <>
Signed-off-by: YAMAMOTO Takashi <>
6 years agobfd: Require bfd control packet received in forwarding_if_rx mode.
Alex Wang [Wed, 16 Apr 2014 23:00:40 +0000 (16:00 -0700)]
bfd: Require bfd control packet received in forwarding_if_rx mode.

This commit adds a requirement that bfd session must receive at least
one bfd control packet every 100 * bfd->cfg_min_rx amount of time in
forwarding_if_rx mode.  Otherwise, even if the data packets are received
on the monitored interface, the bfd->forwarding is still false.

Since the datapath flow is not purged when the userspace Open Vswitch
crashes, data packet can still be forwarded through the tunnel and
fool the remote BFD session in forwarding_if_rx mode.  Thus, this commit
can prevent the remote BFD session from falsely declaring tunnel liveness
in this situation.

Signed-off-by: Alex Wang <>
Acked-by: Ethan Jackson <>
6 years agocfm: Require ccm received in demand mode.
Alex Wang [Wed, 9 Apr 2014 17:58:54 +0000 (10:58 -0700)]
cfm: Require ccm received in demand mode.

This commit adds a new requirement that cfm session must receive
at least one ccm every 100 * cfm_interval amount of time in demand
mode.  Otherwise, even if the data packets are received on the
monitored interface, the cfm session still reports "[recv]" fault.

Since the datapath flow is not purged when the userspace Open Vswitch
crashes, data packet can still be forwarded through the tunnel and
fool the remote CFM session in demand mode.  Thus, this commit can
prevent the remote CFM session from falsely declaring tunnel liveness
in this situation.

Signed-off-by: Alex Wang <>
Acked-by: Ethan Jackson <>
6 years agobridge: Remove traces of flow-eviction-threshold.
Joe Stringer [Wed, 30 Apr 2014 21:50:59 +0000 (09:50 +1200)]
bridge: Remove traces of flow-eviction-threshold.

This configuration option was shifted in 2.0, then removed in 2.1.
Remove the misleading log message.

Signed-off-by: Joe Stringer <>
Acked-by: Ethan Jackson <>
6 years agolib/classifier: Use a prefix tree to optimize ports wildcarding.
Jarno Rajahalme [Wed, 30 Apr 2014 21:09:08 +0000 (14:09 -0700)]
lib/classifier: Use a prefix tree to optimize ports wildcarding.

Using a prefix tree (aka 'trie') for transport ports matching produces
less specific (more wildcarded) datapath megaflows.

Each subtable that matches on transport ports has it's own ports trie.
This trie is consulted only after a failing lookup to determine the
number of bits that need to be unwildcarded to guarantee that any
packet that should match on any of the other rules will not match this

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agoofproto-dpif: Close race between processing packet_ins and checking seqno.
Ben Pfaff [Wed, 30 Apr 2014 18:07:46 +0000 (11:07 -0700)]
ofproto-dpif: Close race between processing packet_ins and checking seqno.

If a packet-in were to be queued, and the sequence number changed, after
grabbing the list of packet-ins, then the existing code could have gone to
sleep until something happened.  By grabbing the sequence number before
the list of packet-ins, we avoid this race.

Found by inspection.

Signed-off-by: Ben Pfaff <>
6 years agodatapath: Remove unnecessary flow variable.
Pravin B Shelar [Tue, 29 Apr 2014 23:27:50 +0000 (16:27 -0700)]
datapath: Remove unnecessary flow variable.

Patch fixes following warning:
datapath/linux/flow_table.c:580:40: warning: symbol 'flow' shadows an earlier one
datapath/linux/flow_table.c:558:24: originally declared here

Reported-by: Ben Pfaff <>
Signed-off-by: Pravin B Shelar <>
Acked-by: Jesse Gross <>
6 years agoEnable OpenFlow 1.0, 1.1, 1.2, and 1.3 by default.
Ben Pfaff [Wed, 30 Apr 2014 13:54:09 +0000 (06:54 -0700)]
Enable OpenFlow 1.0, 1.1, 1.2, and 1.3 by default.

The Open vSwitch software switch now supports all the required features of
OpenFlow 1.0 through 1.3, with one known trivial exception[*].  Enable them
by default in ovs-vswitchd.

For now, ovs-ofctl only enables OpenFlow 1.0 by default.  This is
because ovs-ofctl implements command such as "add-flow" as raw
OpenFlow requests, but those requests have subtly different semantics
in different OpenFlow versions.  For example:

    - In OpenFlow 1.0, a "mod-flow" operation that does not find any
      existing flow to modify adds a new flow.

    - In OpenFlow 1.1, a "mod-flow" operation that does not find any
      existing flow to modify adds a new flow, but only if the
      mod-flow did not match on the flow cookie.

    - In OpenFlow 1.2 and a later, a "mod-flow" operation never adds a
      new flow.

[*] OpenFlow 1.1, but not any earlier or later version of OpenFlow,
    requires support for VLANs introduced by Ethertype 0x88a8, but Open
    vSwitch does not support this Ethertype.

Signed-off-by: Ben Pfaff <>
Reviewed-by: YAMAMOTO Takashi <>
6 years agoAdd BuildRequires to RHEL specfile
Jasper Capel [Wed, 9 Apr 2014 06:38:43 +0000 (08:38 +0200)]
Add BuildRequires to RHEL specfile

Added a build-time dependency on openssl-devel, so you can easily build
a source RPM and then pass it into mock for building in a clean build
environment (without manually having to install the buildrequires).

Signed-off-by: Jasper Capel <>
6 years agobond: fix uninitialized use of use_recirc variable
Andy Zhou [Tue, 29 Apr 2014 20:04:00 +0000 (13:04 -0700)]
bond: fix uninitialized use of use_recirc variable

Caught by clang-3.5.

Reported-by: Simon Horman <>
Signed-off-by: Andy Zhou <>
Acked-by: Pritesh Kothari <>
6 years agolib/classifier: Support variable sized miniflows.
Jarno Rajahalme [Tue, 29 Apr 2014 22:50:39 +0000 (15:50 -0700)]
lib/classifier: Support variable sized miniflows.

Change the classifier to allocate variable sized miniflows and
minimasks in cls_match and cls_subtable, respectively.  Do not
duplicate the mask in cls_rule any more.

miniflow_clone and miniflow_move can now take variably sized miniflows
as source.  The destination is assumed to be regularly sized miniflow.

Inlining miniflow and mask values reduces memory indirection and helps
reduce cache misses.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agolib/flow: Maintain miniflow offline values explicitly.
Jarno Rajahalme [Tue, 29 Apr 2014 22:50:39 +0000 (15:50 -0700)]
lib/flow: Maintain miniflow offline values explicitly.

This allows use of miniflows that have all of their values inline.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agolib/classifier: Separate cls_rule internals from the API.
Jarno Rajahalme [Tue, 29 Apr 2014 22:50:38 +0000 (15:50 -0700)]
lib/classifier: Separate cls_rule internals from the API.

Keep an internal representation of a rule separate from the one
embedded into user's structs.  This allows for further memory
optimization in the classifier.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agoclassifier: Use array for subtables instead of a list.
Jarno Rajahalme [Tue, 29 Apr 2014 22:50:38 +0000 (15:50 -0700)]
classifier: Use array for subtables instead of a list.

Using a linear array allows more efficient memory access for lookups.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agolib: Add prefetch support (for GCC)
Jarno Rajahalme [Tue, 29 Apr 2014 22:50:38 +0000 (15:50 -0700)]
lib: Add prefetch support (for GCC)

Define OVS_PREFETCH() and OVS_PREFETCH_WRITE() using builtin prefetch
for GCC, and ovs_prefetch_range() for prefetching a range of addresses.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agolib/flow: Optimize minimask_has_extra() and minimask_is_catchall()
Jarno Rajahalme [Tue, 29 Apr 2014 22:50:38 +0000 (15:50 -0700)]
lib/flow: Optimize minimask_has_extra() and minimask_is_catchall()

We only need to iterate over the bits masked by the 'b' in
minimask_has_extra(), since for zeroes in 'b' there can be no 'extra'
wildcards in 'a', as 'b' has already wildcarded all the bits.

minimask_is_catchall() can be simplified by the invariant that mask's
map never has 1-bits for all-zero values.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agolib/classifier: Hide more of the internal data structures.
Jarno Rajahalme [Tue, 29 Apr 2014 22:50:38 +0000 (15:50 -0700)]
lib/classifier: Hide more of the internal data structures.

It is better not to expose definitions not needed by users.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agoofproto: Use classifer cursor API to collect vlan usage.
Jarno Rajahalme [Tue, 29 Apr 2014 22:50:38 +0000 (15:50 -0700)]
ofproto: Use classifer cursor API to collect vlan usage.

This was the only place in OVS code that accessed classifier internal
data structures directly.  Use the classifier cursor API instead, so
that following patches can hide classifier internal data structures.

Note: There seems to be no test case to verify that this vlan usage
collection is implemented correctly.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agolib: Inline functions used in classifier_lookup.
Jarno Rajahalme [Tue, 29 Apr 2014 22:50:38 +0000 (15:50 -0700)]
lib: Inline functions used in classifier_lookup.

This helps about 1% in TCP_CRR performance test.  However, this also
helps by clearly showing the classifier_lookup() cost in perf reports
as one item.

This also cleans up the flow/match APIs from functionality only used
by the classifier, making is more straightforward to evolve them

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agolib/flow: Simplify miniflow accessors, add ipv6 support.
Jarno Rajahalme [Tue, 29 Apr 2014 22:50:38 +0000 (15:50 -0700)]
lib/flow: Simplify miniflow accessors, add ipv6 support.

Add new macro MINIFLOW_MAP(FIELD) that returns the map covering the
given struct flow field.

Change the miniflow accessors to macros so that they can take the
field name directly.

Use these to add ipv6 support to miniflow_hash_5tuple().

Add ipv6 support to flow_hash_5tuple() as well so that these two
functions continue to return the same hash value for the corresponding

Also, simplify miniflow_get_metadata().

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agoofproto: Inline trivial functions.
Jarno Rajahalme [Tue, 29 Apr 2014 22:50:38 +0000 (15:50 -0700)]
ofproto: Inline trivial functions.

rule_dpif_is_internal is among the top ten OVS internal functions in
recent perf reports.  Inline it and some other equally trivial

This change removes rule_is_internal(), since the fact that a table is
an internal one is defined within ofproto-dpif, not ofproto.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ben Pfaff <>
6 years agoofproto: Inline actions in struct rule_actions.
Jarno Rajahalme [Tue, 29 Apr 2014 22:50:38 +0000 (15:50 -0700)]
ofproto: Inline actions in struct rule_actions.

Allocate struct rule_actions and the space for the actions at once.
This reduces one memory indirection and helps reduce cache misses
visible in perf annotations.

Fix some old comments referring to ref count, since we now use RCU for

Enforce constness of the actions that are assigned from rule_actions
throughout the code.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ben Pfaff <>
6 years agoovs-rcu: Log the name of the main thread as "main" instead of "".
Ben Pfaff [Tue, 29 Apr 2014 21:44:39 +0000 (14:44 -0700)]
ovs-rcu: Log the name of the main thread as "main" instead of "".

The main thread has the empty string as its name, but that's not a good
log string.

Without this patch we can get log message like
    blocked 1000 ms waiting for  to quiesce
from ovsrcu_synchronize().

Signed-off-by: Ben Pfaff <>
Acked-by: Alex Wang <>
6 years agotests: Whitelist messages about RCU blocking in the testsuite.
Ben Pfaff [Tue, 29 Apr 2014 21:40:51 +0000 (14:40 -0700)]
tests: Whitelist messages about RCU blocking in the testsuite.

In production these may indicate a bug, but in the testsuite they probably
just indicate a time-warp.

Reported-by: Alex Wang <>
Signed-off-by: Ben Pfaff <>
Acked-by: Alex Wang <>
6 years agoofp-version-opt: Fix spelling and capitalization.
Ben Pfaff [Tue, 29 Apr 2014 20:55:54 +0000 (13:55 -0700)]
ofp-version-opt: Fix spelling and capitalization.

"OpenFlow" is one word.
"Version" isn't a proper noun.

Signed-off-by: Ben Pfaff <>
Acked-by: Justin Pettit <>
6 years agodatapath: Convert mask list in mask array.
Pravin B Shelar [Wed, 23 Apr 2014 15:34:51 +0000 (08:34 -0700)]
datapath: Convert mask list in mask array.

mask caches index of mask in mask_list.  On packet recv OVS
need to traverse mask-list to get cached mask.  Therefore array
is better for retrieving cached mask.  This also allows better
cache replacement algorithm by directly checking mask's existence.

Signed-off-by: Pravin B Shelar <>
Acked-by: Thomas Graf <>
6 years agodatapath: Add flow mask cache.
Pravin B Shelar [Wed, 23 Apr 2014 15:34:08 +0000 (08:34 -0700)]
datapath: Add flow mask cache.

On every packet OVS needs to lookup flow-table with every mask
until it finds a match. The packet flow-key is first masked
with mask in the list and then the masked key is looked up in
flow-table.  Therefore number of masks can affect packet
processing performance.

Following patch adds mask index to mask cache from last
pakcet lookup in same flow.  Index of mask is stored in
this cache. This cache is searched by 5 tuple hash (skb rxhash).

Signed-off-by: Pravin B Shelar <>
Acked-by: Thomas Graf <>
6 years agodatapath: Move table destroy to dp-rcu callback.
Pravin B Shelar [Wed, 23 Apr 2014 15:33:38 +0000 (08:33 -0700)]
datapath: Move table destroy to dp-rcu callback.

Ths simplifies flow-table-destroy API.  This change is required
for following patches.

Signed-off-by: Pravin B Shelar <>
Acked-by: Thomas Graf <>
6 years agonetdev: Fix an use of uninitialized mutex.
Alex Wang [Tue, 29 Apr 2014 06:42:51 +0000 (23:42 -0700)]
netdev: Fix an use of uninitialized mutex.

Commit 05bf6d3c62e1d (ovs-thread: Add checking for mutex and
rwlock initialization.) helps find an use of uninitialized
mutex (netdev_class_mutex) during upgrade.  The assertion
check aborts the ovs.

This commit fixes the issue by adding the proper initialization.

Bug #1239914.
Bug #1240598.
Bug #1240626.

Signed-off-by: Alex Wang <>
Acked-by: Ben Pfaff <>
6 years agodpif-linux: Fix a bug in creating port.
Alex Wang [Tue, 29 Apr 2014 05:05:05 +0000 (22:05 -0700)]
dpif-linux: Fix a bug in creating port.

Based on the policy of 'OVS_VPORT_ATTR_UPCALL_PID', if upcall should
not be sent to userspace (i.e. the number of handler threads is zero),
the netlink message for creating vport should be an one-element array of
value 0.  However, dpif_linux_port_add__() fails to obey it and generates
zero-payload netlink message which causes the netlink transaction failing
with ERANGE error.

This is particularly bad when the 'flow-restore-wait' is set during upgrade,
since number of handler threads is not set in dpif-linux module and ovs is
not able to add port in datapath until the 'flow-restore-wait' is disabled.
Connection may lose due to this bug.

This bug was introduced by commit 1579cf677fc (dpif-linux: Implement the
API functions to allow multiple handler threads read upcall.).

This commit fixes the bug by fixing the dpif_linux_port_add__() to generate
the correct netlink message when the number of handler threads is not set.

Bug #1239914.
Bug #1240598.
Bug #1240626.

Reported-by: Gurucharan Shetty <>
Signed-off-by: Alex Wang <>
Acked-by: Ben Pfaff <>
6 years agoofproto-dpif: restore bond rebalance for non-recirc bond
Andy Zhou [Fri, 25 Apr 2014 02:20:05 +0000 (19:20 -0700)]
ofproto-dpif: restore bond rebalance for non-recirc bond

Bond rebalancing was disabled for bonds not using recirculation. The
patch fixes this bug.

While fixing the bug, the bond_rebalance() was also restructured
slightly to move bond related logic back into ofproto/bond.c

Signed-off-by: Andy Zhou <>
Acked-by: Ben Pfaff <>
6 years agoofproto-bond: do not allow recirculation when we failed to allocate recirc_id
Andy Zhou [Fri, 25 Apr 2014 02:21:40 +0000 (19:21 -0700)]
ofproto-bond: do not allow recirculation when we failed to allocate recirc_id

When recirc pool is exhausted, a new bond won't be allocate a new
recirc_id. The bond->recirc_id will remain zero. This condition
should prevent the bond from use recirculation. This check was missing
before this patch.

Signed-off-by: Andy Zhou <>
Acked-by: Ben Pfaff <>
6 years agoopenvswitch.h: Clarify use of key attributes.
Jarno Rajahalme [Tue, 29 Apr 2014 00:31:26 +0000 (17:31 -0700)]
openvswitch.h: Clarify use of key attributes.

Key attributes relating to actual packet headers are ignored for
OVS_PACKET_CMD_EXECUTE as the header key attributes are retrieved
from the packet itself.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Jesse Gross <>
6 years agolib/odp-util: Remove extra parenthesis from sctp key output.
Jarno Rajahalme [Tue, 29 Apr 2014 00:31:25 +0000 (17:31 -0700)]
lib/odp-util: Remove extra parenthesis from sctp key output.

Signed-off-by: Jarno Rajahalme <>
Reviewed-by: YAMAMOTO Takashi <>
6 years agoopenvswitch.h: Note that 64 bit ints are 4-aligned.
Jarno Rajahalme [Tue, 29 Apr 2014 00:31:25 +0000 (17:31 -0700)]
openvswitch.h: Note that 64 bit ints are 4-aligned.

In general, all Netlink 64-bit data may be 4-byte aligned, due to
netlink header and attributes being 4-aligned.

To avoid unaligned access the data should be copied out of the netlink
attribute before access.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Jesse Gross <>
6 years agolib/ofp-actions: Update comment.
Jarno Rajahalme [Tue, 29 Apr 2014 00:31:25 +0000 (17:31 -0700)]
lib/ofp-actions: Update comment.

We recently renamed ofpbuf's 'l2' member as 'frame'.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Justin Pettit <>
6 years agotests: Fix up "ofproto-dpif - ofproto-dpif-monitor 1".
Ben Pfaff [Mon, 28 Apr 2014 22:59:40 +0000 (15:59 -0700)]
tests: Fix up "ofproto-dpif - ofproto-dpif-monitor 1".

Commit 1335a8d578b03e (tests: Fix race condition waiting for monitor
thread.) fixed a race condition in a test.  Commit 8ba0a5227f6 (ovs-thread:
Make caller provide thread name when creating a thread.) slightly changed
the output that the test checked, breaking the test.  However, I was used
to the test occasionally failing due to the race (not realizing that the
race had been fixed) so I applied the commit anyway.

This commit fixes the broken test.

Signed-off-by: Ben Pfaff <>
Acked-by: Justin Pettit <>
6 years agoovs-thread: Add checking for mutex and rwlock initialization.
Ben Pfaff [Thu, 24 Apr 2014 23:49:05 +0000 (16:49 -0700)]
ovs-thread: Add checking for mutex and rwlock initialization.

With glibc, a mutex or rwlock filled with all-zero-bytes is properly
initialized for use, but this is not true for any other libc that OVS
supports.  However, OVS gets a lot more testing with glibc than any other
libc.  This means that developers keep introducing bugs that do not
manifest on the main development platform.

This commit should help avoid the problem, by reusing the existing 'where'
members to indicate whether a mutex or rwlock has been initialized.

Signed-off-by: Ben Pfaff <>
6 years agolacp: Don't lock potentially uninitialized mutex in lacp_status().
Ben Pfaff [Thu, 24 Apr 2014 23:58:45 +0000 (16:58 -0700)]
lacp: Don't lock potentially uninitialized mutex in lacp_status().

If the 'lacp' parameter is nonnull, then we know that the file scope mutex
has been initialized, since that's done as a side effect of creating a
lacp object, but otherwise there's no guarantee.

Signed-off-by: Ben Pfaff <>
6 years agoPrepare for post-2.2.0 (2.2.90).
Justin Pettit [Mon, 28 Apr 2014 21:45:07 +0000 (14:45 -0700)]
Prepare for post-2.2.0 (2.2.90).

Signed-off-by: Justin Pettit <>
6 years agoPrepare for 2.2.0.
Justin Pettit [Mon, 28 Apr 2014 21:30:27 +0000 (14:30 -0700)]
Prepare for 2.2.0.

Signed-off-by: Justin Pettit <>
6 years agoovs-rcu: Log a helpful warning when ovsrcu_synchronize() stalls.
Ben Pfaff [Mon, 28 Apr 2014 22:25:19 +0000 (15:25 -0700)]
ovs-rcu: Log a helpful warning when ovsrcu_synchronize() stalls.

This made it easier for me to find a thread that was causing stalls.

Signed-off-by: Ben Pfaff <>
Acked-by: Alex Wang <>
6 years agoovs-thread: Make caller provide thread name when creating a thread.
Ben Pfaff [Sat, 26 Apr 2014 00:46:21 +0000 (17:46 -0700)]
ovs-thread: Make caller provide thread name when creating a thread.

Thread names are occasionally very useful for debugging, but from time to
time we've forgotten to set one.  This commit adds the new thread's name
as a parameter to the function to start a thread, to make that mistake
impossible.  This also simplifies code, since two function calls become
only one.

This makes a few other changes to the thread creation function:

    * Since it is no longer a direct wrapper around a pthread function,
      rename it to avoid giving that impression.

    * Remove 'pthread_attr_t *' param that every caller supplied as NULL.

    * Change 'pthread *' parameter into a return value, for convenience.

The system-stats code hadn't set a thread name, so this fixes that issue.

This patch is a prerequisite for making RCU report the name of a thread
that is blocking RCU synchronization, because the easiest way to do that is
for ovsrcu_quiesce_end() to record the current thread's name.
ovsrcu_quiesce_end() is called before the thread function is called, so it
won't get a name set within the thread function itself.  Setting the thread
name earlier, as in this patch, avoids the problem.

Signed-off-by: Ben Pfaff <>
Acked-by: Alex Wang <>
6 years agoovs-thread: Quiesce in xpthread_barrier_wait().
Ben Pfaff [Fri, 25 Apr 2014 20:50:48 +0000 (13:50 -0700)]
ovs-thread: Quiesce in xpthread_barrier_wait().

Otherwise the udpif revalidator threads can postpone RCU callbacks
essentially forever, especially if there are many revalidator threads and
little network traffic.

Reported-by: Alex Wang <>
Signed-off-by: Ben Pfaff <>
Acked-by: Alex Wang <>
6 years agotimeval: Preserve quiescence across time_poll().
Ben Pfaff [Sat, 26 Apr 2014 01:25:06 +0000 (18:25 -0700)]
timeval: Preserve quiescence across time_poll().

Otherwise ovsrcu_synchronize() busy-waits in its loop because its
poll_block() un-quiesces, causing the global_seqno to increase, which is
what it waits for.

Reported-by: Alex Wang <>
Signed-off-by: Ben Pfaff <>
Acked-by: Alex Wang <>
6 years agodatapath: Check for backported skb_orphan_frags().
Joe Stringer [Mon, 28 Apr 2014 01:59:25 +0000 (13:59 +1200)]
datapath: Check for backported skb_orphan_frags().

This was causing build failures on debian wheezy. Check for the feature
rather than the version.

Signed-off-by: Joe Stringer <>
Acked-by: Jesse Gross <>
6 years agoPython Logging Formatting Improvements
Dave Tucker [Sun, 30 Mar 2014 11:26:55 +0000 (12:26 +0100)]
Python Logging Formatting Improvements

The Open vSwitch daemons written in C support user-configured logging
patterns as described in ovs-appctl(8). This commit adds this capability
to the daemons written in Python.

- Add a '__log_patterns' attribute to the Vlog class
- Populate this using the default patterns in ovs-appctl(8)
- Add a '__start_time' attribute to the Vlog class to support '%r'
- Update the '_log' method to build the log message according to the
- Add a 'set_pattern' method to allow the default patterns to be changed
- Update 'set_levels_from_string' to support setting the pattern from a

Signed-off-by: Dave Tucker <>
Signed-off-by: Ben Pfaff <>
6 years agobridge: Refactor the 'Instant' stats logic.
Alex Wang [Thu, 3 Apr 2014 20:12:35 +0000 (13:12 -0700)]
bridge: Refactor the 'Instant' stats logic.

This commit refactors the 'Instant' stats related logic in bridge.c
by moving it into bridge_run().

This change brings the following effects:

1. bridge.c will wait on the global connectivity sequence number when
   there is no pending instant stats transaction.  and the main thread
   will no longer be waken up every 100 ms for 'Instant' stats check.
   the related overhead is eliminated.

2. the netdev's sequence number is used to avoid updating unchanged netdev
   status.  so, the update is more efficient.

Signed-off-by: Alex Wang <>
Acked-by: Joe Stringer <>
6 years agoofproto-dpif: Use sequence number to wake up main thread for
Alex Wang [Thu, 17 Apr 2014 19:24:45 +0000 (12:24 -0700)]
ofproto-dpif: Use sequence number to wake up main thread for
packet-in I/O.

This commit adds per 'struct ofproto_dpif' sequence number for
packet-in I/O.  Whenever ofproto_dpif_send_packet_in() is called,
the calling thread will change the sequence number to wake up the
main thread.

Signed-off-by: Alex Wang <>
Acked-by: Joe Stringer <>
6 years agotests: Fix race condition waiting for monitor thread.
Joe Stringer [Sun, 27 Apr 2014 23:51:28 +0000 (11:51 +1200)]
tests: Fix race condition waiting for monitor thread.

Occasionally, test #770 "ofproto-dpif - ofproto-dpif-monitor 1" would
fail, because the testsuite looked in the logs for evidence of a thread
being created, but it checked before vswitchd was able to spawn the

This patch fixes the race by modifying the commands that check for
creation/termination of threads to wait until they see the messages

Signed-off-by: Joe Stringer <>
Reviewed-by: YAMAMOTO Takashi <>
6 years agorevalidator: Fix ukey stats cache updating.
Joe Stringer [Fri, 25 Apr 2014 22:23:43 +0000 (15:23 -0700)]
revalidator: Fix ukey stats cache updating.

revalidate_ukey() had a bug where it would update the ukey->stats even
if it decided not to push stats (as an optimisation). ukey->stats should
only be updated when those stats are pushed.

This bug would arise in the following situation:
* A flow has been dumped before.
* The flow needs to be revalidated.
* The flow is low-throughput.
* The flow has new statistics to push.

Such cases rely on flow deletion to update the stats. However, that code
pushes the delta between the ukey->stats and the final flow dump. If the
ukey stats cache is updated without the stats being pushed, those stats
would be lost.

This caused intermittent testsuite failures on "learning action -
self-modifying flow with idle_timeout". Introduced by 698ffe3623f1b630ae
"revalidator: Only revalidate high-throughput flows."

Bug #1238927.

Signed-off-by: Joe Stringer <>
Acked-by: Alex Wang <>
6 years agoofproto-dpif-upcall: Fix a bug.
Alex Wang [Fri, 25 Apr 2014 17:39:53 +0000 (10:39 -0700)]
ofproto-dpif-upcall: Fix a bug.

Commit 7d170098 (ofproto-dpif-upcall: Remove the flow_dumper thread.)
initialized the memory barrier inside the udpif_start_threads() function.
However, the udpif_start_threads() function does not check the number of
revalidator threads specified in udpif.  So, when the number is zero, it
causes the error in barrier initialization.  This could happen when the
other_config:flow-restore-wait is set and the udpif_flush() is called.

This commit fixes the issue, by checking the specified number of threads
in udpif_start_threads().

Reported-by: Gurucharan Shetty <>
Signed-off-by: Alex Wang <>
Acked-by: Gurucharan Shetty <>
6 years agoofproto: Don't destroy mutex before its use.
Gurucharan Shetty [Tue, 22 Apr 2014 17:18:02 +0000 (10:18 -0700)]
ofproto: Don't destroy mutex before its use.

Currently, we are calling guarded_list_destroy()
to destroy a mutex and then go ahead and use it through

The group related unit tests cause ovs-vswitchd to crash
because of this (on windows).

Calling guarded_list_destroy() after delete_group() solves the

Signed-off-by: Gurucharan Shetty <>
Acked-by: Ben Pfaff <>
6 years agonetdev: Initialize netdev_class_mutex.
Gurucharan Shetty [Wed, 16 Apr 2014 20:33:26 +0000 (13:33 -0700)]
netdev: Initialize netdev_class_mutex.

This code path currently does not initialize

ovsdb-server on windows crashes without it.

This commit adds a new initialization function.

Signed-off-by: Gurucharan Shetty <>
Acked-by: Ben Pfaff <>
6 years agoFAQ: Explain what to do when building against a too-new kernel.
Ben Pfaff [Thu, 24 Apr 2014 22:35:35 +0000 (15:35 -0700)]
FAQ: Explain what to do when building against a too-new kernel.

Also add references to this FAQ from INSTALL and configure.

Signed-off-by: Ben Pfaff <>
Acked-by: Gurucharan Shetty <>
6 years agobfd/cfm: Check status change before update status to database.
Alex Wang [Thu, 3 Apr 2014 17:20:44 +0000 (10:20 -0700)]
bfd/cfm: Check status change before update status to database.

This commit adds boolean flag in bfd/cfm module for checking
status change.  If there is no status change, the current
update to OVS database will skip the bfd/cfm session.

In the experiment with 5K bfd sessions, when one session is
flapping at rate of every 0.3 second, this patch reduces the
cpu utilization of the ovs-vswitchd thread from 13 to 6.

Signed-off-by: Alex Wang <>
Acked-by: Joe Stringer <>
6 years agodaemon: Move some common code to daemon.c
Gurucharan Shetty [Wed, 23 Apr 2014 21:22:38 +0000 (14:22 -0700)]
daemon: Move some common code to daemon.c

We have some common code between daemon-unix.c and
daemon-windows.c. Move them to daemon.c

Signed-off-by: Gurucharan Shetty <>
Acked-by: Ben Pfaff <>
6 years agodaemon: Close standard file descriptors after detach for windows.
Gurucharan Shetty [Wed, 23 Apr 2014 17:28:00 +0000 (10:28 -0700)]
daemon: Close standard file descriptors after detach for windows.

In the unit tests, we check for some logs stored in stderr. In case
of windows, unit tests fail because the child writes additional information
into stderr because it does not have it closed. This commit
closes standard file descriptors for windows too.

Because the functions related to closing file descriptors is common
for both windows and unix, add it to the common daemonization file

Signed-off-by: Gurucharan Shetty <>
Acked-by: Ben Pfaff <>
6 years agodaemon: Rename daemon.c as daemon-unix.c
Gurucharan Shetty [Wed, 23 Apr 2014 16:03:38 +0000 (09:03 -0700)]
daemon: Rename daemon.c as daemon-unix.c

An upcoming commit re-introduces daemon.c to have
common functions across daemon-unix.c and daemon-windows.c

Signed-off-by: Gurucharan Shetty <>
Acked-by: Ben Pfaff <>
6 years agoofproto-dpif-xlate: Identify STP BPDUs more specifically.
Padmanabhan Krishnan [Thu, 24 Apr 2014 20:18:18 +0000 (13:18 -0700)]
ofproto-dpif-xlate: Identify STP BPDUs more specifically.

Apart from STP, EVB extension of LLDP as well as IEEE 802.1QBG use the
Nearest Customer Bridge (NCB) DMAC which has a value of 0180.c200.0000.
STP can be distinguished by Ethertype from these protocols.

Signed-off-by: Padmanabhan Krishnan <>
[ rewrote the details of the patch]
Signed-off-by: Ben Pfaff <>
Tested-by: Padmanabhan Krishnan <>
6 years agoofproto: Reduce taking rule references.
Jarno Rajahalme [Thu, 24 Apr 2014 15:21:49 +0000 (08:21 -0700)]
ofproto: Reduce taking rule references.

Only take reference to a looked up rule when needed.

This reduces the total CPU utilization of rule_ref/unref calls by 80%,
from 5% of total server CPU capacity to 1% in a netperf TCP_CRR
test stressing the userspace.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agoofproto: Make taking rule reference conditional on lookup.
Jarno Rajahalme [Thu, 24 Apr 2014 15:21:49 +0000 (08:21 -0700)]
ofproto: Make taking rule reference conditional on lookup.

Prior to this paths the rule lookup functions have always taken a
reference on the found rule before returning.  Make this conditional,
so that unnecessary refs/unrefs can be avoided in a later patch.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agoofproto: RCU postpone rule destruction.
Jarno Rajahalme [Thu, 24 Apr 2014 15:21:49 +0000 (08:21 -0700)]
ofproto: RCU postpone rule destruction.

This allows rules to be used without taking references while RCU

The last step of destroying an ofproto also needs to be postponed, as
the rule destruction requires the class structure to be available at
the postponed destruction callback.

Signed-off-by: Jarno Rajahalme <>
Acked-by: Ethan Jackson <>
6 years agohmap_random_node: Improve distribution
YAMAMOTO Takashi [Tue, 22 Apr 2014 04:34:36 +0000 (13:34 +0900)]
hmap_random_node: Improve distribution

Improve random distribution for an hmap with a small number of nodes
with the expense of the increased cpu cost.
It would be a fair trade-off because the situation is rather common
for bond, which is currently the only consumer of this API in tree.

Consider 2 items, 4 buckets, no collision.

    bucket 0   item 0
    bucket 1
    bucket 2
    bucket 3   item 1

The old algorithm picks item 0 if rand % 4 == 0.  (25%)
Otherwise it picks item 1.  (75%)

This change makes them 50%.

Acked-by: Ben Pfaff <>
Signed-off-by: YAMAMOTO Takashi <>
6 years agoofproto-dpif-upcall: Remove the flow_dumper thread.
Ethan Jackson [Thu, 10 Apr 2014 07:14:08 +0000 (07:14 +0000)]
ofproto-dpif-upcall: Remove the flow_dumper thread.

Previously, we had a separate flow_dumper thread that fetched flows from
the datapath to distribute to revalidator threads. This patch takes the
logic for dumping and pushes it into the revalidator threads, resulting
in simpler code with similar performance to the current code.

One thread, the "leader", is responsible for beginning and ending each
flow dump, maintaining the flow_limit, and checking whether the
revalidator threads need to exit. All revalidator threads dump,
revalidate, delete datapath flows and garbage collect ukeys.

Co-authored-by: Joe Stringer <>
Signed-off-by: Joe Stringer <>
Acked-by: Ben Pfaff <>
6 years agobridge: When ports disappear from a datapath, add them back.
Ben Pfaff [Thu, 24 Apr 2014 01:33:36 +0000 (18:33 -0700)]
bridge: When ports disappear from a datapath, add them back.

Before commit 2a73b1d73d4bdb (bridge: Reconfigure in single pass.), if a
port disappeared, for one reason or another, from a datapath, the next
bridge reconfiguration pass would notice and, if the port was still
configured in the database, add the port back to the datapath.  That
commit, however, removed the logic from bridge_refresh_ofp_port() that
did that and failed to add the same logic to the replacement function
bridge_delete_or_reconfigure_ports().  This commit fixes the problem.

To see this problem on a Linux kernel system:

ovs-vsctl add-br br0                             # 1
tunctl -t tap                                    # 2
ovs-vsctl add-port br0 tap                       # 3
ovs-dpctl show                                   # 4
tunctl -d tap                                    # 5
ovs-dpctl show                                   # 6
tunctl -t tap                                    # 7
ovs-vsctl del-port tap -- add-port br0 tap       # 8
ovs-dpctl show                                   # 9

Steps 1-4 create a bridge and a tap and add it to the bridge and
demonstrate that the tap is part of the datapath.  Step 5 and 6 delete
the tap and demonstrate that it has therefore disappeared from the
datapath.  Step 7 recreates a tap with the same name, and step 8
forces ovs-vswitchd to reconfigure.  Step 9 shows the effect of the
fix: without the fix, the new tap is not added back to the datapath;
with this fix, it is.

Special thanks to Gurucharan Shetty <> for finding a
simple reproduction case and then bisecting to find the commit that
introduced the problem.

Bug #1238467.
Reported-by: Ronald Lee <>
Signed-off-by: Ben Pfaff <>
Acked-by: Ethan Jackson <>
6 years agorevalidator: Prevent handling the same flow twice.
Joe Stringer [Wed, 23 Apr 2014 03:31:17 +0000 (15:31 +1200)]
revalidator: Prevent handling the same flow twice.

When the datapath flow table is modified while a flow dump operation is
in progress, it is possible for the same flow to be dumped twice. In
such cases, revalidators may perform redundant work, or attempt to
delete the same flow twice.

This was causing intermittent testsuite failures for test #670 -
"ofproto-dpif, active-backup bonding" where a flow (that had not
previously been dumped) was dumped, revalidated and deleted twice.

The logs show errors such as:
"failed to flow_get (No such file or directory) skb_priority(0),..."
"failed to flow_del (No such file or directory) skb_priority(0),..."

This patch adds a 'flow_exists' field to 'struct udpif_key' to track
whether the flow is (in progress) to be deleted. After doing a ukey
lookup, we check whether ukey->mark or ukey->flow indicates that the
flow has already been handled. If it has already been handled, we skip
handling the flow again.

We also defer ukey cleanup for flows that fail revalidation, so that the
ukey will still exist if the same flow is dumped twice. This allows the
above logic to work in this case.

Signed-off-by: Joe Stringer <>
Acked-by: Alex Wang <>
6 years agoofproto-dpif: Improve code clarity and comments on recirc changes to rule_dpif_lookup()
Andy Zhou [Wed, 23 Apr 2014 20:05:40 +0000 (13:05 -0700)]
ofproto-dpif: Improve code clarity and comments on recirc changes to rule_dpif_lookup()

This patch improves the code readability and comments on the
recirculation related changes to rule_dpif_lookup() base on off-line
discussions with Jarno.  There is no behavior changes.

Signed-off-by: Andy Zhou <>
Acked-by: Ethan Jackson <>
6 years agolib/util: Input validation in str_to_uint
Zoltan Kiss [Wed, 23 Apr 2014 13:45:21 +0000 (14:45 +0100)]
lib/util: Input validation in str_to_uint

This function returns true when 's' is negative or greater than UINT_MAX. Also,
the representation of 'int' and 'unsigned int' is implementation dependent, so
converting [INT_MAX..UINT_MAX] values with str_to_int is fragile.
Instead, we should convert straight to 'long long' and do a boundary check
before returning the converted value.
This patch also move the function to the .c file as it's not-trivial now, and
deletes the other str_to_u* functions as they are not used.

Signed-off-by: Zoltan Kiss <>
Signed-off-by: Ben Pfaff <>
6 years agorun-ryu: Use unix socket rather than patch ports
Simon Horman [Wed, 23 Apr 2014 05:06:12 +0000 (14:06 +0900)]
run-ryu: Use unix socket rather than patch ports

My understanding of the implementation of patch ports is that they
are rather special, being handled as a special case inside
compose_output_action__() and do not exist in the datapath.

A side effect of the implementation of patch ports (though perhaps not the
portion mentioned above) is that the OFPUTIL_PC_PORT_DOWN bit may not be
set via a port mod message. In particular, the call to
netdev_turn_flags_on() in update_port_config() fails.

There is a test provided by Ryu that test this via port mod and thus fails.

While that test could be modified or the results ignored it seems to me
that it would be best if ryu-check used ports which were more fully
featured and not special cases.

Thus this patch moves run-ryu to use unix socket backed ports rather than
patch ports.

I believe a more significant problem with the use of patch ports
is that they will require (more) special case code in order to correctly
handle recirculation. As Ryu provides many tests that exercise
recirculation for MPLS it would be nice if they could be used to exercise
recirculation for MPLS (which I have provided patches for separately[1])
without the need to add more special-case code for that purpose.

I believe that patch ports are also incompatible with recirculation for
bonding, which has already been merged, though I have not verified that
and it is not strictly related to this patch as I do not believe that Ryu
provides any tests to exercise that case.

The key problem with patch ports in the context of recirculation is that
the ofproto and in_port may change during translation.  And this
information is lost by the time that execution occurs.

Furthermore the new in_port will not exist in the datapath as it is a
patch port. That particular problem may be addressed by executing the
actions in user-space, I have posted patches to provide infrastructure
for that[1].

Overall it is not clear to me that the complexity of supporting
recirculation for patch-ports would have sufficient pay-off.

[1] [PATCH v3 00/16] Flow-Based Recirculation for MPLS

Signed-off-by: Simon Horman <>
Signed-off-by: Ben Pfaff <>
6 years agodaemon-windows: Recognize --no-chdir option for windows.
Gurucharan Shetty [Fri, 18 Apr 2014 18:04:14 +0000 (11:04 -0700)]
daemon-windows: Recognize --no-chdir option for windows.

The option won't have any effect on the running of the daemon.
Recognizing the option lets us avoid if else conditions in unit

Signed-off-by: Gurucharan Shetty <>
Acked-by: Ben Pfaff <>
6 years agoTODO: Add the project list from the hackathon.
Ben Pfaff [Tue, 22 Apr 2014 23:26:05 +0000 (16:26 -0700)]
TODO: Add the project list from the hackathon.

I've had a couple of requests for an updated project list, so this commit
adds it to the tree.

Signed-off-by: Ben Pfaff <>
Acked-by: Joe Stringer <>
6 years Workaround for carriage returns on windows.
Gurucharan Shetty [Fri, 18 Apr 2014 16:00:46 +0000 (09:00 -0700)] Workaround for carriage returns on windows.

In unit tests, we compare text written in logs or stdout/stderr
to figure out the success or failure of tests. In Windows,
since new line is represented by CR+LF, autoconf tests run in
MinGW environment fail.

Asking diff to ignore trailing carriage returns is one way
to solve the problem

Suggested-by: Ben Pfaff <>
Signed-off-by: Gurucharan Shetty <>
Acked-by: Ben Pfaff <>