diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2010-01-15 16:22:10 +0300 |
---|---|---|
committer | Denis Ovsienko <infrastation@yandex.ru> | 2010-01-15 16:22:10 +0300 |
commit | 65957886bfd0dd9d95360d8b015781fc82cc09be (patch) | |
tree | 71352e214bd59277a50a43779bb2cbafbace6cc3 /bgpd/bgpd.c | |
parent | 2cd754de60210748e61069fed2c9d4086d24c21e (diff) |
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
Diffstat (limited to 'bgpd/bgpd.c')
-rw-r--r-- | bgpd/bgpd.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index cf3a6b42..882fe37c 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -241,6 +241,17 @@ bgp_cluster_id_unset (struct bgp *bgp) return 0; } +/* time_t value that is monotonicly increasing + * and uneffected by adjustments to system clock + */ +time_t bgp_clock (void) +{ + struct timeval tv; + + quagga_gettime(QUAGGA_CLK_MONOTONIC, &tv); + return tv.tv_sec; +} + /* BGP timer configuration. */ int bgp_timers_set (struct bgp *bgp, u_int32_t keepalive, u_int32_t holdtime) @@ -850,11 +861,8 @@ peer_create (union sockunion *su, struct bgp *bgp, as_t local_as, if (afi && safi) peer->afc[afi][safi] = 1; - /* Last read time set */ - peer->readtime = time (NULL); - - /* Last reset time set */ - peer->resettime = time (NULL); + /* Last read and reset time set */ + peer->readtime = peer->resettime = bgp_clock (); /* Default TTL set. */ peer->ttl = (peer_sort (peer) == BGP_PEER_IBGP ? 255 : 1); @@ -4453,7 +4461,7 @@ peer_uptime (time_t uptime2, char *buf, size_t len) } /* Get current time. */ - uptime1 = time (NULL); + uptime1 = bgp_clock (); uptime1 -= uptime2; tm = gmtime (&uptime1); @@ -5145,7 +5153,7 @@ bgp_master_init (void) bm->listen_sockets = list_new (); bm->port = BGP_PORT_DEFAULT; bm->master = thread_master_create (); - bm->start_time = time (NULL); + bm->start_time = bgp_clock (); } |