Reduce the number of restarts of systemd-networkd

Start the timer once we get the dbus request and wait for timeout
if we get the dbus request in meanwhile, reset the timer and
wait for timeout.

Listen for ipv6 rtnetlink address also.

Resolves openbmc/openbmc#2227

Change-Id: I3f448e84107826defafb9ada523c1ab08ec1b971
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/network_manager.cpp b/network_manager.cpp
index bb6d204..e9d8ad9 100644
--- a/network_manager.cpp
+++ b/network_manager.cpp
@@ -25,7 +25,8 @@
 namespace network
 {
 
-extern std::unique_ptr<phosphor::network::Timer> refreshTimer;
+extern std::unique_ptr<phosphor::network::Timer> refreshObjectTimer;
+extern std::unique_ptr<phosphor::network::Timer> restartTimer;
 using namespace phosphor::logging;
 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
 
@@ -201,20 +202,24 @@
         intf.second->writeConfigurationFile();
 
     }
-    restartNetwork();
+    restartTimers();
 }
 
-void Manager::restartNetwork()
+void Manager::restartTimers()
 {
     using namespace std::chrono;
-
-    if (refreshTimer && !refreshTimer->isExpired())
+    if (refreshObjectTimer && restartTimer)
     {
-        auto time =  duration_cast<microseconds>(
-                        phosphor::network::networkChangeTimeout);
-        refreshTimer->startTimer(time);
+        // start the restart timer.
+        auto restartTime = duration_cast<microseconds>(
+                phosphor::network::restartTimeout);
+        restartTimer->startTimer(restartTime);
+
+        // start the refresh timer.
+        auto refreshTime =  duration_cast<microseconds>(
+                phosphor::network::refreshTimeout);
+        refreshObjectTimer->startTimer(refreshTime);
     }
-    restartSystemdUnit("systemd-networkd.service");
 }
 
 }//namespace network