diff options
| author | Chen Qi <Qi.Chen@windriver.com> | 2013-08-28 10:52:03 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-08-30 16:23:47 +0100 |
| commit | b2a0e3ad91ddc0d62592a59cf0367be1349170d0 (patch) | |
| tree | a4d19508593b89bae41e41489fa5c2857f9e1577 /scripts | |
| parent | 5bffc4ff4dde35d2ceb21242c1372113406369ff (diff) | |
| download | poky-b2a0e3ad91ddc0d62592a59cf0367be1349170d0.tar.gz | |
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]
(From OE-Core rev: ef38a0aed35357d035ca587162158cd2f55b958f)
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/runqemu-ifdown | 14 |
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 | |||
| 50 | fi | 50 | fi |
| 51 | 51 | ||
| 52 | $TUNCTL -d $TAP | 52 | $TUNCTL -d $TAP |
| 53 | |||
| 54 | # cleanup the remaining iptables rules | ||
| 55 | IPTABLES=`which iptables 2> /dev/null` | ||
| 56 | if [ "x$IPTABLES" = "x" ]; then | ||
| 57 | IPTABLES=/sbin/iptables | ||
| 58 | fi | ||
| 59 | if [ ! -x "$IPTABLES" ]; then | ||
| 60 | echo "$IPTABLES cannot be executed" | ||
| 61 | exit 1 | ||
| 62 | fi | ||
| 63 | n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ] | ||
| 64 | dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ] | ||
| 65 | $IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32 | ||
| 66 | $IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32 | ||
