Blame 0014-network-support-multiple-bonding-interfaces.patch

Harald Hoyer ab11ed
From d136ca4eeb3d7be2beef210dcf51a18210900844 Mon Sep 17 00:00:00 2001
Harald Hoyer ab11ed
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer ab11ed
Date: Mon, 8 Apr 2013 17:47:49 +0800
Harald Hoyer ab11ed
Subject: [PATCH] network: support multiple bonding interfaces
Harald Hoyer ab11ed
Harald Hoyer ab11ed
Currently dracut only support 1 bond, namyly bond0 by default. However multiple
Harald Hoyer ab11ed
bonds configuration may be needed. For example in kdump, in 1st kernel, more
Harald Hoyer ab11ed
than one bonds may be configured, and bondX other than bond0 is used as output
Harald Hoyer ab11ed
interface to remote host which will store dump core. This patch can solve this
Harald Hoyer ab11ed
problem, to write real bond information to initramfs, 2nd kdump kernel will
Harald Hoyer ab11ed
use it to create the relevant bondX interface.
Harald Hoyer ab11ed
Harald Hoyer ab11ed
Tested-by: Baoquan He <bhe@redhat.com>
Harald Hoyer ab11ed
Signed-off-by: Baoquan He <bhe@redhat.com>
Harald Hoyer ab11ed
---
Harald Hoyer ab11ed
 modules.d/40network/ifup.sh         | 15 ++++++++++-----
Harald Hoyer ab11ed
 modules.d/40network/net-genrules.sh |  9 ++++++---
Harald Hoyer ab11ed
 modules.d/40network/parse-bond.sh   |  6 +++---
Harald Hoyer ab11ed
 modules.d/40network/parse-bridge.sh |  6 ------
Harald Hoyer ab11ed
 modules.d/45ifcfg/write-ifcfg.sh    |  9 +++++----
Harald Hoyer ab11ed
 5 files changed, 24 insertions(+), 21 deletions(-)
Harald Hoyer ab11ed
Harald Hoyer ab11ed
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
Harald Hoyer ab11ed
index 815ab64..593f387 100755
Harald Hoyer ab11ed
--- a/modules.d/40network/ifup.sh
Harald Hoyer ab11ed
+++ b/modules.d/40network/ifup.sh
Harald Hoyer ab11ed
@@ -21,14 +21,18 @@ use_bridge='false'
Harald Hoyer ab11ed
 use_vlan='false'
Harald Hoyer ab11ed
 
Harald Hoyer ab11ed
 # enslave this interface to bond?
Harald Hoyer ab11ed
-if [ -e /tmp/bond.info ]; then
Harald Hoyer ab11ed
-    . /tmp/bond.info
Harald Hoyer ab11ed
+for i in /tmp/bond.*.info; do
Harald Hoyer ab11ed
+    [ -e "$i" ] || continue
Harald Hoyer ab11ed
+    unset bondslaves
Harald Hoyer ab11ed
+    unset bondname
Harald Hoyer ab11ed
+    . "$i"
Harald Hoyer ab11ed
     for slave in $bondslaves ; do
Harald Hoyer ab11ed
         if [ "$netif" = "$slave" ] ; then
Harald Hoyer ab11ed
             netif=$bondname
Harald Hoyer ab11ed
+            break 2
Harald Hoyer ab11ed
         fi
Harald Hoyer ab11ed
     done
Harald Hoyer ab11ed
-fi
Harald Hoyer ab11ed
+done
Harald Hoyer ab11ed
 
Harald Hoyer ab11ed
 if [ -e /tmp/team.info ]; then
Harald Hoyer ab11ed
     . /tmp/team.info
Harald Hoyer ab11ed
@@ -138,11 +142,12 @@ if [ "$netif" = "lo" ] ; then
Harald Hoyer ab11ed
 fi
Harald Hoyer ab11ed
 
Harald Hoyer ab11ed
 # start bond if needed
Harald Hoyer ab11ed
-if [ -e /tmp/bond.info ]; then
Harald Hoyer ab11ed
-    . /tmp/bond.info
Harald Hoyer ab11ed
+if [ -e /tmp/bond.${netif}.info ]; then
Harald Hoyer ab11ed
+    . /tmp/bond.${netif}.info
Harald Hoyer ab11ed
 
Harald Hoyer ab11ed
     if [ "$netif" = "$bondname" ] && [ ! -e /tmp/net.$bondname.up ] ; then # We are master bond device
Harald Hoyer ab11ed
         modprobe bonding
Harald Hoyer ab11ed
+        echo "+$netif" >  /sys/class/net/bonding_masters
Harald Hoyer ab11ed
         ip link set $netif down
Harald Hoyer ab11ed
 
Harald Hoyer ab11ed
         # Stolen from ifup-eth
Harald Hoyer ab11ed
diff --git a/modules.d/40network/net-genrules.sh b/modules.d/40network/net-genrules.sh
Harald Hoyer ab11ed
index f4652b9..05fa5f3 100755
Harald Hoyer ab11ed
--- a/modules.d/40network/net-genrules.sh
Harald Hoyer ab11ed
+++ b/modules.d/40network/net-genrules.sh
Harald Hoyer ab11ed
@@ -28,11 +28,14 @@ fi
Harald Hoyer ab11ed
     fi
Harald Hoyer ab11ed
 
