diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lbdata.hh | 3 | ||||
-rw-r--r-- | src/lbdatafactory.cc | 10 | ||||
-rw-r--r-- | src/lbdatafactory.hh | 3 | ||||
-rw-r--r-- | src/lbdecision.cc | 14 |
4 files changed, 27 insertions, 3 deletions
diff --git a/src/lbdata.hh b/src/lbdata.hh index 03e617f..3bfdf76 100644 --- a/src/lbdata.hh +++ b/src/lbdata.hh @@ -116,7 +116,7 @@ class LBData { typedef map<string,LBHealth>::iterator InterfaceHealthIter; typedef map<string,LBHealth>::const_iterator InterfaceHealthConstIter; - LBData() : _disable_source_nat(false),_flush_conntrack(false) {} + LBData() : _disable_source_nat(false),_enable_source_based_routing(false),_flush_conntrack(false) {} bool error() {return false;} @@ -140,6 +140,7 @@ class LBData { InterfaceHealthColl _iface_health_coll; bool _disable_source_nat; + bool _enable_source_based_routing; bool _flush_conntrack; }; diff --git a/src/lbdatafactory.cc b/src/lbdatafactory.cc index ebe63d0..17b4260 100644 --- a/src/lbdatafactory.cc +++ b/src/lbdatafactory.cc @@ -123,6 +123,9 @@ LBDataFactory::process(const vector<string> &path, int depth, const string &key, if (path[0] == "disable-source-nat") { process_disablesourcenat(l_key,l_value); } + else if (path[0] == "enable-source-based-routing") { + process_enablesourcebasedrouting(l_key,l_value); + } else if (path[0] == "flush-conntrack") { process_flushconntrack(l_key,l_value); } @@ -175,6 +178,13 @@ LBDataFactory::process_flushconntrack(const string &key, const string &value) } void +LBDataFactory::process_enablesourcebasedrouting(const string &key, const string &value) +{ + _lb_data._enable_source_based_routing = true; +} + + +void LBDataFactory::process_health(const string &key, const string &value) { if (value.empty() == false) { diff --git a/src/lbdatafactory.hh b/src/lbdatafactory.hh index 6d2211c..9aefda0 100644 --- a/src/lbdatafactory.hh +++ b/src/lbdatafactory.hh @@ -47,6 +47,9 @@ private: process_flushconntrack(const string &key, const string &value); void + process_enablesourcebasedrouting(const string &key, const string &value); + + void process_health(const string &key, const string &value); void diff --git a/src/lbdecision.cc b/src/lbdecision.cc index 70f9a8e..5373b9e 100644 --- a/src/lbdecision.cc +++ b/src/lbdecision.cc @@ -273,10 +273,20 @@ LBDecision::run(LBData &lb_data) for (w_iter = weights.begin(); w_iter != (--weights.end()); w_iter++) { 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); + if (lb_data._enable_source_based_routing) { + execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -m statistic --mode random --probability " + fbuf + " -j ISP_" + dbuf, stdout); + } + else { + execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -m state --state NEW -m statistic --mode random --probability " + fbuf + " -j ISP_" + dbuf, stdout); + } } sprintf(dbuf,"%d",(--weights.end())->first); - execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -m state --state NEW -j ISP_" + dbuf, stdout); + if (lb_data._enable_source_based_routing) { + execute(string("iptables -t mangle -A PREROUTING ") + app_cmd + " -j ISP_" + dbuf, stdout); + } + else { + 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); } } |