]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: time: remove recent_relative_time()
authorDavid Lamparter <equinox@opensourcerouting.org>
Tue, 17 Jan 2017 21:46:07 +0000 (22:46 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Mon, 23 Jan 2017 17:26:32 +0000 (18:26 +0100)
Replace with monotime() [which is not cached].

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
bgpd/bgp_packet.c
lib/thread.c
lib/thread.h
ospf6d/ospf6_area.c
ospf6d/ospf6_neighbor.c
ospf6d/ospf6_spf.c
ospfd/ospf_flood.c
ospfd/ospf_lsa.c
ospfd/ospf_nsm.c

index 38470a3c7e9ff6d513da368d55afacd633d6e9b5..b4f5cc1e8e8c6f1e3dbe594ef16e2ab58089c819 100644 (file)
@@ -2153,15 +2153,6 @@ bgp_marker_all_one (struct stream *s, int length)
   return 1;
 }
 
-/* Recent thread time.
-   On same clock base as bgp_clock (MONOTONIC)
-   but can be time of last context switch to bgp_read thread. */
-static time_t
-bgp_recent_clock (void)
-{
-  return recent_relative_time().tv_sec;
-}
-
 /* Starting point of packet process function. */
 int
 bgp_read (struct thread *thread)
@@ -2288,14 +2279,14 @@ bgp_read (struct thread *thread)
       bgp_open_receive (peer, size); /* XXX return value ignored! */
       break;
     case BGP_MSG_UPDATE:
-      peer->readtime = bgp_recent_clock ();
+      peer->readtime = monotime (NULL);
       bgp_update_receive (peer, size);
       break;
     case BGP_MSG_NOTIFY:
       bgp_notify_receive (peer, size);
       break;
     case BGP_MSG_KEEPALIVE:
-      peer->readtime = bgp_recent_clock ();
+      peer->readtime = monotime (NULL);
       bgp_keepalive_receive (peer, size);
       break;
     case BGP_MSG_ROUTE_REFRESH_NEW:
index 64eaae45b9617c26551ba1cf4c55f285a90c8594..711dd3b730b5d3b20f101c2a3e46cd0180832289 100644 (file)
@@ -179,13 +179,6 @@ quagga_monotime (void)
   return tv.tv_sec;
 }
 