Harald Hoyer ab11ed
     # bond: attempt only the defined interface (override bridge defines)
Harald Hoyer ab11ed
-    if [ -e /tmp/bond.info ]; then
Harald Hoyer ab11ed
-        . /tmp/bond.info
Harald Hoyer ab11ed
+    for i in /tmp/bond.*.info; do
Harald Hoyer ab11ed
+        [ -e "$i" ] || continue
Harald Hoyer ab11ed
+        unset bondslaves
Harald Hoyer ab11ed
+        unset bondname
Harald Hoyer ab11ed
+        . "$i"
Harald Hoyer ab11ed
         # It is enough to fire up only one
Harald Hoyer ab11ed
         IFACES="$IFACES ${bondslaves%% *}"
Harald Hoyer ab11ed
-    fi
Harald Hoyer ab11ed
+    done
Harald Hoyer ab11ed
 
Harald Hoyer ab11ed
     if [ -e /tmp/team.info ]; then
Harald Hoyer ab11ed
         . /tmp/team.info
Harald Hoyer ab11ed
diff --git a/modules.d/40network/parse-bond.sh b/modules.d/40network/parse-bond.sh
Harald Hoyer ab11ed
index 983eb3a..25c51b8 100755
Harald Hoyer ab11ed
--- a/modules.d/40network/parse-bond.sh
Harald Hoyer ab11ed
+++ b/modules.d/40network/parse-bond.sh
Harald Hoyer ab11ed
@@ -54,8 +54,8 @@ if getarg bond >/dev/null; then
Harald Hoyer ab11ed
     fi
Harald Hoyer ab11ed
     # Make it suitable for initscripts export
Harald Hoyer ab11ed
     bondoptions=$(str_replace "$bondoptions" ";" ",")
Harald Hoyer ab11ed
-    echo "bondname=$bondname" > /tmp/bond.info
Harald Hoyer ab11ed
-    echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.info
Harald Hoyer ab11ed
-    echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.info
Harald Hoyer ab11ed
+    echo "bondname=$bondname" > /tmp/bond.${bondname}.info
Harald Hoyer ab11ed
+    echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.${bondname}.info
Harald Hoyer ab11ed
+    echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.${bondname}.info
Harald Hoyer ab11ed
     return
Harald Hoyer ab11ed
 fi
Harald Hoyer ab11ed
diff --git a/modules.d/40network/parse-bridge.sh b/modules.d/40network/parse-bridge.sh
Harald Hoyer ab11ed
index 1f027bb..8c305c0 100755
Harald Hoyer ab11ed
--- a/modules.d/40network/parse-bridge.sh
Harald Hoyer ab11ed
+++ b/modules.d/40network/parse-bridge.sh
Harald Hoyer ab11ed
@@ -37,12 +37,6 @@ parsebridge() {
Harald Hoyer ab11ed
 unset bridgename ethnames
Harald Hoyer ab11ed
 
Harald Hoyer ab11ed
 iface=eth0
Harald Hoyer ab11ed
-if [ -e /tmp/bond.info ]; then
Harald Hoyer ab11ed
-    . /tmp/bond.info
Harald Hoyer ab11ed
-    if [ -n "$bondname" ] ; then
Harald Hoyer ab11ed
-        iface=$bondname
Harald Hoyer ab11ed
-    fi
Harald Hoyer ab11ed
-fi
Harald Hoyer ab11ed
 
Harald Hoyer ab11ed
 # Parse bridge for bridgename and ethnames
Harald Hoyer ab11ed
 if bridge="$(getarg bridge)"; then
Harald Hoyer ab11ed
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
Harald Hoyer ab11ed
index f7a476c..16da5e4 100755
Harald Hoyer ab11ed
--- a/modules.d/45ifcfg/write-ifcfg.sh
Harald Hoyer ab11ed
+++ b/modules.d/45ifcfg/write-ifcfg.sh
Harald Hoyer ab11ed
@@ -9,10 +9,6 @@ udevadm settle --timeout=30
Harald Hoyer ab11ed
 
Harald Hoyer ab11ed
 read IFACES < /tmp/net.ifaces
Harald Hoyer ab11ed
 
Harald Hoyer ab11ed
-if [ -e /tmp/bond.info ]; then
Harald Hoyer ab11ed
-    . /tmp/bond.info
Harald Hoyer ab11ed
-fi
Harald Hoyer ab11ed
-
Harald Hoyer ab11ed
 if [ -e /tmp/bridge.info ]; then
Harald Hoyer ab11ed
     . /tmp/bridge.info
Harald Hoyer ab11ed
 fi
Harald Hoyer ab11ed
@@ -89,6 +85,11 @@ for netif in $IFACES ; do
Harald Hoyer ab11ed
     # bridge?
Harald Hoyer ab11ed
     unset bridge
Harald Hoyer ab11ed
     unset bond
Harald Hoyer ab11ed
+    unset bondslaves
Harald Hoyer ab11ed
+    unset bondname
Harald Hoyer ab11ed
+    unset bondoptions
Harald Hoyer ab11ed
+    [ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info
Harald Hoyer ab11ed
+
Harald Hoyer ab11ed
     uuid=$(cat /proc/sys/kernel/random/uuid)
Harald Hoyer ab11ed
     if [ "$netif" = "$bridgename" ]; then
Harald Hoyer ab11ed
         bridge=yes