ethernet_interface: Fix u-boot MAC environment variable
Previously, no matter what interface we were changing we would always
set the MAC address for eth0 on the next boot. There is a loose
mapping between ethaddr <-> eth0 and eth1addr <-> eth1 for storing the
MAC address in the u-boot environment.
https://www.denx.de/wiki/view/DULG/UBootEnvVariables
Change-Id: I90f608a876c03e74c32561cf24947cfc44da0e34
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index 82f6ae3..f4f8d57 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -768,7 +768,12 @@
MacAddressIntf::mACAddress(value);
auto interface = interfaceName();
- execute("/sbin/fw_setenv", "fw_setenv", "ethaddr", value.c_str());
+ auto envVar = interfaceToUbootEthAddr(interface.c_str());
+ if (envVar)
+ {
+ execute("/sbin/fw_setenv", "fw_setenv", envVar->c_str(),
+ value.c_str());
+ }
// TODO: would remove the call below and
// just restart systemd-netwokd
// through https://github.com/systemd/systemd/issues/6696