diff options
Diffstat (limited to 'isisd/isis_spf.c')
| -rw-r--r-- | isisd/isis_spf.c | 137 |
1 files changed, 20 insertions, 117 deletions
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index c1fb062e55..6efc1fc4d0 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -50,9 +50,6 @@ #include "isis_route.h" #include "isis_csm.h" -int isis_run_spf_l1 (struct thread *thread); -int isis_run_spf_l2 (struct thread *thread); - /* 7.2.7 */ static void remove_excess_adjs (struct list *adjs) @@ -266,14 +263,12 @@ isis_spftree_new (struct isis_area *area) tree->last_run_timestamp = 0; tree->last_run_duration = 0; tree->runcount = 0; - tree->pending = 0; return tree; } void isis_spftree_del (struct isis_spftree *spftree) { - THREAD_TIMER_OFF (spftree->t_spf); spftree->tents->del = (void (*)(void *)) isis_vertex_del; list_delete (spftree->tents); @@ -1240,7 +1235,6 @@ isis_run_spf (struct isis_area *area, int level, int family, u_char *sysid) out: isis_route_validate (area); - spftree->pending = 0; spftree->runcount++; spftree->last_run_timestamp = time (NULL); monotime(&time_now); @@ -1248,11 +1242,10 @@ out: end_time = (end_time * 1000000) + time_now.tv_usec; spftree->last_run_duration = end_time - start_time; - return retval; } -int +static int isis_run_spf_l1 (struct thread *thread) { struct isis_area *area; @@ -1261,8 +1254,7 @@ isis_run_spf_l1 (struct thread *thread) area = THREAD_ARG (thread); assert (area); - area->spftree[0]->t_spf = NULL; - area->spftree[0]->pending = 0; + area->spf_timer[0] = NULL; if (!(area->is_type & IS_LEVEL_1)) { @@ -1277,11 +1269,13 @@ isis_run_spf_l1 (struct thread *thread) if (area->ip_circuits) retval = isis_run_spf (area, 1, AF_INET, isis->sysid); + if (area->ipv6_circuits) + retval = isis_run_spf (area, 1, AF_INET6, isis->sysid); return retval; } -int +static int isis_run_spf_l2 (struct thread *thread) { struct isis_area *area; @@ -1290,8 +1284,7 @@ isis_run_spf_l2 (struct thread *thread) area = THREAD_ARG (thread); assert (area); - area->spftree[1]->t_spf = NULL; - area->spftree[1]->pending = 0; + area->spf_timer[1] = NULL; if (!(area->is_type & IS_LEVEL_2)) { @@ -1305,6 +1298,8 @@ isis_run_spf_l2 (struct thread *thread) if (area->ip_circuits) retval = isis_run_spf (area, 2, AF_INET, isis->sysid); + if (area->ipv6_circuits) + retval = isis_run_spf (area, 2, AF_INET6, isis->sysid); return retval; } @@ -1323,126 +1318,34 @@ isis_spf_schedule (struct isis_area *area, int level) zlog_debug ("ISIS-Spf (%s) L%d SPF schedule called, lastrun %d sec ago", area->area_tag, level, diff); - if (spftree->pending) + if (area->spf_timer[level -1]) return ISIS_OK; - THREAD_TIMER_OFF (spftree->t_spf); - /* wait configured min_spf_interval before doing the SPF */ if (diff >= area->min_spf_interval[level-1]) - return isis_run_spf (area, level, AF_INET, isis->sysid); - - if (level == 1) - THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf_l1, area, - area->min_spf_interval[0] - diff); - else - THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf_l2, area, - area->min_spf_interval[1] - diff); - - if (isis->debugs & DEBUG_SPF_EVENTS) - zlog_debug ("ISIS-Spf (%s) L%d SPF scheduled %d sec from now", - area->area_tag, level, area->min_spf_interval[level-1] - diff); - - spftree->pending = 1; - - return ISIS_OK; -} - -static int -isis_run_spf6_l1 (struct thread *thread) -{ - struct isis_area *area; - int retval = ISIS_OK; - - area = THREAD_ARG (thread); - assert (area); - - area->spftree6[0]->t_spf = NULL; - area->spftree6[0]->pending = 0; - - if (!(area->is_type & IS_LEVEL_1)) { - if (isis->debugs & DEBUG_SPF_EVENTS) - zlog_warn ("ISIS-SPF (%s) area does not share level", area->area_tag); - return ISIS_WARNING; - } - - if (isis->debugs & DEBUG_SPF_EVENTS) - zlog_debug ("ISIS-Spf (%s) L1 SPF needed, periodic SPF", area->area_tag); - - if (area->ipv6_circuits) - retval = isis_run_spf (area, 1, AF_INET6, isis->sysid); + int retval = ISIS_OK; - return retval; -} - -static int -isis_run_spf6_l2 (struct thread *thread) -{ - struct isis_area *area; - int retval = ISIS_OK; - - area = THREAD_ARG (thread); - assert (area); - - area->spftree6[1]->t_spf = NULL; - area->spftree6[1]->pending = 0; + if (area->ip_circuits) + retval = isis_run_spf (area, level, AF_INET, isis->sysid); + if (area->ipv6_circuits) + retval = isis_run_spf (area, level, AF_INET6, isis->sysid); - if (!(area->is_type & IS_LEVEL_2)) - { - if (isis->debugs & DEBUG_SPF_EVENTS) - zlog_warn ("ISIS-SPF (%s) area does not share level", area->area_tag); - return ISIS_WARNING; + return retval; } - if (isis->debugs & DEBUG_SPF_EVENTS) - zlog_debug ("ISIS-Spf (%s) L2 SPF needed, periodic SPF.", area->area_tag); - - if (area->ipv6_circuits) - retval = isis_run_spf (area, 2, AF_INET6, isis->sysid); - - return retval; -} - -int -isis_spf_schedule6 (struct isis_area *area, int level) -{ - int retval = ISIS_OK; - struct isis_spftree *spftree = area->spftree6[level - 1]; - time_t now = time (NULL); - time_t diff = now - spftree->last_run_timestamp; - - assert (diff >= 0); - assert (area->is_type & level); - - if (isis->debugs & DEBUG_SPF_EVENTS) - zlog_debug ("ISIS-Spf (%s) L%d SPF schedule called, lastrun %lld sec ago", - area->area_tag, level, (long long)diff); - - if (spftree->pending) - return ISIS_OK; - - THREAD_TIMER_OFF (spftree->t_spf); - - /* wait configured min_spf_interval before doing the SPF */ - if (diff >= area->min_spf_interval[level-1]) - return isis_run_spf (area, level, AF_INET6, isis->sysid); - if (level == 1) - THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf6_l1, area, + THREAD_TIMER_ON (master, area->spf_timer[0], isis_run_spf_l1, area, area->min_spf_interval[0] - diff); else - THREAD_TIMER_ON (master, spftree->t_spf, isis_run_spf6_l2, area, + THREAD_TIMER_ON (master, area->spf_timer[1], isis_run_spf_l2, area, area->min_spf_interval[1] - diff); if (isis->debugs & DEBUG_SPF_EVENTS) - zlog_debug ("ISIS-Spf (%s) L%d SPF scheduled %lld sec from now", - area->area_tag, level, - (long long)(area->min_spf_interval[level-1] - diff)); - - spftree->pending = 1; + zlog_debug ("ISIS-Spf (%s) L%d SPF scheduled %d sec from now", + area->area_tag, level, area->min_spf_interval[level-1] - diff); - return retval; + return ISIS_OK; } static void |
