diff options
Diffstat (limited to 'scripts/runqemu-ifdown')
-rwxr-xr-x | scripts/runqemu-ifdown | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/scripts/runqemu-ifdown b/scripts/runqemu-ifdown index ffbc9de442..e0eb5344c6 100755 --- a/scripts/runqemu-ifdown +++ b/scripts/runqemu-ifdown @@ -13,18 +13,8 @@ # # Copyright (c) 2006-2011 Linux Foundation # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. +# SPDX-License-Identifier: GPL-2.0-only # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. usage() { echo "sudo $(basename $0) <tap-dev> <native-sysroot-basedir>" @@ -51,6 +41,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 @@ -64,3 +64,4 @@ 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 +true |