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