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_damp.c b/bgpd/bgp_damp.c
index e21131e..ba059f8 100644
--- a/bgpd/bgp_damp.c
+++ b/bgpd/bgp_damp.c
@@ -117,7 +117,7 @@
damp->t_reuse =
thread_add_timer (master, bgp_reuse_timer, NULL, DELTA_REUSE);
- t_now = time (NULL);
+ t_now = bgp_clock ();
/* 1. save a pointer to the current zeroth queue head and zero the
list head entry. */
@@ -181,7 +181,7 @@
struct bgp_damp_info *bdi = NULL;
double last_penalty = 0;
- t_now = time (NULL);
+ t_now = bgp_clock ();
/* Processing Unreachable Messages. */
if (binfo->extra)
@@ -268,7 +268,7 @@
if (!binfo->extra || !((bdi = binfo->extra->damp_info)))
return BGP_DAMP_USED;
- t_now = time (NULL);
+ t_now = bgp_clock ();
bgp_info_unset_flag (rn, binfo, BGP_INFO_HISTORY);
bdi->lastrecord = BGP_RECORD_UPDATE;
@@ -306,7 +306,7 @@
assert (binfo->extra && binfo->extra->damp_info);
- t_now = time (NULL);
+ t_now = bgp_clock ();
bdi = binfo->extra->damp_info;
if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
@@ -597,7 +597,7 @@
return;
/* Calculate new penalty. */
- t_now = time (NULL);
+ t_now = bgp_clock ();
t_diff = t_now - bdi->t_updated;
penalty = bgp_damp_decay (t_diff, bdi->penalty);
@@ -633,7 +633,7 @@
return NULL;
/* Calculate new penalty. */
- t_now = time (NULL);
+ t_now = bgp_clock ();
t_diff = t_now - bdi->t_updated;
penalty = bgp_damp_decay (t_diff, bdi->penalty);