diff options
author | Adrian Freihofer <adrian.freihofer@gmail.com> | 2023-06-22 19:01:22 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-06-24 12:21:48 +0100 |
commit | 2401847d7333b1cf1ca5a7ed05a84bfec2f16b67 (patch) | |
tree | 3c8a89fffba31ad6acd8ac7d7cc7ea160969105e /scripts | |
parent | 2d0913ff6f6c4cbab2e293cc05c2de322e2ef090 (diff) | |
download | poky-2401847d7333b1cf1ca5a7ed05a84bfec2f16b67.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.
(From OE-Core rev: c9ea17c13935e805a5b7497b14e1f049b0548779)
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')
-rwxr-xr-x | scripts/runqemu-ifup | 14 |
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 | |||
40 | fi | 40 | fi |
41 | 41 | ||
42 | 42 | ||
43 | if [ -z "$OE_TAP_NAME" ]; then | ||
44 | OE_TAP_NAME=tap | ||
45 | fi | ||
46 | |||
43 | if taps=$(ip tuntap list 2>/dev/null); then | 47 | if taps=$(ip tuntap list 2>/dev/null); then |
44 | tap_no=$(( $(echo "$taps" |cut -f 1 -d ":" | sed 's/tap//g' | sort -rn | head -n 1) + 1 )) | 48 | tap_no=$(( $(echo "$taps" |cut -f 1 -d ":" | sed "s/$OE_TAP_NAME//g" | sort -rn | head -n 1) + 1 )) |
45 | ip tuntap add tap$tap_no mode tap group "$GROUP" && TAP=tap$tap_no | 49 | ip tuntap add "$OE_TAP_NAME$tap_no" mode tap group "$GROUP" && TAP="$OE_TAP_NAME$tap_no" |
46 | fi | 50 | fi |
47 | 51 | ||
48 | if [ -z $TAP ]; then | 52 | if [ -z "$TAP" ]; then |
49 | echo "Error: Unable to find a tap device to use" | 53 | echo "Error: Unable to find a tap device to use" |
50 | exit 1 | 54 | exit 1 |
51 | fi | 55 | fi |
@@ -69,7 +73,7 @@ if [ ! -x "$IPTABLES" ]; then | |||
69 | exit 1 | 73 | exit 1 |
70 | fi | 74 | fi |
71 | 75 | ||
72 | n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ] | 76 | n=$[ (`echo $TAP | sed "s/$OE_TAP_NAME//"` * 2) + 1 ] |
73 | $IPTOOL addr add 192.168.7.$n/32 broadcast 192.168.7.255 dev $TAP | 77 | $IPTOOL addr add 192.168.7.$n/32 broadcast 192.168.7.255 dev $TAP |
74 | STATUS=$? | 78 | STATUS=$? |
75 | if [ $STATUS -ne 0 ]; then | 79 | if [ $STATUS -ne 0 ]; then |
@@ -83,7 +87,7 @@ if [ $STATUS -ne 0 ]; then | |||
83 | exit 1 | 87 | exit 1 |
84 | fi | 88 | fi |
85 | 89 | ||
86 | dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ] | 90 | dest=$[ (`echo $TAP | sed "s/$OE_TAP_NAME//"` * 2) + 2 ] |
87 | $IPTOOL route add to 192.168.7.$dest dev $TAP | 91 | $IPTOOL route add to 192.168.7.$dest dev $TAP |
88 | STATUS=$? | 92 | STATUS=$? |
89 | if [ $STATUS -ne 0 ]; then | 93 | if [ $STATUS -ne 0 ]; then |