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. */
struct bgp_damp_info *bdi = NULL;
double last_penalty = 0;
- t_now = time (NULL);
+ t_now = bgp_clock ();
/* Processing Unreachable Messages. */
if (binfo->extra)
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;
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))
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);
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);
"%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);
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[] =
{
}
/* 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;
}
#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++)
/* Increment packet counter. */
peer->update_in++;
- peer->update_time = time (NULL);
+ peer->update_time = bgp_clock ();
/* Generate BGP event. */
BGP_EVENT_ADD (peer, Receive_UPDATE_message);
/* If the update is implicit withdraw. */
if (ri)
{
- ri->uptime = time (NULL);
+ ri->uptime = bgp_clock ();
/* Same attribute comes in. */
if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)
new->sub_type = sub_type;
new->peer = peer;
new->attr = attr_new;
- new->uptime = time (NULL);
+ new->uptime = bgp_clock ();
/* Update MPLS tag. */
if (safi == SAFI_MPLS_VPN)
/* If the update is implicit withdraw. */
if (ri)
{
- ri->uptime = time (NULL);
+ ri->uptime = bgp_clock ();
/* Same attribute comes in. */
if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
new->sub_type = sub_type;
new->peer = peer;
new->attr = attr_new;
- new->uptime = time (NULL);
+ new->uptime = bgp_clock ();
/* Update MPLS tag. */
if (safi == SAFI_MPLS_VPN)
bgp_info_restore(rn, ri);
bgp_attr_unintern (ri->attr);
ri->attr = attr_new;
- ri->uptime = time (NULL);
+ ri->uptime = bgp_clock ();
/* Process change. */
bgp_process (bgp, rn, afi, safi);
new->peer = bgp->peer_self;
SET_FLAG (new->flags, BGP_INFO_VALID);
new->attr = attr_new;
- new->uptime = time (NULL);
+ new->uptime = bgp_clock ();
/* Register new BGP information. */
bgp_info_add (rn, new);
bgp_aggregate_decrement (bgp, p, ri, afi, safi);
bgp_attr_unintern (ri->attr);
ri->attr = attr_new;
- ri->uptime = time (NULL);
+ ri->uptime = bgp_clock ();
/* Process change. */
bgp_aggregate_increment (bgp, p, ri, afi, safi);
new->peer = bgp->peer_self;
SET_FLAG (new->flags, BGP_INFO_VALID);
new->attr = attr_new;
- new->uptime = time (NULL);
+ new->uptime = bgp_clock ();
/* Aggregate address increment. */
bgp_aggregate_increment (bgp, p, new, afi, safi);
new->peer = bgp->peer_self;
new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP);
SET_FLAG (new->flags, BGP_INFO_VALID);
- new->uptime = time (NULL);
+ new->uptime = bgp_clock ();
new->extra = bgp_info_extra_new();
memcpy (new->extra->tag, tag, 3);
new->peer = bgp->peer_self;
SET_FLAG (new->flags, BGP_INFO_VALID);
new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
- new->uptime = time (NULL);
+ new->uptime = bgp_clock ();
bgp_info_add (rn, new);
bgp_unlock_node (rn);
new->peer = bgp->peer_self;
SET_FLAG (new->flags, BGP_INFO_VALID);
new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
- new->uptime = time (NULL);
+ new->uptime = bgp_clock ();
bgp_info_add (rn, new);
bgp_unlock_node (rn);
bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
bgp_attr_unintern (bi->attr);
bi->attr = new_attr;
- bi->uptime = time (NULL);
+ bi->uptime = bgp_clock ();
/* Process change. */
bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
new->peer = bgp->peer_self;
SET_FLAG (new->flags, BGP_INFO_VALID);
new->attr = new_attr;
- new->uptime = time (NULL);
+ new->uptime = bgp_clock ();
bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
bgp_info_add (bn, new);
if (peer->uptime == 0)
return SNMP_INTEGER (0);
else
- return SNMP_INTEGER (time (NULL) - peer->uptime);
+ return SNMP_INTEGER (bgp_clock () - peer->uptime);
break;
case BGPPEERCONNECTRETRYINTERVAL:
*write_method = write_bgpPeerTable;
if (peer->update_time == 0)
return SNMP_INTEGER (0);
else
- return SNMP_INTEGER (time (NULL) - peer->update_time);
+ return SNMP_INTEGER (bgp_clock () - peer->update_time);
break;
default:
return NULL;
smux_trap (bgp_oid, sizeof bgp_oid / sizeof (oid),
index, IN_ADDR_SIZE,
bgpTrapList, sizeof bgpTrapList / sizeof (struct trap_object),
- bm->start_time - time (NULL), BGPESTABLISHED);
+ bm->start_time - bgp_clock (), BGPESTABLISHED);
}
void
smux_trap (bgp_oid, sizeof bgp_oid / sizeof (oid),
index, IN_ADDR_SIZE,
bgpTrapList, sizeof bgpTrapList / sizeof (struct trap_object),
- bm->start_time - time (NULL), BGPBACKWARDTRANSITION);
+ bm->start_time - bgp_clock (), BGPBACKWARDTRANSITION);
}
void
return 0;
}
\f
+/* 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)
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);
}
/* Get current time. */
- uptime1 = time (NULL);
+ uptime1 = bgp_clock ();
uptime1 -= uptime2;
tm = gmtime (&uptime1);
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 ();
}
\f
/* Prototypes. */
extern void bgp_terminate (void);
extern void bgp_reset (void);
+extern time_t bgp_clock (void);
extern void bgp_zclient_reset (void);
extern int bgp_nexthop_set (union sockunion *, union sockunion *,
struct bgp_nexthop *, struct peer *);