summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Larson <mike@suva.vyatta.com>2008-08-29 13:21:22 -0700
committerMike Larson <mike@suva.vyatta.com>2008-08-29 13:21:22 -0700
commit9be5bc2b6f7094cd54366aeea659be899cf0122b (patch)
treeb612473087c50c2a2d54a2cef5d94196c751bacf /src
parent22610d1769c6dabce2b4675085cab369f2d96331 (diff)
downloadvyatta-wanloadbalance-9be5bc2b6f7094cd54366aeea659be899cf0122b.tar.gz
vyatta-wanloadbalance-9be5bc2b6f7094cd54366aeea659be899cf0122b.zip
modified failover algorithm to provide deterministic control over which interface is selected. The interface with the highest weight will be preferred.
Diffstat (limited to 'src')
-rw-r--r--src/lbdecision.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/lbdecision.cc b/src/lbdecision.cc
index e6cafac..b265acb 100644
--- a/src/lbdecision.cc
+++ b/src/lbdecision.cc
@@ -336,14 +336,20 @@ LBDecision::get_new_weights(LBData &data, LBRule &rule)
}
if (rule._failover == true) { //add single entry if active
- if (weights.empty() == false) {
- weights.insert(pair<int,float>(ct,0.));
+ if (data.is_active(iter->first)) {
+ //select the active interface that has the highest weight
+ if (iter->second > group) {
+ map<int,float>::iterator w_iter = weights.begin();
+ while (w_iter != weights.end()) {
+ w_iter->second = 0.; //zero out previous weight
+ ++w_iter;
+ }
+ }
+ weights.insert(pair<int,float>(ct,iter->second));
+ group = iter->second;
}
else {
- if (data.is_active(iter->first)) {
- weights.insert(pair<int,float>(ct,1.));
- group = 1;
- }
+ weights.insert(pair<int,float>(ct,0.));
}
}
else {