bgp: use monotonic clock for time of day

BGP uses time() to get system time of day; but that value
fluctuates with time adjustments from NTP. This can cause premature
flapping of peer sessions and other failures.

Use the system monotonic clock supported by Quagga thread library
to avoid issue.

See: http://bugzilla.vyatta.com/show_bug.cgi?id=4467

* bgpd/bgp_fsm.c
  * bgp_uptime_reset(): dismiss function
* bgpd/bgpd.c
  * bgp_clock(): new function
* bgpd/bgp_damp.c
  * bgp_reuse_timer(): employ bgp_clock() instead of time(NULL)
  * bgp_damp_withdraw(): idem
  * bgp_damp_update(): idem
  * bgp_damp_scan(): idem
  * bgp_damp_info_vty(): idem
  * bgp_damp_reuse_time_vty(): idem
* bgpd/bgp_fsm.c
  * bgp_routeadv_timer(): idem
  * bgp_stop(): idem
  * bgp_establish(): idem
* bgpd/bgp_packet.c
  * bgp_update_receive(): idem
* bgpd/bgp_route.c
  * bgp_update_rsclient(): idem
  * bgp_update_main(): idem
  * bgp_static_update_rsclient(): idem
  * bgp_static_update_main(): idem
  * bgp_static_update_vpnv4(): idem
  * bgp_aggregate_route(): idem
  * bgp_aggregate_add(): idem
  * bgp_redistribute_add(): idem
* bgpd/bgp_snmp.c
  * bgpPeerTable(): idem
  * bgpTrapEstablished(): idem
  * bgpTrapBackwardTransition(): idem
* bgpd/bgpd.c
  * peer_create(): idem
  * peer_uptime(): idem
  * bgp_master_init(): idem
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index c815f9a..487ebdd 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -305,7 +305,7 @@
 	  "%s [FSM] Timer (routeadv timer expire)",
 	  peer->host);
 
-  peer->synctime = time (NULL);
+  peer->synctime = bgp_clock ();
 
   BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd);
 
@@ -315,13 +315,6 @@
   return 0;
 }
 
-/* Reset bgp update timer */
-static void
-bgp_uptime_reset (struct peer *peer)
-{
-  peer->uptime = time (NULL);
-}
-
 /* BGP Peer Down Cause */
 const char *peer_down_str[] =
 {
@@ -493,17 +486,12 @@
 	}
 
       /* set last reset time */
-      peer->resettime = time (NULL);
-      /* Reset uptime. */
-      bgp_uptime_reset (peer);
+      peer->resettime = peer->uptime = bgp_clock ();
 
 #ifdef HAVE_SNMP
       bgpTrapBackwardTransition (peer);
 #endif /* HAVE_SNMP */
 
-      /* Reset uptime. */
-      bgp_uptime_reset (peer);
-
       /* Reset peer synctime */
       peer->synctime = 0;
     }
@@ -857,7 +845,7 @@
 #endif /* HAVE_SNMP */
 
   /* Reset uptime, send keepalive, send current table. */
-  bgp_uptime_reset (peer);
+  peer->uptime = bgp_clock ();
 
   /* Send route-refresh when ORF is enabled */
   for (afi = AFI_IP ; afi < AFI_MAX ; afi++)