network_manager: Reloads should be delayed via timer

Our restarts of systemd waited a short amount of time (3s) prior to
triggering in the past and didn't cause it to reconfigure immediately.
This allowed lan users to queue up a bunch of configuration commands
that would reconfigure the network before it applied.

This patch restores that behavior.

Change-Id: I4c3c589c07528a9d90e6d7e5d3b649688fcf4587
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/network_manager.cpp b/src/network_manager.cpp
index b8fcaab..19e4673 100644
--- a/src/network_manager.cpp
+++ b/src/network_manager.cpp
@@ -35,7 +35,7 @@
 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;
 
@@ -255,6 +255,11 @@
 
 void Manager::reloadConfigs()
 {
+    reloadTimer->restartOnce(reloadTimeout);
+}
+
+void Manager::doReloadConfigs()
+{
     for (auto& hook : reloadPreHooks)
     {
         try
diff --git a/src/network_manager.hpp b/src/network_manager.hpp
index 332971b..f574891 100644
--- a/src/network_manager.hpp
+++ b/src/network_manager.hpp
@@ -125,10 +125,15 @@
     void setFistBootMACOnInterface(
         const std::pair<std::string, std::string>& ethPair);
 
-    /** @brief Tell systemd-network to reload all of the network configurations
+    /** @brief Arms a timer to tell systemd-network to reload all of the network
+     * configurations
      */
     virtual void reloadConfigs();
 
+    /** @brief Tell systemd-network to reload all of the network configurations
+     */
+    void doReloadConfigs();
+
     /** @brief Returns the number of interfaces under this manager.
      *
      * @return the number of interfaces managed by this manager.
diff --git a/src/network_manager_main.cpp b/src/network_manager_main.cpp
index c295996..349c2ea 100644
--- a/src/network_manager_main.cpp
+++ b/src/network_manager_main.cpp
@@ -48,6 +48,7 @@
 
 std::unique_ptr<phosphor::network::Manager> manager = nullptr;
 std::unique_ptr<Timer> refreshObjectTimer = nullptr;
+std::unique_ptr<Timer> reloadTimer = nullptr;
 
 #ifdef SYNC_MAC_FROM_INVENTORY
 std::unique_ptr<sdbusplus::bus::match::match> EthInterfaceMatch = nullptr;
@@ -243,11 +244,22 @@
     }
 }
 
+void reloadNetworkd()
+{
+    if (manager)
+    {
+        log<level::INFO>("Sending networkd reload");
+        manager->doReloadConfigs();
+        log<level::INFO>("Done networkd reload");
+    }
+}
+
 void initializeTimers()
 {
     auto event = sdeventplus::Event::get_default();
     refreshObjectTimer =
         std::make_unique<Timer>(event, std::bind(refreshObjects));
+    reloadTimer = std::make_unique<Timer>(event, std::bind(reloadNetworkd));
 }
 
 } // namespace network
diff --git a/src/types.hpp b/src/types.hpp
index 082d588..69a314d 100644
--- a/src/types.hpp
+++ b/src/types.hpp
@@ -27,12 +27,12 @@
 
 using namespace std::chrono_literals;
 
-// wait for three seconds before restarting the networkd
-constexpr auto restartTimeout = 3s;
+// wait for three seconds before reloading systemd-networkd
+constexpr auto reloadTimeout = 3s;
 
 // refresh the objets after five seconds as network
 // configuration takes 3-4 sec after systemd-networkd restart.
-constexpr auto refreshTimeout = restartTimeout + 7s;
+constexpr auto refreshTimeout = reloadTimeout + 7s;
 
 namespace systemd
 {
diff --git a/test/global_network_objects.cpp b/test/global_network_objects.cpp
index 1aa71b7..0f6550f 100644
--- a/test/global_network_objects.cpp
+++ b/test/global_network_objects.cpp
@@ -11,7 +11,7 @@
 
 std::unique_ptr<MockManager> manager = nullptr;
 std::unique_ptr<Timer> refreshObjectTimer = nullptr;
-std::unique_ptr<Timer> restartTimer = nullptr;
+std::unique_ptr<Timer> reloadTimer = nullptr;
 
 /** @brief refresh the network objects. */
 void refreshObjects()
diff --git a/test/test_rtnetlink.cpp b/test/test_rtnetlink.cpp
index 47ccecf..c6a5f8f 100644
--- a/test/test_rtnetlink.cpp
+++ b/test/test_rtnetlink.cpp
@@ -21,7 +21,6 @@
 sdbusplus::bus::bus bus(sdbusplus::bus::new_default());
 extern std::unique_ptr<MockManager> manager;
 extern std::unique_ptr<Timer> refreshObjectTimer;
-extern std::unique_ptr<Timer> restartTimer;
 EventPtr eventPtr = nullptr;
 
 class TestRtNetlink : public testing::Test