From 5e1e18fde92bae1ae87f78d470e80b1ffc9350d1 Mon Sep 17 00:00:00 2001 From: Michal Kubecek 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/xen-network-common.sh | 6 ++---- .../i386-dm/qemu-ifup-Linux | 5 +++-- 9 files changed, 26 insertions(+), 26 deletions(-) Index: xen-4.17.0-testing/README =================================================================== --- xen-4.17.0-testing.orig/README +++ xen-4.17.0-testing/README @@ -61,8 +61,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) Index: xen-4.17.0-testing/tools/hotplug/Linux/remus-netbuf-setup =================================================================== --- xen-4.17.0-testing.orig/tools/hotplug/Linux/remus-netbuf-setup +++ xen-4.17.0-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.17.0-testing/tools/hotplug/Linux/vif-bridge =================================================================== --- xen-4.17.0-testing.orig/tools/hotplug/Linux/vif-bridge +++ xen-4.17.0-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 Index: xen-4.17.0-testing/tools/hotplug/Linux/vif-nat =================================================================== --- xen-4.17.0-testing.orig/tools/hotplug/Linux/vif-nat +++ xen-4.17.0-testing/tools/hotplug/Linux/vif-nat @@ -172,7 +172,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.17.0-testing/tools/hotplug/Linux/vif-route =================================================================== --- xen-4.17.0-testing.orig/tools/hotplug/Linux/vif-route +++ xen-4.17.0-testing/tools/hotplug/Linux/vif-route @@ -23,13 +23,23 @@ main_ip=$(dom0_ip) 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='' ;; 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.17.0-testing/tools/hotplug/Linux/xen-network-common.sh =================================================================== --- xen-4.17.0-testing.orig/tools/hotplug/Linux/xen-network-common.sh +++ xen-4.17.0-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. @@ -152,8 +158,10 @@ remove_from_bridge () { log debug "removing $dev from bridge $bridge" 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 else log debug "$dev not on bridge $bridge"