From 36ee8bacb09df55fe5496c023811b80c2e500c50 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 9 Feb 2016 16:40:12 +0000 Subject: [PATCH 1/3] Remove all vethwe* interfaces in reset --- weave | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/weave b/weave index 580c3493..ee8ec32c 100755 --- a/weave +++ b/weave @@ -677,10 +677,10 @@ destroy_bridge() { fi done - # Remove any lingering bridged fastdp and pcap veths - ip link del $DATAPATH_IFNAME >/dev/null 2>&1 || true - ip link del $BRIDGE_IFNAME >/dev/null 2>&1 || true - ip link del $PCAP_IFNAME >/dev/null 2>&1 || true + # Remove any lingering bridged fastdp, pcap and attach-bridge veths + for VETH in $(ip -o link show | grep -o v${CONTAINER_IFNAME}[^:]*) ; do + ip link del $VETH >/dev/null 2>&1 || true + done if [ "$DOCKER_BRIDGE" != "$BRIDGE" ] ; then run_iptables -t filter -D FORWARD -i $DOCKER_BRIDGE -o $BRIDGE -j DROP 2>/dev/null || true From 2bfc86e7b2cae5b19a06d7c70ef914c5158cdaae Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 9 Feb 2016 16:51:04 +0000 Subject: [PATCH 2/3] Cleanup attach-bridge iptables rule --- weave | 1 + 1 file changed, 1 insertion(+) diff --git a/weave b/weave index ee8ec32c..721a2347 100755 --- a/weave +++ b/weave @@ -698,6 +698,7 @@ destroy_bridge() { run_iptables -t filter -D FORWARD -i $BRIDGE -o $BRIDGE -j ACCEPT 2>/dev/null || true 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 -D POSTROUTING -o $BRIDGE -j ACCEPT >/dev/null 2>&1 || true run_iptables -t nat -X WEAVE >/dev/null 2>&1 || true } From 264d5e482838973bf2ac350753ddd702be45ec3e Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 9 Feb 2016 17:13:20 +0000 Subject: [PATCH 3/3] Make attach-bridge iptables rule insertion idempotent --- weave | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/weave b/weave index 721a2347..b2c7e124 100755 --- a/weave +++ b/weave @@ -403,6 +403,15 @@ add_iptables_rule() { fi } +# Insert a rule in iptables, if it doesn't exist already +insert_iptables_rule() { + IPTABLES_TABLE="$1" + shift 1 + if ! run_iptables -t $IPTABLES_TABLE -C "$@" >/dev/null 2>&1 ; then + run_iptables -t $IPTABLES_TABLE -I "$@" >/dev/null + fi +} + # Delete a rule from iptables, if it exist delete_iptables_rule() { IPTABLES_TABLE="$1" @@ -1832,7 +1841,7 @@ EOF attach-bridge) if detect_bridge_type ; then attach_bridge ${1:-$DOCKER_BRIDGE} - run_iptables -t nat -I POSTROUTING -o $BRIDGE -j ACCEPT + insert_iptables_rule nat POSTROUTING -o $BRIDGE -j ACCEPT else echo "Weave bridge not found. Please run 'weave launch' and try again" >&2 exit 1