diff options
author | Jafar Al-Gharaibeh <jafar@atcorp.com> | 2022-08-24 18:25:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 18:25:16 +0200 |
commit | 8783ed4bb434a6c229408acd6ca3def7b6b1cd73 (patch) | |
tree | 7b6818d351f397b126381ecf6fbf381f6c2aafa7 | |
parent | Merge pull request #11856 from opensourcerouting/fix/revert_clist_internet (diff) | |
parent | ripd: Use a sequence number instead of time (diff) | |
download | frr-8783ed4bb434a6c229408acd6ca3def7b6b1cd73.tar.xz frr-8783ed4bb434a6c229408acd6ca3def7b6b1cd73.zip |
Merge pull request #11829 from donaldsharp/time_32_bits
Time 32 bits
-rw-r--r-- | babeld/kernel.c | 4 | ||||
-rw-r--r-- | babeld/kernel.h | 2 | ||||
-rw-r--r-- | bgpd/bgp_advertise.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_damp.c | 10 | ||||
-rw-r--r-- | bgpd/bgp_dump.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_evpn.c | 8 | ||||
-rw-r--r-- | bgpd/bgp_evpn_mh.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_fsm.c | 10 | ||||
-rw-r--r-- | bgpd/bgp_io.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_mplsvpn.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_nexthop.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_nht.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_packet.c | 10 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 12 | ||||
-rw-r--r-- | bgpd/bgp_snmp.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_updgrp.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 10 | ||||
-rw-r--r-- | bgpd/bgpd.c | 17 | ||||
-rw-r--r-- | bgpd/bgpd.h | 3 | ||||
-rw-r--r-- | bgpd/rfapi/bgp_rfapi_cfg.c | 2 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi.c | 11 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi_import.c | 2 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi_private.h | 5 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi_rib.c | 22 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi_vty.c | 2 | ||||
-rw-r--r-- | pimd/mtracebis_netlink.c | 2 | ||||
-rw-r--r-- | ripd/ripd.c | 3 | ||||
-rw-r--r-- | zebra/zserv.c | 12 | ||||
-rw-r--r-- | zebra/zserv.h | 10 |
29 files changed, 87 insertions, 96 deletions
diff --git a/babeld/kernel.c b/babeld/kernel.c index 3941db8d5..5aa01ceb4 100644 --- a/babeld/kernel.c +++ b/babeld/kernel.c @@ -227,10 +227,10 @@ if_eui64(int ifindex, unsigned char *eui) /* Like gettimeofday, but returns monotonic time. If POSIX clocks are not available, falls back to gettimeofday but enforces monotonicity. */ -int +void gettime(struct timeval *tv) { - return monotime(tv); + monotime(tv); } /* If /dev/urandom doesn't exist, this will fail with ENOENT, which the diff --git a/babeld/kernel.h b/babeld/kernel.h index 5b1437ef3..f39bc35bd 100644 --- a/babeld/kernel.h +++ b/babeld/kernel.h @@ -43,7 +43,7 @@ int kernel_route(enum babel_kernel_routes operation, const unsigned char *dest, unsigned int metric, const unsigned char *newgate, int newifindex, unsigned int newmetric); int if_eui64(int ifindex, unsigned char *eui); -int gettime(struct timeval *tv); +void gettime(struct timeval *tv); int read_random_bytes(void *buf, size_t len); #endif /* BABEL_KERNEL_H */ diff --git a/bgpd/bgp_advertise.c b/bgpd/bgp_advertise.c index cfbb29df1..f62a54b03 100644 --- a/bgpd/bgp_advertise.c +++ b/bgpd/bgp_advertise.c @@ -197,7 +197,7 @@ void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer, struct attr *attr, adj = XCALLOC(MTYPE_BGP_ADJ_IN, sizeof(struct bgp_adj_in)); adj->peer = peer_lock(peer); /* adj_in peer reference */ adj->attr = bgp_attr_intern(attr); - adj->uptime = bgp_clock(); + adj->uptime = monotime(NULL); adj->addpath_rx_id = addpath_id; BGP_ADJ_IN_ADD(dest, adj); bgp_dest_lock_node(dest); diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index 9acbaf773..664619078 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -125,7 +125,7 @@ static void bgp_reuse_timer(struct thread *t) thread_add_timer(bm->master, bgp_reuse_timer, bdc, DELTA_REUSE, &bdc->t_reuse); - t_now = bgp_clock(); + t_now = monotime(NULL); /* 1. save a pointer to the current zeroth queue head and zero the list head entry. */ @@ -189,7 +189,7 @@ int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_dest *dest, unsigned int last_penalty = 0; struct bgp_damp_config *bdc = &damp[afi][safi]; - t_now = bgp_clock(); + t_now = monotime(NULL); /* Processing Unreachable Messages. */ if (path->extra) @@ -273,7 +273,7 @@ int bgp_damp_update(struct bgp_path_info *path, struct bgp_dest *dest, if (!path->extra || !((bdi = path->extra->damp_info))) return BGP_DAMP_USED; - t_now = bgp_clock(); + t_now = monotime(NULL); bgp_path_info_unset_flag(dest, path, BGP_PATH_HISTORY); bdi->lastrecord = BGP_RECORD_UPDATE; @@ -588,7 +588,7 @@ void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *path, afi_t afi, return; /* Calculate new penalty. */ - t_now = bgp_clock(); + t_now = monotime(NULL); t_diff = t_now - bdi->t_updated; penalty = bgp_damp_decay(t_diff, bdi->penalty, bdc); @@ -642,7 +642,7 @@ const char *bgp_damp_reuse_time_vty(struct vty *vty, struct bgp_path_info *path, return NULL; /* Calculate new penalty. */ - t_now = bgp_clock(); + t_now = monotime(NULL); t_diff = t_now - bdi->t_updated; penalty = bgp_damp_decay(t_diff, bdi->penalty, bdc); diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index 720925b20..9f6434164 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -367,7 +367,7 @@ bgp_dump_route_node_record(int afi, struct bgp_dest *dest, stream_putw(obuf, path->peer->table_dump_index); /* Originated */ - stream_putl(obuf, time(NULL) - (bgp_clock() - path->uptime)); + stream_putl(obuf, time(NULL) - (monotime(NULL) - path->uptime)); /*Path Identifier*/ if (addpath_capable) { diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 0642c966e..23b330c15 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -1263,7 +1263,7 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_evpn, /* Unintern existing, set to new. */ bgp_attr_unintern(&tmp_pi->attr); tmp_pi->attr = attr_new; - tmp_pi->uptime = bgp_clock(); + tmp_pi->uptime = monotime(NULL); } } return 0; @@ -1626,7 +1626,7 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, /* Unintern existing, set to new. */ bgp_attr_unintern(&tmp_pi->attr); tmp_pi->attr = attr_new; - tmp_pi->uptime = bgp_clock(); + tmp_pi->uptime = monotime(NULL); } } @@ -2520,7 +2520,7 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf, /* Unintern existing, set to new. */ bgp_attr_unintern(&pi->attr); pi->attr = attr_new; - pi->uptime = bgp_clock(); + pi->uptime = monotime(NULL); } /* Gateway IP nexthop should be resolved */ @@ -2643,7 +2643,7 @@ static int install_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, /* Unintern existing, set to new. */ bgp_attr_unintern(&pi->attr); pi->attr = attr_new; - pi->uptime = bgp_clock(); + pi->uptime = monotime(NULL); } /* Add this route to remote IP hashtable */ diff --git a/bgpd/bgp_evpn_mh.c b/bgpd/bgp_evpn_mh.c index 3f801f7ea..95a0c31b5 100644 --- a/bgpd/bgp_evpn_mh.c +++ b/bgpd/bgp_evpn_mh.c @@ -233,7 +233,7 @@ static int bgp_evpn_es_route_install(struct bgp *bgp, /* Unintern existing, set to new. */ bgp_attr_unintern(&pi->attr); pi->attr = attr_new; - pi->uptime = bgp_clock(); + pi->uptime = monotime(NULL); } /* Perform route selection and update zebra, if required. */ @@ -432,7 +432,7 @@ int bgp_evpn_mh_route_update(struct bgp *bgp, struct bgp_evpn_es *es, /* Unintern existing, set to new. */ bgp_attr_unintern(&tmp_pi->attr); tmp_pi->attr = attr_new; - tmp_pi->uptime = bgp_clock(); + tmp_pi->uptime = monotime(NULL); } } diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index b570c84d8..7b9655591 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -574,7 +574,7 @@ void bgp_routeadv_timer(struct thread *thread) zlog_debug("%s [FSM] Timer (routeadv timer expire)", peer->host); - peer->synctime = bgp_clock(); + peer->synctime = monotime(NULL); thread_add_timer_msec(bm->master, bgp_generate_updgrp_packets, peer, 0, &peer->t_generate_updgrp_packets); @@ -975,7 +975,7 @@ void bgp_start_routeadv(struct bgp *bgp) */ void bgp_adjust_routeadv(struct peer *peer) { - time_t nowtime = bgp_clock(); + time_t nowtime = monotime(NULL); double diff; unsigned long remain; @@ -987,7 +987,7 @@ void bgp_adjust_routeadv(struct peer *peer) */ THREAD_OFF(peer->t_routeadv); - peer->synctime = bgp_clock(); + peer->synctime = monotime(NULL); /* If suppress fib pending is enabled, route is advertised to * peers when the status is received from the FIB. The delay * is added to update group packet generate which will allow @@ -1471,7 +1471,7 @@ int bgp_stop(struct peer *peer) } /* set last reset time */ - peer->resettime = peer->uptime = bgp_clock(); + peer->resettime = peer->uptime = monotime(NULL); if (BGP_DEBUG(update_groups, UPDATE_GROUPS)) zlog_debug("%s remove from all update group", @@ -2220,7 +2220,7 @@ static int bgp_establish(struct peer *peer) if (!peer->v_holdtime) bgp_keepalives_on(peer); - peer->uptime = bgp_clock(); + peer->uptime = monotime(NULL); /* Send route-refresh when ORF is enabled. * Stop Long-lived Graceful Restart timers. diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c index aba28fa50..7af1fae28 100644 --- a/bgpd/bgp_io.c +++ b/bgpd/bgp_io.c @@ -431,7 +431,7 @@ static uint16_t bgp_write(struct peer *peer) } done : { - now = bgp_clock(); + now = monotime(NULL); /* * Update last_update if UPDATEs were written. * Note: that these are only updated at end, diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 7b8f0df2e..e99c2ba66 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -925,7 +925,7 @@ leak_update(struct bgp *to_bgp, struct bgp_dest *bn, bgp_aggregate_decrement(to_bgp, p, bpi, afi, safi); bgp_attr_unintern(&bpi->attr); bpi->attr = new_attr; - bpi->uptime = bgp_clock(); + bpi->uptime = monotime(NULL); /* * rewrite labels diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index e1fcc743e..d42f2e669 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -868,7 +868,7 @@ static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp, if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED)) vty_out(vty, " Is not Registered\n"); } - tbuf = time(NULL) - (bgp_clock() - bnc->last_update); + tbuf = time(NULL) - (monotime(NULL) - bnc->last_update); vty_out(vty, " Last update: %s", ctime(&tbuf)); vty_out(vty, "\n"); diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 344608fda..c12c12b19 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -436,7 +436,7 @@ static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc, int i; bool evpn_resolved = false; - bnc->last_update = bgp_clock(); + bnc->last_update = monotime(NULL); bnc->change_flags = 0; /* debug print the input */ @@ -609,7 +609,7 @@ static void bgp_nht_ifp_table_handle(struct bgp *bgp, if (bnc->ifindex != ifp->ifindex) continue; - bnc->last_update = bgp_clock(); + bnc->last_update = monotime(NULL); bnc->change_flags = 0; /* diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index fe1887565..7daac4494 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -131,11 +131,11 @@ static void bgp_packet_add(struct peer *peer, struct stream *s) * after it'll get confused */ if (!stream_fifo_count_safe(peer->obuf)) - peer->last_sendq_ok = bgp_clock(); + peer->last_sendq_ok = monotime(NULL); stream_fifo_push(peer->obuf, s); - delta = bgp_clock() - peer->last_sendq_ok; + delta = monotime(NULL) - peer->last_sendq_ok; holdtime = atomic_load_explicit(&peer->holdtime, memory_order_relaxed); @@ -156,12 +156,12 @@ static void bgp_packet_add(struct peer *peer, struct stream *s) peer->host); BGP_EVENT_ADD(peer, TCP_fatal_error); } else if (delta > (intmax_t)holdtime && - bgp_clock() - peer->last_sendq_warn > 5) { + monotime(NULL) - peer->last_sendq_warn > 5) { flog_warn( EC_BGP_SENDQ_STUCK_WARN, "%s has not made any SendQ progress for 1 holdtime, peer overloaded?", peer->host); - peer->last_sendq_warn = bgp_clock(); + peer->last_sendq_warn = monotime(NULL); } } } @@ -2026,7 +2026,7 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) interned in bgp_attr_parse(). */ bgp_attr_unintern_sub(&attr); - peer->update_time = bgp_clock(); + peer->update_time = monotime(NULL); /* Notify BGP Conditional advertisement scanner process */ peer->advmap_table_change = true; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 04f955f97..85540627b 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3672,7 +3672,7 @@ struct bgp_path_info *info_make(int type, int sub_type, unsigned short instance, new->sub_type = sub_type; new->peer = peer; new->attr = attr; - new->uptime = bgp_clock(); + new->uptime = monotime(NULL); new->net = dest; return new; } @@ -4062,7 +4062,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id, /* If the update is implicit withdraw. */ if (pi) { - pi->uptime = bgp_clock(); + pi->uptime = monotime(NULL); same_attr = attrhash_cmp(pi->attr, attr_new); hook_call(bgp_process, bgp, afi, safi, dest, peer, true); @@ -5995,7 +5995,7 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p, #endif bgp_attr_unintern(&pi->attr); pi->attr = attr_new; - pi->uptime = bgp_clock(); + pi->uptime = monotime(NULL); #ifdef ENABLE_BGP_VNC if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) { @@ -6297,7 +6297,7 @@ static void bgp_static_update_safi(struct bgp *bgp, const struct prefix *p, bgp_aggregate_decrement(bgp, p, pi, afi, safi); bgp_attr_unintern(&pi->attr); pi->attr = attr_new; - pi->uptime = bgp_clock(); + pi->uptime = monotime(NULL); #ifdef ENABLE_BGP_VNC if (pi->extra) label = decode_label(&pi->extra->label[0]); @@ -8521,7 +8521,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p, bgp, p, bpi, afi, SAFI_UNICAST); bgp_attr_unintern(&bpi->attr); bpi->attr = new_attr; - bpi->uptime = bgp_clock(); + bpi->uptime = monotime(NULL); /* Process change. */ bgp_aggregate_increment(bgp, p, bpi, afi, @@ -10808,7 +10808,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn, } /* Line 9 display Uptime */ - tbuf = time(NULL) - (bgp_clock() - path->uptime); + tbuf = time(NULL) - (monotime(NULL) - path->uptime); if (json_paths) { json_last_update = json_object_new_object(); json_object_int_add(json_last_update, "epoch", tbuf); diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c index e25d8d90d..6bc313464 100644 --- a/bgpd/bgp_snmp.c +++ b/bgpd/bgp_snmp.c @@ -588,7 +588,7 @@ static uint8_t *bgpPeerTable(struct variable *v, oid name[], size_t *length, if (peer->uptime == 0) return SNMP_INTEGER(0); else - return SNMP_INTEGER(bgp_clock() - peer->uptime); + return SNMP_INTEGER(monotime(NULL) - peer->uptime); case BGPPEERCONNECTRETRYINTERVAL: *write_method = write_bgpPeerTable; return SNMP_INTEGER(peer->v_connect); @@ -615,7 +615,7 @@ static uint8_t *bgpPeerTable(struct variable *v, oid name[], size_t *length, if (peer->update_time == 0) return SNMP_INTEGER(0); else - return SNMP_INTEGER(bgp_clock() - peer->update_time); + return SNMP_INTEGER(monotime(NULL) - peer->update_time); default: return NULL; } diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index f1173941a..3a974910f 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -70,14 +70,14 @@ static void update_group_checkin(struct update_group *updgrp) { updgrp->id = ++bm->updgrp_idspace; - updgrp->uptime = bgp_clock(); + updgrp->uptime = monotime(NULL); } static void update_subgroup_checkin(struct update_subgroup *subgrp, struct update_group *updgrp) { subgrp->id = ++bm->subgrp_idspace; - subgrp->uptime = bgp_clock(); + subgrp->uptime = monotime(NULL); } static void sync_init(struct update_subgroup *subgrp, diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 0eba5ea44..3fdff899c 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -12723,7 +12723,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, if (peer_established(p)) { time_t uptime; - uptime = bgp_clock(); + uptime = monotime(NULL); uptime -= p->uptime; epoch_tbuf = time(NULL) - uptime; @@ -12751,7 +12751,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, time_t uptime; struct tm tm; - uptime = bgp_clock(); + uptime = monotime(NULL); uptime -= p->readtime; gmtime_r(&uptime, &tm); @@ -12759,7 +12759,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, (tm.tm_sec * 1000) + (tm.tm_min * 60000) + (tm.tm_hour * 3600000)); - uptime = bgp_clock(); + uptime = monotime(NULL); uptime -= p->last_write; gmtime_r(&uptime, &tm); @@ -12767,7 +12767,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, (tm.tm_sec * 1000) + (tm.tm_min * 60000) + (tm.tm_hour * 3600000)); - uptime = bgp_clock(); + uptime = monotime(NULL); uptime -= p->update_time; gmtime_r(&uptime, &tm); @@ -14039,7 +14039,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, time_t uptime; struct tm tm; - uptime = bgp_clock(); + uptime = monotime(NULL); uptime -= p->resettime; gmtime_r(&uptime, &tm); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index c17bd76ad..247c8c5f5 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -531,17 +531,6 @@ void bgp_cluster_id_unset(struct bgp *bgp) } } -/* time_t value that is monotonicly increasing - * and uneffected by adjustments to system clock - */ -time_t bgp_clock(void) -{ - struct timeval tv; - - monotime(&tv); - return tv.tv_sec; -} - /* BGP timer configuration. */ void bgp_timers_set(struct bgp *bgp, uint32_t keepalive, uint32_t holdtime, uint32_t connect_retry, uint32_t delayopen) @@ -1760,7 +1749,7 @@ struct peer *peer_create(union sockunion *su, const char *conf_if, } /* Last read and reset time set */ - peer->readtime = peer->resettime = bgp_clock(); + peer->readtime = peer->resettime = monotime(NULL); /* Default TTL set. */ peer->ttl = (peer->sort == BGP_PEER_IBGP) ? MAXTTL : BGP_DEFAULT_TTL; @@ -7960,7 +7949,7 @@ char *peer_uptime(time_t uptime2, char *buf, size_t len, bool use_json, } /* Get current time. */ - uptime1 = bgp_clock(); + uptime1 = monotime(NULL); uptime1 -= uptime2; gmtime_r(&uptime1, &tm); @@ -8002,7 +7991,7 @@ void bgp_master_init(struct thread_master *master, const int buffer_size, bm->port = BGP_PORT_DEFAULT; bm->addresses = addresses; bm->master = master; - bm->start_time = bgp_clock(); + bm->start_time = monotime(NULL); bm->t_rmap_update = NULL; bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; bm->v_update_delay = BGP_UPDATE_DELAY_DEF; diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 8348b37b8..dc7ad32a5 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -2043,7 +2043,6 @@ extern unsigned int multipath_num; /* Prototypes. */ extern void bgp_terminate(void); extern void bgp_reset(void); -extern time_t bgp_clock(void); extern void bgp_zclient_reset(void); extern struct bgp *bgp_get_default(void); extern struct bgp *bgp_lookup(as_t, const char *); @@ -2449,7 +2448,7 @@ static inline int peer_group_af_configured(struct peer_group *group) static inline char *timestamp_string(time_t ts) { time_t tbuf; - tbuf = time(NULL) - (bgp_clock() - ts); + tbuf = time(NULL) - (monotime(NULL) - ts); return ctime(&tbuf); } diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index 2437bd8cf..831f92996 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -94,7 +94,7 @@ DEFINE_QOBJ_TYPE(rfapi_l2_group_cfg); */ time_t rfapi_time(time_t *t) { - time_t clock = bgp_clock(); + time_t clock = monotime(NULL); if (t) *t = clock; return clock; diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index 382886e0b..a34c10d84 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -1006,7 +1006,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ bgp_aggregate_decrement(bgp, p, bpi, afi, safi); bgp_attr_unintern(&bpi->attr); bpi->attr = new_attr; - bpi->uptime = bgp_clock(); + bpi->uptime = monotime(NULL); if (safi == SAFI_MPLS_VPN) { @@ -1351,8 +1351,7 @@ int rfapi_init_and_open(struct bgp *bgp, struct rfapi_descriptor *rfd, struct prefix pfx_un; struct agg_node *rn; - - rfapi_time(&rfd->open_time); + rfd->open_time = monotime(NULL); if (rfg->type == RFAPI_GROUP_CFG_VRF) SET_FLAG(rfd->flags, RFAPI_HD_FLAG_IS_VRF); @@ -1521,10 +1520,10 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target, } rfd->rsp_counter++; /* dedup: identify this generation */ - rfd->rsp_time = rfapi_time(NULL); /* response content dedup */ + rfd->rsp_time = monotime(NULL); /* response content dedup */ rfd->ftd_last_allowed_time = - bgp_clock() - - bgp->rfapi_cfg->rfp_cfg.ftd_advertisement_interval; + monotime(NULL) - + bgp->rfapi_cfg->rfp_cfg.ftd_advertisement_interval; if (l2o) { if (!memcmp(l2o->macaddr.octet, rfapi_ethaddr0.octet, diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 1d4270276..6fb509fd9 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -489,7 +489,7 @@ static struct bgp_path_info *rfapiBgpInfoCreate(struct attr *attr, bgp_path_info_extra_get(new); if (prd) { new->extra->vnc.import.rd = *prd; - rfapi_time(&new->extra->vnc.import.create_time); + new->extra->vnc.import.create_time = monotime(NULL); } if (label) encode_label(*label, &new->extra->label[0]); diff --git a/bgpd/rfapi/rfapi_private.h b/bgpd/rfapi/rfapi_private.h index bc0e192ae..8c76e1dd0 100644 --- a/bgpd/rfapi/rfapi_private.h +++ b/bgpd/rfapi/rfapi_private.h @@ -364,6 +364,11 @@ extern int rfapi_extract_l2o( * compaitibility to old quagga_time call * time_t value in terms of stabilised absolute time. * replacement for POSIX time() + * + * Please do not use this. This is kept only for + * Lou's CI in that that CI compiles against some + * private bgp code and it will just fail to compile + * without this. Use monotime() */ extern time_t rfapi_time(time_t *t); diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index 9d61ada7d..9e13c4813 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -784,7 +784,7 @@ int rfapiRibPreloadBi( skiplist_insert(slRibPt, &ori->rk, ori); } - ori->last_sent_time = rfapi_time(NULL); + ori->last_sent_time = monotime(NULL); /* * poke timer @@ -797,7 +797,7 @@ int rfapiRibPreloadBi( * Update last sent time for prefix */ trn = agg_node_get(rfd->rsp_times[afi], p); /* locks trn */ - trn->info = (void *)(uintptr_t)bgp_clock(); + trn->info = (void *)(uintptr_t)monotime(NULL); if (agg_node_get_lock_count(trn) > 1) agg_unlock_node(trn); @@ -1089,7 +1089,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd, rfapiFreeBgpTeaOptionChain(ori->tea_options); ori->tea_options = rfapiOptionsDup(ri->tea_options); - ori->last_sent_time = rfapi_time(NULL); + ori->last_sent_time = monotime(NULL); rfapiFreeRfapiVnOptionChain(ori->vn_options); ori->vn_options = @@ -1115,7 +1115,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd, ori->lifetime = ri->lifetime; ori->tea_options = rfapiOptionsDup(ri->tea_options); - ori->last_sent_time = rfapi_time(NULL); + ori->last_sent_time = monotime(NULL); ori->vn_options = rfapiVnOptionsDup(ri->vn_options); ori->un_options = @@ -1227,7 +1227,7 @@ callback: */ trn = agg_node_get(rfd->rsp_times[afi], p); /* locks trn */ - trn->info = (void *)(uintptr_t)bgp_clock(); + trn->info = (void *)(uintptr_t)monotime(NULL); if (agg_node_get_lock_count(trn) > 1) agg_unlock_node(trn); @@ -1376,7 +1376,7 @@ callback: rfapiRibStartTimer(rfd, ri, rn, 1); RFAPI_RIB_CHECK_COUNTS( 0, delete_list->count); - ri->last_sent_time = rfapi_time(NULL); + ri->last_sent_time = monotime(NULL); #if DEBUG_RIB_SL_RD { char buf_rd[RD_ADDRSTRLEN]; @@ -1400,7 +1400,7 @@ callback: rfapiRibStartTimer(rfd, ri_del, rn, 1); RFAPI_RIB_CHECK_COUNTS( 0, delete_list->count); - ri->last_sent_time = rfapi_time(NULL); + ri->last_sent_time = monotime(NULL); } } } else { @@ -1849,7 +1849,7 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd, vnc_zlog_debug_verbose("%s: loading response=%p, use_eth_resolution=%d", __func__, response, use_eth_resolution); - new_last_sent_time = rfapi_time(NULL); + new_last_sent_time = monotime(NULL); for (nhp = response; nhp; nhp = nhp_next) { @@ -2019,7 +2019,7 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd, ri->lifetime = nhp->lifetime; ri->vn_options = rfapiVnOptionsDup(nhp->vn_options); ri->rsp_counter = rfd->rsp_counter; - ri->last_sent_time = rfapi_time(NULL); + ri->last_sent_time = monotime(NULL); if (need_insert) { int rc; @@ -2042,7 +2042,7 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd, * update this NVE's timestamp for this prefix */ trn = agg_node_get(rfd->rsp_times[afi], &pfx); /* locks trn */ - trn->info = (void *)(uintptr_t)bgp_clock(); + trn->info = (void *)(uintptr_t)monotime(NULL); if (agg_node_get_lock_count(trn) > 1) agg_unlock_node(trn); @@ -2275,7 +2275,7 @@ static int print_rib_sl(int (*fp)(void *, const char *, ...), struct vty *vty, rfapiFormatAge(ri->last_sent_time, str_age, BUFSIZ); #else { - time_t now = rfapi_time(NULL); + time_t now = monotime(NULL); time_t expire = ri->last_sent_time + (time_t)ri->lifetime; /* allow for delayed/async removal */ diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index c8fdadcac..a8ab61841 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -109,7 +109,7 @@ char *rfapiFormatAge(time_t age, char *buf, size_t len) { time_t now, age_adjusted; - now = rfapi_time(NULL); + now = monotime(NULL); age_adjusted = now - age; return rfapiFormatSeconds(age_adjusted, buf, len); diff --git a/pimd/mtracebis_netlink.c b/pimd/mtracebis_netlink.c index fe2cb56a2..81e28f240 100644 --- a/pimd/mtracebis_netlink.c +++ b/pimd/mtracebis_netlink.c @@ -92,7 +92,7 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, rth->local.nl_family); return -1; } - rth->seq = time(NULL); + rth->seq = (uint32_t)time(NULL); return 0; } diff --git a/ripd/ripd.c b/ripd/ripd.c index 979818603..c3a9369a0 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -996,6 +996,7 @@ static size_t rip_auth_md5_ah_write(struct stream *s, struct rip_interface *ri, struct key *key) { size_t doff = 0; + static uint32_t seq = 0; assert(s && ri && ri->auth_type == RIP_AUTH_MD5); @@ -1028,7 +1029,7 @@ static size_t rip_auth_md5_ah_write(struct stream *s, struct rip_interface *ri, /* RFC2080: The value used in the sequence number is arbitrary, but two suggestions are the time of the message's creation or a simple message counter. */ - stream_putl(s, time(NULL)); + stream_putl(s, ++seq); /* Reserved field must be zero. */ stream_putl(s, 0); diff --git a/zebra/zserv.c b/zebra/zserv.c index f76b29def..ebe246ffb 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -228,8 +228,7 @@ static void zserv_write(struct thread *thread) case BUFFER_ERROR: goto zwrite_fail; case BUFFER_PENDING: - atomic_store_explicit(&client->last_write_time, - (uint32_t)monotime(NULL), + atomic_store_explicit(&client->last_write_time, monotime(NULL), memory_order_relaxed); zserv_client_event(client, ZSERV_CLIENT_WRITE); return; @@ -264,8 +263,7 @@ static void zserv_write(struct thread *thread) case BUFFER_ERROR: goto zwrite_fail; case BUFFER_PENDING: - atomic_store_explicit(&client->last_write_time, - (uint32_t)monotime(NULL), + atomic_store_explicit(&client->last_write_time, monotime(NULL), memory_order_relaxed); zserv_client_event(client, ZSERV_CLIENT_WRITE); return; @@ -276,8 +274,8 @@ static void zserv_write(struct thread *thread) atomic_store_explicit(&client->last_write_cmd, wcmd, memory_order_relaxed); - atomic_store_explicit(&client->last_write_time, - (uint32_t)monotime(NULL), memory_order_relaxed); + atomic_store_explicit(&client->last_write_time, monotime(NULL), + memory_order_relaxed); return; @@ -748,7 +746,7 @@ static struct zserv *zserv_client_create(int sock) client->wb = buffer_new(0); TAILQ_INIT(&(client->gr_info_queue)); - atomic_store_explicit(&client->connect_time, (uint32_t) monotime(NULL), + atomic_store_explicit(&client->connect_time, monotime(NULL), memory_order_relaxed); /* Initialize flags */ diff --git a/zebra/zserv.h b/zebra/zserv.h index 9986cc9f7..db7b70d7c 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -216,15 +216,15 @@ struct zserv { */ /* monotime of client creation */ - _Atomic uint32_t connect_time; + _Atomic uint64_t connect_time; /* monotime of last message received */ - _Atomic uint32_t last_read_time; + _Atomic uint64_t last_read_time; /* monotime of last message sent */ - _Atomic uint32_t last_write_time; + _Atomic uint64_t last_write_time; /* command code of last message read */ - _Atomic uint32_t last_read_cmd; + _Atomic uint64_t last_read_cmd; /* command code of last message written */ - _Atomic uint32_t last_write_cmd; + _Atomic uint64_t last_write_cmd; /* * Number of instances configured with |