Harald Hoyer 89f6fa
From 2db6d7111870c5d16d812d9cddc23558f3f4a202 Mon Sep 17 00:00:00 2001
Harald Hoyer 89f6fa
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 89f6fa
Date: Fri, 1 Aug 2014 13:16:29 +0200
Harald Hoyer 89f6fa
Subject: [PATCH] fixed bridge setup
Harald Hoyer 89f6fa
Harald Hoyer 89f6fa
renamed "ethnames" in bridge.info to "bridgeslaves"
Harald Hoyer 89f6fa
Harald Hoyer 89f6fa
fixed ifcfg generation
Harald Hoyer 89f6fa
---
Harald Hoyer 89f6fa
 modules.d/40network/ifup.sh         |  4 ++--
Harald Hoyer 89f6fa
 modules.d/40network/net-genrules.sh |  2 +-
Harald Hoyer 89f6fa
 modules.d/40network/parse-bridge.sh | 18 ++++++++--------
Harald Hoyer 89f6fa
 modules.d/45ifcfg/write-ifcfg.sh    | 42 +++++++++----------------------------
Harald Hoyer 89f6fa
 4 files changed, 22 insertions(+), 44 deletions(-)
Harald Hoyer 89f6fa
Harald Hoyer 89f6fa
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
Harald Hoyer 89f6fa
index 349530f..41ea631 100755
Harald Hoyer 89f6fa
--- a/modules.d/40network/ifup.sh
Harald Hoyer 89f6fa
+++ b/modules.d/40network/ifup.sh
Harald Hoyer 89f6fa
@@ -60,7 +60,7 @@ fi
Harald Hoyer 89f6fa
 # bridge this interface?
Harald Hoyer 89f6fa
 if [ -e /tmp/bridge.info ]; then
Harald Hoyer 89f6fa
     . /tmp/bridge.info
Harald Hoyer 89f6fa
-    for ethname in $ethnames ; do
Harald Hoyer 89f6fa
+    for ethname in $bridgeslaves ; do
Harald Hoyer 89f6fa
         if [ "$netif" = "$ethname" ]; then
Harald Hoyer 89f6fa
             if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
Harald Hoyer 89f6fa
                 : # We need to really setup bond (recursive call)
Harald Hoyer 89f6fa
@@ -236,7 +236,7 @@ if [ -e /tmp/bridge.info ]; then
Harald Hoyer 89f6fa
     if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
Harald Hoyer 89f6fa
         brctl addbr $bridgename
Harald Hoyer 89f6fa
         brctl setfd $bridgename 0
Harald Hoyer 89f6fa
-        for ethname in $ethnames ; do
Harald Hoyer 89f6fa
+        for ethname in $bridgeslaves ; do
Harald Hoyer 89f6fa
             if [ "$ethname" = "$bondname" ] ; then
Harald Hoyer 89f6fa
                 DO_BOND_SETUP=yes ifup $bondname -m
Harald Hoyer 89f6fa
             elif [ "$ethname" = "$teammaster" ] ; then
Harald Hoyer 89f6fa
diff --git a/modules.d/40network/net-genrules.sh b/modules.d/40network/net-genrules.sh
Harald Hoyer 89f6fa
index af2f09c..a43e3df 100755
Harald Hoyer 89f6fa
--- a/modules.d/40network/net-genrules.sh
Harald Hoyer 89f6fa
+++ b/modules.d/40network/net-genrules.sh
Harald Hoyer 89f6fa
@@ -16,7 +16,7 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
Harald Hoyer 89f6fa
     # bridge: attempt only the defined interface
Harald Hoyer 89f6fa
     if [ -e /tmp/bridge.info ]; then
Harald Hoyer 89f6fa
         . /tmp/bridge.info
Harald Hoyer 89f6fa
-        IFACES="$IFACES ${ethnames%% *}"
Harald Hoyer 89f6fa
+        IFACES="$IFACES ${bridgeslaves%% *}"
Harald Hoyer 89f6fa
         MASTER_IFACES="$MASTER_IFACES $bridgename"
Harald Hoyer 89f6fa
     fi
Harald Hoyer 89f6fa
 
Harald Hoyer 89f6fa
diff --git a/modules.d/40network/parse-bridge.sh b/modules.d/40network/parse-bridge.sh
Harald Hoyer 89f6fa
index 8c305c0..a910109 100755
Harald Hoyer 89f6fa
--- a/modules.d/40network/parse-bridge.sh
Harald Hoyer 89f6fa
+++ b/modules.d/40network/parse-bridge.sh
Harald Hoyer 89f6fa
@@ -3,9 +3,9 @@
Harald Hoyer 89f6fa
 # ex: ts=8 sw=4 sts=4 et filetype=sh
