/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
+#include <math.h>
#include "coverage.h"
#include "dynamic-string.h"
struct bond_entry {
struct bond_slave *slave; /* Assigned slave, NULL if unassigned. */
uint64_t tx_bytes; /* Count of bytes recently transmitted. */
- tag_type tag; /* Tag for entry<->slave association. */
+ tag_type tag; /* Tag for entry<->facet association. */
struct list list_node; /* In bond_slave's 'entries' list. */
};
if (bond->balance != s->balance) {
bond->balance = s->balance;
revalidate = true;
+
+ if (bond->balance == BM_STABLE) {
+ VLOG_WARN_ONCE("Stable bond mode is deprecated and may be removed"
+ " in February 2013. Please email"
+ " dev@openvswitch.org with concerns.");
+ }
}
if (bond->basis != s->basis) {
may_send_learning_packets(const struct bond *bond)
{
return bond->lacp_status == LACP_DISABLED
- && bond->balance != BM_STABLE
+ && (bond->balance == BM_SLB || bond->balance == BM_AB)
&& bond->active_slave;
}
tag_type tags = 0;
struct flow flow;
- assert(may_send_learning_packets(bond));
+ ovs_assert(may_send_learning_packets(bond));
memset(&flow, 0, sizeof flow);
memcpy(flow.dl_src, eth_src, ETH_ADDR_LEN);
hash->tag = tag_create_random();
}
-/* Pick and returns a bond_entry to migrate to 'to' (the least-loaded slave),
+/* Picks and returns a bond_entry to migrate from 'from' (the most heavily
+ * loaded bond slave) to a bond slave that has 'to_tx_bytes' bytes of load,
* given that doing so must decrease the ratio of the load on the two slaves by
* at least 0.1. Returns NULL if there is no appropriate entry.
*
delta = e->tx_bytes;
old_ratio = (double)from->tx_bytes / to_tx_bytes;
new_ratio = (double)(from->tx_bytes - delta) / (to_tx_bytes + delta);
- if (old_ratio - new_ratio > 0.1) {
- /* Would decrease the ratio, move it. */
+ if (old_ratio - new_ratio > 0.1
+ && fabs(new_ratio - 1.0) < fabs(old_ratio - 1.0)) {
+ /* We're aiming for an ideal ratio of 1, meaning both the 'from'
+ and 'to' slave have the same load. Therefore, we only move an
+ entry if it decreases the load on 'from', and brings us closer
+ to equal traffic load. */
return e;
}
}
break;
}
- /* 'from' is carrying significantly more load than 'to', and that load
- * is split across at least two different hashes. */
+ /* 'from' is carrying significantly more load than 'to'. Pick a hash
+ * to move from 'from' to 'to'. */
e = choose_entry_to_migrate(from, to->tx_bytes);
if (e) {
bond_shift_load(e, to, tags);
static unsigned int
bond_hash(const struct bond *bond, const struct flow *flow, uint16_t vlan)
{
- assert(bond->balance == BM_TCP || bond->balance == BM_SLB);
+ ovs_assert(bond->balance == BM_TCP || bond->balance == BM_SLB);
return (bond->balance == BM_TCP
? bond_hash_tcp(flow, vlan, bond->basis)