DHCP value was not getting updated correctly

This commit fixes
=>Disable zeroconf.
=>Correct the network conf file path in factory reset.
=>Updating the DHCP value correctly.

Resolves openbmc/openbmc#2230
Resolves openbmc/openbmc#2215

Change-Id: I8f87c2afb53cc952755165d34bfb62b8aba80fe5
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index ac138f3..c24a3e8 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -327,11 +327,8 @@
     }
 
     EthernetInterfaceIntf::dHCPEnabled(value);
-    if (value)
-    {
-        writeConfigurationFile();
-        createIPAddressObjects();
-    }
+    writeConfigurationFile();
+    createIPAddressObjects();
 
     return value;
 }
@@ -426,7 +423,14 @@
 
     // write the network section
     stream << "[" << "Network" << "]\n";
-    stream << "LinkLocalAddressing=yes\n";
+
+    // Add the VLAN entry
+    for (const auto& intf: vlanInterfaces)
+    {
+        stream << "VLAN=" << intf.second->EthernetInterface::interfaceName()
+            << "\n";
+    }
+
     // DHCP
     if (dHCPEnabled() == true)
     {
@@ -434,13 +438,9 @@
         // configured as dhcp.
         writeDHCPSection(stream);
         stream.close();
+        restartSystemdUnit("systemd-networkd.service");
         return;
     }
-    // Add the Vlan entry
-    for(const auto& intf: vlanInterfaces)
-    {
-        stream << "VLAN=" << intf.second->EthernetInterface::interfaceName() << "\n";
-    }
 
     // Static
     for (const auto& addr : addrs)
diff --git a/network_manager.cpp b/network_manager.cpp
index dd9a319..b152026 100644
--- a/network_manager.cpp
+++ b/network_manager.cpp
@@ -135,12 +135,13 @@
 
         for (auto& intf : interfaces)
         {
-            std::string filename = networkConfig +
-                                   systemd::config::networkFilePrefix +
-                                   intf.first +
-                                   systemd::config::networkFileSuffix;
+            auto fileName = systemd::config::networkFilePrefix + intf.first +
+                            systemd::config::networkFileSuffix;
 
-            bmc::writeDHCPDefault(filename, intf.first);
+            fs::path  filePath = networkConfig;
+            filePath /= fileName;
+
+            bmc::writeDHCPDefault(filePath.string(), intf.first);
             interfacesMapped = true;
         }