treewide: Completely remove global refresh

We no longer need any of the global refresh code as we can dynamically
receive all of the updates to network configuration.

Change-Id: Ia8cb3af827c599c17d5df9fdddaf6cdc6546050d
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/dhcp_configuration.cpp b/src/dhcp_configuration.cpp
index 41c364b..d421111 100644
--- a/src/dhcp_configuration.cpp
+++ b/src/dhcp_configuration.cpp
@@ -66,7 +66,7 @@
     auto name = ConfigIntf::sendHostNameEnabled(value);
 
     manager.writeToConfigurationFile();
-    manager.reloadConfigsNoRefresh();
+    manager.reloadConfigs();
 
     return name;
 }
@@ -80,7 +80,7 @@
 
     auto name = ConfigIntf::hostNameEnabled(value);
     manager.writeToConfigurationFile();
-    manager.reloadConfigsNoRefresh();
+    manager.reloadConfigs();
 
     return name;
 }
@@ -94,7 +94,7 @@
 
     auto ntp = ConfigIntf::ntpEnabled(value);
     manager.writeToConfigurationFile();
-    manager.reloadConfigsNoRefresh();
+    manager.reloadConfigs();
 
     return ntp;
 }
@@ -108,7 +108,7 @@
 
     auto dns = ConfigIntf::dnsEnabled(value);
     manager.writeToConfigurationFile();
-    manager.reloadConfigsNoRefresh();
+    manager.reloadConfigs();
 
     return dns;
 }
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index 67dd16b..e836268 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -95,22 +95,6 @@
     EthernetInterfaceIntf::dhcp6(dhcpVal.v6);
     EthernetInterfaceIntf::ipv6AcceptRA(getIPv6AcceptRA(config));
     EthernetInterfaceIntf::nicEnabled(enabled);
-    {
-        const auto& gws = manager.getRouteTable().getDefaultGateway();
-        auto it = gws.find(ifIdx);
-        if (it != gws.end())
-        {
-            EthernetInterfaceIntf::defaultGateway(std::to_string(it->second));
-        }
-    }
-    {
-        const auto& gws = manager.getRouteTable().getDefaultGateway6();
-        auto it = gws.find(ifIdx);
-        if (it != gws.end())
-        {
-            EthernetInterfaceIntf::defaultGateway6(std::to_string(it->second));
-        }
-    }
 
     EthernetInterfaceIntf::ntpServers(
         config.map.getValueStrings("Network", "NTP"));
@@ -194,15 +178,6 @@
     }
 }
 
-void EthernetInterface::createIPAddressObjects()
-{
-    addrs.clear();
-    for (const auto& addr : system::getAddresses({.ifidx = ifIdx}))
-    {
-        manager.addAddress(addr);
-    }
-}
-
 void EthernetInterface::addStaticNeigh(const NeighborInfo& info)
 {
     if (!info.mac || !info.addr)
@@ -225,15 +200,6 @@
     }
 }
 
-void EthernetInterface::createStaticNeighborObjects()
-{
-    staticNeighbors.clear();
-    for (const auto& neighbor : system::getNeighbors({.ifidx = ifIdx}))
-    {
-        manager.addNeighbor(neighbor);
-    }
-}
-
 ObjectPath EthernetInterface::ip(IP::Protocol protType, std::string ipaddress,
                                  uint8_t prefixLength, std::string)
 {
@@ -281,7 +247,7 @@
                                     ifaddr, IP::AddressOrigin::Static));
 
     writeConfigurationFile();
-    manager.reloadConfigsNoRefresh();
+    manager.reloadConfigs();
 
     return it->second->getObjPath();
 }
@@ -324,7 +290,7 @@
                                    lladdr, Neighbor::State::Permanent));
 
     writeConfigurationFile();
-    manager.reloadConfigsNoRefresh();
+    manager.reloadConfigs();
 
     return it->second->getObjPath();
 }
@@ -334,7 +300,7 @@
     if (ipv6AcceptRA() != EthernetInterfaceIntf::ipv6AcceptRA(value))
     {
         writeConfigurationFile();
-        manager.reloadConfigsNoRefresh();
+        manager.reloadConfigs();
     }
     return value;
 }
