summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Freihofer <adrian.freihofer@gmail.com>2023-06-26 15:29:26 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-28 07:56:34 +0100
commit95c785baeb60c750352873a190da34ed0b362569 (patch)
treef2f32592dd5258fcbbbbd7795492e4dfef4422b6
parentabeb4f1a7c7cec22c578fdc07f6125714559206b (diff)
downloadpoky-95c785baeb60c750352873a190da34ed0b362569.tar.gz
runqemu-ifdown: catch up with ifup
- Drop the native-sysroot-basedir parameter still allow it to keep backward compatibility write a warning to stderr - Add a space after ! in the if as suggested by shellcheck - Support the new OE_TAP_NAME variable as well (From OE-Core rev: be72e5e32da5a251db14b42d3e9c0951178e216d) Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xscripts/runqemu-ifdown21
1 files changed, 15 insertions, 6 deletions
diff --git a/scripts/runqemu-ifdown b/scripts/runqemu-ifdown
index 78be28812d..822a2a39b9 100755
--- a/scripts/runqemu-ifdown
+++ b/scripts/runqemu-ifdown
@@ -16,7 +16,7 @@
16# 16#
17 17
18usage() { 18usage() {
19 echo "sudo $(basename $0) <tap-dev> <native-sysroot-basedir>" 19 echo "sudo $(basename $0) <tap-dev>"
20} 20}
21 21
22if [ $EUID -ne 0 ]; then 22if [ $EUID -ne 0 ]; then
@@ -24,15 +24,19 @@ if [ $EUID -ne 0 ]; then
24 exit 1 24 exit 1
25fi 25fi
26 26
27if [ $# -ne 2 ]; then 27if [ $# -gt 2 ] || [ $# -lt 1 ]; then
28 usage 28 usage
29 exit 1 29 exit 1
30fi 30fi
31 31
32# backward compatibility
33if [ $# -eq 2 ] ; then
34 echo "Warning: native-sysroot-basedir parameter is ignored. It is no longer needed." >&2
35fi
36
32TAP=$1 37TAP=$1
33STAGING_BINDIR_NATIVE=$2
34 38
35if !ip tuntap del $TAP mode tap 2>/dev/null; then 39if ! ip tuntap del $TAP mode tap 2>/dev/null; then
36 echo "Error: Unable to run up tuntap del" 40 echo "Error: Unable to run up tuntap del"
37 exit 1 41 exit 1
38fi 42fi
@@ -56,8 +60,13 @@ if [ ! -x "$IPTABLES" ]; then
56 echo "$IPTABLES cannot be executed" 60 echo "$IPTABLES cannot be executed"
57 exit 1 61 exit 1
58fi 62fi
59n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ] 63
60dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ] 64if [ -z "$OE_TAP_NAME" ]; then
65 OE_TAP_NAME=tap
66fi
67
68n=$[ (`echo $TAP | sed "s/$OE_TAP_NAME//"` * 2) + 1 ]
69dest=$[ (`echo $TAP | sed "s/$OE_TAP_NAME//"` * 2) + 2 ]
61$IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32 70$IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32
62$IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32 71$IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32
63true 72true