Blame 0034-bonding-use-hwaddr-of-the-slave-rather-than-the-mast.patch

Zbigniew Jędrzejewski-Szmek 7f4a44
From c771f395699e10a534c05bdb790843d74c4898c9 Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 7f4a44
From: Alex Harpin <development@landsofshadow.co.uk>
Zbigniew Jędrzejewski-Szmek 7f4a44
Date: Tue, 6 May 2014 23:41:17 +0100
Zbigniew Jędrzejewski-Szmek 7f4a44
Subject: [PATCH] bonding: use hwaddr of the slave rather than the master
Zbigniew Jędrzejewski-Szmek 7f4a44
Zbigniew Jędrzejewski-Szmek 7f4a44
When a bonded interface is brought up, any slaves included in the bond
Zbigniew Jędrzejewski-Szmek 7f4a44
have their hardware address set to that of the bond master.  Although
Zbigniew Jędrzejewski-Szmek 7f4a44
this allows an interface to be brought up on start up, when the
Zbigniew Jędrzejewski-Szmek 7f4a44
configuration file is imported into the booted system it prevents
Zbigniew Jędrzejewski-Szmek 7f4a44
the bonded interface being successfully restarted.
Zbigniew Jędrzejewski-Szmek 7f4a44
Zbigniew Jędrzejewski-Szmek 7f4a44
The fix involves obtaining the hardware address of the slaves before
Zbigniew Jędrzejewski-Szmek 7f4a44
they are added to the bond and then using this value in the
Zbigniew Jędrzejewski-Szmek 7f4a44
configuration file.
Zbigniew Jędrzejewski-Szmek 7f4a44
---
Zbigniew Jędrzejewski-Szmek 7f4a44
 modules.d/40network/ifup.sh      | 1 +
Zbigniew Jędrzejewski-Szmek 7f4a44
 modules.d/45ifcfg/write-ifcfg.sh | 6 +++++-
Zbigniew Jędrzejewski-Szmek 7f4a44
 2 files changed, 6 insertions(+), 1 deletion(-)
Zbigniew Jędrzejewski-Szmek 7f4a44
Zbigniew Jędrzejewski-Szmek 7f4a44
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
Zbigniew Jędrzejewski-Szmek 7f4a44
index ede018832f..fd84e4cd0f 100755
Zbigniew Jędrzejewski-Szmek 7f4a44
--- a/modules.d/40network/ifup.sh
Zbigniew Jędrzejewski-Szmek 7f4a44
+++ b/modules.d/40network/ifup.sh
Zbigniew Jędrzejewski-Szmek 7f4a44
@@ -188,6 +188,7 @@ if [ -e /tmp/bond.${netif}.info ]; then
Zbigniew Jędrzejewski-Szmek 7f4a44
 
Zbigniew Jędrzejewski-Szmek 7f4a44
         for slave in $bondslaves ; do
Zbigniew Jędrzejewski-Szmek 7f4a44
             ip link set $slave down
Zbigniew Jędrzejewski-Szmek 7f4a44
+            cat /sys/class/net/$slave/address > /tmp/net.${netif}.${slave}.hwaddr
Zbigniew Jędrzejewski-Szmek 7f4a44
             echo "+$slave" > /sys/class/net/$bondname/bonding/slaves
Zbigniew Jędrzejewski-Szmek 7f4a44
             linkup $slave
Zbigniew Jędrzejewski-Szmek 7f4a44
         done
Zbigniew Jędrzejewski-Szmek 7f4a44
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
Zbigniew Jędrzejewski-Szmek 7f4a44
index 7f997a2afd..fb388bcb8e 100755
Zbigniew Jędrzejewski-Szmek 7f4a44
--- a/modules.d/45ifcfg/write-ifcfg.sh
Zbigniew Jędrzejewski-Szmek 7f4a44
+++ b/modules.d/45ifcfg/write-ifcfg.sh
Zbigniew Jędrzejewski-Szmek 7f4a44
@@ -206,7 +206,11 @@ for netup in /tmp/net.*.did-setup ; do
Zbigniew Jędrzejewski-Szmek 7f4a44
                 echo "TYPE=Ethernet"
Zbigniew Jędrzejewski-Szmek 7f4a44
                 echo "ONBOOT=yes"
Zbigniew Jędrzejewski-Szmek 7f4a44
                 echo "NETBOOT=yes"
Zbigniew Jędrzejewski-Szmek 7f4a44
-                echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
Zbigniew Jędrzejewski-Szmek 7f4a44
+                if [ -e /tmp/net.${netif}.${slave}.hwaddr ]; then
Zbigniew Jędrzejewski-Szmek 7f4a44
+                   echo "HWADDR=\"$(cat /tmp/net.${netif}.${slave}.hwaddr)\""
Zbigniew Jędrzejewski-Szmek 7f4a44
+                else
Zbigniew Jędrzejewski-Szmek 7f4a44
+                   echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
Zbigniew Jędrzejewski-Szmek 7f4a44
+                fi
Zbigniew Jędrzejewski-Szmek 7f4a44
                 echo "SLAVE=yes"
Zbigniew Jędrzejewski-Szmek 7f4a44
                 echo "MASTER=\"$netif\""
Zbigniew Jędrzejewski-Szmek 7f4a44
                 echo "NAME=\"$slave\""
Zbigniew Jędrzejewski-Szmek 7f4a44
-- 
Zbigniew Jędrzejewski-Szmek 7f4a44
1.9.3
Zbigniew Jędrzejewski-Szmek 7f4a44