From 91268fa0ba49446d9a15c75bd53599f8bd5e2470 Mon Sep 17 00:00:00 2001 From: David Wragg Date: Fri, 5 Sep 2014 12:51:41 +0100 Subject: [PATCH] Check that 'iptables -w' is supported before using it '-w' was only introduced in a recent version of iptables. It means "Wait for the xtables lock", so it seems reasonable to proceed without it for older versions. --- weaver/weave | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/weaver/weave b/weaver/weave index 4b323d7a..4928526b 100755 --- a/weaver/weave +++ b/weaver/weave @@ -49,9 +49,16 @@ create_bridge() { } add_nat_rule() { - if ! iptables -w -t nat -C $1 >/dev/null 2>&1 + if [ -z "$CHECKED_IPTABLES_W" ] ; then + if iptables -S -w >/dev/null 2>&1 ; then + IPTABLES_W=-w + fi + CHECKED_IPTABLES_W=1 + fi + + if ! iptables $IPTABLES_W -t nat -C $1 >/dev/null 2>&1 then - iptables -w -t nat -A $1 >/dev/null + iptables $IPTABLES_W -t nat -A $1 >/dev/null fi }