-/* Public export of recent_relative_time by value */
-struct timeval
-recent_relative_time (void)
-{
-  return relative_time;
-}
-
 static unsigned int
 cpu_record_hash_key (struct cpu_thread_history *a)
 {
index c22bb4828dbcd78befbbe81825fe07aeed0fa7d6..a28768e50b370cca8baa890ebd3a1f638d93e7e3 100644 (file)
@@ -262,8 +262,6 @@ extern unsigned long thread_consumed_time(RUSAGE_T *after, RUSAGE_T *before,
    be used instead of calling gettimeofday if a recent value is sufficient.
    This is guaranteed to be refreshed before a thread is called. */
 extern struct timeval recent_time;
-/* Similar to recent_time, but a monotonically increasing time value */
-extern struct timeval recent_relative_time (void);
 
 /* only for use in logging functions! */
 extern struct thread *thread_current;
index d9cf97a713abeef542d15f5025449b0dcc00f41f..198526a0eb53c608d92c77c3a3284b8e69d69e73 100644 (file)
@@ -388,7 +388,7 @@ ospf6_area_show (struct vty *vty, struct ospf6_area *oa)
 
   if (oa->ts_spf.tv_sec || oa->ts_spf.tv_usec)
     {
-      result = timeval_elapsed (recent_relative_time (), oa->ts_spf);
+      result = monotime_since(&oa->ts_spf, NULL);
       if (result/TIMER_SECOND_MICRO > 0)
        {
          vty_out (vty, "SPF last executed %ld.%lds ago%s",
index e9bb2493ffc2d4d95c2dd11097464c44364e1178..f8a0d7a317b7f6dd30d73bc5e9c2c4d81100b424 100644 (file)
@@ -633,7 +633,7 @@ ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on)
 {
   char router_id[16];
   char duration[16];
-  struct timeval now, res;
+  struct timeval res;
   char nstate[16];
   char deadtime[16];
   long h, m, s;
@@ -645,13 +645,11 @@ ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on)
   }
 #endif /*HAVE_GETNAMEINFO*/
 
-  quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
-
   /* Dead time */
   h = m = s = 0;
   if (on->inactivity_timer)
     {
-      s = on->inactivity_timer->u.sands.tv_sec - recent_relative_time().tv_sec;
+      s = monotime_until(&on->inactivity_timer->u.sands, NULL) / 1000000LL;
       h = s / 3600;
       s -= h * 3600;
       m = s / 60;
@@ -673,7 +671,7 @@ ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on)
     }
 
   /* Duration */
-  timersub (&now, &on->last_changed, &res);
+  monotime_since(&on->last_changed, &res);
   timerstring (&res, duration, sizeof (duration));
 
   /*
index 04519e7d466009e5f69d781ac2743f920b877448..90144463747592e3ea2dfe865ed0da81884db1bd 100644 (file)
@@ -670,7 +670,6 @@ void
 ospf6_spf_schedule (struct ospf6 *ospf6, unsigned int reason)
 {
   unsigned long delay, elapsed, ht;
-  struct timeval now, result;
 
   ospf6_set_spf_reason(ospf6, reason);
 
@@ -694,11 +693,7 @@ ospf6_spf_schedule (struct ospf6 *ospf6, unsigned int reason)
       return;
     }
 
-  /* XXX Monotic timers: we only care about relative time here. */
-  now = recent_relative_time ();
-  timersub (&now, &ospf6->ts_spf, &result);
-
-  elapsed = (result.tv_sec * 1000) + (result.tv_usec / 1000);
+  elapsed = monotime_since(&ospf6->ts_spf, NULL) / 1000LL;
   ht = ospf6->spf_holdtime * ospf6->spf_hold_multiplier;
 
   if (ht > ospf6->spf_max_holdtime)
index 32dd8e8a9186c47f834921c8bfdd974bf24d0c38..417a7aa8d2750a9c2e31943c6e4f1e3109d536c5 100644 (file)
@@ -970,7 +970,7 @@ ospf_lsa_flush_area (struct ospf_lsa *lsa, struct ospf_area *area)
      more time for the ACK to be received and avoid
      retransmissions */
   lsa->data->ls_age = htons (OSPF_LSA_MAXAGE);
-  lsa->tv_recv = recent_relative_time ();
+  monotime(&lsa->tv_recv);
   lsa->tv_orig = lsa->tv_recv;
   ospf_flood_through_area (area, NULL, lsa);
   ospf_lsa_maxage (area->ospf, lsa);
@@ -983,7 +983,7 @@ ospf_lsa_flush_as (struct ospf *ospf, struct ospf_lsa *lsa)
      more time for the ACK to be received and avoid
      retransmissions */
   lsa->data->ls_age = htons (OSPF_LSA_MAXAGE);
-  lsa->tv_recv = recent_relative_time ();
+  monotime(&lsa->tv_recv);
   lsa->tv_orig = lsa->tv_recv;
   ospf_flood_through_as (ospf, NULL, lsa);
   ospf_lsa_maxage (ospf, lsa);
index 94575d59443d7097699a97bc4e3282f02625bf39..d4811c5b21972858bbbfc702f81b1c96724be53b 100644 (file)
@@ -165,7 +165,7 @@ ospf_lsa_new ()
   new->flags = 0;
   new->lock = 1;
   new->retransmit_counter = 0;
-  new->tv_recv = recent_relative_time ();
+  monotime(&new->tv_recv);
   new->tv_orig = new->tv_recv;
   new->refresh_list = -1;
   
index 17cc1f66c26287f9582c0e8afa812f2cf1fc5fad..ccb82bf8fe57d909e49d0f4969a94fcfb9d0d5d8 100644 (file)
@@ -630,10 +630,10 @@ nsm_notice_state_change (struct ospf_neighbor *nbr, int next_state, int event)
 
   /* Advance in NSM */
   if (next_state > nbr->state)
-    nbr->ts_last_progress = recent_relative_time ();
+    monotime(&nbr->ts_last_progress);
   else /* regression in NSM */
     {
-      nbr->ts_last_regress = recent_relative_time ();
+      monotime(&nbr->ts_last_regress);
       nbr->last_regress_str = ospf_nsm_event_str [event];
     }