@@ -344,7 +310,7 @@
     if (dhcp4() != EthernetInterfaceIntf::dhcp4(value))
     {
         writeConfigurationFile();
-        manager.reloadConfigsNoRefresh();
+        manager.reloadConfigs();
     }
     return value;
 }
@@ -354,7 +320,7 @@
     if (dhcp6() != EthernetInterfaceIntf::dhcp6(value))
     {
         writeConfigurationFile();
-        manager.reloadConfigsNoRefresh();
+        manager.reloadConfigs();
     }
     return value;
 }
@@ -376,7 +342,7 @@
     if (old4 != new4 || old6 != new6 || oldra != newra)
     {
         writeConfigurationFile();
-        manager.reloadConfigsNoRefresh();
+        manager.reloadConfigs();
     }
     return value;
 }
@@ -394,27 +360,6 @@
     return ipv6AcceptRA() ? DHCPConf::v6stateless : DHCPConf::none;
 }
 
-bool EthernetInterface::linkUp() const
-{
-    if (ifIdx == 0)
-    {
-        return EthernetInterfaceIntf::linkUp();
-    }
-    return system::intfIsRunning(interfaceName());
-}
-
-size_t EthernetInterface::mtu() const
-{
-    if (ifIdx == 0)
-    {
-        return EthernetInterfaceIntf::mtu();
-    }
-    const auto ifname = interfaceName();
-    return ignoreError("GetMTU", ifname, std::nullopt,
-                       [&] { return system::getMTU(ifname); })
-        .value_or(EthernetInterfaceIntf::mtu());
-}
-
 size_t EthernetInterface::mtu(size_t value)
 {
     const size_t old = EthernetInterfaceIntf::mtu();
@@ -445,7 +390,7 @@
         manager.addReloadPreHook(
             [ifname = interfaceName()]() { system::setNICUp(ifname, false); });
     }
-    manager.reloadConfigsNoRefresh();
+    manager.reloadConfigs();
 
     return value;
 }
@@ -472,7 +417,7 @@
         EthernetInterfaceIntf::staticNameServers(value);
 
         writeConfigurationFile();
-        manager.reloadConfigsNoRefresh();
+        manager.reloadConfigs();
     }
     catch (const InternalFailure& e)
     {
@@ -613,7 +558,7 @@
     config.writeFile(config::pathForIntfDev(manager.getConfDir(), intfName));
 
     writeConfigurationFile();
-    manager.reloadConfigsNoRefresh();
+    manager.reloadConfigs();
 
     return ret;
 }
@@ -625,7 +570,7 @@
         EthernetInterfaceIntf::staticNTPServers(value);
 
         writeConfigurationFile();
-        manager.reloadConfigsNoRefresh();
+        manager.reloadConfigs();
     }
     catch (InternalFailure& e)
     {
@@ -742,18 +687,15 @@
     {
         auto& dhcp = config.map["DHCP"].emplace_back();
         dhcp["ClientIdentifier"].emplace_back("mac");
-        if (manager.getDHCPConf())
-        {
-            const auto& conf = *manager.getDHCPConf();
-            auto dns_enabled = conf.dnsEnabled() ? "true" : "false";
-            dhcp["UseDNS"].emplace_back(dns_enabled);
-            dhcp["UseDomains"].emplace_back(dns_enabled);
-            dhcp["UseNTP"].emplace_back(conf.ntpEnabled() ? "true" : "false");
-            dhcp["UseHostname"].emplace_back(conf.hostNameEnabled() ? "true"
-                                                                    : "false");
-            dhcp["SendHostname"].emplace_back(
-                conf.sendHostNameEnabled() ? "true" : "false");
-        }
+        const auto& conf = manager.getDHCPConf();
+        auto dns_enabled = conf.dnsEnabled() ? "true" : "false";
+        dhcp["UseDNS"].emplace_back(dns_enabled);
+        dhcp["UseDomains"].emplace_back(dns_enabled);
+        dhcp["UseNTP"].emplace_back(conf.ntpEnabled() ? "true" : "false");
+        dhcp["UseHostname"].emplace_back(conf.hostNameEnabled() ? "true"
+                                                                : "false");
+        dhcp["SendHostname"].emplace_back(conf.sendHostNameEnabled() ? "true"
+                                                                     : "false");
     }
     auto path = config::pathForIntfConf(manager.getConfDir(), interfaceName());
     config.writeFile(path);
@@ -811,7 +753,7 @@
             // The MAC and LLADDRs will only update if the NIC is already down
             system::setNICUp(interface, false);
         });
