]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: improve "monotonic" uptime correction
authorJohn Kemp <kemp@network-services.uoregon.edu>
Fri, 18 Mar 2011 14:52:18 +0000 (17:52 +0300)
committerDenis Ovsienko <infrastation@yandex.ru>
Fri, 18 Mar 2011 14:52:18 +0000 (17:52 +0300)
Older versions of Quagga/Zebra would output a value in MRT table
dump files for "uptime" aka "ORIGINATED" that was a WALL clock
value.  Given that uptime is now internally a bgp_clock MONOTONIC
value, the output in the MRT files is showing up as monotonic.

Note: time of MRT dump is still recorded correctly as a
time() based value, so we haven't lost that value.

Proposal is to correct the uptime output on the vty and in the
MRT files to again display something more akin to WALL time.

* bgp_dump.c: (bgp_dump_routes_func) add conditional correction
* bgp_route.c: (route_vty_out_detail) make correction conditional, move
  variable declaration to beginning of the function

bgpd/bgp_dump.c
bgpd/bgp_route.c

index 8087a403bc6fca9e84c63971c7466c27aafe4d02..edb725a97b353b24961d9869a851e7ae74ab9cf2 100644 (file)
@@ -356,7 +356,11 @@ bgp_dump_routes_func (int afi, int first_run, unsigned int seq)
           stream_putw(obuf, info->peer->table_dump_index);
 
           /* Originated */
+#ifdef HAVE_CLOCK_MONOTONIC
+          stream_putl (obuf, time(NULL) - (bgp_clock() - info->uptime));
+#else
           stream_putl (obuf, info->uptime);
+#endif /* HAVE_CLOCK_MONOTONIC */
 
           /* Dump attribute. */
           /* Skip prefix & AFI/SAFI for MP_NLRI */
index 1cfc451188894f39c9a66707ba5ab79b700c8e46..05c8efc8e22fc01242165ff69d735da3fa4c9148 100644 (file)
@@ -5979,6 +5979,9 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
   char buf1[BUFSIZ];
   struct attr *attr;
   int sockunion_vty_out (struct vty *, union sockunion *);
+#ifdef HAVE_CLOCK_MONOTONIC
+  time_t tbuf;
+#endif
        
   attr = binfo->attr;
 
@@ -6145,8 +6148,12 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
        bgp_damp_info_vty (vty, binfo);
 
       /* Line 7 display Uptime */
-      time_t tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
+#ifdef HAVE_CLOCK_MONOTONIC
+      tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
       vty_out (vty, "      Last update: %s", ctime(&tbuf));
+#else
+      vty_out (vty, "      Last update: %s", ctime(&binfo->uptime));
+#endif /* HAVE_CLOCK_MONOTONIC */
     }
   vty_out (vty, "%s", VTY_NEWLINE);
 }