diff options
Diffstat (limited to 'isisd/isis_spf.c')
| -rw-r--r-- | isisd/isis_spf.c | 133 |
1 files changed, 80 insertions, 53 deletions
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index fb1aad8c49..ebce86bed9 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -35,6 +35,7 @@ #include "table.h" #include "spf_backoff.h" #include "srcdest_table.h" +#include "vrf.h" #include "isis_constants.h" #include "isis_common.h" @@ -877,8 +878,7 @@ static int isis_spf_preload_tent(struct isis_spftree *spftree, if (lsp == NULL || lsp->hdr.rem_lifetime == 0) zlog_warn( - "ISIS-Spf: No LSP %s found for IS adjacency " - "L%d on %s (ID %u)", + "ISIS-Spf: No LSP %s found for IS adjacency L%d on %s (ID %u)", rawlspid_print(lsp_id), spftree->level, circuit->interface->name, @@ -915,8 +915,7 @@ static int isis_spf_preload_tent(struct isis_spftree *spftree, /* if no adj, we are the dis or error */ if (!adj && !circuit->u.bc.is_dr[spftree->level - 1]) { zlog_warn( - "ISIS-Spf: No adjacency found from root " - "to L%d DR %s on %s (ID %d)", + "ISIS-Spf: No adjacency found from root to L%d DR %s on %s (ID %d)", spftree->level, rawlspid_print(lsp_id), circuit->interface->name, circuit->circuit_id); @@ -927,8 +926,7 @@ static int isis_spf_preload_tent(struct isis_spftree *spftree, lsp_id); if (lsp == NULL || lsp->hdr.rem_lifetime == 0) { zlog_warn( - "ISIS-Spf: No lsp (%p) found from root " - "to L%d DR %s on %s (ID %d)", + "ISIS-Spf: No lsp (%p) found from root to L%d DR %s on %s (ID %d)", (void *)lsp, spftree->level, rawlspid_print(lsp_id), circuit->interface->name, @@ -1022,8 +1020,7 @@ static void add_to_paths(struct isis_spftree *spftree, spftree->route_table); else if (IS_DEBUG_SPF_EVENTS) zlog_debug( - "ISIS-Spf: no adjacencies do not install route for " - "%s depth %d dist %d", + "ISIS-Spf: no adjacencies do not install route for %s depth %d dist %d", vid2string(vertex, buff, sizeof(buff)), vertex->depth, vertex->d_N); } @@ -1087,7 +1084,8 @@ struct isis_spftree *isis_run_hopcount_spf(struct isis_area *area, init_spt(spftree, ISIS_MT_IPV4_UNICAST, ISIS_LEVEL2, AF_INET, SPFTREE_IPV4, true); - if (!memcmp(sysid, isis->sysid, ISIS_SYS_ID_LEN)) { + + if (!memcmp(sysid, area->isis->sysid, ISIS_SYS_ID_LEN)) { /* If we are running locally, initialize with information from adjacencies */ struct isis_vertex *root = isis_spf_add_root(spftree, sysid); isis_spf_preload_tent(spftree, sysid, root); @@ -1103,19 +1101,17 @@ struct isis_spftree *isis_run_hopcount_spf(struct isis_area *area, } static int isis_run_spf(struct isis_area *area, int level, - enum spf_tree_id tree_id, - uint8_t *sysid, struct timeval *nowtv) + enum spf_tree_id tree_id, uint8_t *sysid) { int retval = ISIS_OK; struct isis_vertex *root_vertex; struct isis_spftree *spftree = area->spftree[tree_id][level - 1]; - struct timeval time_now; - unsigned long long start_time, end_time; + struct timeval time_start; + struct timeval time_end; uint16_t mtid = 0; /* Get time that can't roll backwards. */ - start_time = nowtv->tv_sec; - start_time = (start_time * 1000000) + nowtv->tv_usec; + monotime(&time_start); int family = -1; switch (tree_id) { @@ -1166,10 +1162,10 @@ static int isis_run_spf(struct isis_area *area, int level, out: spftree->runcount++; spftree->last_run_timestamp = time(NULL); - spftree->last_run_monotime = 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; + spftree->last_run_monotime = monotime(&time_end); + spftree->last_run_duration = + ((time_end.tv_sec - time_start.tv_sec) * 1000000) + + (time_end.tv_usec - time_start.tv_usec); return retval; } @@ -1215,15 +1211,14 @@ static int isis_run_spf_cb(struct thread *thread) area->area_tag, level); if (area->ip_circuits) - retval = isis_run_spf(area, level, SPFTREE_IPV4, isis->sysid, - &thread->real); + retval = isis_run_spf(area, level, SPFTREE_IPV4, + area->isis->sysid); if (area->ipv6_circuits) - retval = isis_run_spf(area, level, SPFTREE_IPV6, isis->sysid, - &thread->real); - if (area->ipv6_circuits - && isis_area_ipv6_dstsrc_enabled(area)) - retval = isis_run_spf(area, level, SPFTREE_DSTSRC, isis->sysid, - &thread->real); + retval = isis_run_spf(area, level, SPFTREE_IPV6, + area->isis->sysid); + if (area->ipv6_circuits && isis_area_ipv6_dstsrc_enabled(area)) + retval = isis_run_spf(area, level, SPFTREE_DSTSRC, + area->isis->sysid); isis_area_verify_routes(area); @@ -1262,8 +1257,7 @@ int _isis_spf_schedule(struct isis_area *area, int level, if (IS_DEBUG_SPF_EVENTS) { zlog_debug( - "ISIS-Spf (%s) L%d SPF schedule called, lastrun %d sec ago" - " Caller: %s %s:%d", + "ISIS-Spf (%s) L%d SPF schedule called, lastrun %d sec ago Caller: %s %s:%d", area->area_tag, level, diff, func, file, line); } @@ -1416,38 +1410,19 @@ static void isis_print_spftree(struct vty *vty, int level, vty_out(vty, "IS-IS paths to level-%d routers %s\n", level, tree_id_text); isis_print_paths(vty, &area->spftree[tree_id][level - 1]->paths, - isis->sysid); + area->isis->sysid); + vty_out(vty, "\n"); } -DEFUN (show_isis_topology, - show_isis_topology_cmd, - "show " PROTO_NAME " topology" -#ifndef FABRICD - " [<level-1|level-2>]" -#endif - , SHOW_STR - PROTO_HELP - "IS-IS paths to Intermediate Systems\n" -#ifndef FABRICD - "Paths to all level-1 routers in the area\n" - "Paths to all level-2 routers in the domain\n" -#endif - ) +static void show_isis_topology_common(struct vty *vty, int levels, + struct isis *isis) { - int levels; struct listnode *node; struct isis_area *area; - if (argc < 4) - levels = ISIS_LEVEL1 | ISIS_LEVEL2; - else if (strmatch(argv[3]->text, "level-1")) - levels = ISIS_LEVEL1; - else - levels = ISIS_LEVEL2; - if (!isis->area_list || isis->area_list->count == 0) - return CMD_SUCCESS; + return; for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { vty_out(vty, "Area %s:\n", @@ -1480,6 +1455,58 @@ DEFUN (show_isis_topology, vty_out(vty, "\n"); } +} + +DEFUN(show_isis_topology, show_isis_topology_cmd, + "show " PROTO_NAME + " [vrf <NAME|all>] topology" +#ifndef FABRICD + " [<level-1|level-2>]" +#endif + , + SHOW_STR PROTO_HELP VRF_CMD_HELP_STR + "All VRFs\n" + "IS-IS paths to Intermediate Systems\n" +#ifndef FABRICD + "Paths to all level-1 routers in the area\n" + "Paths to all level-2 routers in the domain\n" +#endif +) +{ + int levels = ISIS_LEVELS; + struct listnode *inode, *nnode; + struct isis *isis = NULL; + int idx = 0; + const char *vrf_name = VRF_DEFAULT_NAME; + bool all_vrf = false; + int idx_vrf = 0; + + if (argv_find(argv, argc, "topology", &idx)) { + if (argc < idx + 2) + levels = ISIS_LEVEL1 | ISIS_LEVEL2; + else if (strmatch(argv[idx + 1]->arg, "level-1")) + levels = ISIS_LEVEL1; + else + levels = ISIS_LEVEL2; + } + + if (!im) { + vty_out(vty, "IS-IS Routing Process not enabled\n"); + return CMD_SUCCESS; + } + ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); + + if (vrf_name) { + if (all_vrf) { + for (ALL_LIST_ELEMENTS(im->isis, nnode, inode, isis)) { + show_isis_topology_common(vty, levels, isis); + } + return 0; + } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis != NULL) + show_isis_topology_common(vty, levels, isis); + } return CMD_SUCCESS; } |