-        manager.reloadConfigsNoRefresh();
+        manager.reloadConfigs();
     }
 
 #ifdef HAVE_UBOOT_ENV
@@ -839,7 +781,7 @@
     addrs.clear();
 
     writeConfigurationFile();
-    manager.reloadConfigsNoRefresh();
+    manager.reloadConfigs();
 }
 
 std::string EthernetInterface::defaultGateway(std::string gateway)
@@ -866,7 +808,7 @@
     EthernetInterfaceIntf::defaultGateway(gateway);
 
     writeConfigurationFile();
-    manager.reloadConfigsNoRefresh();
+    manager.reloadConfigs();
 
     return gateway;
 }
@@ -895,7 +837,7 @@
     EthernetInterfaceIntf::defaultGateway6(gateway);
 
     writeConfigurationFile();
-    manager.reloadConfigsNoRefresh();
+    manager.reloadConfigs();
 
     return gateway;
 }
diff --git a/src/ethernet_interface.hpp b/src/ethernet_interface.hpp
index a2fb409..f29efa2 100644
--- a/src/ethernet_interface.hpp
+++ b/src/ethernet_interface.hpp
@@ -124,16 +124,6 @@
      */
     ObjectPath neighbor(std::string ipAddress, std::string macAddress) override;
 
-    /* @brief creates the dbus object(IPaddres) given in the address list.
-     * @param[in] addrs - address list for which dbus objects needs
-     *                    to create.
-     */
-    void createIPAddressObjects();
-
-    /* @brief creates the dbus object(Neighbor) given in the neighbor list.
-     */
-    void createStaticNeighborObjects();
-
     /** Set value of DHCPEnabled */
     DHCPConf dhcpEnabled() const override;
     DHCPConf dhcpEnabled(DHCPConf value) override;
@@ -155,12 +145,6 @@
         return std::visit([&](auto v) { return dhcpIsEnabled(v); }, addr);
     }
 
-    /** Retrieve Link State */
-    bool linkUp() const override;
-
-    /** Retrieve MTU Size */
-    size_t mtu() const override;
-
     /** Set size of MTU */
     size_t mtu(size_t value) override;
 
diff --git a/src/ipaddress.cpp b/src/ipaddress.cpp
index b3ca3db..560129d 100644
--- a/src/ipaddress.cpp
+++ b/src/ipaddress.cpp
@@ -111,7 +111,7 @@
     }
 
     parent.writeConfigurationFile();
-    parent.manager.reloadConfigsNoRefresh();
+    parent.manager.reloadConfigs();
 }
 
 } // namespace network
diff --git a/src/neighbor.cpp b/src/neighbor.cpp
index 58334b2..0f5140e 100644
--- a/src/neighbor.cpp
+++ b/src/neighbor.cpp
@@ -57,7 +57,7 @@
     }
 
     parent.writeConfigurationFile();
-    parent.manager.reloadConfigsNoRefresh();
+    parent.manager.reloadConfigs();
 }
 
 using sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed;
