This is largely a bulk-replace made with coccinelle.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
{
struct timeval tv;
- quagga_gettime(QUAGGA_CLK_MONOTONIC, &tv);
+ monotime(&tv);
return tv.tv_sec;
}
unsigned long long start_time, end_time;
/* Get time that can't roll backwards. */
- quagga_gettime(QUAGGA_CLK_MONOTONIC, &time_now);
+ monotime(&time_now);
start_time = time_now.tv_sec;
start_time = (start_time * 1000000) + time_now.tv_usec;
spftree->pending = 0;
spftree->runcount++;
spftree->last_run_timestamp = time (NULL);
- quagga_gettime(QUAGGA_CLK_MONOTONIC, &time_now);
+ monotime(&time_now);
end_time = time_now.tv_sec;
end_time = (end_time * 1000000) + time_now.tv_usec;
spftree->last_run_duration = end_time - start_time;
}
/* Get current time. */
- quagga_gettime(QUAGGA_CLK_MONOTONIC, &tv);
+ monotime(&tv);
curr = tv.tv_sec;
diff = curr - last_update;
tm = gmtime (&diff);
return ret;
}
-/* Exported Quagga timestamp function.
- * Modelled on POSIX clock_gettime.
- */
-int
-quagga_gettime (enum quagga_clkid clkid, struct timeval *tv)
-{
- switch (clkid)
- {
- case QUAGGA_CLK_MONOTONIC:
- return quagga_get_relative (tv);
- default:
- errno = EINVAL;
- return -1;
- }
-}
-
-time_t
-quagga_monotime (void)
-{
- struct timeval tv;
- quagga_get_relative(&tv);
- return tv.tv_sec;
-}
-
static unsigned int
cpu_record_hash_key (struct cpu_thread_history *a)
{
#define _ZEBRA_THREAD_H
#include <zebra.h>
+#include "monotime.h"
struct rusage_t
{
extern void thread_getrusage (RUSAGE_T *);
extern void thread_cmd_init (void);
-/* replacements for the system gettimeofday(), clock_gettime() and
- * time() functions, providing support for non-decrementing clock on
- * all systems, and fully monotonic on /some/ systems.
- */
-extern int quagga_gettime (enum quagga_clkid, struct timeval *);
-extern time_t quagga_monotime (void);
-
/* Returns elapsed real (wall clock) time. */
extern unsigned long thread_consumed_time(RUSAGE_T *after, RUSAGE_T *before,
unsigned long *cpu_time_elapsed);
else
{
summary->type = route->type;
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &summary->changed);
+ monotime(&summary->changed);
}
summary->path.router_bits = route->path.router_bits;
old_status = bfd_info->status;
bfd_info->status = status;
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &tv);
+ monotime(&tv);
bfd_info->last_update = tv.tv_sec;
if ((status == BFD_STATUS_DOWN) && (old_status == BFD_STATUS_UP))
ospf6_flood_clear (old);
}
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
if (! OSPF6_LSA_IS_MAXAGE (lsa))
lsa->expire = thread_add_timer (master, ospf6_lsa_expire, lsa,
OSPF_LSA_MAXAGE + lsa->birth.tv_sec - now.tv_sec);
if (old)
{
struct timeval now, res;
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
timersub (&now, &old->installed, &res);
time_delta_ms = (res.tv_sec * 1000) + (int)(res.tv_usec/1000);
if (time_delta_ms < from->ospf6_if->area->ospf6->lsa_minarrival)
}
}
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &new->received);
+ monotime(&new->received);
if (is_debug)
zlog_debug ("Install, Flood, Possibly acknowledge the received LSA");
vty_out (vty, " Number of I/F scoped LSAs is %u%s",
oi->lsdb->count, VNL);
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
timerclear (&res);
if (oi->thread_send_lsupdate)
ospf6_linkstate_prefix2str (&brouter->prefix, destination,
sizeof (destination));
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
timersub (&now, &brouter->installed, &res);
timerstring (&res, installed, sizeof (installed));
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
timersub (&now, &brouter->changed, &res);
timerstring (&res, changed, sizeof (changed));
assert (lsa && lsa->header);
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
lsa->birth.tv_sec = now.tv_sec - ntohs (lsa->header->age);
lsa->birth.tv_usec = now.tv_usec;
assert (lsa->header);
/* current time */
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
if (ntohs (lsa->header->age) >= OSPF_LSA_MAXAGE)
{
inet_ntop (AF_INET, &lsa->header->adv_router,
adv_router, sizeof (adv_router));
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
timersub (&now, &lsa->installed, &res);
timerstring (&res, duration, sizeof (duration));
if (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT) &&
(on->dbdesc_seqnum == 0))
{
- on->dbdesc_seqnum = quagga_monotime ();
+ on->dbdesc_seqnum = monotime(NULL);
}
dbdesc->options[0] = on->ospf6_if->area->options[0];
on->ospf6_if = oi;
on->state = OSPF6_NEIGHBOR_DOWN;
on->state_change = 0;
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &on->last_changed);
+ monotime(&on->last_changed);
on->router_id = router_id;
on->summary_list = ospf6_lsdb_create (on);
return;
on->state_change++;
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &on->last_changed);
+ monotime(&on->last_changed);
/* log */
if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
timersub (&now, &on->last_changed, &res);
timerstring (&res, duration, sizeof (duration));
inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));
inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
timersub (&now, &on->last_changed, &res);
timerstring (&res, duration, sizeof (duration));
else if (IS_OSPF6_DEBUG_ROUTE (TABLE))
zlog_debug ("%s: route add: %s", ospf6_route_table_name (table), buf);
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
node = route_node_get (table->table, &route->prefix);
route->rnode = node;
struct listnode *node;
struct ospf6_nexthop *nh;
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
timersub (&now, &route->changed, &res);
timerstring (&res, duration, sizeof (duration));
struct listnode *node;
struct ospf6_nexthop *nh;
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
/* destination */
if (route->type == OSPF6_DEST_TYPE_LINKSTATE)
ospf6->t_spf_calc = NULL;
/* execute SPF calculation */
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &start);
+ monotime(&start);
if (ospf6_is_router_abr (ospf6))
ospf6_abr_range_reset_cost (ospf6);
if (ospf6_is_router_abr (ospf6))
ospf6_abr_defaults_to_stub (ospf6);
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &end);
+ monotime(&end);
timersub (&end, &start, &runtime);
ospf6->ts_spf_duration = runtime;
o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));
/* initialize */
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &o->starttime);
+ monotime(&o->starttime);
o->area_list = list_new ();
o->area_list->cmp = ospf6_area_cmp;
o->lsdb = ospf6_lsdb_create (o);
router_id, VNL);
/* running time */
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
timersub (&now, &o->starttime, &running);
timerstring (&running, duration, sizeof (duration));
vty_out (vty, " Running %s%s", duration, VNL);
{
ospf->ase_calc = 0;
- quagga_gettime(QUAGGA_CLK_MONOTONIC, &start_time);
+ monotime(&start_time);
/* Calculate external route for each AS-external-LSA */
LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
ospf->old_external_route = ospf->new_external_route;
ospf->new_external_route = route_table_init ();
- quagga_gettime(QUAGGA_CLK_MONOTONIC, &stop_time);
+ monotime(&stop_time);
zlog_info ("SPF Processing Time(usecs): External Routes: %lld\n",
(stop_time.tv_sec - start_time.tv_sec)*1000000LL+
old_status = bfd_info->status;
bfd_info->status = status;
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &tv);
+ monotime(&tv);
bfd_info->last_update = tv.tv_sec;
if ((status == BFD_STATUS_DOWN) && (old_status == BFD_STATUS_UP))
*/
delay = (random() % (max_delay - min_delay)) + min_delay;
- current_index = ospf->lsa_refresh_queue.index + (quagga_monotime ()
- - ospf->lsa_refresher_started)/OSPF_LSA_REFRESHER_GRANULARITY;
+ current_index = ospf->lsa_refresh_queue.index + (monotime(NULL)
+ - ospf->lsa_refresher_started)/OSPF_LSA_REFRESHER_GRANULARITY;
index = (current_index + delay/OSPF_LSA_REFRESHER_GRANULARITY)
% (OSPF_LSA_REFRESHER_SLOTS);
modulus. */
ospf->lsa_refresh_queue.index =
((unsigned long)(ospf->lsa_refresh_queue.index +
- (quagga_monotime () - ospf->lsa_refresher_started)
+ (monotime(NULL) - ospf->lsa_refresher_started)
/ OSPF_LSA_REFRESHER_GRANULARITY))
% OSPF_LSA_REFRESHER_SLOTS;
ospf->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
ospf, ospf->lsa_refresh_interval);
- ospf->lsa_refresher_started = quagga_monotime ();
+ ospf->lsa_refresher_started = monotime(NULL);
for (ALL_LIST_ELEMENTS (lsa_to_refresh, node, nnode, lsa))
{
if (nbr->last_send)
ospf_packet_free (nbr->last_send);
nbr->last_send = ospf_packet_dup (op);
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &nbr->last_send_ts);
+ monotime(&nbr->last_send_ts);
}
/* Re-send Database Description. */
/* Increment SPF Calculation Counter. */
area->spf_calculation++;
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &area->ospf->ts_spf);
+ monotime(&area->ospf->ts_spf);
area->ts_spf = area->ospf->ts_spf;
if (IS_DEBUG_OSPF_EVENT)
ospf->t_spf_calc = NULL;
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &spf_start_time);
+ monotime(&spf_start_time);
/* Allocate new table tree. */
new_table = route_table_init ();
new_rtrs = route_table_init ();
areas_processed++;
}
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &stop_time);
+ monotime(&stop_time);
spf_time = timeval_elapsed (stop_time, spf_start_time);
ospf_vl_shut_unapproved (ospf);
ospf_ia_routing (ospf, new_table, new_rtrs);
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &stop_time);
+ monotime(&stop_time);
ia_time = timeval_elapsed (stop_time, start_time);
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &start_time);
+ monotime(&start_time);
ospf_prune_unreachable_networks (new_table);
ospf_prune_unreachable_routers (new_rtrs);
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &stop_time);
+ monotime(&stop_time);
prune_time = timeval_elapsed (stop_time, start_time);
/* AS-external-LSA calculation should not be performed here. */
ospf_ase_calculate_timer_add (ospf);
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &start_time);
+ monotime(&start_time);
/* Update routing table. */
ospf_route_install (ospf, new_table);
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &stop_time);
+ monotime(&stop_time);
rt_time = timeval_elapsed (stop_time, start_time);
/* Update ABR/ASBR routing table */
if (ospf->old_rtrs)
ospf->old_rtrs = ospf->new_rtrs;
ospf->new_rtrs = new_rtrs;
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &start_time);
+ monotime(&start_time);
if (IS_OSPF_ABR (ospf))
ospf_abr_task (ospf);
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &stop_time);
+ monotime(&stop_time);
abr_time = timeval_elapsed (stop_time, start_time);
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &stop_time);
+ monotime(&stop_time);
total_spf_time = timeval_elapsed (stop_time, spf_start_time);
ospf->ts_spf_duration.tv_sec = total_spf_time/1000000;
ospf->ts_spf_duration.tv_usec = total_spf_time % 1000000;
new->lsa_refresh_interval = OSPF_LSA_REFRESH_INTERVAL_DEFAULT;
new->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
new, new->lsa_refresh_interval);
- new->lsa_refresher_started = quagga_monotime ();
+ new->lsa_refresher_started = monotime(NULL);
if ((new->fd = ospf_sock_init()) < 0)
{
return 1;
time_left = ospf->lsa_refresh_interval -
- (quagga_monotime () - ospf->lsa_refresher_started);
+ (monotime(NULL) - ospf->lsa_refresher_started);
if (time_left > interval)
{
int time_left;
time_left = ospf->lsa_refresh_interval -
- (quagga_monotime () - ospf->lsa_refresher_started);
+ (monotime(NULL) - ospf->lsa_refresher_started);
if (time_left > OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
{
for (i = 0; i < SCHEDULE_TIMERS; i++)
thread_cancel(timers[i]);
- quagga_gettime(QUAGGA_CLK_MONOTONIC, &tv_start);
+ monotime(&tv_start);
for (i = 0; i < SCHEDULE_TIMERS; i++)
{
NULL, interval_msec);
}
- quagga_gettime(QUAGGA_CLK_MONOTONIC, &tv_lap);
+ monotime(&tv_lap);
for (i = 0; i < REMOVE_TIMERS; i++)
{
timers[index] = NULL;
}
- quagga_gettime(QUAGGA_CLK_MONOTONIC, &tv_stop);
+ monotime(&tv_stop);
t_schedule = 1000 * (tv_lap.tv_sec - tv_start.tv_sec);
t_schedule += (tv_lap.tv_usec - tv_start.tv_usec) / 1000;
{
time_t now;
- now = quagga_monotime ();
+ now = monotime(NULL);
if (now < reference)
{
*/
zfpm_g->connect_calls++;
zfpm_g->stats.connect_calls++;
- zfpm_g->last_connect_call_time = quagga_monotime ();
+ zfpm_g->last_connect_call_time = monotime(NULL);
ret = connect (sock, (struct sockaddr *) &serv, sizeof (serv));
if (ret >= 0)
zfpm_stop_stats_timer ();
zfpm_start_stats_timer ();
- zfpm_g->last_stats_clear_time = quagga_monotime();
+ zfpm_g->last_stats_clear_time = monotime(NULL);
vty_out (vty, "Cleared FPM stats%s", VTY_NEWLINE);
}
}
stream_putw_at (s, 0, stream_get_endp (s));
- client->nh_last_upd_time = quagga_monotime();
+ client->nh_last_upd_time = monotime(NULL);
client->last_write_cmd = cmd;
return zebra_server_send_message(client);
}
break;
}
- client->last_write_time = quagga_monotime();
+ client->last_write_time = monotime(NULL);
return 0;
}
break;
}
- client->last_write_time = quagga_monotime();
+ client->last_write_time = monotime(NULL);
return 0;
}
s = client->ibuf;
- client->nh_reg_time = quagga_monotime();
+ client->nh_reg_time = monotime(NULL);
while (l < length)
{
rnh = zebra_lookup_rnh(&p, zvrf_id (zvrf), type);
if (rnh)
{
- client->nh_dereg_time = quagga_monotime();
+ client->nh_dereg_time = monotime(NULL);
zebra_remove_rnh_client(rnh, client, type);
}
}
/* Set table number. */
client->rtm_table = zebrad.rtm_table_default;
- client->connect_time = quagga_monotime();
+ client->connect_time = monotime(NULL);
/* Initialize flags */
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
zlog_debug ("zebra message received [%s] %d in VRF %u",
zserv_command_string (command), length, vrf_id);
- client->last_read_time = quagga_monotime();
+ client->last_read_time = monotime(NULL);
client->last_read_cmd = command;
zvrf = zebra_vrf_lookup_by_id (vrf_id);
return (buf);
}
- now = quagga_monotime();
+ now = monotime(NULL);
now -= *time1;
tm = gmtime(&now);