aboutsummaryrefslogtreecommitdiff
path: root/lib/bond.c
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2011-04-01 17:37:56 -0700
committerEthan Jackson <ethan@nicira.com>2011-04-04 12:32:22 -0700
commitc804cadfe92268da4658d3089ad8fb99c35121f3 (patch)
tree52c80626000d84d50e2d72758ef40b710b67fa12 /lib/bond.c
parentaacea8ba432bdffcca77696ba407be0c62661394 (diff)
bond: Choose slaves randomly.
When the bonding library encounters a flow it hasn't seen before, it assigns it to the active slave and waits for load balancing to move it to a more appropriate place. This commit causes it to first attempt a random slave.
Diffstat (limited to 'lib/bond.c')
-rw-r--r--lib/bond.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/bond.c b/lib/bond.c
index e27d5f40..ccd8a07e 100644
--- a/lib/bond.c
+++ b/lib/bond.c
@@ -1379,9 +1379,11 @@ choose_output_slave(const struct bond *bond, const struct flow *flow,
case BM_TCP:
e = lookup_bond_entry(bond, flow, vlan);
if (!e->slave || !e->slave->enabled) {
- /* XXX select interface properly. The current interface selection
- * is only good for testing the rebalancing code. */
- e->slave = bond->active_slave;
+ e->slave = CONTAINER_OF(hmap_random_node(&bond->slaves),
+ struct bond_slave, hmap_node);
+ if (!e->slave->enabled) {
+ e->slave = bond->active_slave;
+ }
e->tag = tag_create_random();
}
return e->slave;