diff --git a/src/network_manager.cpp b/src/network_manager.cpp
index 2634e11..99bedaa 100644
--- a/src/network_manager.cpp
+++ b/src/network_manager.cpp
@@ -33,7 +33,6 @@
 namespace network
 {
 
-extern std::unique_ptr<Timer> refreshObjectTimer;
 extern std::unique_ptr<Timer> reloadTimer;
 using namespace phosphor::logging;
 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
@@ -46,10 +45,9 @@
     "PropertiesChanged',arg0='org.freedesktop.network1.Link',";
 
 Manager::Manager(sdbusplus::bus_t& bus, const char* objPath,
-                 const fs::path& confDir) :
-    details::VLANCreateIface(bus, objPath,
-                             details::VLANCreateIface::action::defer_emit),
-    bus(bus), objectPath(objPath),
+                 const std::filesystem::path& confDir) :
+    ManagerIface(bus, objPath, ManagerIface::action::defer_emit),
+    bus(bus), objPath(std::string(objPath)), confDir(confDir),
     systemdNetworkdEnabledMatch(
         bus, enabledMatch, [&](sdbusplus::message_t& m) {
             std::string intf;
@@ -82,7 +80,6 @@
             }
         })
 {
-    setConfDir(confDir);
     std::vector<
         std::tuple<int32_t, std::string, sdbusplus::message::object_path>>
         links;
@@ -112,25 +109,29 @@
         rsp.read(val);
         handleAdminState(std::get<std::string>(val), ifidx);
     }
-}
 
-void Manager::setConfDir(const fs::path& dir)
-{
-    confDir = dir;
-
-    if (!fs::exists(confDir))
-    {
-        if (!fs::create_directories(confDir))
-        {
-            log<level::ERR>("Unable to create the network conf dir",
-                            entry("DIR=%s", confDir.c_str()));
-            elog<InternalFailure>();
-        }
-    }
+    std::filesystem::create_directories(confDir);
+    systemConf = std::make_unique<phosphor::network::SystemConfiguration>(
+        bus, (this->objPath / "config").str);
+    dhcpConf = std::make_unique<phosphor::network::dhcp::Configuration>(
+        bus, (this->objPath / "dhcp").str, *this);
 }
 
 void Manager::createInterface(const UndiscoveredInfo& info, bool enabled)
 {
+    if (auto it = interfacesByIdx.find(info.intf.idx);
+        it != interfacesByIdx.end())
+    {
+        it->second->updateInfo(info.intf);
+        if (info.intf.name && *info.intf.name != it->second->interfaceName())
+        {
+            fmt::print(stderr, "Interface name change detected {} -> {}\n",
+                       it->second->interfaceName(), *info.intf.name);
+            fflush(stderr);
+            std::abort();
+        }
+        return;
+    }
     if (!info.intf.name)
     {
         auto msg = fmt::format("Can't create interface without name: {}",
@@ -138,12 +139,25 @@
         log<level::ERR>(msg.c_str(), entry("IFIDX=%u", info.intf.idx));
         return;
     }
-    removeInterface(info.intf);
     config::Parser config(config::pathForIntfConf(confDir, *info.intf.name));
     auto intf = std::make_unique<EthernetInterface>(
-        bus, *this, info.intf, objectPath, config, true, enabled);
-    intf->createIPAddressObjects();
-    intf->createStaticNeighborObjects();
+        bus, *this, info.intf, objPath.str, config, true, enabled);
+    if (info.defgw4)
+    {
+        intf->EthernetInterface::defaultGateway(std::to_string(*info.defgw4));
+    }
+    if (info.defgw6)
+    {
+        intf->EthernetInterface::defaultGateway6(std::to_string(*info.defgw6));
+    }
+    for (const auto& [_, addr] : info.addrs)
+    {
+        intf->addAddr(addr);
+    }
+    for (const auto& [_, neigh] : info.staticNeighs)
+    {
+        intf->addStaticNeigh(neigh);
+    }
     intf->loadNameServers(config);
     intf->loadNTPServers(config);
     auto ptr = intf.get();
@@ -407,39 +421,6 @@
     }
 }
 
