diff options
author | Jörg Sommer <joerg.sommer@navimatix.de> | 2023-06-09 10:51:06 +0200 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2023-06-30 04:07:59 -1000 |
commit | d6433056607ba01af94df996822d900b3b31abe7 (patch) | |
tree | b42bc09b709b8f6e623a906f4d94ffa84eff4165 /scripts/runqemu-ifup | |
parent | 6e706f41560481e2b3122498ffdf53ee14a7f1ef (diff) | |
download | poky-d6433056607ba01af94df996822d900b3b31abe7.tar.gz |
runqemu-ifupdown/get-tapdevs: Add support for ip tuntap
The *ip* command supports the creation and destruction of TAP devices since
2009 and might be more likely installed on systems then *tunctl*. Therefore
it should be tried to setup or teardown the TAP interface with *ip* before
falling back to *tunctl*.
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=580fbd88f75cc9eea0d28a48c025b090eb9419a7
(From OE-Core rev: e448f9b292aba2bf344a69f32d62b107c18993e9)
Signed-off-by: Jörg Sommer <joerg.sommer@navimatix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
(cherry picked from commit 424ede206baae1c228583aab1df6c18513ac104f)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'scripts/runqemu-ifup')
-rwxr-xr-x | scripts/runqemu-ifup | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup index bb661740c5..5fdcddeeda 100755 --- a/scripts/runqemu-ifup +++ b/scripts/runqemu-ifup | |||
@@ -41,22 +41,29 @@ USERID="-u $1" | |||
41 | GROUP="-g $2" | 41 | GROUP="-g $2" |
42 | STAGING_BINDIR_NATIVE=$3 | 42 | STAGING_BINDIR_NATIVE=$3 |
43 | 43 | ||
44 | TUNCTL=$STAGING_BINDIR_NATIVE/tunctl | 44 | if taps=$(ip tuntap list 2>/dev/null); then |
45 | if [ ! -x "$TUNCTL" ]; then | 45 | tap_no=$(( $(echo "$taps" |sort -r |sed 's/^tap//; s/:.*//; q') + 1 )) |
46 | echo "Error: Unable to find tunctl binary in '$STAGING_BINDIR_NATIVE', please bitbake qemu-helper-native" | 46 | ip tuntap add tap$tap_no mode tap group $2 && TAP=tap$tap_no |
47 | exit 1 | ||
48 | fi | 47 | fi |
49 | 48 | ||
50 | TAP=`$TUNCTL -b $GROUP 2>&1` | 49 | if [ -z $TAP ]; then |
51 | STATUS=$? | 50 | TUNCTL=$STAGING_BINDIR_NATIVE/tunctl |
52 | if [ $STATUS -ne 0 ]; then | 51 | if [ ! -x "$TUNCTL" ]; then |
53 | # If tunctl -g fails, try using tunctl -u, for older host kernels | 52 | echo "Error: Unable to find tunctl binary in '$STAGING_BINDIR_NATIVE', please bitbake qemu-helper-native" |
54 | # which do not support the TUNSETGROUP ioctl | 53 | exit 1 |
55 | TAP=`$TUNCTL -b $USERID 2>&1` | 54 | fi |
55 | |||
56 | TAP=`$TUNCTL -b $GROUP 2>&1` | ||
56 | STATUS=$? | 57 | STATUS=$? |
57 | if [ $STATUS -ne 0 ]; then | 58 | if [ $STATUS -ne 0 ]; then |
58 | echo "tunctl failed:" | 59 | # If tunctl -g fails, try using tunctl -u, for older host kernels |
59 | exit 1 | 60 | # which do not support the TUNSETGROUP ioctl |
61 | TAP=`$TUNCTL -b $USERID 2>&1` | ||
62 | STATUS=$? | ||
63 | if [ $STATUS -ne 0 ]; then | ||
64 | echo "tunctl failed:" | ||
65 | exit 1 | ||
66 | fi | ||
60 | fi | 67 | fi |
61 | fi | 68 | fi |
62 | 69 | ||