Ensure that the MAC address is saved in u-boot-env
During the full flash update `u-boot-env` is cleaned. The followed MAC
address synchronization leaves this partition untouched because the
actual address is still valid. As a result, we lose this address on the
next power cycle.
This commit makes `phosphor-networkd` saving the new MAC address to
`u-boot-env`, even if it was not changed in fact.
Tested: after the MAC address synchronization is completed `u-boot-env`
always contains the valid MAC address.
Change-Id: I9df6b5ab858145e00f077f2fb65e69ab874f71d5
Signed-off-by: Alexander Filippov <a.filippov@yadro.com>
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index 721cdf9..eddcb7b 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -1006,6 +1006,8 @@
Argument::ARGUMENT_VALUE(value.c_str()));
}
+ auto interface = interfaceName();
+
// We don't need to update the system if the address is unchanged
ether_addr oldMAC = mac_address::fromString(MacAddressIntf::mACAddress());
if (!stdplus::raw::equal(newMAC, oldMAC))
@@ -1017,17 +1019,6 @@
}
MacAddressIntf::mACAddress(value);
- auto interface = interfaceName();
-
-#ifdef HAVE_UBOOT_ENV
- auto envVar = interfaceToUbootEthAddr(interface.c_str());
- if (envVar)
- {
- execute("/sbin/fw_setenv", "fw_setenv", envVar->c_str(),
- value.c_str());
- }
-#endif // HAVE_UBOOT_ENV
-
// TODO: would remove the call below and
// just restart systemd-netwokd
// through https://github.com/systemd/systemd/issues/6696
@@ -1036,6 +1027,15 @@
manager.writeToConfigurationFile();
}
+#ifdef HAVE_UBOOT_ENV
+ // Ensure that the valid address is stored in the u-boot-env
+ auto envVar = interfaceToUbootEthAddr(interface.c_str());
+ if (envVar)
+ {
+ execute("/sbin/fw_setenv", "fw_setenv", envVar->c_str(), value.c_str());
+ }
+#endif // HAVE_UBOOT_ENV
+
return value;
}