diff options
| author | root <root@eng-140.vyatta.com> | 2008-08-22 09:41:27 -0700 |
|---|---|---|
| committer | root <root@eng-140.vyatta.com> | 2008-08-22 09:41:27 -0700 |
| commit | d7e0e1579b84215eee801e0e033c0b60eb09a1c8 (patch) | |
| tree | 7441204438820065bca2ef3154c56cf4f7f011ad /src/lbdecision.cc | |
| parent | f078bf6b45cd1ab2742f79534369a54a0df27791 (diff) | |
| download | vyatta-wanloadbalance-d7e0e1579b84215eee801e0e033c0b60eb09a1c8.tar.gz vyatta-wanloadbalance-d7e0e1579b84215eee801e0e033c0b60eb09a1c8.zip | |
fix for bug 3620. exclusion option is now provided and will create an accept rule. For an exclusion the user does not need to configure interfaces for that rule to balance across.
Diffstat (limited to 'src/lbdecision.cc')
| -rw-r--r-- | src/lbdecision.cc | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/src/lbdecision.cc b/src/lbdecision.cc index 9bf56cf..0f51d84 100644 --- a/src/lbdecision.cc +++ b/src/lbdecision.cc @@ -209,34 +209,40 @@ LBDecision::run(LBData &lb_data) //and compute the new set and apply LBData::LBRuleIter iter = lb_data._lb_rule_coll.begin(); while (iter != lb_data._lb_rule_coll.end()) { - map<int,float> weights = get_new_weights(lb_data,iter->second); - map<int,float>::iterator w_iter = weights.begin(); //NEED TO HANDLE APPLICATION SPECIFIC DETAILS string app_cmd = get_application_cmd(iter->second); - char fbuf[20],dbuf[20]; - if (weights.empty()) { - //no rules here! - } - else if (weights.size() == 1) { - sprintf(dbuf,"%d",w_iter->first); - execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -m state --state NEW -j ISP_" + dbuf, stdout); - execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -j CONNMARK --restore-mark", stdout); + if (iter->second._exclude == true) { + execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -j ACCEPT", stdout); } else { - map<int,float>::iterator w_end = weights.end(); - --w_end; - while (w_iter != w_end) { - sprintf(fbuf,"%f",w_iter->second); + map<int,float> weights = get_new_weights(lb_data,iter->second); + map<int,float>::iterator w_iter = weights.begin(); + + char fbuf[20],dbuf[20]; + if (weights.empty()) { + //no rules here! + } + else if (weights.size() == 1) { sprintf(dbuf,"%d",w_iter->first); - execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -m state --state NEW -m statistic --mode random --probability " + fbuf + " -j ISP_" + dbuf, stdout); + execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -m state --state NEW -j ISP_" + dbuf, stdout); + execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -j CONNMARK --restore-mark", stdout); + } + else { + map<int,float>::iterator w_end = weights.end(); + --w_end; + while (w_iter != w_end) { + sprintf(fbuf,"%f",w_iter->second); + sprintf(dbuf,"%d",w_iter->first); + execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -m state --state NEW -m statistic --mode random --probability " + fbuf + " -j ISP_" + dbuf, stdout); + ++w_iter; + } + //last one is special case, the catch all rule ++w_iter; + sprintf(dbuf,"%d",w_iter->first); + execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -m state --state NEW -j ISP_" + dbuf, stdout); + execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -j CONNMARK --restore-mark", stdout); } - //last one is special case, the catch all rule - ++w_iter; - sprintf(dbuf,"%d",w_iter->first); - execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -m state --state NEW -j ISP_" + dbuf, stdout); - execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -j CONNMARK --restore-mark", stdout); } ++iter; continue; |
