dhcp_configuration: Use the correct file for DHCP settings

Now that we are writing settings per interface, we should only look at
settings for that interface itself, not the latest file in the network
directory.

Change-Id: I51910a28cac7fa8b876d4c2c28617023f24ed61a
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/dhcp_configuration.cpp b/src/dhcp_configuration.cpp
index 1e4e999..b818a59 100644
--- a/src/dhcp_configuration.cpp
+++ b/src/dhcp_configuration.cpp
@@ -3,14 +3,10 @@
 #include "config_parser.hpp"
 #include "network_manager.hpp"
 
-#include <sys/stat.h>
-
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/lg2.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
-#include <filesystem>
-
 namespace phosphor
 {
 namespace network
@@ -28,27 +24,8 @@
     Iface(bus, objPath.c_str(), Iface::action::defer_emit),
     parent(parent)
 {
-    config::Parser conf;
-    std::filesystem::directory_entry newest_file;
-    time_t newest_time = 0;
-    for (const auto& dirent : std::filesystem::directory_iterator(
-             parent.get().manager.get().getConfDir()))
-    {
-        struct stat st = {};
-        stat(dirent.path().native().c_str(), &st);
-        if (st.st_mtime > newest_time)
-        {
-            newest_file = dirent;
-            newest_time = st.st_mtime;
-        }
-    }
-    if (newest_file != std::filesystem::directory_entry{})
-    {
-        lg2::info("Using DHCP options from {CFG_FILE}", "CFG_FILE",
-                  newest_file.path().native());
-        conf.setFile(newest_file.path());
-    }
-
+    config::Parser conf(config::pathForIntfConf(
+        parent.get().manager.get().getConfDir(), parent.get().interfaceName()));
     ConfigIntf::domainEnabled(getDHCPProp(conf, type, "UseDomains"), true);
     ConfigIntf::dnsEnabled(getDHCPProp(conf, type, "UseDNS"), true);
     ConfigIntf::ntpEnabled(getDHCPProp(conf, type, "UseNTP"), true);