summaryrefslogtreecommitdiffstats
path: root/0014-network-support-multiple-bonding-interfaces.patch
blob: ff582936c317c8df96f25eff61e8175721fa2063 (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
From d136ca4eeb3d7be2beef210dcf51a18210900844 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Mon, 8 Apr 2013 17:47:49 +0800
Subject: [PATCH] network: support multiple bonding interfaces

Currently dracut only support 1 bond, namyly bond0 by default. However multiple
bonds configuration may be needed. For example in kdump, in 1st kernel, more
than one bonds may be configured, and bondX other than bond0 is used as output
interface to remote host which will store dump core. This patch can solve this
problem, to write real bond information to initramfs, 2nd kdump kernel will
use it to create the relevant bondX interface.

Tested-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Baoquan He <bhe@redhat.com>
---
 modules.d/40network/ifup.sh         | 15 ++++++++++-----
 modules.d/40network/net-genrules.sh |  9 ++++++---
 modules.d/40network/parse-bond.sh   |  6 +++---
 modules.d/40network/parse-bridge.sh |  6 ------
 modules.d/45ifcfg/write-ifcfg.sh    |  9 +++++----
 5 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
index 815ab64..593f387 100755
--- a/modules.d/40network/ifup.sh
+++ b/modules.d/40network/ifup.sh
@@ -21,14 +21,18 @@ use_bridge='false'
 use_vlan='false'
 
 # enslave this interface to bond?
-if [ -e /tmp/bond.info ]; then
-    . /tmp/bond.info
+for i in /tmp/bond.*.info; do
+    [ -e "$i" ] || continue
+    unset bondslaves
+    unset bondname
+    . "$i"
     for slave in $bondslaves ; do
         if [ "$netif" = "$slave" ] ; then
             netif=$bondname
+            break 2
         fi
     done
-fi
+done
 
 if [ -e /tmp/team.info ]; then
     . /tmp/team.info
@@ -138,11 +142,12 @@ if [ "$netif" = "lo" ] ; then
 fi
 
 # start bond if needed
-if [ -e /tmp/bond.info ]; then
-    . /tmp/bond.info
+if [ -e /tmp/bond.${netif}.info ]; then
+    . /tmp/bond.${netif}.info
 
     if [ "$netif" = "$bondname" ] && [ ! -e /tmp/net.$bondname.up ] ; then # We are master bond device
         modprobe bonding
+        echo "+$netif" >  /sys/class/net/bonding_masters
         ip link set $netif down
 
         # Stolen from ifup-eth
diff --git a/modules.d/40network/net-genrules.sh b/modules.d/40network/net-genrules.sh
index f4652b9..05fa5f3 100755
--- a/modules.d/40network/net-genrules.sh
+++ b/modules.d/40network/net-genrules.sh
@@ -28,11 +28,14 @@ fi
     fi
 
     # bond: attempt only the defined interface (override bridge defines)
-    if [ -e /tmp/bond.info ]; then
-        . /tmp/bond.info
+    for i in /tmp/bond.*.info; do
+        [ -e "$i" ] || continue
+        unset bondslaves
+        unset bondname
+        . "$i"
         # It is enough to fire up only one
         IFACES="$IFACES ${bondslaves%% *}"
-    fi
+    done
 
     if [ -e /tmp/team.info ]; then
         . /tmp/team.info
diff --git a/modules.d/40network/parse-bond.sh b/modules.d/40network/parse-bond.sh
index 983eb3a..25c51b8 100755
--- a/modules.d/40network/parse-bond.sh
+++ b/modules.d/40network/parse-bond.sh
@@ -54,8 +54,8 @@ if getarg bond >/dev/null; then
     fi
     # Make it suitable for initscripts export
     bondoptions=$(str_replace "$bondoptions" ";" ",")
-    echo "bondname=$bondname" > /tmp/bond.info
-    echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.info
-    echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.info
+    echo "bondname=$bondname" > /tmp/bond.${bondname}.info
+    echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.${bondname}.info
+    echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.${bondname}.info
     return
 fi
diff --git a/modules.d/40network/parse-bridge.sh b/modules.d/40network/parse-bridge.sh
index 1f027bb..8c305c0 100755
--- a/modules.d/40network/parse-bridge.sh
+++ b/modules.d/40network/parse-bridge.sh
@@ -37,12 +37,6 @@ parsebridge() {
 unset bridgename ethnames
 
 iface=eth0
-if [ -e /tmp/bond.info ]; then
-    . /tmp/bond.info
-    if [ -n "$bondname" ] ; then
-        iface=$bondname
-    fi
-fi
 
 # Parse bridge for bridgename and ethnames
 if bridge="$(getarg bridge)"; then
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
index f7a476c..16da5e4 100755
--- a/modules.d/45ifcfg/write-ifcfg.sh
+++ b/modules.d/45ifcfg/write-ifcfg.sh
@@ -9,10 +9,6 @@ udevadm settle --timeout=30
 
 read IFACES < /tmp/net.ifaces
 
-if [ -e /tmp/bond.info ]; then
-    . /tmp/bond.info
-fi
-
 if [ -e /tmp/bridge.info ]; then
     . /tmp/bridge.info
 fi
@@ -89,6 +85,11 @@ for netif in $IFACES ; do
     # bridge?
     unset bridge
     unset bond
+    unset bondslaves
+    unset bondname
+    unset bondoptions
+    [ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info
+
     uuid=$(cat /proc/sys/kernel/random/uuid)
     if [ "$netif" = "$bridgename" ]; then
         bridge=yes