diff options
author | slioch <slioch@eng-140.vyatta.com> | 2009-06-02 15:47:59 -0700 |
---|---|---|
committer | slioch <slioch@eng-140.vyatta.com> | 2009-06-02 16:08:45 -0700 |
commit | 16d937141226777cf030d02e87a96b7e4c9c8edb (patch) | |
tree | 084966f60d0d762598aa125a17774ea62016feb5 /src/lbdecision.cc | |
parent | 3f808deb0a81976df125f56755fefeb987dd57ab (diff) | |
download | vyatta-wanloadbalance-16d937141226777cf030d02e87a96b7e4c9c8edb.tar.gz vyatta-wanloadbalance-16d937141226777cf030d02e87a96b7e4c9c8edb.zip |
fix for bug 4409. Additional dynamic support for dynamic policy route and snat when wlb is configured and during runtime. also fix for wlb when running in
debug mode.
Diffstat (limited to 'src/lbdecision.cc')
-rw-r--r-- | src/lbdecision.cc | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/src/lbdecision.cc b/src/lbdecision.cc index 5373b9e..7030cf3 100644 --- a/src/lbdecision.cc +++ b/src/lbdecision.cc @@ -174,19 +174,26 @@ LBDecision::update_paths(LBData &lbdata) //first let's remove the entry LBData::InterfaceHealthIter iter = lbdata._iface_health_coll.begin(); while (iter != lbdata._iface_health_coll.end()) { - if (iter->second._nexthop == "dhcp") { + if (iter->second._is_active == true) { string iface = iter->first; string new_addr = fetch_iface_addr(iface); + char buf[20]; + sprintf(buf,"%d",iter->second._interface_index); + + //now let's update the nexthop here in the route table + if (iter->second._nexthop == "dhcp") { + string nexthop = fetch_iface_nexthop(iface); + insert_default(string("ip route replace table ") + buf + " default dev " + iface + " via " + nexthop, iter->second._interface_index); + } + else { + insert_default(string("ip route replace table ") + buf + " default dev " + iface + " via " + iter->second._nexthop, iter->second._interface_index); + } + if (new_addr != iter->second._address) { - char buf[20]; - sprintf(buf,"%d",iter->second._interface_index); execute(string("iptables -t nat -D WANLOADBALANCE -m connmark --mark ") + buf + " -j SNAT --to-source " + iter->second._address, stdout); execute(string("iptables -t nat -A WANLOADBALANCE -m connmark --mark ") + buf + " -j SNAT --to-source " + new_addr, stdout); iter->second._address = new_addr; - //now let's update the nexthop here in the route table - string nexthop = fetch_iface_nexthop(iface); - execute(string("ip route replace table ") + buf + " default dev " + iface + " via " + nexthop, stdout); } } ++iter; @@ -217,26 +224,7 @@ LBDecision::run(LBData &lb_data) cout << "LBDecision::run(), state changed, applying new rule set" << endl; } - //now reapply the routing tables. - LBData::InterfaceHealthIter h_iter = lb_data._iface_health_coll.begin(); - while (h_iter != lb_data._iface_health_coll.end()) { - if (h_iter->second._is_active == true) { - char buf[40]; - sprintf(buf,"%d",h_iter->second._interface_index); - if (h_iter->second._nexthop == "dhcp") { - string nexthop = fetch_iface_nexthop(h_iter->first); - insert_default(string("ip route replace table ") + buf + " default dev " + h_iter->first + " via " + nexthop, h_iter->second._interface_index); - } - else { - insert_default(string("ip route replace table ") + buf + " default dev " + h_iter->first + " via " + h_iter->second._nexthop, h_iter->second._interface_index); - } - } - else { - //right now replace route, but don't delete until race condition is resolved - // execute(string("ip route delete ") + route_str); - } - ++h_iter; - } + update_paths(lb_data); //first determine if we need to alter the rule set if (!lb_data.state_changed()) { @@ -542,10 +530,7 @@ LBDecision::insert_default(string cmd, int table) showcmd += string(buf); execute(showcmd,stdout,true); - // cout << "LBDecision::insert_default(stdout): '" << stdout << "'" << endl; - if (stdout.empty() == true) { - // cout << "LBDecision::insert_default(cmd): " << cmd << endl; execute(cmd,stdout); } } |