Harald Hoyer 89f6fa
 #
Harald Hoyer 89f6fa
 # Format:
Harald Hoyer 89f6fa
-#       bridge=<bridgename>:<ethnames>
Harald Hoyer 89f6fa
+#       bridge=<bridgename>:<bridgeslaves>
Harald Hoyer 89f6fa
 #
Harald Hoyer 89f6fa
-#       <ethnames> is a comma-separated list of physical (ethernet) interfaces
Harald Hoyer 89f6fa
+#       <bridgeslaves> is a comma-separated list of physical (ethernet) interfaces
Harald Hoyer 89f6fa
 #       bridge without parameters assumes bridge=br0:eth0
Harald Hoyer 89f6fa
 #
Harald Hoyer 89f6fa
 
Harald Hoyer 89f6fa
@@ -25,20 +25,20 @@ parsebridge() {
Harald Hoyer 89f6fa
         v=${v#*:}
Harald Hoyer 89f6fa
     done
Harald Hoyer 89f6fa
 
Harald Hoyer 89f6fa
-    unset bridgename ethnames
Harald Hoyer 89f6fa
+    unset bridgename bridgeslaves
Harald Hoyer 89f6fa
     case $# in
Harald Hoyer 89f6fa
-        0)  bridgename=br0; ethnames=$iface ;;
Harald Hoyer 89f6fa
+        0)  bridgename=br0; bridgeslaves=$iface ;;
Harald Hoyer 89f6fa
         1)  die "bridge= requires two parameters" ;;
Harald Hoyer 89f6fa
-        2)  bridgename=$1; ethnames=$(str_replace "$2" "," " ") ;;
Harald Hoyer 89f6fa
+        2)  bridgename=$1; bridgeslaves=$(str_replace "$2" "," " ") ;;
Harald Hoyer 89f6fa
         *)  die "bridge= requires two parameters" ;;
Harald Hoyer 89f6fa
     esac
Harald Hoyer 89f6fa
 }
Harald Hoyer 89f6fa
 
Harald Hoyer 89f6fa
-unset bridgename ethnames
Harald Hoyer 89f6fa
+unset bridgename bridgeslaves
Harald Hoyer 89f6fa
 
Harald Hoyer 89f6fa
 iface=eth0
Harald Hoyer 89f6fa
 
Harald Hoyer 89f6fa
-# Parse bridge for bridgename and ethnames
Harald Hoyer 89f6fa
+# Parse bridge for bridgename and bridgeslaves
Harald Hoyer 89f6fa
 if bridge="$(getarg bridge)"; then
Harald Hoyer 89f6fa
     # Read bridge= parameters if they exist
Harald Hoyer 89f6fa
     if [ -n "$bridge" ]; then
Harald Hoyer 89f6fa
@@ -47,9 +47,9 @@ if bridge="$(getarg bridge)"; then
Harald Hoyer 89f6fa
     # Simple default bridge
Harald Hoyer 89f6fa
     if [ -z "$bridgename" ]; then
Harald Hoyer 89f6fa
         bridgename=br0
Harald Hoyer 89f6fa
-        ethnames=$iface
Harald Hoyer 89f6fa
+        bridgeslaves=$iface
Harald Hoyer 89f6fa
     fi
Harald Hoyer 89f6fa
     echo "bridgename=$bridgename" > /tmp/bridge.info
Harald Hoyer 89f6fa
-    echo "ethnames=\"$ethnames\"" >> /tmp/bridge.info
Harald Hoyer 89f6fa
+    echo "bridgeslaves=\"$bridgeslaves\"" >> /tmp/bridge.info
Harald Hoyer 89f6fa
     return
Harald Hoyer 89f6fa
 fi
Harald Hoyer 89f6fa
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
Harald Hoyer 89f6fa
index 7e301de..d920c22 100755
Harald Hoyer 89f6fa
--- a/modules.d/45ifcfg/write-ifcfg.sh
Harald Hoyer 89f6fa
+++ b/modules.d/45ifcfg/write-ifcfg.sh
Harald Hoyer 89f6fa
@@ -214,6 +214,7 @@ for netup in /tmp/net.*.did-setup ; do
Harald Hoyer 89f6fa
                 echo "SLAVE=yes"
Harald Hoyer 89f6fa
                 echo "MASTER=\"$netif\""
Harald Hoyer 89f6fa
                 echo "NAME=\"$slave\""
