File replace-obsolete-network-configuration-commands-in-s.patch of Package xen.34726

From 5e1e18fde92bae1ae87f78d470e80b1ffc9350d1 Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Wed, 26 Jul 2017 10:28:54 +0200
Subject: [PATCH] replace obsolete network configuration commands in scripts

Some scripts still use obsolete network configuration commands ifconfig and
brctl. Replace them by commands from iproute2 package.
---
 README                                                     |  3 +--
 tools/hotplug/Linux/colo-proxy-setup                       | 14 ++++++--------
 tools/hotplug/Linux/remus-netbuf-setup                     |  3 ++-
 tools/hotplug/Linux/vif-bridge                             |  7 ++++---
 tools/hotplug/Linux/vif-nat                                |  2 +-
 tools/hotplug/Linux/vif-route                              |  6 ++++--
 tools/hotplug/Linux/vif2                                   |  6 +++---
 tools/hotplug/Linux/xen-network-common.sh                  |  6 ++----
 .../i386-dm/qemu-ifup-Linux                                |  5 +++--
 9 files changed, 26 insertions(+), 26 deletions(-)

Index: xen-4.14.6-testing/README
===================================================================
--- xen-4.14.6-testing.orig/README
+++ xen-4.14.6-testing/README
@@ -57,8 +57,7 @@ provided by your OS distributor:
     * Development install of GLib v2.0 (e.g. libglib2.0-dev)
     * Development install of Pixman (e.g. libpixman-1-dev)
     * pkg-config
-    * bridge-utils package (/sbin/brctl)
-    * iproute package (/sbin/ip)
+    * iproute package (/sbin/ip, /sbin/bridge)
     * GNU bison and GNU flex
     * ACPI ASL compiler (iasl)
     * Libc multiarch package (e.g. libc6-dev-i386 / glibc-devel.i686).
Index: xen-4.14.6-testing/tools/hotplug/Linux/remus-netbuf-setup
===================================================================
--- xen-4.14.6-testing.orig/tools/hotplug/Linux/remus-netbuf-setup
+++ xen-4.14.6-testing/tools/hotplug/Linux/remus-netbuf-setup
@@ -76,6 +76,7 @@
 #specific setup code such as renaming.
 dir=$(dirname "$0")
 . "$dir/xen-hotplug-common.sh"
+. "$dir/xen-network-common.sh"
 
 findCommand "$@"
 
@@ -139,8 +140,16 @@ check_ifb() {
 
 setup_ifb() {
 
-    for ifb in `ifconfig -a -s|egrep ^ifb|cut -d ' ' -f1`
+    if [ "$legacy_tools" ]; then
+        ifbs=`ifconfig -a -s|egrep ^ifb|cut -d ' ' -f1`
+    else
+        ifbs=$(ip --oneline link show type ifb | cut -d ' ' -f2)
+    fi
+    for ifb in $ifbs
     do
+        if [ ! "$legacy_tools" ]; then
+            ifb="${ifb%:}"
+        fi
         check_ifb "$ifb" || continue
         REMUS_IFB="$ifb"
         break
Index: xen-4.14.6-testing/tools/hotplug/Linux/vif-bridge
===================================================================
--- xen-4.14.6-testing.orig/tools/hotplug/Linux/vif-bridge
+++ xen-4.14.6-testing/tools/hotplug/Linux/vif-bridge
@@ -42,7 +42,8 @@ if [ -z "$bridge" ]; then
     if which brctl >&/dev/null; then
         bridge=$(brctl show | awk 'NR==2{print$1}')
     else
-        bridge=$(bridge link | cut -d" " -f7)
+        bridge=$(ip --oneline link show type bridge | awk '(NR == 1) { print $2; }')
+        bridge="${bridge%:}"
     fi
   if [ -z "$bridge" ]
   then
@@ -93,10 +94,11 @@ case "$command" in
     offline)
         if which brctl >&/dev/null; then
             do_without_error brctl delif "$bridge" "$dev"
+            do_without_error ifconfig "$dev" down
         else
             do_without_error ip link set "$dev" nomaster
+            do_without_error ip link set "$dev" down
         fi
-        do_without_error ifconfig "$dev" down
         ;;
 
     add)
Index: xen-4.14.6-testing/tools/hotplug/Linux/vif-nat
===================================================================
--- xen-4.14.6-testing.orig/tools/hotplug/Linux/vif-nat
+++ xen-4.14.6-testing/tools/hotplug/Linux/vif-nat
@@ -174,7 +174,11 @@ case "$command" in
         ;;
     offline)
         [ "$dhcp" != 'no' ] && dhcp_down
-        do_without_error ifconfig "${dev}" down
+        if [ "$legacy_tools" ]; then
+            do_without_error ifconfig "${dev}" down
+        else
+            do_without_error ip link set "${dev}" down
+        fi
         ;;
 esac
 
Index: xen-4.14.6-testing/tools/hotplug/Linux/vif-route
===================================================================
--- xen-4.14.6-testing.orig/tools/hotplug/Linux/vif-route
+++ xen-4.14.6-testing/tools/hotplug/Linux/vif-route
@@ -25,7 +25,12 @@ case "${command}" in
     add)
         ;&
     online)
-        ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up
+        if [ "$legacy_tools" ]; then
+            ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up
+        else
+            ip addr add "${main_ip}/32" dev "$dev"
+        fi
+        ip link set "dev" up
         echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp
         ipcmd='add'
         cmdprefix=''
@@ -33,7 +38,12 @@ case "${command}" in
     remove)
         ;&
     offline)
-        do_without_error ifdown ${dev}
+        if [ "$legacy_tools" ]; then
+            do_without_error ifdown ${dev}
+        else
+            do_without_error ip addr flush dev "$dev"
+            do_without_error ip link set "$dev" down
+        fi
         ipcmd='del'
         cmdprefix='do_without_error'
         ;;
Index: xen-4.14.6-testing/tools/hotplug/Linux/vif2
===================================================================
--- xen-4.14.6-testing.orig/tools/hotplug/Linux/vif2
+++ xen-4.14.6-testing/tools/hotplug/Linux/vif2
@@ -10,7 +10,7 @@ if [ -z "$bridge" ]
     if which brctl >&/dev/null; then
         nr_bridges=$(($(brctl show | cut -f 1 | grep -v "^$" | wc -l) - 1))
     else
-        nr_bridges=$(bridge link | wc -l)
+        nr_bridges=$(ip --oneline link show type bridge | wc -l)
     fi
     if [ "$nr_bridges" != 1 ]
 	then
@@ -20,7 +20,8 @@ if [ -z "$bridge" ]
         bridge=$(brctl show | cut -d "
 " -f 2 | cut -f 1)
     else
-        bridge=$(bridge link | cut -d" " -f6)
+        bridge=$(ip --oneline link show type bridge | head -1 | cut -d ' ' -f2)
+        bridge="${bridge%:}"
     fi
 fi
 
Index: xen-4.14.6-testing/tools/hotplug/Linux/xen-network-common.sh
===================================================================
--- xen-4.14.6-testing.orig/tools/hotplug/Linux/xen-network-common.sh
+++ xen-4.14.6-testing/tools/hotplug/Linux/xen-network-common.sh
@@ -15,6 +15,12 @@
 #
 
 
+# Use brctl and ifconfig on older systems
+legacy_tools=
+if [ -f /sbin/brctl -a -f /sbin/ifconfig ]; then
+  legacy_tools="true"
+fi
+
 # Gentoo doesn't have ifup/ifdown, so we define appropriate alternatives.
 
 # Other platforms just use ifup / ifdown directly.
openSUSE Build Service is sponsored by