ethernet_interface: Write the MAC to configuration

u-boot environment support for MAC address configuration is not well
supported for all adapter configurations. Instead of just relying on
this configuration, also set the MAC address in the systemd
configuration. We don't want to get rid of the u-boot configuration
entirely since netboots will want to have the new MAC.

Change-Id: I0db6edfae31dafe394bbcd4802fcd17ba0d7526d
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index a2cd1c8..82f6ae3 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -606,6 +606,14 @@
 
     auto addrs = getAddresses();
 
+    // Write the link section
+    stream << "[Link]\n";
+    auto mac = MacAddressIntf::mACAddress();
+    if (!mac.empty())
+    {
+        stream << "MACAddress=" << mac << "\n";
+    }
+
     // write the network section
     stream << "[Network]\n";
 #ifdef LINK_LOCAL_AUTOCONFIGURATION
@@ -761,16 +769,12 @@
 
         auto interface = interfaceName();
         execute("/sbin/fw_setenv", "fw_setenv", "ethaddr", value.c_str());
-        // TODO: would replace below three calls
-        //      with restarting of systemd-netwokd
+        // TODO: would remove the call below and
+        //      just restart systemd-netwokd
         //      through https://github.com/systemd/systemd/issues/6696
         execute("/sbin/ip", "ip", "link", "set", "dev", interface.c_str(),
                 "down");
-        execute("/sbin/ip", "ip", "link", "set", "dev", interface.c_str(),
-                "address", value.c_str());
-        execute("/sbin/ip", "ip", "link", "set", "dev", interface.c_str(),
-                "up");
-        manager.restartSystemdUnit(networkdService);
+        manager.writeToConfigurationFile();
     }
 
     return value;