summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Larson <slioch@slioch.vyatta.com>2010-06-19 18:51:16 -0700
committerMichael Larson <slioch@slioch.vyatta.com>2010-06-19 18:51:16 -0700
commitef4a85e5b5fe554137f923a156b5537ff5d54216 (patch)
treee9bb9f6f884c1bdc69d7ecec25900e0d8ecea697
parentf5c3497121df93446d7acafd12ca03be0a511ae4 (diff)
downloadvyatta-wanloadbalance-ef4a85e5b5fe554137f923a156b5537ff5d54216.tar.gz
vyatta-wanloadbalance-ef4a85e5b5fe554137f923a156b5537ff5d54216.zip
submission in reponse to forum posting on multiple entries found in snat table with adsl dhcp configuration:
http://www.vyatta.org/forum/viewtopic.php?t=4254
-rw-r--r--src/lbdecision.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lbdecision.cc b/src/lbdecision.cc
index c1731fe..22d56a9 100644
--- a/src/lbdecision.cc
+++ b/src/lbdecision.cc
@@ -211,8 +211,13 @@ LBDecision::update_paths(LBData &lbdata)
if (lbdata._disable_source_nat == false) {
if (new_addr != iter->second._address) {
- int err = execute(string("iptables -t nat -D WANLOADBALANCE -m connmark --mark ") + buf + " -j SNAT --to-source " + iter->second._address, stdout);
- err |= execute(string("iptables -t nat -A WANLOADBALANCE -m connmark --mark ") + buf + " -j SNAT --to-source " + new_addr, stdout);
+ int err = 0;
+ if (iter->second._address.empty() == false) {
+ int err = execute(string("iptables -t nat -D WANLOADBALANCE -m connmark --mark ") + buf + " -j SNAT --to-source " + iter->second._address, stdout);
+ }
+ if (new_addr.empty() == false) {
+ err |= execute(string("iptables -t nat -A WANLOADBALANCE -m connmark --mark ") + buf + " -j SNAT --to-source " + new_addr, stdout);
+ }
if (err == 0) { //only set if both are 0
iter->second._address = new_addr;
}