-void Manager::createInterfaces()
-{
-    // clear all the interfaces first
-    interfaces.clear();
-    interfacesByIdx.clear();
-    for (auto& info : system::getInterfaces())
-    {
-        addInterface(info);
-    }
-}
-
-void Manager::createChildObjects()
-{
-    routeTable.refresh();
-
-    // creates the ethernet interface dbus object.
-    createInterfaces();
-
-    systemConf.reset(nullptr);
-    dhcpConf.reset(nullptr);
-
-    fs::path objPath = objectPath;
-    objPath /= "config";
-
-    // create the system conf object.
-    systemConf = std::make_unique<phosphor::network::SystemConfiguration>(
-        bus, objPath.string());
-    // create the dhcp conf object.
-    objPath /= "dhcp";
-    dhcpConf = std::make_unique<phosphor::network::dhcp::Configuration>(
-        bus, objPath.string(), *this);
-}
-
 ObjectPath Manager::vlan(std::string interfaceName, uint32_t id)
 {
     if (id == 0 || id >= 4095)
@@ -462,14 +443,12 @@
 
 void Manager::reset()
 {
-    if (fs::is_directory(confDir))
+    for (const auto& dirent : std::filesystem::directory_iterator(confDir))
     {
-        for (const auto& file : fs::directory_iterator(confDir))
-        {
-            fs::remove(file.path());
-        }
+        std::error_code ec;
+        std::filesystem::remove(dirent.path(), ec);
     }
-    log<level::INFO>("Network Factory Reset queued.");
+    log<level::INFO>("Network data purged.");
 }
 
 // Need to merge the below function with the code which writes the
@@ -517,16 +496,9 @@
 
 #endif
 
-void Manager::reloadConfigsNoRefresh()
-{
-    reloadTimer->restartOnce(reloadTimeout);
-}
-
 void Manager::reloadConfigs()
 {
-    reloadConfigsNoRefresh();
-    // Ensure that the next refresh happens after reconfiguration
-    refreshObjectTimer->setRemaining(reloadTimeout + refreshTimeout);
+    reloadTimer->restartOnce(reloadTimeout);
 }
 
 void Manager::doReloadConfigs()
@@ -556,11 +528,6 @@
                         entry("ERR=%s", ex.what()));
         elog<InternalFailure>();
     }
-    // Ensure reconfiguration has enough time
-    if (refreshObjectTimer->isEnabled())
-    {
-        refreshObjectTimer->setRemaining(refreshTimeout);
-    }
 }
 
 void Manager::handleAdminState(std::string_view state, unsigned ifidx)
diff --git a/src/network_manager.hpp b/src/network_manager.hpp
index 74e4fb1..3f7a050 100644
--- a/src/network_manager.hpp
+++ b/src/network_manager.hpp
@@ -11,6 +11,7 @@
 #include <memory>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/bus/match.hpp>
+#include <sdbusplus/message/native_types.hpp>
 #include <string>
 #include <string_view>
 #include <vector>
