summaryrefslogtreecommitdiffstats
path: root/scripts/runqemu-ifup
diff options
context:
space:
mode:
authorAdrian Freihofer <adrian.freihofer@gmail.com>2023-06-22 19:01:22 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-24 12:19:52 +0100
commitc9ea17c13935e805a5b7497b14e1f049b0548779 (patch)
treeb0d1b00817e4ca445e56a27bef760e6218adec67 /scripts/runqemu-ifup
parent9ccbabc06d02addd429a21dbe15a1a42738c58d6 (diff)
downloadopenembedded-core-contrib-c9ea17c13935e805a5b7497b14e1f049b0548779.tar.gz
runqemu-ifup: configurable tap names
Feature: Hard-coding the interface names to tap* is not always a good idea. Introduce an environment variable which allows to change this: OE_TAP_NAME. Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/runqemu-ifup')
-rwxr-xr-xscripts/runqemu-ifup14
1 files changed, 9 insertions, 5 deletions
diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup
index 2671451802..9820dc535c 100755
--- a/scripts/runqemu-ifup
+++ b/scripts/runqemu-ifup
@@ -40,12 +40,16 @@ else
fi
+if [ -z "$OE_TAP_NAME" ]; then
+ OE_TAP_NAME=tap
+fi
+
if taps=$(ip tuntap list 2>/dev/null); then
- tap_no=$(( $(echo "$taps" |cut -f 1 -d ":" | sed 's/tap//g' | sort -rn | head -n 1) + 1 ))
- ip tuntap add tap$tap_no mode tap group "$GROUP" && TAP=tap$tap_no
+ tap_no=$(( $(echo "$taps" |cut -f 1 -d ":" | sed "s/$OE_TAP_NAME//g" | sort -rn | head -n 1) + 1 ))
+ ip tuntap add "$OE_TAP_NAME$tap_no" mode tap group "$GROUP" && TAP="$OE_TAP_NAME$tap_no"
fi
-if [ -z $TAP ]; then
+if [ -z "$TAP" ]; then
echo "Error: Unable to find a tap device to use"
exit 1
fi
@@ -69,7 +73,7 @@ if [ ! -x "$IPTABLES" ]; then
exit 1
fi
-n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ]
+n=$[ (`echo $TAP | sed "s/$OE_TAP_NAME//"` * 2) + 1 ]
$IPTOOL addr add 192.168.7.$n/32 broadcast 192.168.7.255 dev $TAP
STATUS=$?
if [ $STATUS -ne 0 ]; then
@@ -83,7 +87,7 @@ if [ $STATUS -ne 0 ]; then
exit 1
fi
-dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ]
+dest=$[ (`echo $TAP | sed "s/$OE_TAP_NAME//"` * 2) + 2 ]
$IPTOOL route add to 192.168.7.$dest dev $TAP
STATUS=$?
if [ $STATUS -ne 0 ]; then