]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
network: support multiple bonding interfaces
authorHarald Hoyer <harald@redhat.com>
Mon, 8 Apr 2013 09:47:49 +0000 (17:47 +0800)
committerHarald Hoyer <harald@redhat.com>
Tue, 9 Apr 2013 08:52:22 +0000 (10:52 +0200)
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
modules.d/40network/net-genrules.sh
modules.d/40network/parse-bond.sh
modules.d/40network/parse-bridge.sh
modules.d/45ifcfg/write-ifcfg.sh

index 815ab64f4edfbb502c4a232c8200d1d1ab007353..593f3879dd78f34d148e04495659570f02cc3b31 100755 (executable)
@@ -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
index f4652b904d274f6627b4fbee95ec61fbf43998a7..05fa5f3bf4b15835226dac6b992968810520e0fd 100755 (executable)
@@ -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
index 983eb3aeb850c3a2b18b26e34b882b5623d3ab38..25c51b89c229616620a1bfecaaf5f36e48b64d97 100755 (executable)
@@ -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
index 1f027bb0d3feb6170ed43e7f97ecb27acfbc0e10..8c305c0f7cc6b7a8279800414d8b104ed5dc4004 100755 (executable)
@@ -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
index f7a476cd3ba9b29e825d15087fbfe53843bed0d5..16da5e485c872b533d427f8f513ff5918f901eb4 100755 (executable)
@@ -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