@@ -21,26 +22,14 @@
 namespace network
 {
 
-using SystemConfPtr = std::unique_ptr<SystemConfiguration>;
-using DHCPConfPtr = std::unique_ptr<dhcp::Configuration>;
-
-namespace fs = std::filesystem;
-namespace details
-{
-
-template <typename T, typename U>
-using ServerObject = typename sdbusplus::server::object_t<T, U>;
-
-using VLANCreateIface = details::ServerObject<
+using ManagerIface = sdbusplus::server::object_t<
     sdbusplus::xyz::openbmc_project::Network::VLAN::server::Create,
     sdbusplus::xyz::openbmc_project::Common::server::FactoryReset>;
 
-} // namespace details
-
 /** @class Manager
  *  @brief OpenBMC network manager implementation.
  */
-class Manager : public details::VLANCreateIface
+class Manager : public ManagerIface
 {
   public:
     Manager(const Manager&) = delete;
@@ -55,7 +44,7 @@
      *  @param[in] confDir - Network Configuration directory path.
      */
     Manager(sdbusplus::bus_t& bus, const char* objPath,
-            const fs::path& confDir);
+            const std::filesystem::path& confDir);
 
     ObjectPath vlan(std::string interfaceName, uint32_t id) override;
 
@@ -79,24 +68,9 @@
     void addDefGw(unsigned ifidx, InAddrAny addr);
     void removeDefGw(unsigned ifidx, InAddrAny addr);
 
-    /** @brief Fetch the interface and the ipaddress details
-     *         from the system and create the ethernet interraces
-     *         dbus object.
-     */
-    virtual void createInterfaces();
-
-    /** @brief create child interface object and the system conf object.
-     */
-    void createChildObjects();
-
-    /** @brief sets the network conf directory.
-     *  @param[in] dirName - Absolute path of the directory.
-     */
-    void setConfDir(const fs::path& dir);
-
     /** @brief gets the network conf directory.
      */
-    inline const fs::path& getConfDir() const
+    inline const auto& getConfDir() const
     {
         return confDir;
     }
@@ -104,17 +78,17 @@
     /** @brief gets the system conf object.
      *
      */
-    inline const SystemConfPtr& getSystemConf()
+    inline auto& getSystemConf()
     {
-        return systemConf;
+        return *systemConf;
     }
 
     /** @brief gets the dhcp conf object.
      *
      */
-    inline const DHCPConfPtr& getDHCPConf()
+    inline auto& getDHCPConf()
     {
-        return dhcpConf;
+        return *dhcpConf;
     }
 
     /** @brief This function gets the MAC address from the VPD and
@@ -134,7 +108,6 @@
     /** @brief Arms a timer to tell systemd-network to reload all of the network
      * configurations
      */
-    virtual void reloadConfigsNoRefresh();
     virtual void reloadConfigs();
 
     /** @brief Tell systemd-network to reload all of the network configurations
@@ -146,15 +119,6 @@
     string_umap<std::unique_ptr<EthernetInterface>> interfaces;
     std::unordered_map<unsigned, EthernetInterface*> interfacesByIdx;
 
-    /** @brief Get the routing table owned by the manager
-     *
-     * @return Routing table reference.
-     */
-    inline const auto& getRouteTable() const
-    {
-        return routeTable;
-    }
-
     /** @brief Adds a hook that runs immediately prior to reloading
      *
      *  @param[in] hook - The hook to execute before reloading
@@ -172,19 +136,16 @@
     void reset() override;
 
     /** @brief Path of Object. */
-    std::string objectPath;
+    sdbusplus::message::object_path objPath;
 
     /** @brief pointer to system conf object. */
-    SystemConfPtr systemConf = nullptr;
+    std::unique_ptr<SystemConfiguration> systemConf = nullptr;
 
     /** @brief pointer to dhcp conf object. */
-    DHCPConfPtr dhcpConf = nullptr;
+    std::unique_ptr<dhcp::Configuration> dhcpConf = nullptr;
 
     /** @brief Network Configuration directory. */
-    fs::path confDir;
-
-    /** @brief The routing table */
-    route::Table routeTable;
+    std::filesystem::path confDir;
 
     /** @brief Map of interface info for undiscovered interfaces */
     struct UndiscoveredInfo
diff --git a/src/network_manager_main.cpp b/src/network_manager_main.cpp
index ffd97df..15bc59f 100644
--- a/src/network_manager_main.cpp
+++ b/src/network_manager_main.cpp
@@ -52,7 +52,6 @@
 {
 
 std::unique_ptr<Manager> manager = nullptr;
-std::unique_ptr<Timer> refreshObjectTimer = nullptr;
 std::unique_ptr<Timer> reloadTimer = nullptr;
 
 #ifdef SYNC_MAC_FROM_INVENTORY
@@ -239,17 +238,6 @@
 
 #endif
 
-/** @brief refresh the network objects. */
-void refreshObjects()
-{
-    if (manager)
-    {
-        log<level::INFO>("Refreshing the objects.");
-        manager->createChildObjects();
-        log<level::INFO>("Refreshing complete.");
-    }
-}
-
 void reloadNetworkd()
 {
     if (manager)
@@ -262,8 +250,6 @@
 
 void initializeTimers(sdeventplus::Event& event)
 {
-    refreshObjectTimer =
-        std::make_unique<Timer>(event, std::bind(refreshObjects));
     reloadTimer = std::make_unique<Timer>(event, std::bind(reloadNetworkd));
 }
 
@@ -301,11 +287,6 @@
     watchEthernetInterface(bus, configJson);
 #endif
 
-    // Trigger the initial object scan
-    // This is intentionally deferred, to ensure that systemd-networkd is
-    // fully configured.
-    refreshObjectTimer->restartOnce(refreshTimeout);
-
     return event.loop();
 }
 
diff --git a/src/rtnetlink_server.cpp b/src/rtnetlink_server.cpp
index ffa123e..a4266b7 100644
--- a/src/rtnetlink_server.cpp
+++ b/src/rtnetlink_server.cpp
@@ -7,20 +7,11 @@
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
 
-#include <memory>
 #include <phosphor-logging/log.hpp>
 #include <stdplus/fd/create.hpp>
 #include <stdplus/fd/ops.hpp>
-#include <string_view>
 
-namespace phosphor
-{
-namespace network
-{
-
-extern std::unique_ptr<Timer> refreshObjectTimer;
-
-namespace netlink
+namespace phosphor::network::netlink
 {
 
 using phosphor::logging::entry;
@@ -122,6 +113,4 @@
     performRequest(NETLINK_ROUTE, RTM_GETNEIGH, NLM_F_DUMP, ndmsg{}, cb);
 }
 
-} // namespace netlink
-} // namespace network
-} // namespace phosphor
+} // namespace phosphor::network::netlink
diff --git a/src/system_queries.cpp b/src/system_queries.cpp
index 894fc09..9a360bd 100644
--- a/src/system_queries.cpp
+++ b/src/system_queries.cpp
@@ -1,8 +1,5 @@
 #include "system_queries.hpp"
 