Harald Hoyer 89f6fa
+                echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
Harald Hoyer 89f6fa
             } >> /tmp/ifcfg/ifcfg-$slave
Harald Hoyer 89f6fa
         done
Harald Hoyer 89f6fa
     fi
Harald Hoyer 89f6fa
@@ -224,44 +225,21 @@ for netup in /tmp/net.*.did-setup ; do
Harald Hoyer 89f6fa
             echo "TYPE=Bridge"
Harald Hoyer 89f6fa
             echo "NAME=\"$netif\""
Harald Hoyer 89f6fa
         } >> /tmp/ifcfg/ifcfg-$netif
Harald Hoyer 89f6fa
-        if [ "$ethname" = "$bondname" ] ; then
Harald Hoyer 89f6fa
-            {
Harald Hoyer 89f6fa
-                echo "# Generated by dracut initrd"
Harald Hoyer 89f6fa
-                echo "DEVICE=\"$bondname\""
Harald Hoyer 89f6fa
-                echo "ONBOOT=yes"
Harald Hoyer 89f6fa
-                echo "NETBOOT=yes"
Harald Hoyer 89f6fa
-                # This variable is an indicator of a bond interface for initscripts
Harald Hoyer 89f6fa
-                echo "BONDING_OPTS=\"$bondoptions\""
Harald Hoyer 89f6fa
-                echo "BRIDGE=\"$netif\""
Harald Hoyer 89f6fa
-                echo "NAME=\"$bondname\""
Harald Hoyer 89f6fa
-            } >> /tmp/ifcfg/ifcfg-$bondname
Harald Hoyer 89f6fa
-            for slave in $bondslaves ; do
Harald Hoyer 89f6fa
-                # write separate ifcfg file for the raw eth interface
Harald Hoyer 89f6fa
-                {
Harald Hoyer 89f6fa
-                    echo "# Generated by dracut initrd"
Harald Hoyer 89f6fa
-                    echo "DEVICE=\"$slave\""
Harald Hoyer 89f6fa
-                    echo "TYPE=Ethernet"
Harald Hoyer 89f6fa
-                    echo "ONBOOT=yes"
Harald Hoyer 89f6fa
-                    echo "NETBOOT=yes"
Harald Hoyer 89f6fa
-                    echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
Harald Hoyer 89f6fa
-                    echo "SLAVE=yes"
Harald Hoyer 89f6fa
-                    echo "MASTER=\"$bondname\""
Harald Hoyer 89f6fa
-                    echo "NAME=\"$slave\""
Harald Hoyer 89f6fa
-                } >> /tmp/ifcfg/ifcfg-$slave
Harald Hoyer 89f6fa
-            done
Harald Hoyer 89f6fa
-        else
Harald Hoyer 89f6fa
+        for slave in $bridgeslaves ; do
Harald Hoyer 89f6fa
             # write separate ifcfg file for the raw eth interface
Harald Hoyer 89f6fa
             {
Harald Hoyer 89f6fa
                 echo "# Generated by dracut initrd"
Harald Hoyer 89f6fa
-                echo "DEVICE=\"$ethname\""
Harald Hoyer 89f6fa
+                echo "DEVICE=\"$slave\""
Harald Hoyer 89f6fa
                 echo "TYPE=Ethernet"
Harald Hoyer 89f6fa
                 echo "ONBOOT=yes"
Harald Hoyer 89f6fa
                 echo "NETBOOT=yes"
Harald Hoyer 89f6fa
-                echo "HWADDR=\"$(cat /sys/class/net/$ethname/address)\""
Harald Hoyer 89f6fa
-                echo "BRIDGE=\"$netif\""
Harald Hoyer 89f6fa
-                echo "NAME=\"$ethname\""
Harald Hoyer 89f6fa
-            } >> /tmp/ifcfg/ifcfg-$ethname
Harald Hoyer 89f6fa
-        fi
Harald Hoyer 89f6fa
+                echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
Harald Hoyer 89f6fa
+                echo "SLAVE=yes"
Harald Hoyer 89f6fa
+                echo "MASTER=\"$bridgename\""
Harald Hoyer 89f6fa
+                echo "NAME=\"$slave\""
Harald Hoyer 89f6fa
+                echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
Harald Hoyer 89f6fa
+            } >> /tmp/ifcfg/ifcfg-$slave
Harald Hoyer 89f6fa
+        done
Harald Hoyer 89f6fa
     fi
Harald Hoyer 89f6fa
     i=1
Harald Hoyer 89f6fa
     for ns in $(getargs nameserver); do