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

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