]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
ifcfg/write-ifcfg.sh: bind bond and bridge interfaces to HW
authorHarald Hoyer <harald@redhat.com>
Fri, 12 Sep 2014 07:48:00 +0000 (09:48 +0200)
committerHarald Hoyer <harald@redhat.com>
Fri, 12 Sep 2014 07:53:20 +0000 (09:53 +0200)
either by s390 SUBCHANNELS or HWADDR, if the interface name is not
persistent.

Previously, this was bound unconditionally with HWADDR.

(cherry picked from commit 80043e21c16db168ad087a162f1fa97cae866c8d)

modules.d/45ifcfg/write-ifcfg.sh

index 48e75a631a202460f60f6a6de00a7eb65588330b..aed3069806a287eccb82f5efe8d1bdb616cc959d 100755 (executable)
@@ -82,6 +82,20 @@ print_s390() {
     return 0
 }
 
+interface_bind() {
+    local netif="$1"
+    local macaddr="$2"
+    if ! print_s390 $netif; then
+        if [ -z "$macaddr" ] && \
+            ! is_persistent_ethernet_name "$netif" && \
+            [ -f /sys/class/net/$netif/addr_assign_type ] && \
+            [ "$(cat /sys/class/net/$netif/addr_assign_type)" = "0" ] && \
+            [ -f /sys/class/net/$netif/address ]; then
+            echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
+        fi
+    fi
+}
+
 for netup in /tmp/net.*.did-setup ; do
     [ -f $netup ] || continue
 
@@ -114,8 +128,7 @@ for netup in /tmp/net.*.did-setup ; do
     if [ "$netif" = "$vlanname" ]; then
         vlan=yes
     fi
-    [ -e /sys/class/net/$netif/address ] && \
-        cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr
+
     {
         echo "# Generated by dracut initrd"
         echo "DEVICE=\"$netif\""
@@ -165,15 +178,7 @@ for netup in /tmp/net.*.did-setup ; do
         # standard interface
         {
             [ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
-            if ! print_s390 $netif; then
-                if [ -z "$macaddr" ] && \
-                    ! is_persistent_ethernet_name "$netif" && \
-                    [ -f /sys/class/net/$netif/addr_assign_type ] && \
-                    [ "$(cat /sys/class/net/$netif/addr_assign_type)" = "0" ] && \
-                    [ -f /sys/class/net/$netif/address ]; then
-                    echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
-                fi
-            fi
+            interface_bind "$netif" "$macaddr"
             echo "TYPE=Ethernet"
             echo "NAME=\"$netif\""
             [ -n "$mtu" ] && echo "MTU=\"$mtu\""
@@ -200,22 +205,20 @@ for netup in /tmp/net.*.did-setup ; do
 
         for slave in $bondslaves ; do
             # write separate ifcfg file for the raw eth interface
-            {
+            (
                 echo "# Generated by dracut initrd"
                 echo "DEVICE=\"$slave\""
                 echo "TYPE=Ethernet"
                 echo "ONBOOT=yes"
                 echo "NETBOOT=yes"
-                if [ -e /tmp/net.${netif}.${slave}.hwaddr ]; then
-                   echo "HWADDR=\"$(cat /tmp/net.${netif}.${slave}.hwaddr)\""
-                else
-                   echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
-                fi
                 echo "SLAVE=yes"
                 echo "MASTER=\"$netif\""
                 echo "NAME=\"$slave\""
                 echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
-            } >> /tmp/ifcfg/ifcfg-$slave
+                [ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
+                [ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
+                interface_bind "$slave" "$macaddr"
+            ) >> /tmp/ifcfg/ifcfg-$slave
         done
     fi
 
@@ -227,17 +230,19 @@ for netup in /tmp/net.*.did-setup ; do
         } >> /tmp/ifcfg/ifcfg-$netif
         for slave in $bridgeslaves ; do
             # write separate ifcfg file for the raw eth interface
-            {
+            (
                 echo "# Generated by dracut initrd"
                 echo "DEVICE=\"$slave\""
                 echo "TYPE=Ethernet"
                 echo "ONBOOT=yes"
                 echo "NETBOOT=yes"
-                echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
                 echo "BRIDGE=\"$bridgename\""
                 echo "NAME=\"$slave\""
                 echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
-            } >> /tmp/ifcfg/ifcfg-$slave
+                [ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
+                [ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
+                interface_bind "$slave" "$macaddr"
+            ) >> /tmp/ifcfg/ifcfg-$slave
         done
     fi
     i=1