mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 16:04:49 +00:00
[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.
This commit is contained in:
parent
db9c0df934
commit
2518efd15b
@ -1,3 +1,15 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
2006-08-04 Paul Jakma <paul.jakma@sun.com>
|
2006-08-04 Paul Jakma <paul.jakma@sun.com>
|
||||||
|
|
||||||
* ospf_lsdb.c: (ospf_lsdb_delete_entry) new function, consolidate
|
* ospf_lsdb.c: (ospf_lsdb_delete_entry) new function, consolidate
|
||||||
|
@ -300,7 +300,7 @@ ospf_timer_dump (struct thread *t, char *buf, size_t size)
|
|||||||
if (!t)
|
if (!t)
|
||||||
return "inactive";
|
return "inactive";
|
||||||
|
|
||||||
result = tv_sub (t->u.sands, recent_time);
|
result = tv_sub (t->u.sands, recent_relative_time());
|
||||||
return ospf_timeval_dump (&result, buf, size);
|
return ospf_timeval_dump (&result, buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ ospf_flood (struct ospf *ospf, struct ospf_neighbor *nbr,
|
|||||||
"while local one is initial instance.");
|
"while local one is initial instance.");
|
||||||
; /* Accept this LSA for quick LSDB resynchronization. */
|
; /* Accept this LSA for quick LSDB resynchronization. */
|
||||||
}
|
}
|
||||||
else if (tv_cmp (tv_sub (recent_time, current->tv_recv),
|
else if (tv_cmp (tv_sub (recent_relative_time (), current->tv_recv),
|
||||||
int2tv (OSPF_MIN_LS_ARRIVAL)) < 0)
|
int2tv (OSPF_MIN_LS_ARRIVAL)) < 0)
|
||||||
{
|
{
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
|
@ -141,7 +141,7 @@ ospf_lsa_refresh_delay (struct ospf_lsa *lsa)
|
|||||||
struct timeval delta, now;
|
struct timeval delta, now;
|
||||||
int delay = 0;
|
int delay = 0;
|
||||||
|
|
||||||
gettimeofday (&now, NULL);
|
quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
|
||||||
delta = tv_sub (now, lsa->tv_orig);
|
delta = tv_sub (now, lsa->tv_orig);
|
||||||
|
|
||||||
if (tv_cmp (delta, int2tv (OSPF_MIN_LS_INTERVAL)) < 0)
|
if (tv_cmp (delta, int2tv (OSPF_MIN_LS_INTERVAL)) < 0)
|
||||||
@ -163,10 +163,9 @@ int
|
|||||||
get_age (struct ospf_lsa *lsa)
|
get_age (struct ospf_lsa *lsa)
|
||||||
{
|
{
|
||||||
int age;
|
int age;
|
||||||
struct timeval now;
|
|
||||||
|
|
||||||
gettimeofday (&now, NULL);
|
age = ntohs (lsa->data->ls_age)
|
||||||
age = ntohs (lsa->data->ls_age) + tv_floor (tv_sub (now, lsa->tv_recv));
|
+ tv_floor (tv_sub (recent_relative_time (), lsa->tv_recv));
|
||||||
|
|
||||||
return age;
|
return age;
|
||||||
}
|
}
|
||||||
@ -229,7 +228,7 @@ ospf_lsa_new ()
|
|||||||
new->flags = 0;
|
new->flags = 0;
|
||||||
new->lock = 1;
|
new->lock = 1;
|
||||||
new->retransmit_counter = 0;
|
new->retransmit_counter = 0;
|
||||||
gettimeofday (&new->tv_recv, NULL);
|
new->tv_recv = recent_relative_time ();
|
||||||
new->tv_orig = new->tv_recv;
|
new->tv_orig = new->tv_recv;
|
||||||
new->refresh_list = -1;
|
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);
|
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
|
||||||
|
|
||||||
/* Record timestamp. */
|
|
||||||
gettimeofday (&new->tv_orig, NULL);
|
|
||||||
|
|
||||||
/* Re-calculate checksum. */
|
/* Re-calculate checksum. */
|
||||||
ospf_lsa_checksum (new->data);
|
ospf_lsa_checksum (new->data);
|
||||||
|
|
||||||
@ -3770,7 +3766,7 @@ ospf_refresher_register_lsa (struct ospf *ospf, struct ospf_lsa *lsa)
|
|||||||
delay = 0;
|
delay = 0;
|
||||||
|
|
||||||
current_index = ospf->lsa_refresh_queue.index +
|
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)
|
index = (current_index + delay/OSPF_LSA_REFRESHER_GRANULARITY)
|
||||||
% (OSPF_LSA_REFRESHER_SLOTS);
|
% (OSPF_LSA_REFRESHER_SLOTS);
|
||||||
@ -3829,7 +3825,7 @@ ospf_lsa_refresh_walker (struct thread *t)
|
|||||||
modulus. */
|
modulus. */
|
||||||
ospf->lsa_refresh_queue.index =
|
ospf->lsa_refresh_queue.index =
|
||||||
((unsigned long)(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;
|
OSPF_LSA_REFRESHER_GRANULARITY)) % OSPF_LSA_REFRESHER_SLOTS;
|
||||||
|
|
||||||
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
|
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->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
|
||||||
ospf, ospf->lsa_refresh_interval);
|
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))
|
for (ALL_LIST_ELEMENTS (lsa_to_refresh, node, nnode, lsa))
|
||||||
ospf_lsa_refresh (ospf, lsa);
|
ospf_lsa_refresh (ospf, lsa);
|
||||||
|
@ -617,10 +617,10 @@ nsm_notice_state_change (struct ospf_neighbor *nbr, int next_state, int event)
|
|||||||
|
|
||||||
/* Advance in NSM */
|
/* Advance in NSM */
|
||||||
if (next_state > nbr->state)
|
if (next_state > nbr->state)
|
||||||
nbr->ts_last_progress = recent_time;
|
nbr->ts_last_progress = recent_relative_time ();
|
||||||
else /* regression in NSM */
|
else /* regression in NSM */
|
||||||
{
|
{
|
||||||
nbr->ts_last_regress = recent_time;
|
nbr->ts_last_regress = recent_relative_time ();
|
||||||
nbr->last_regress_str = ospf_nsm_event_str [event];
|
nbr->last_regress_str = ospf_nsm_event_str [event];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,7 +747,7 @@ nsm_change_state (struct ospf_neighbor *nbr, int state)
|
|||||||
if (state == NSM_ExStart)
|
if (state == NSM_ExStart)
|
||||||
{
|
{
|
||||||
if (nbr->dd_seqnum == 0)
|
if (nbr->dd_seqnum == 0)
|
||||||
nbr->dd_seqnum = time (NULL);
|
nbr->dd_seqnum = quagga_time (NULL);
|
||||||
else
|
else
|
||||||
nbr->dd_seqnum++;
|
nbr->dd_seqnum++;
|
||||||
|
|
||||||
|
@ -337,7 +337,9 @@ ospf_make_md5_digest (struct ospf_interface *oi, struct ospf_packet *op)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* We do this here so when we dup a packet, we don't have to
|
/* We do this here so when we dup a packet, we don't have to
|
||||||
waste CPU rewriting other headers. */
|
waste CPU rewriting other headers.
|
||||||
|
|
||||||
|
Note that quagga_time /deliberately/ is not used here */
|
||||||
t = (time(NULL) & 0xFFFFFFFF);
|
t = (time(NULL) & 0xFFFFFFFF);
|
||||||
if (t > oi->crypt_seqnum)
|
if (t > oi->crypt_seqnum)
|
||||||
oi->crypt_seqnum = t;
|
oi->crypt_seqnum = t;
|
||||||
@ -444,7 +446,7 @@ ospf_ls_upd_timer (struct thread *thread)
|
|||||||
fired. This is a small tweak to what is in the RFC,
|
fired. This is a small tweak to what is in the RFC,
|
||||||
but it will cut out out a lot of retransmit traffic
|
but it will cut out out a lot of retransmit traffic
|
||||||
- MAG */
|
- MAG */
|
||||||
if (tv_cmp (tv_sub (recent_time, lsa->tv_recv),
|
if (tv_cmp (tv_sub (recent_relative_time (), lsa->tv_recv),
|
||||||
int2tv (retransmit_interval)) >= 0)
|
int2tv (retransmit_interval)) >= 0)
|
||||||
listnode_add (update, rn->info);
|
listnode_add (update, rn->info);
|
||||||
}
|
}
|
||||||
@ -1363,7 +1365,7 @@ ospf_db_desc (struct ip *iph, struct ospf_header *ospfh,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct timeval t, now;
|
struct timeval t, now;
|
||||||
gettimeofday (&now, NULL);
|
quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
|
||||||
t = tv_sub (now, nbr->last_send_ts);
|
t = tv_sub (now, nbr->last_send_ts);
|
||||||
if (tv_cmp (t, int2tv (nbr->v_inactivity)) < 0)
|
if (tv_cmp (t, int2tv (nbr->v_inactivity)) < 0)
|
||||||
{
|
{
|
||||||
@ -1948,7 +1950,7 @@ ospf_ls_upd (struct ip *iph, struct ospf_header *ospfh,
|
|||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
|
|
||||||
gettimeofday (&now, NULL);
|
quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
|
||||||
|
|
||||||
if (tv_cmp (tv_sub (now, current->tv_orig),
|
if (tv_cmp (tv_sub (now, current->tv_orig),
|
||||||
int2tv (OSPF_MIN_LS_ARRIVAL)) > 0)
|
int2tv (OSPF_MIN_LS_ARRIVAL)) > 0)
|
||||||
@ -3158,7 +3160,7 @@ ospf_db_desc_send (struct ospf_neighbor *nbr)
|
|||||||
if (nbr->last_send)
|
if (nbr->last_send)
|
||||||
ospf_packet_free (nbr->last_send);
|
ospf_packet_free (nbr->last_send);
|
||||||
nbr->last_send = ospf_packet_dup (op);
|
nbr->last_send = ospf_packet_dup (op);
|
||||||
gettimeofday (&nbr->last_send_ts, NULL);
|
quagga_gettime (QUAGGA_CLK_MONOTONIC, &nbr->last_send_ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Re-send Database Description. */
|
/* Re-send Database Description. */
|
||||||
|
@ -47,7 +47,7 @@ ospf_route_new ()
|
|||||||
|
|
||||||
new = XCALLOC (MTYPE_OSPF_ROUTE, sizeof (struct ospf_route));
|
new = XCALLOC (MTYPE_OSPF_ROUTE, sizeof (struct ospf_route));
|
||||||
|
|
||||||
new->ctime = time (NULL);
|
new->ctime = quagga_time (NULL);
|
||||||
new->mtime = new->ctime;
|
new->mtime = new->ctime;
|
||||||
new->paths = list_new ();
|
new->paths = list_new ();
|
||||||
new->paths->del = (void (*) (void *))ospf_path_free;
|
new->paths->del = (void (*) (void *))ospf_path_free;
|
||||||
|
@ -1136,7 +1136,7 @@ ospf_spf_calculate (struct ospf_area *area, struct route_table *new_table,
|
|||||||
/* Increment SPF Calculation Counter. */
|
/* Increment SPF Calculation Counter. */
|
||||||
area->spf_calculation++;
|
area->spf_calculation++;
|
||||||
|
|
||||||
gettimeofday (&area->ospf->ts_spf, NULL);
|
quagga_gettime (QUAGGA_CLK_MONOTONIC, &area->ospf->ts_spf);
|
||||||
|
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug ("ospf_spf_calculate: Stop. %ld vertices",
|
zlog_debug ("ospf_spf_calculate: Stop. %ld vertices",
|
||||||
@ -1243,7 +1243,7 @@ ospf_spf_calculate_schedule (struct ospf *ospf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* XXX Monotic timers: we only care about relative time here. */
|
/* XXX Monotic timers: we only care about relative time here. */
|
||||||
result = tv_sub (recent_time, ospf->ts_spf);
|
result = tv_sub (recent_relative_time (), ospf->ts_spf);
|
||||||
|
|
||||||
elapsed = (result.tv_sec * 1000) + (result.tv_usec / 1000);
|
elapsed = (result.tv_sec * 1000) + (result.tv_usec / 1000);
|
||||||
ht = ospf->spf_holdtime * ospf->spf_hold_multiplier;
|
ht = ospf->spf_holdtime * ospf->spf_hold_multiplier;
|
||||||
|
@ -2691,7 +2691,7 @@ DEFUN (show_ip_ospf,
|
|||||||
vty_out (vty, " SPF algorithm ");
|
vty_out (vty, " SPF algorithm ");
|
||||||
if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
|
if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
|
||||||
{
|
{
|
||||||
result = tv_sub (recent_time, ospf->ts_spf);
|
result = tv_sub (recent_relative_time (), ospf->ts_spf);
|
||||||
vty_out (vty, "last executed %s ago%s",
|
vty_out (vty, "last executed %s ago%s",
|
||||||
ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
|
ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
|
||||||
VTY_NEWLINE);
|
VTY_NEWLINE);
|
||||||
@ -3157,7 +3157,8 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
|
|||||||
vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
|
vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
|
||||||
if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
|
if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
|
||||||
{
|
{
|
||||||
struct timeval res = tv_sub (recent_time, nbr->ts_last_progress);
|
struct timeval res
|
||||||
|
= tv_sub (recent_relative_time (), nbr->ts_last_progress);
|
||||||
vty_out (vty, " Most recent state change statistics:%s",
|
vty_out (vty, " Most recent state change statistics:%s",
|
||||||
VTY_NEWLINE);
|
VTY_NEWLINE);
|
||||||
vty_out (vty, " Progressive change %s ago%s",
|
vty_out (vty, " Progressive change %s ago%s",
|
||||||
@ -3166,7 +3167,8 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
|
|||||||
}
|
}
|
||||||
if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
|
if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
|
||||||
{
|
{
|
||||||
struct timeval res = tv_sub (recent_time, nbr->ts_last_regress);
|
struct timeval res
|
||||||
|
= tv_sub (recent_relative_time (), nbr->ts_last_regress);
|
||||||
vty_out (vty, " Regressive change %s ago, due to %s%s",
|
vty_out (vty, " Regressive change %s ago, due to %s%s",
|
||||||
ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
|
ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
|
||||||
(nbr->last_regress_str ? nbr->last_regress_str : "??"),
|
(nbr->last_regress_str ? nbr->last_regress_str : "??"),
|
||||||
|
@ -202,7 +202,7 @@ ospf_new (void)
|
|||||||
new->lsa_refresh_interval = OSPF_LSA_REFRESH_INTERVAL_DEFAULT;
|
new->lsa_refresh_interval = OSPF_LSA_REFRESH_INTERVAL_DEFAULT;
|
||||||
new->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
|
new->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
|
||||||
new, new->lsa_refresh_interval);
|
new, new->lsa_refresh_interval);
|
||||||
new->lsa_refresher_started = time (NULL);
|
new->lsa_refresher_started = quagga_time (NULL);
|
||||||
|
|
||||||
if ((new->fd = ospf_sock_init()) < 0)
|
if ((new->fd = ospf_sock_init()) < 0)
|
||||||
{
|
{
|
||||||
@ -1317,7 +1317,7 @@ ospf_timers_refresh_set (struct ospf *ospf, int interval)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
time_left = ospf->lsa_refresh_interval -
|
time_left = ospf->lsa_refresh_interval -
|
||||||
(time (NULL) - ospf->lsa_refresher_started);
|
(quagga_time (NULL) - ospf->lsa_refresher_started);
|
||||||
|
|
||||||
if (time_left > interval)
|
if (time_left > interval)
|
||||||
{
|
{
|
||||||
@ -1336,7 +1336,7 @@ ospf_timers_refresh_unset (struct ospf *ospf)
|
|||||||
int time_left;
|
int time_left;
|
||||||
|
|
||||||
time_left = ospf->lsa_refresh_interval -
|
time_left = ospf->lsa_refresh_interval -
|
||||||
(time (NULL) - ospf->lsa_refresher_started);
|
(quagga_time (NULL) - ospf->lsa_refresher_started);
|
||||||
|
|
||||||
if (time_left > OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
|
if (time_left > OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
|
||||||
{
|
{
|
||||||
@ -1657,5 +1657,5 @@ ospf_master_init ()
|
|||||||
om = &ospf_master;
|
om = &ospf_master;
|
||||||
om->ospf = list_new ();
|
om->ospf = list_new ();
|
||||||
om->master = thread_master_create ();
|
om->master = thread_master_create ();
|
||||||
om->start_time = time (NULL);
|
om->start_time = quagga_time (NULL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user