From 8297fef53d83a95112a688ed0c08dee6f9e667b4 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 15 Sep 2014 12:03:29 +0100 Subject: [PATCH] remove WEAVE iptable chain on 'weave stop' No point keeping it around. Also, simplify idempotence of masquerading setup. Follow-up to issue #48. --- weaver/weave | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/weaver/weave b/weaver/weave index 4a954777..ca40708d 100755 --- a/weaver/weave +++ b/weaver/weave @@ -80,17 +80,16 @@ add_nat_rule() { } setup_masquerading() { - if ! run_iptables -t nat -S WEAVE >/dev/null 2>&1 - then - run_iptables -t nat -N WEAVE - add_nat_rule POSTROUTING -j WEAVE - fi + run_iptables -t nat -N WEAVE >/dev/null 2>&1 || true + add_nat_rule POSTROUTING -j WEAVE add_nat_rule WEAVE -o $BRIDGE ! -s $1 -j MASQUERADE add_nat_rule WEAVE -s $1 ! -o $BRIDGE -j MASQUERADE } stop_masquerading() { run_iptables -t nat -F WEAVE >/dev/null 2>&1 || true + run_iptables -t nat -D POSTROUTING -j WEAVE >/dev/null 2>&1 || true + run_iptables -t nat -X WEAVE >/dev/null 2>&1 || true } # the following borrows from https://github.com/jpetazzo/pipework