-#include "netlink.hpp"
-#include "rtnetlink.hpp"
-
 #include <fmt/format.h>
 #include <linux/ethtool.h>
 #include <linux/sockios.h>
@@ -13,10 +10,8 @@
 #include <phosphor-logging/log.hpp>
 #include <stdexcept>
 #include <stdplus/fd/create.hpp>
-#include <stdplus/raw.hpp>
 #include <stdplus/util/cexec.hpp>
 #include <string_view>
-#include <system_error>
 
 namespace phosphor::network::system
 {
@@ -99,17 +94,6 @@
         .value_or(EthInfo{});
 }
 
-bool intfIsRunning(std::string_view ifname)
-{
-    return executeIFReq(ifname, SIOCGIFFLAGS).ifr_flags & IFF_RUNNING;
-}
-
-std::optional<unsigned> getMTU(stdplus::zstring_view ifname)
-{
-    return optionalIFReq(ifname, SIOCGIFMTU, "GMTU",
-                         [](const ifreq& ifr) { return ifr.ifr_mtu; });
-}
-
 void setMTU(std::string_view ifname, unsigned mtu)
 {
     auto ifr = makeIFReq(ifname);
@@ -125,93 +109,4 @@
     getIFSock().ioctl(SIOCSIFFLAGS, &ifr);
 }
 
