Patchwork [1/4] runqemu: Replace use of ifconfig with ip

login
register
mail settings
Submitter Khem Raj
Date May 13, 2013, 5:42 a.m.
Message ID <a5c9cc4750706a0a84751170a0f10ce9e4f07f0d.1368423406.git.raj.khem@gmail.com>
Download mbox | patch
Permalink /patch/49821/
State New
Headers show

Comments

Khem Raj - May 13, 2013, 5:42 a.m.
ifconfig and its ilk (net-tools package) is deprecated in favour of iproute2 package
and is now removed by many distro's e.g. Archlinux. So we replace ifconfig with ip utility

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 scripts/runqemu-gen-tapdevs | 6 +++---
 scripts/runqemu-ifup        | 6 +++---
 scripts/runqemu-internal    | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

Patch

diff --git a/scripts/runqemu-gen-tapdevs b/scripts/runqemu-gen-tapdevs
index f5be30a..d3b27be 100755
--- a/scripts/runqemu-gen-tapdevs
+++ b/scripts/runqemu-gen-tapdevs
@@ -59,10 +59,10 @@  if [ ! -x "$RUNQEMU_IFUP" ]; then
 	exit 1
 fi
 
-IFCONFIG=`which ifconfig 2> /dev/null`
+IFCONFIG=`which ip 2> /dev/null`
 if [ -z "$IFCONFIG" ]; then
 	# Is it ever anywhere else?
-	IFCONFIG=/sbin/ifconfig
+	IFCONFIG=/sbin/ip
 fi
 if [ ! -x "$IFCONFIG" ]; then
        echo "$IFCONFIG cannot be executed"
@@ -70,7 +70,7 @@  if [ ! -x "$IFCONFIG" ]; then
 fi
 
 # Ensure we start with a clean slate
-for tap in `$IFCONFIG | grep ^tap | awk '{ print \$1 }' | sed s/://`; do
+for tap in `$IFCONFIG link | grep tap | awk '{ print \$2 }' | sed s/://`; do
 	echo "Note: Destroying pre-existing tap interface $tap..."
 	$TUNCTL -d $tap
 done
diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup
index 0926faf..8948153 100755
--- a/scripts/runqemu-ifup
+++ b/scripts/runqemu-ifup
@@ -70,10 +70,10 @@  if [ $STATUS -ne 0 ]; then
 	fi
 fi
 
-IFCONFIG=`which ifconfig 2> /dev/null`
+IFCONFIG=`which ip 2> /dev/null`
 if [ "x$IFCONFIG" = "x" ]; then
 	# better than nothing...
-	IFCONFIG=/sbin/ifconfig
+	IFCONFIG=/sbin/ip
 fi
 if [ ! -x "$IFCONFIG" ]; then
 	echo "$IFCONFIG cannot be executed"
@@ -100,7 +100,7 @@  if [ ! -x "$IPTABLES" ]; then
 fi
 
 n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ]
-$IFCONFIG $TAP 192.168.7.$n netmask 255.255.255.255
+$IFCONFIG addr add 192.168.7.$n/32 dev $TAP
 
 dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ]
 $ROUTE add -host 192.168.7.$dest $TAP
diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
index 3bd0a09..3c5282d 100755
--- a/scripts/runqemu-internal
+++ b/scripts/runqemu-internal
@@ -139,16 +139,16 @@  if [ ! -d "$LOCKDIR" ]; then
     chmod 777 $LOCKDIR
 fi
 
-IFCONFIG=`which ifconfig 2> /dev/null`
+IFCONFIG=`which ip 2> /dev/null`
 if [ -z "$IFCONFIG" ]; then
-    IFCONFIG=/sbin/ifconfig
+    IFCONFIG=/sbin/ip
 fi
 if [ ! -x "$IFCONFIG" ]; then
        echo "$IFCONFIG cannot be executed"
        exit 1
 fi
 
-POSSIBLE=`$IFCONFIG -a | grep '^tap' | awk '{print $1}' | sed s/://`
+POSSIBLE=`$IFCONFIG link | grep 'tap' | awk '{print $2}' | sed s/://`
 TAP=""
 LOCKFILE=""
 for tap in $POSSIBLE; do