From 609fc157180778025b2f416736839a7935217731 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 15 Jun 2023 17:59:06 +0100 Subject: runqemu/qemu-helper: Drop tunctl ip tuntap provides the functionality that we obtained from tunctl. We only needed tunctl when ifconfig was more available than ip. That isn't the case now so we can drop tunctl and all the hoops we need to jump through to build and provide it. (From OE-Core rev: 2abfbca690ff00cb58ce08a65cde006578ee3de9) Signed-off-by: Richard Purdie --- scripts/runqemu-gen-tapdevs | 26 +++++--------------------- scripts/runqemu-ifdown | 12 +++--------- scripts/runqemu-ifup | 26 +++----------------------- 3 files changed, 11 insertions(+), 53 deletions(-) (limited to 'scripts') diff --git a/scripts/runqemu-gen-tapdevs b/scripts/runqemu-gen-tapdevs index ffb82adce6..4f8ea979d2 100755 --- a/scripts/runqemu-gen-tapdevs +++ b/scripts/runqemu-gen-tapdevs @@ -1,11 +1,7 @@ #!/bin/bash # # Create a "bank" of tap network devices that can be used by the -# runqemu script. This script needs to be run as root, and will -# use the tunctl binary from the build system sysroot. Note: many Linux -# distros these days still use an older version of tunctl which does not -# support the group permissions option, hence the need to use the build -# system provided version. +# runqemu script. This script needs to be run as root # # Copyright (C) 2010 Intel Corp. # @@ -62,29 +58,17 @@ if [ ! -x "$RUNQEMU_IFUP" ]; then exit 1 fi -TUNCTL=$STAGING_BINDIR_NATIVE/tunctl -ip_supports_tuntap=false if interfaces=`ip tuntap list` 2>/dev/null; then - ip_supports_tuntap=true interfaces=`echo "$interfaces |cut -f1 -d:` -elif [[ ! -x "$TUNCTL" || -d "$TUNCTL" ]]; then - echo "Error: $TUNCTL is not an executable" - usage -elif interfaces=`ip link` 2>/dev/null; then - interfaces=`echo "$interfaces" | sed '/^[0-9]\+: \(docker[0-9]\+\):.*/!d; s//\1/'` else - echo "Failed to call 'ip link'" >&2 + echo "Failed to call 'ip tuntap list'" >&2 exit 1 fi # Ensure we start with a clean slate for tap in $interfaces; do echo "Note: Destroying pre-existing tap interface $tap..." - if $ip_supports_tuntap; then - ip tuntap del $tap mode tap - else - $TUNCTL -d $tap - fi + ip tuntap del $tap mode tap done rm -f /etc/runqemu-nosudo @@ -95,8 +79,8 @@ fi echo "Creating $COUNT tap devices for UID: $TUID GID: $GID..." for ((index=0; index < $COUNT; index++)); do echo "Creating tap$index" - if ! ifup=`$RUNQEMU_IFUP $TUID $GID $STAGING_BINDIR_NATIVE 2>&1`; then - echo "Error running tunctl: $ifup" + if ! ifup=`$RUNQEMU_IFUP $TUID $GID 2>&1`; then + echo "Error bringing up interface: $ifup" exit 1 fi done diff --git a/scripts/runqemu-ifdown b/scripts/runqemu-ifdown index f72166b32b..98ac7f07b3 100755 --- a/scripts/runqemu-ifdown +++ b/scripts/runqemu-ifdown @@ -1,8 +1,7 @@ #!/bin/bash # # QEMU network configuration script to bring down tap devices. This -# utility needs to be run as root, and will use the tunctl binary -# from the native sysroot. +# utility needs to be run as root, and will use the ip utility # # If you find yourself calling this script a lot, you can add the # the following to your /etc/sudoers file to be able to run this @@ -34,13 +33,8 @@ TAP=$1 STAGING_BINDIR_NATIVE=$2 if !ip tuntap del $TAP mode tap 2>/dev/null; then - TUNCTL=$STAGING_BINDIR_NATIVE/tunctl - if [ ! -e "$TUNCTL" ]; then - echo "Error: Unable to find tunctl binary in '$STAGING_BINDIR_NATIVE', please bitbake qemu-helper-native" - exit 1 - fi - - $TUNCTL -d $TAP + echo "Error: Unable to run up tuntap del" + exit 1 fi IFCONFIG=`which ip 2> /dev/null` diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup index 5fdcddeeda..237bf2a07b 100755 --- a/scripts/runqemu-ifup +++ b/scripts/runqemu-ifup @@ -1,10 +1,7 @@ #!/bin/bash # # QEMU network interface configuration script. This utility needs to -# be run as root, and will use the tunctl binary from a native sysroot. -# Note: many Linux distros these days still use an older version of -# tunctl which does not support the group permissions option, hence -# the need to use build system's version. +# be run as root, and will use the ip utility # # If you find yourself calling this script a lot, you can add the # the following to your /etc/sudoers file to be able to run this @@ -39,7 +36,6 @@ fi USERID="-u $1" GROUP="-g $2" -STAGING_BINDIR_NATIVE=$3 if taps=$(ip tuntap list 2>/dev/null); then tap_no=$(( $(echo "$taps" |sort -r |sed 's/^tap//; s/:.*//; q') + 1 )) @@ -47,24 +43,8 @@ if taps=$(ip tuntap list 2>/dev/null); then fi if [ -z $TAP ]; then - TUNCTL=$STAGING_BINDIR_NATIVE/tunctl - if [ ! -x "$TUNCTL" ]; then - echo "Error: Unable to find tunctl binary in '$STAGING_BINDIR_NATIVE', please bitbake qemu-helper-native" - exit 1 - fi - - TAP=`$TUNCTL -b $GROUP 2>&1` - STATUS=$? - if [ $STATUS -ne 0 ]; then - # If tunctl -g fails, try using tunctl -u, for older host kernels - # which do not support the TUNSETGROUP ioctl - TAP=`$TUNCTL -b $USERID 2>&1` - STATUS=$? - if [ $STATUS -ne 0 ]; then - echo "tunctl failed:" - exit 1 - fi - fi + echo "Error: Unable to find a tap device to use" + exit 1 fi IFCONFIG=`which ip 2> /dev/null` -- cgit v1.2.3-54-g00ecf