summaryrefslogtreecommitdiff
path: root/replace-obsolete-network-configuration-commands-in-s.patch
blob: 58e4c5a7c0f9986e4b110efb983e5062f599e649 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
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.13.0-testing/README
===================================================================
--- xen-4.13.0-testing.orig/README
+++ xen-4.13.0-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
     * GNU gettext
     * ACPI ASL compiler (iasl)
Index: xen-4.13.0-testing/tools/hotplug/Linux/colo-proxy-setup
===================================================================
--- xen-4.13.0-testing.orig/tools/hotplug/Linux/colo-proxy-setup
+++ xen-4.13.0-testing/tools/hotplug/Linux/colo-proxy-setup
@@ -76,10 +76,16 @@ function teardown_primary()
 
 function setup_secondary()
 {
-    do_without_error brctl delif $bridge $vifname
-    do_without_error brctl addbr $forwardbr
-    do_without_error brctl addif $forwardbr $vifname
-    do_without_error brctl addif $forwardbr $forwarddev
+    if [ "$legacy_tools" ]; then
+        do_without_error brctl delif $bridge $vifname
+        do_without_error brctl addbr $forwardbr
+        do_without_error brctl addif $forwardbr $vifname
+        do_without_error brctl addif $forwardbr $forwarddev
+    else
+        do_without_error ip link add "$forwardbr" type bridge
+        do_without_error ip link set "$vifname" master "$forwardbr"
+        do_without_error ip link set "$forwarddev" master "$forwardbr"
+    fi
     do_without_error ip link set dev $forwardbr up
     do_without_error modprobe xt_SECCOLO
 
@@ -91,10 +97,16 @@ function setup_secondary()
 
 function teardown_secondary()
 {
-    do_without_error brctl delif $forwardbr $forwarddev
-    do_without_error brctl delif $forwardbr $vifname
-    do_without_error brctl delbr $forwardbr
-    do_without_error brctl addif $bridge $vifname
+    if [ "$legacy_tools" ]; then
+        do_without_error brctl delif $forwardbr $forwarddev
+        do_without_error brctl delif $forwardbr $vifname
+        do_without_error brctl delbr $forwardbr
+        do_without_error brctl addif $bridge $vifname
+    else
+        do_without_error ip link set "$forwarddev" nomaster
+        do_without_error ip link set "$vifname" master "$bridge"
+        do_without_error ip link del "$forwardbr"
+    fi
 
     do_without_error iptables -t mangle -D PREROUTING -m physdev --physdev-in \
         $vifname -j SECCOLO --index $index
Index: xen-4.13.0-testing/tools/hotplug/Linux/remus-netbuf-setup
===================================================================
--- xen-4.13.0-testing.orig/tools/hotplug/Linux/remus-netbuf-setup
+++ xen-4.13.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.13.0-testing/tools/hotplug/Linux/vif-bridge
===================================================================
--- xen-4.13.0-testing.orig/tools/hotplug/Linux/vif-bridge
+++ xen-4.13.0-testing/tools/hotplug/Linux/vif-bridge
@@ -40,7 +40,12 @@ bridge=$(xenstore_read_default "$XENBUS_
 
 if [ -z "$bridge" ]
 then
-  bridge=$(brctl show | awk 'NR==2{print$1}')
+  if [ "$legacy_tools" ]; then
+      bridge=$(brctl show | awk 'NR==2{print$1}')
+  else
+      bridge=$(ip --oneline link show type bridge | awk '(NR == 1) { print $2; }')
+      bridge="${bridge%:}"
+  fi
 
   if [ -z "$bridge" ]
   then
@@ -89,8 +94,13 @@ case "$command" in
         ;;
 
     offline)
-        do_without_error brctl delif "$bridge" "$dev"
-        do_without_error ifconfig "$dev" down
+        if [ "$legacy_tools" ]; 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
         ;;
 
     add)
Index: xen-4.13.0-testing/tools/hotplug/Linux/vif-nat
===================================================================
--- xen-4.13.0-testing.orig/tools/hotplug/Linux/vif-nat
+++ xen-4.13.0-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.13.0-testing/tools/hotplug/Linux/vif-route
===================================================================
--- xen-4.13.0-testing.orig/tools/hotplug/Linux/vif-route
+++ xen-4.13.0-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.13.0-testing/tools/hotplug/Linux/vif2
===================================================================
--- xen-4.13.0-testing.orig/tools/hotplug/Linux/vif2
+++ xen-4.13.0-testing/tools/hotplug/Linux/vif2
@@ -7,13 +7,22 @@ dir=$(dirname "$0")
 bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge")
 if [ -z "$bridge" ]
     then
-    nr_bridges=$(($(brctl show | cut -f 1 | grep -v "^$" | wc -l) - 1))
+    if [ "$legacy_tools" ]; then
+        nr_bridges=$(($(brctl show | cut -f 1 | grep -v "^$" | wc -l) - 1))
+    else
+        nr_bridges=$(ip --oneline link show type bridge | wc -l)
+    fi
     if [ "$nr_bridges" != 1 ]
 	then
 	fatal "no bridge specified, and don't know which one to use ($nr_bridges found)"
     fi
-    bridge=$(brctl show | cut -d "
+    if [ "$legacy_tools" ]; then
+        bridge=$(brctl show | cut -d "
 " -f 2 | cut -f 1)
+    else
+        bridge=$(ip --oneline link show type bridge | head -1 | cut -d ' ' -f2)
+        bridge="${bridge%:}"
+    fi
 fi
 
 command="$1"
Index: xen-4.13.0-testing/tools/hotplug/Linux/xen-network-common.sh
===================================================================
--- xen-4.13.0-testing.orig/tools/hotplug/Linux/xen-network-common.sh
+++ xen-4.13.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.
@@ -111,9 +117,13 @@ create_bridge () {
 
     # Don't create the bridge if it already exists.
     if [ ! -e "/sys/class/net/${bridge}/bridge" ]; then
-	brctl addbr ${bridge}
-	brctl stp ${bridge} off
-	brctl setfd ${bridge} 0
+        if [ "$legacy_tools" ]; then
+            brctl addbr ${bridge}
+            brctl stp ${bridge} off
+            brctl setfd ${bridge} 0
+        else
+            ip link add "$bridge" type bridge stp_state 0 forward_delay 0
+        fi
     fi
 }
 
@@ -127,7 +137,11 @@ add_to_bridge () {
 	ip link set dev ${dev} up || true
 	return
     fi
-    brctl addif ${bridge} ${dev}
+    if [ "$legacy_tools" ]; then
+        brctl addif ${bridge} ${dev}
+    else
+        ip link set "$dev" master "$bridge"
+    fi
     ip link set dev ${dev} up
 }