[ovs-dev] [PATCH 1/3] bond: Pseudo-randomly choose initial slave.

Ethan Jackson ethan at nicira.com
Tue Feb 5 03:13:34 UTC 2013

Traditionally, (unless balancing was turned off), the bonding code
chose the active slave for all flows which hadn't previously been
allocated to another.  This worked fine in theory because traffic
would eventually be balanced away if there was congestion.

Instead of the historical approach, this patch uses a hash to
choose the initial slave, giving what behaves like a random
allocation.  This performs better on switches using a long
rebalance interval, is less confusing to users, and removes a
special case needed for dealing with non-balanced bonds.

Signed-off-by: Ethan Jackson <ethan at nicira.com>
 lib/bond.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lib/bond.c b/lib/bond.c
index 06680ee..c74bcfb 100644
--- a/lib/bond.c
+++ b/lib/bond.c
@@ -1442,15 +1442,12 @@ choose_output_slave(const struct bond *bond, const struct flow *flow,
         /* Fall Through. */
     case BM_SLB:
-        if (!bond_is_balanced(bond)) {
-            return choose_stb_slave(bond, bond_hash(bond, flow, vlan));
-        }
         e = lookup_bond_entry(bond, flow, vlan);
         if (!e->slave || !e->slave->enabled) {
             e->slave = CONTAINER_OF(hmap_random_node(&bond->slaves),
                                     struct bond_slave, hmap_node);
             if (!e->slave->enabled) {
-                e->slave = bond->active_slave;
+                e->slave = choose_stb_slave(bond, bond_hash(bond, flow, vlan));
             e->tag = tag_create_random();

More information about the dev mailing list