network_manager: Allow faster non-reconfiguration reloads

The main reason we wait so long for reloads is because we need to be
sure it captures all of the reconfiguration data. Delay the reload timer
around reconfiguration to ensure we can lower the value sanely for
non-reconfiguration reloads.

Change-Id: I9b68d9330ee89e52f5adf364941a39b65eb8a336
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/network_manager.cpp b/src/network_manager.cpp
index 6e7deeb..89925b2 100644
--- a/src/network_manager.cpp
+++ b/src/network_manager.cpp
@@ -35,6 +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;
@@ -268,6 +269,8 @@
 void Manager::reloadConfigs()
 {
     reloadTimer->restartOnce(reloadTimeout);
+    // Ensure that the next refresh happens after reconfiguration
+    refreshObjectTimer->setRemaining(reloadTimeout + refreshTimeout);
 }
 
 void Manager::doReloadConfigs()
@@ -297,6 +300,8 @@
                         entry("ERR=%s", ex.what()));
         elog<InternalFailure>();
     }
+    // Ensure reconfiguration has enough time
+    refreshObjectTimer->setRemaining(refreshTimeout);
 }
 
 } // namespace network
diff --git a/src/types.hpp b/src/types.hpp
index 69a314d..a4173c1 100644
--- a/src/types.hpp
+++ b/src/types.hpp
@@ -30,9 +30,9 @@
 // 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 = reloadTimeout + 7s;
+// refresh the objets after four seconds as network
+// configuration takes 3-4 sec to reconfigure at most.
+constexpr auto refreshTimeout = 4s;
 
 namespace systemd
 {