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

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