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