Blame SOURCES/0218-ifcfg-write-ifcfg.sh-bind-bond-and-bridge-interfaces.patch

712866
From efaa5b05dfb3578999c31a1bbbc053706ec89ddb Mon Sep 17 00:00:00 2001
712866
From: Harald Hoyer <harald@redhat.com>
712866
Date: Fri, 12 Sep 2014 09:48:00 +0200
712866
Subject: [PATCH] ifcfg/write-ifcfg.sh: bind bond and bridge interfaces to HW
712866
712866
either by s390 SUBCHANNELS or HWADDR, if the interface name is not
712866
persistent.
712866
712866
Previously, this was bound unconditionally with HWADDR.
712866
712866
(cherry picked from commit 80043e21c16db168ad087a162f1fa97cae866c8d)
712866
---
712866
 modules.d/45ifcfg/write-ifcfg.sh | 47 ++++++++++++++++++++++------------------
712866
 1 file changed, 26 insertions(+), 21 deletions(-)
712866
712866
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
712866
index 48e75a6..aed3069 100755
712866
--- a/modules.d/45ifcfg/write-ifcfg.sh
712866
+++ b/modules.d/45ifcfg/write-ifcfg.sh
712866
@@ -82,6 +82,20 @@ print_s390() {
712866
     return 0
712866
 }
712866
 
712866
+interface_bind() {
712866
+    local netif="$1"
712866
+    local macaddr="$2"
712866
+    if ! print_s390 $netif; then
712866
+        if [ -z "$macaddr" ] && \
712866
+            ! is_persistent_ethernet_name "$netif" && \
712866
+            [ -f /sys/class/net/$netif/addr_assign_type ] && \
712866
+            [ "$(cat /sys/class/net/$netif/addr_assign_type)" = "0" ] && \
712866
+            [ -f /sys/class/net/$netif/address ]; then
712866
+            echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
712866
+        fi
712866
+    fi
712866
+}
712866
+
712866
 for netup in /tmp/net.*.did-setup ; do
712866
     [ -f $netup ] || continue
712866
 
712866
@@ -114,8 +128,7 @@ for netup in /tmp/net.*.did-setup ; do
712866
     if [ "$netif" = "$vlanname" ]; then
712866
         vlan=yes
712866
     fi
712866
-    [ -e /sys/class/net/$netif/address ] && \
712866
-        cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr
712866
+
712866
     {
712866
         echo "# Generated by dracut initrd"
712866
         echo "DEVICE=\"$netif\""
712866
@@ -165,15 +178,7 @@ for netup in /tmp/net.*.did-setup ; do
712866
         # standard interface
712866
         {
712866
             [ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
712866
-            if ! print_s390 $netif; then
712866
-                if [ -z "$macaddr" ] && \
712866
-                    ! is_persistent_ethernet_name "$netif" && \
712866
-                    [ -f /sys/class/net/$netif/addr_assign_type ] && \
712866
-                    [ "$(cat /sys/class/net/$netif/addr_assign_type)" = "0" ] && \
712866
-                    [ -f /sys/class/net/$netif/address ]; then
712866
-                    echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
712866
-                fi
712866
-            fi
712866
+            interface_bind "$netif" "$macaddr"
712866
             echo "TYPE=Ethernet"
712866
             echo "NAME=\"$netif\""
712866
             [ -n "$mtu" ] && echo "MTU=\"$mtu\""
712866
@@ -200,22 +205,20 @@ for netup in /tmp/net.*.did-setup ; do
712866
 
712866
         for slave in $bondslaves ; do
712866
             # write separate ifcfg file for the raw eth interface
712866
-            {
712866
+            (
712866
                 echo "# Generated by dracut initrd"
712866
                 echo "DEVICE=\"$slave\""
712866
                 echo "TYPE=Ethernet"
712866
                 echo "ONBOOT=yes"
712866
                 echo "NETBOOT=yes"
712866
-                if [ -e /tmp/net.${netif}.${slave}.hwaddr ]; then
712866
-                   echo "HWADDR=\"$(cat /tmp/net.${netif}.${slave}.hwaddr)\""
712866
-                else
712866
-                   echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
712866
-                fi
712866
                 echo "SLAVE=yes"
712866
                 echo "MASTER=\"$netif\""
712866
                 echo "NAME=\"$slave\""
712866
                 echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
712866
-            } >> /tmp/ifcfg/ifcfg-$slave
712866
+                [ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
712866
+                [ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
712866
+                interface_bind "$slave" "$macaddr"
712866
+            ) >> /tmp/ifcfg/ifcfg-$slave
712866
         done
712866
     fi
712866
 
712866
@@ -227,17 +230,19 @@ for netup in /tmp/net.*.did-setup ; do
712866
         } >> /tmp/ifcfg/ifcfg-$netif
712866
         for slave in $bridgeslaves ; do
712866
             # write separate ifcfg file for the raw eth interface
712866
-            {
712866
+            (
712866
                 echo "# Generated by dracut initrd"
712866
                 echo "DEVICE=\"$slave\""
712866
                 echo "TYPE=Ethernet"
712866
                 echo "ONBOOT=yes"
712866
                 echo "NETBOOT=yes"
712866
-                echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
712866
                 echo "BRIDGE=\"$bridgename\""
712866
                 echo "NAME=\"$slave\""
712866
                 echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
712866
-            } >> /tmp/ifcfg/ifcfg-$slave
712866
+                [ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
712866
+                [ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
712866
+                interface_bind "$slave" "$macaddr"
712866
+            ) >> /tmp/ifcfg/ifcfg-$slave
712866
         done
712866
     fi
712866
     i=1