-bool detail::validateNewAddr(const AddressInfo& info,
-                             const AddressFilter& filter) noexcept
-{
-    if (filter.ifidx != 0 && filter.ifidx != info.ifidx)
-    {
-        return false;
-    }
-    return true;
-}
-
-bool detail::validateNewNeigh(const NeighborInfo& info,
-                              const NeighborFilter& filter) noexcept
-{
-    if (filter.ifidx != 0 && filter.ifidx != info.ifidx)
-    {
-        return false;
-    }
-    return true;
-}
-
-std::vector<InterfaceInfo> getInterfaces()
-{
-    std::vector<InterfaceInfo> ret;
-    auto cb = [&](const nlmsghdr&, std::string_view msg) {
-        try
-        {
-            ret.emplace_back(netlink::intfFromRtm(msg));
-        }
-        catch (const std::exception& e)
-        {
-            auto msg = fmt::format("Failed parsing interface: {}", e.what());
-            log<level::ERR>(msg.c_str());
-        }
-    };
-    ifinfomsg msg{};
-    netlink::performRequest(NETLINK_ROUTE, RTM_GETLINK, NLM_F_DUMP, msg, cb);
-    return ret;
-}
-
-std::vector<AddressInfo> getAddresses(const AddressFilter& filter)
-{
-    std::vector<AddressInfo> ret;
-    auto cb = [&](const nlmsghdr&, std::string_view msg) {
-        try
-        {
-            auto info = netlink::addrFromRtm(msg);
-            if (detail::validateNewAddr(info, filter))
-            {
-                ret.emplace_back(std::move(info));
-            }
-        }
-        catch (const std::exception& e)
-        {
-            auto msg = fmt::format("Failed parsing address for ifidx {}: {}",
-                                   filter.ifidx, e.what());
-            log<level::ERR>(msg.c_str());
-        }
-    };
-    ifaddrmsg msg{};
-    msg.ifa_index = filter.ifidx;
-    netlink::performRequest(NETLINK_ROUTE, RTM_GETADDR, NLM_F_DUMP, msg, cb);
-    return ret;
-}
-
-std::vector<NeighborInfo> getNeighbors(const NeighborFilter& filter)
-{
-    std::vector<NeighborInfo> ret;
-    auto cb = [&](const nlmsghdr&, std::string_view msg) {
-        try
-        {
-            auto info = netlink::neighFromRtm(msg);
-            if (detail::validateNewNeigh(info, filter))
-            {
-                ret.push_back(std::move(info));
-            }
-        }
-        catch (const std::exception& e)
-        {
-            auto msg = fmt::format("Failed parsing neighbor for ifidx {}: {}",
-                                   filter.ifidx, e.what());
-            log<level::ERR>(msg.c_str());
-        }
-    };
-    ndmsg msg{};
-    msg.ndm_ifindex = filter.ifidx;
-    netlink::performRequest(NETLINK_ROUTE, RTM_GETNEIGH, NLM_F_DUMP, msg, cb);
-    return ret;
-}
-
 } // namespace phosphor::network::system
diff --git a/src/system_queries.hpp b/src/system_queries.hpp
index 7785c39..4c187c7 100644
--- a/src/system_queries.hpp
+++ b/src/system_queries.hpp
@@ -1,17 +1,9 @@
 #pragma once
 #include "types.hpp"
 
-#include <net/ethernet.h>
-
 #include <cstdint>
-#include <optional>
-#include <stdplus/zstring.hpp>
 #include <stdplus/zstring_view.hpp>
-#include <string>
 #include <string_view>
-#include <vector>
-
-struct nlmsghdr;
 
 namespace phosphor::network::system
 {
@@ -22,44 +14,8 @@
 };
 EthInfo getEthInfo(stdplus::zstring_view ifname);
 
-bool intfIsRunning(std::string_view ifname);
-
-std::optional<unsigned> getMTU(stdplus::zstring_view ifname);
-
 void setMTU(std::string_view ifname, unsigned mtu);
 
 void setNICUp(std::string_view ifname, bool up);
 
-struct AddressFilter
-{
-    unsigned ifidx = 0;
-};
-
-struct NeighborFilter
-{
-    unsigned ifidx = 0;
-};
-
-namespace detail
-{
-bool validateNewAddr(const AddressInfo& info,
-                     const AddressFilter& filter) noexcept;
-bool validateNewNeigh(const NeighborInfo& info,
-                      const NeighborFilter& filter) noexcept;
-} // namespace detail
-
-/** @brief Get all the interfaces from the system.
- *  @returns list of interface names.
- */
-std::vector<InterfaceInfo> getInterfaces();
-
-/** @brief Get all the addreses from the system.
- *  @returns list of addresses
- */
-std::vector<AddressInfo> getAddresses(const AddressFilter& filter);
-
-/** @brief Returns a list of system neighbor table
- */
-std::vector<NeighborInfo> getNeighbors(const NeighborFilter& filter);
-
 } // namespace phosphor::network::system
diff --git a/src/types.hpp b/src/types.hpp
index 709874c..badc977 100644
--- a/src/types.hpp
+++ b/src/types.hpp
@@ -42,10 +42,6 @@
 // wait for three seconds before reloading systemd-networkd
 constexpr auto reloadTimeout = 3s;
 
-// refresh the objets after four seconds as network
-// configuration takes 3-4 sec to reconfigure at most.
-constexpr auto refreshTimeout = 4s;
-
 // Byte representations for common address types in network byte order
 using InAddrAny = std::variant<in_addr, in6_addr>;
 class IfAddr