summaryrefslogtreecommitdiff
path: root/scripts/runqemu-ifdown
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2013-08-28 10:52:03 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-30 16:21:15 +0100
commitef38a0aed35357d035ca587162158cd2f55b958f (patch)
tree3d65e71e0705bcf44f415307d02a8624806f48f8 /scripts/runqemu-ifdown
parentec08d92641cc51c567cc3745937b1839d3faa095 (diff)
downloadopenembedded-core-ef38a0aed35357d035ca587162158cd2f55b958f.tar.gz
openembedded-core-ef38a0aed35357d035ca587162158cd2f55b958f.tar.bz2
openembedded-core-ef38a0aed35357d035ca587162158cd2f55b958f.zip
runqemu-ifdown: clean up the remaining iptables rules
The iptables rules for the tap interface are added by runqemu-ifup everytime we use runqemu to start a qemu target. But it's not cleaned up when runqemu exits. This patch cleans up the remaining iptables rules for the tap interface in runqemu-ifdown. [YOCTO #5047] Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/runqemu-ifdown')
-rwxr-xr-xscripts/runqemu-ifdown14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/runqemu-ifdown b/scripts/runqemu-ifdown
index 8b8c5a4a7a..8f66cfa2a9 100755
--- a/scripts/runqemu-ifdown
+++ b/scripts/runqemu-ifdown
@@ -50,3 +50,17 @@ if [ ! -e "$TUNCTL" ]; then
fi
$TUNCTL -d $TAP
+
+# cleanup the remaining iptables rules
+IPTABLES=`which iptables 2> /dev/null`
+if [ "x$IPTABLES" = "x" ]; then
+ IPTABLES=/sbin/iptables
+fi
+if [ ! -x "$IPTABLES" ]; then
+ echo "$IPTABLES cannot be executed"
+ exit 1
+fi
+n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ]
+dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ]
+$IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32
+$IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32