diff options
author | Mike Larson <mike@suva.vyatta.com> | 2008-08-29 13:21:22 -0700 |
---|---|---|
committer | Mike Larson <mike@suva.vyatta.com> | 2008-08-29 13:21:22 -0700 |
commit | 9be5bc2b6f7094cd54366aeea659be899cf0122b (patch) | |
tree | b612473087c50c2a2d54a2cef5d94196c751bacf | |
parent | 22610d1769c6dabce2b4675085cab369f2d96331 (diff) | |
download | vyatta-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.
-rw-r--r-- | src/lbdecision.cc | 18 |
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 { |