mirror of
https://git.yoctoproject.org/poky
synced 2026-06-03 01:40:07 +00:00
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: 424ede206baae1c228583aab1df6c18513ac104f) Signed-off-by: Jörg Sommer <joerg.sommer@navimatix.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
177886950e
commit
d43c41fcaf
@@ -50,12 +50,6 @@ if ! [ $COUNT -ge 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TUNCTL=$STAGING_BINDIR_NATIVE/tunctl
|
|
||||||
if [[ ! -x "$TUNCTL" || -d "$TUNCTL" ]]; then
|
|
||||||
echo "Error: $TUNCTL is not an executable"
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $EUID -ne 0 ]; then
|
if [ $EUID -ne 0 ]; then
|
||||||
echo "Error: This script must be run with root privileges"
|
echo "Error: This script must be run with root privileges"
|
||||||
exit
|
exit
|
||||||
@@ -68,15 +62,29 @@ if [ ! -x "$RUNQEMU_IFUP" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! interfaces=`ip link` 2>/dev/null; then
|
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 link'" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure we start with a clean slate
|
# Ensure we start with a clean slate
|
||||||
for tap in `echo "$interfaces" | sed '/^[0-9]\+: \(docker[0-9]\+\):.*/!d; s//\1/'`; do
|
for tap in $interfaces; do
|
||||||
echo "Note: Destroying pre-existing tap interface $tap..."
|
echo "Note: Destroying pre-existing tap interface $tap..."
|
||||||
$TUNCTL -d $tap
|
if $ip_supports_tuntap; then
|
||||||
|
ip tuntap del $tap mode tap
|
||||||
|
else
|
||||||
|
$TUNCTL -d $tap
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
rm -f /etc/runqemu-nosudo
|
rm -f /etc/runqemu-nosudo
|
||||||
|
|
||||||
|
|||||||
@@ -33,13 +33,15 @@ fi
|
|||||||
TAP=$1
|
TAP=$1
|
||||||
STAGING_BINDIR_NATIVE=$2
|
STAGING_BINDIR_NATIVE=$2
|
||||||
|
|
||||||
TUNCTL=$STAGING_BINDIR_NATIVE/tunctl
|
if !ip tuntap del $TAP mode tap 2>/dev/null; then
|
||||||
if [ ! -e "$TUNCTL" ]; then
|
TUNCTL=$STAGING_BINDIR_NATIVE/tunctl
|
||||||
echo "Error: Unable to find tunctl binary in '$STAGING_BINDIR_NATIVE', please bitbake qemu-helper-native"
|
if [ ! -e "$TUNCTL" ]; then
|
||||||
exit 1
|
echo "Error: Unable to find tunctl binary in '$STAGING_BINDIR_NATIVE', please bitbake qemu-helper-native"
|
||||||
fi
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
$TUNCTL -d $TAP
|
$TUNCTL -d $TAP
|
||||||
|
fi
|
||||||
|
|
||||||
IFCONFIG=`which ip 2> /dev/null`
|
IFCONFIG=`which ip 2> /dev/null`
|
||||||
if [ "x$IFCONFIG" = "x" ]; then
|
if [ "x$IFCONFIG" = "x" ]; then
|
||||||
|
|||||||
+19
-12
@@ -41,22 +41,29 @@ USERID="-u $1"
|
|||||||
GROUP="-g $2"
|
GROUP="-g $2"
|
||||||
STAGING_BINDIR_NATIVE=$3
|
STAGING_BINDIR_NATIVE=$3
|
||||||
|
|
||||||
TUNCTL=$STAGING_BINDIR_NATIVE/tunctl
|
if taps=$(ip tuntap list 2>/dev/null); then
|
||||||
if [ ! -x "$TUNCTL" ]; then
|
tap_no=$(( $(echo "$taps" |sort -r |sed 's/^tap//; s/:.*//; q') + 1 ))
|
||||||
echo "Error: Unable to find tunctl binary in '$STAGING_BINDIR_NATIVE', please bitbake qemu-helper-native"
|
ip tuntap add tap$tap_no mode tap group $2 && TAP=tap$tap_no
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TAP=`$TUNCTL -b $GROUP 2>&1`
|
if [ -z $TAP ]; then
|
||||||
STATUS=$?
|
TUNCTL=$STAGING_BINDIR_NATIVE/tunctl
|
||||||
if [ $STATUS -ne 0 ]; then
|
if [ ! -x "$TUNCTL" ]; then
|
||||||
# If tunctl -g fails, try using tunctl -u, for older host kernels
|
echo "Error: Unable to find tunctl binary in '$STAGING_BINDIR_NATIVE', please bitbake qemu-helper-native"
|
||||||
# which do not support the TUNSETGROUP ioctl
|
exit 1
|
||||||
TAP=`$TUNCTL -b $USERID 2>&1`
|
fi
|
||||||
|
|
||||||
|
TAP=`$TUNCTL -b $GROUP 2>&1`
|
||||||
STATUS=$?
|
STATUS=$?
|
||||||
if [ $STATUS -ne 0 ]; then
|
if [ $STATUS -ne 0 ]; then
|
||||||
echo "tunctl failed:"
|
# If tunctl -g fails, try using tunctl -u, for older host kernels
|
||||||
exit 1
|
# 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
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user