]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospfd: monotonic clock for lsa_refresher_started
authorDavid Lamparter <equinox@opensourcerouting.org>
Thu, 28 Jul 2016 15:23:36 +0000 (17:23 +0200)
committerDonald Sharp <sharpd@cumulusnetwroks.com>
Thu, 28 Jul 2016 11:27:47 +0000 (07:27 -0400)
ospf->lsa_refresher_started is only used in relative timing to itself;
replace with monotonic clock which is appropriate for this.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/thread.c
lib/thread.h
ospfd/ospf_lsa.c
ospfd/ospfd.c

index a8ccb8b3d0c002393d500c9fe8e4d20dd7852483..717210b950fecc4a254f7abe096a825495a50e84 100644 (file)
@@ -237,6 +237,14 @@ quagga_gettime (enum quagga_clkid clkid, struct timeval *tv)
     }
 }
 
+time_t
+quagga_monotime (void)
+{
+  struct timeval tv;
+  quagga_get_relative(&tv);
+  return tv.tv_sec;
+}
+
 /* time_t value in terms of stabilised absolute time. 
  * replacement for POSIX time()
  */
index 8b42ffe58a201cd19df832eb107a0ca33616473e..ac87595ee41a7358ef57c8b1c6f8c60201e840c3 100644 (file)
@@ -253,6 +253,7 @@ extern struct cmd_element clear_thread_cpu_cmd;
  * all systems, and fully monotonic on /some/ systems.
  */
 extern int quagga_gettime (enum quagga_clkid, struct timeval *);
+extern time_t quagga_monotime (void);
 extern time_t quagga_time (time_t *);
 
 /* Returns elapsed real (wall clock) time. */
index ec0eab5f0a3e11efd877258e6a3fa4f09f906375..7e34e5dd9eb731538bc67e0328a00245c76a7d13 100644 (file)
@@ -3731,7 +3731,7 @@ ospf_refresher_register_lsa (struct ospf *ospf, struct ospf_lsa *lsa)
        */
       delay = (random() % (max_delay - min_delay)) + min_delay;
 
-      current_index = ospf->lsa_refresh_queue.index + (quagga_time (NULL)
+      current_index = ospf->lsa_refresh_queue.index + (quagga_monotime ()
                 - ospf->lsa_refresher_started)/OSPF_LSA_REFRESHER_GRANULARITY;
       
       index = (current_index + delay/OSPF_LSA_REFRESHER_GRANULARITY)
@@ -3795,7 +3795,7 @@ ospf_lsa_refresh_walker (struct thread *t)
      modulus. */
   ospf->lsa_refresh_queue.index =
    ((unsigned long)(ospf->lsa_refresh_queue.index +
-                   (quagga_time (NULL) - ospf->lsa_refresher_started)
+                   (quagga_monotime () - ospf->lsa_refresher_started)
                    / OSPF_LSA_REFRESHER_GRANULARITY))
                    % OSPF_LSA_REFRESHER_SLOTS;
 
@@ -3836,7 +3836,7 @@ ospf_lsa_refresh_walker (struct thread *t)
 
   ospf->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
                                           ospf, ospf->lsa_refresh_interval);
-  ospf->lsa_refresher_started = quagga_time (NULL);
+  ospf->lsa_refresher_started = quagga_monotime ();
 
   for (ALL_LIST_ELEMENTS (lsa_to_refresh, node, nnode, lsa))
     {
index 2034ed1dbda8cf1e9942ee516452fc3d4fe22b8c..2a3f9c1d084e1ed57aadae966a296b697edffebf 100644 (file)
@@ -272,7 +272,7 @@ ospf_new (u_short instance)
   new->lsa_refresh_interval = OSPF_LSA_REFRESH_INTERVAL_DEFAULT;
   new->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
                                           new, new->lsa_refresh_interval);
-  new->lsa_refresher_started = quagga_time (NULL);
+  new->lsa_refresher_started = quagga_monotime ();
 
   if ((new->fd = ospf_sock_init()) < 0)
     {
@@ -1598,7 +1598,7 @@ ospf_timers_refresh_set (struct ospf *ospf, int interval)
     return 1;
 
   time_left = ospf->lsa_refresh_interval -
-    (quagga_time (NULL) - ospf->lsa_refresher_started);
+    (quagga_monotime () - ospf->lsa_refresher_started);
   
   if (time_left > interval)
     {
@@ -1617,7 +1617,7 @@ ospf_timers_refresh_unset (struct ospf *ospf)
   int time_left;
 
   time_left = ospf->lsa_refresh_interval -
-    (quagga_time (NULL) - ospf->lsa_refresher_started);
+    (quagga_monotime () - ospf->lsa_refresher_started);
 
   if (time_left > OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
     {