[oe-commits] Chen Qi : runqemu-ifdown: clean up the remaining iptables rules
git at git.openembedded.org
git at git.openembedded.org
Fri Aug 30 15:17:01 UTC 2013
Module: openembedded-core.git
Branch: master
Commit: ef38a0aed35357d035ca587162158cd2f55b958f
URL: http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=ef38a0aed35357d035ca587162158cd2f55b958f
Author: Chen Qi <Qi.Chen at windriver.com>
Date: Wed Aug 28 10:52:03 2013 +0800
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 at windriver.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
scripts/runqemu-ifdown | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/scripts/runqemu-ifdown b/scripts/runqemu-ifdown
index 8b8c5a4..8f66cfa 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
More information about the Openembedded-commits
mailing list