summaryrefslogtreecommitdiff
path: root/ospfd/ospf_lsa.c
diff options
context:
space:
mode:
authorPaul Jakma <paul.jakma@sun.com>2006-08-27 06:49:29 +0000
committerPaul Jakma <paul.jakma@sun.com>2006-08-27 06:49:29 +0000
commit2518efd15b75687d4791a5eb4b0d7febc36cffbc (patch)
tree075b833f292ba3e64117a9ffb440578c70be5a2a /ospfd/ospf_lsa.c
parentdb9c0df934e62835bc09604a7ae7932693b4254a (diff)
[ospfd] Bug #134, ospfd should be more robust to backward time change
2006-08-25 Paul Jakma <paul.jakma@sun.com> * (general) Bug #134. Be more robust to backward time changes, use the newly added libzebra time functions. In most cases: recent_time -> recent_relative_time() gettimeofday -> quagga_gettime (QUAGGA_CLK_MONOTONIC, ..) time -> quagga_time. (ospf_make_md5_digest) time() call deliberately not changed. (ospf_external_lsa_refresh) remove useless gettimeofday, LSA tv_orig time was already set in ospf_lsa_new, called via ospf_external_lsa_new.
Diffstat (limited to 'ospfd/ospf_lsa.c')
-rw-r--r--ospfd/ospf_lsa.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index b99b931c..05eed35e 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -141,7 +141,7 @@ ospf_lsa_refresh_delay (struct ospf_lsa *lsa)
struct timeval delta, now;
int delay = 0;
- gettimeofday (&now, NULL);
+ quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
delta = tv_sub (now, lsa->tv_orig);
if (tv_cmp (delta, int2tv (OSPF_MIN_LS_INTERVAL)) < 0)
@@ -163,10 +163,9 @@ int
get_age (struct ospf_lsa *lsa)
{
int age;
- struct timeval now;
- gettimeofday (&now, NULL);
- age = ntohs (lsa->data->ls_age) + tv_floor (tv_sub (now, lsa->tv_recv));
+ age = ntohs (lsa->data->ls_age)
+ + tv_floor (tv_sub (recent_relative_time (), lsa->tv_recv));
return age;
}
@@ -229,7 +228,7 @@ ospf_lsa_new ()
new->flags = 0;
new->lock = 1;
new->retransmit_counter = 0;
- gettimeofday (&new->tv_recv, NULL);
+ new->tv_recv = recent_relative_time ();
new->tv_orig = new->tv_recv;
new->refresh_list = -1;
@@ -2460,9 +2459,6 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
- /* Record timestamp. */
- gettimeofday (&new->tv_orig, NULL);
-
/* Re-calculate checksum. */
ospf_lsa_checksum (new->data);
@@ -3770,7 +3766,7 @@ ospf_refresher_register_lsa (struct ospf *ospf, struct ospf_lsa *lsa)
delay = 0;
current_index = ospf->lsa_refresh_queue.index +
- (time (NULL) - ospf->lsa_refresher_started)/OSPF_LSA_REFRESHER_GRANULARITY;
+ (quagga_time (NULL) - ospf->lsa_refresher_started)/OSPF_LSA_REFRESHER_GRANULARITY;
index = (current_index + delay/OSPF_LSA_REFRESHER_GRANULARITY)
% (OSPF_LSA_REFRESHER_SLOTS);
@@ -3829,7 +3825,7 @@ ospf_lsa_refresh_walker (struct thread *t)
modulus. */
ospf->lsa_refresh_queue.index =
((unsigned long)(ospf->lsa_refresh_queue.index +
- (time (NULL) - ospf->lsa_refresher_started) /
+ (quagga_time (NULL) - ospf->lsa_refresher_started) /
OSPF_LSA_REFRESHER_GRANULARITY)) % OSPF_LSA_REFRESHER_SLOTS;
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
@@ -3867,7 +3863,7 @@ ospf_lsa_refresh_walker (struct thread *t)
ospf->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
ospf, ospf->lsa_refresh_interval);
- ospf->lsa_refresher_started = time (NULL);
+ ospf->lsa_refresher_started = quagga_time (NULL);
for (ALL_LIST_ELEMENTS (lsa_to_refresh, node, nnode, lsa))
ospf_lsa_refresh (ospf, lsa);