From 77f2a04099a7fd5107d11a5b0dcd3b0dc73f9bea Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Wed, 8 Jan 2014 00:40:16 +0100 Subject: isisd: add a slight delay to lsp_regenerate_schedule isisd implements a holdoff interval and will refrain from regenerating an lsp if the difference between the current time and its last refresh is less than the holdoff interval, but instead, it will schedule a timer to regenerate the lsp after the holdoff interval has passed. This implementation has one disadvantage in the case where there is a succession of calls to lsp_regenerate_schedule. In such a case, the first call will trigger an immediate regeneration of the lsp, while the other calls will only schedule the regeneration timer. This leads to cases where it takes holdoff interval time for information to propagate, just because the information was only available e.g. at the second call of lsp_regenerate_schedule in such a succession of calls. By not immediately regenerating an lsp if the last generation time is sufficiently long ago, but instead scheduling the regeneration with a very small delay, we allow all information from such a succession of calls to be considered. Signed-off-by: Christian Franke --- isisd/isis_lsp.c | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index f2a7923d..9bbba7fc 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -1741,6 +1741,7 @@ lsp_regenerate_schedule (struct isis_area *area, int level, int all_pseudo) struct isis_lsp *lsp; u_char id[ISIS_SYS_ID_LEN + 2]; time_t now, diff; + long timeout; struct listnode *cnode; struct isis_circuit *circuit; int lvl; @@ -1770,20 +1771,20 @@ lsp_regenerate_schedule (struct isis_area *area, int level, int all_pseudo) THREAD_TIMER_OFF (area->t_lsp_refresh[lvl - 1]); diff = now - lsp->last_generated; if (diff < area->lsp_gen_interval[lvl - 1]) + timeout = 1000 * (area->lsp_gen_interval[lvl - 1] - diff); + else + timeout = 100; + + area->lsp_regenerate_pending[lvl - 1] = 1; + if (lvl == IS_LEVEL_1) { - area->lsp_regenerate_pending[lvl - 1] = 1; - if (lvl == IS_LEVEL_1) - THREAD_TIMER_ON (master, area->t_lsp_refresh[lvl - 1], - lsp_l1_refresh, area, - area->lsp_gen_interval[lvl - 1] - diff); - else if (lvl == IS_LEVEL_2) - THREAD_TIMER_ON (master, area->t_lsp_refresh[lvl - 1], - lsp_l2_refresh, area, - area->lsp_gen_interval[lvl - 1] - diff); + THREAD_TIMER_MSEC_ON(master, area->t_lsp_refresh[lvl - 1], + lsp_l1_refresh, area, timeout); } - else + else if (lvl == IS_LEVEL_2) { - lsp_regenerate (area, lvl); + THREAD_TIMER_MSEC_ON(master, area->t_lsp_refresh[lvl - 1], + lsp_l2_refresh, area, timeout); } } @@ -2100,6 +2101,7 @@ lsp_regenerate_schedule_pseudo (struct isis_circuit *circuit, int level) struct isis_lsp *lsp; u_char lsp_id[ISIS_SYS_ID_LEN + 2]; time_t now, diff; + long timeout; int lvl; if (circuit == NULL || @@ -2131,22 +2133,23 @@ lsp_regenerate_schedule_pseudo (struct isis_circuit *circuit, int level) THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1]); diff = now - lsp->last_generated; if (diff < circuit->area->lsp_gen_interval[lvl - 1]) + timeout = 1000 * (circuit->area->lsp_gen_interval[lvl - 1] - diff); + else + timeout = 100; + + circuit->lsp_regenerate_pending[lvl - 1] = 1; + + if (lvl == IS_LEVEL_1) { - circuit->lsp_regenerate_pending[lvl - 1] = 1; - if (lvl == IS_LEVEL_1) - THREAD_TIMER_ON (master, - circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1], - lsp_l1_refresh_pseudo, circuit, - circuit->area->lsp_gen_interval[lvl - 1] - diff); - else if (lvl == IS_LEVEL_2) - THREAD_TIMER_ON (master, - circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1], - lsp_l2_refresh_pseudo, circuit, - circuit->area->lsp_gen_interval[lvl - 1] - diff); + THREAD_TIMER_MSEC_ON(master, + circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1], + lsp_l1_refresh_pseudo, circuit, timeout); } - else + else if (lvl == IS_LEVEL_2) { - lsp_regenerate_pseudo (circuit, lvl); + THREAD_TIMER_MSEC_ON(master, + circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1], + lsp_l2_refresh_pseudo, circuit, timeout); } } -- cgit v1.2.1