config_parser: Reduce number of file reads

This changes focuses on reducing the number of Parser() constructions to
limit the number of duplicate file reads.

Change-Id: I05df943844c70dc6aa729ab744d2d405cbfe2c76
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/network_manager.cpp b/src/network_manager.cpp
index c32c36e..86b8550 100644
--- a/src/network_manager.cpp
+++ b/src/network_manager.cpp
@@ -66,11 +66,7 @@
                 continue;
             }
 
-            auto fileName = systemd::config::networkFilePrefix + interface +
-                            systemd::config::networkFileSuffix;
-
-            fs::path filePath = confDir;
-            filePath /= fileName;
+            fs::path filePath = config::pathForIntfConf(confDir, interface);
 
             // create the interface specific network file
             // if not existing.
@@ -134,18 +130,16 @@
         }
         // normal ethernet interface
         objPath /= interface;
-
-        auto dhcp = getDHCPValue(confDir, interface);
+        config::Parser config(config::pathForIntfConf(confDir, interface));
 
         auto intf = std::make_shared<phosphor::network::EthernetInterface>(
-            bus, objPath.string(), dhcp, *this);
+            bus, objPath.string(), config, getDHCPValue(config), *this);
 
         intf->createIPAddressObjects();
         intf->createStaticNeighborObjects();
-        intf->loadNameServers();
+        intf->loadNameServers(config);
 
-        this->interfaces.emplace(
-            std::make_pair(std::move(interface), std::move(intf)));
+        this->interfaces.emplace(std::move(interface), std::move(intf));
     }
 }