]> code.ossystems Code Review - openembedded-core.git/commitdiff
runqemu-ifdown: ensure to clean up TAP
authorChen Qi <Qi.Chen@windriver.com>
Thu, 7 Jun 2018 07:52:47 +0000 (15:52 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 18 Jun 2018 09:59:33 +0000 (10:59 +0100)
In runqemu-ifup, ip command is used to add TAP; in runqemu-ifdown,
we should do the reversed logic, using ip command to delete TAP, to
make sure TAP is cleaned up by ourselves.

I can see that in runqemu-ifdown script, 'tunctl -d' and 'iptables'
commands are used to deal with TAP, but these two commands cannot
make sure that the TAP is cleaned up.

runqemu-ifup uses 'ip' to set up TAP, we really need to do the opposite
in runqemu-ifdown.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/runqemu-ifdown

index ffbc9de442ef6aee6fe368294ddf14bc4979b2a2..24869685889d4474db0185277e2a1ba20386d307 100755 (executable)
@@ -51,6 +51,16 @@ fi
 
 $TUNCTL -d $TAP
 
+IFCONFIG=`which ip 2> /dev/null`
+if [ "x$IFCONFIG" = "x" ]; then
+       # better than nothing...
+       IFCONFIG=/sbin/ip
+fi
+if [ -x "$IFCONFIG" ]; then
+       if `$IFCONFIG link show $TAP > /dev/null 2>&1`; then
+               $IFCONFIG link del $TAP
+       fi
+fi
 # cleanup the remaining iptables rules
 IPTABLES=`which iptables 2> /dev/null`
 if [ "x$IPTABLES" = "x" ]; then