summaryrefslogtreecommitdiffstats
path: root/isisd/isis_spf.c
diff options
context:
space:
mode:
Diffstat (limited to 'isisd/isis_spf.c')
-rw-r--r--isisd/isis_spf.c183
1 files changed, 125 insertions, 58 deletions
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c
index 3b3e1fd..1197f8c 100644
--- a/isisd/isis_spf.c
+++ b/isisd/isis_spf.c
@@ -873,6 +873,9 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree,
|| (mt_router_info && !mt_router_info->overload));
lspfragloop:
+ if (!lsp->tlvs)
+ return ISIS_OK;
+
if (lsp->hdr.seqno == 0) {
zlog_warn("%s: lsp with 0 seq_num - ignore", __func__);
return ISIS_WARNING;
@@ -2345,9 +2348,6 @@ static void show_isis_topology_common(struct vty *vty, int levels,
return;
for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
- vty_out(vty,
- "Area %s:", area->area_tag ? area->area_tag : "null");
-
#ifndef FABRICD
/*
* The shapes of the flex algo spftree 2-dimensional array
@@ -2362,7 +2362,12 @@ static void show_isis_topology_common(struct vty *vty, int levels,
fa_data = (struct isis_flex_algo_data *)fa->data;
} else
fa_data = NULL;
+#endif /* ifndef FABRICD */
+ vty_out(vty,
+ "Area %s:", area->area_tag ? area->area_tag : "null");
+
+#ifndef FABRICD
if (algo != SR_ALGORITHM_SPF)
vty_out(vty, " Algorithm %hhu\n", algo);
else
@@ -2426,7 +2431,7 @@ DEFUN(show_isis_topology, show_isis_topology_cmd,
" [vrf <NAME|all>] topology"
#ifndef FABRICD
" [<level-1|level-2>]"
- " [algorithm (128-255)]"
+ " [algorithm [(128-255)]]"
#endif /* ifndef FABRICD */
,
SHOW_STR PROTO_HELP VRF_CMD_HELP_STR
@@ -2445,8 +2450,10 @@ DEFUN(show_isis_topology, show_isis_topology_cmd,
struct isis *isis = NULL;
const char *vrf_name = VRF_DEFAULT_NAME;
bool all_vrf = false;
+ bool all_algorithm = false;
int idx_vrf = 0;
- uint8_t algorithm = SR_ALGORITHM_SPF;
+ uint16_t algorithm = SR_ALGORITHM_SPF;
+
#ifndef FABRICD
int idx = 0;
@@ -2455,8 +2462,12 @@ DEFUN(show_isis_topology, show_isis_topology_cmd,
levels = ISIS_LEVEL1;
if (argv_find(argv, argc, "level-2", &idx))
levels = ISIS_LEVEL2;
- if (argv_find(argv, argc, "algorithm", &idx))
- algorithm = (uint8_t)strtoul(argv[idx + 1]->arg, NULL, 10);
+ if (argv_find(argv, argc, "algorithm", &idx)) {
+ if (argv_find(argv, argc, "(128-255)", &idx))
+ algorithm = (uint16_t)strtoul(argv[idx]->arg, NULL, 10);
+ else
+ all_algorithm = true;
+ }
#endif /* ifndef FABRICD */
if (!im) {
@@ -2465,17 +2476,33 @@ DEFUN(show_isis_topology, show_isis_topology_cmd,
}
ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
- if (vrf_name) {
- if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
+ if (all_vrf) {
+ for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
+ if (all_algorithm) {
+ for (algorithm = SR_ALGORITHM_FLEX_MIN;
+ algorithm <= SR_ALGORITHM_FLEX_MAX;
+ algorithm++)
+ show_isis_topology_common(
+ vty, levels, isis,
+ (uint8_t)algorithm);
+ } else {
show_isis_topology_common(vty, levels, isis,
- algorithm);
- return CMD_SUCCESS;
+ (uint8_t)algorithm);
+ }
}
- isis = isis_lookup_by_vrfname(vrf_name);
- if (isis != NULL)
- show_isis_topology_common(vty, levels, isis, algorithm);
+ return CMD_SUCCESS;
}
+ isis = isis_lookup_by_vrfname(vrf_name);
+ if (isis == NULL)
+ return CMD_SUCCESS;
+ if (all_algorithm) {
+ for (algorithm = SR_ALGORITHM_FLEX_MIN;
+ algorithm <= SR_ALGORITHM_FLEX_MAX; algorithm++) {
+ show_isis_topology_common(vty, levels, isis,
+ (uint8_t)algorithm);
+ }
+ } else
+ show_isis_topology_common(vty, levels, isis, (uint8_t)algorithm);
return CMD_SUCCESS;
}
@@ -2648,17 +2675,14 @@ DEFUN(show_isis_flex_algo, show_isis_flex_algo_cmd,
ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
- if (vrf_name) {
- if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
- show_isis_flex_algo_common(vty, isis,
- flex_algo);
- return CMD_SUCCESS;
- }
- isis = isis_lookup_by_vrfname(vrf_name);
- if (isis != NULL)
+ if (all_vrf) {
+ for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
show_isis_flex_algo_common(vty, isis, flex_algo);
+ return CMD_SUCCESS;
}
+ isis = isis_lookup_by_vrfname(vrf_name);
+ if (isis != NULL)
+ show_isis_flex_algo_common(vty, isis, flex_algo);
return CMD_SUCCESS;
}
@@ -2884,7 +2908,7 @@ static void show_isis_route_common(struct vty *vty, int levels,
struct isis_spftree *spftree;
struct listnode *node;
struct isis_area *area;
- char key[8];
+ char key[18];
if (!isis->area_list || isis->area_list->count == 0)
return;
@@ -2914,6 +2938,7 @@ static void show_isis_route_common(struct vty *vty, int levels,
jstr = json_object_new_string(
area->area_tag ? area->area_tag : "null");
json_object_object_add(*json, "area", jstr);
+ json_object_int_add(*json, "algorithm", algo);
} else {
vty_out(vty, "Area %s:",
area->area_tag ? area->area_tag : "null");
@@ -3013,6 +3038,39 @@ static void show_isis_route_common(struct vty *vty, int levels,
}
}
+static void show_isis_route_all_algos(struct vty *vty, int levels,
+ struct isis *isis, bool prefix_sid,
+ bool backup, json_object **json)
+{
+ uint16_t algo;
+
+ json_object *json_algo = NULL, *json_algos = NULL;
+
+ if (json) {
+ *json = json_object_new_object();
+ json_algos = json_object_new_array();
+ }
+
+ for (algo = SR_ALGORITHM_FLEX_MIN; algo <= SR_ALGORITHM_FLEX_MAX;
+ algo++) {
+ show_isis_route_common(vty, levels, isis, prefix_sid, backup,
+ (uint8_t)algo, json ? &json_algo : NULL);
+ if (!json)
+ continue;
+ if (json_object_object_length(json_algo) == 0) {
+ json_object_free(json_algo);
+ continue;
+ }
+ json_object_object_add(json_algo, "algorithm",
+ json_object_new_int(algo));
+ json_object_array_add(json_algos, json_algo);
+ }
+
+ if (json)
+ json_object_object_add(*json, "algorithms", json_algos);
+}
+
+
DEFUN(show_isis_route, show_isis_route_cmd,
"show " PROTO_NAME
" [vrf <NAME|all>] route"
@@ -3021,7 +3079,7 @@ DEFUN(show_isis_route, show_isis_route_cmd,
#endif /* ifndef FABRICD */
" [<prefix-sid|backup>]"
#ifndef FABRICD
- " [algorithm (128-255)]"
+ " [algorithm [(128-255)]]"
#endif /* ifndef FABRICD */
" [json$uj]",
SHOW_STR PROTO_HELP VRF_FULL_CMD_HELP_STR
@@ -3043,6 +3101,7 @@ DEFUN(show_isis_route, show_isis_route_cmd,
struct listnode *node;
const char *vrf_name = VRF_DEFAULT_NAME;
bool all_vrf = false;
+ bool all_algorithm = false;
bool prefix_sid = false;
bool backup = false;
bool uj = use_json(argc, argv);
@@ -3069,40 +3128,50 @@ DEFUN(show_isis_route, show_isis_route_cmd,
backup = true;
#ifndef FABRICD
- if (argv_find(argv, argc, "algorithm", &idx))
- algorithm = (uint8_t)strtoul(argv[idx + 1]->arg, NULL, 10);
+ if (argv_find(argv, argc, "algorithm", &idx)) {
+ if (argv_find(argv, argc, "(128-255)", &idx))
+ algorithm = (uint8_t)strtoul(argv[idx]->arg, NULL, 10);
+ else
+ all_algorithm = true;
+ }
#endif /* ifndef FABRICD */
if (uj)
json = json_object_new_array();
- if (vrf_name) {
- if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
- show_isis_route_common(
- vty, levels, isis, prefix_sid, backup,
- algorithm, uj ? &json_vrf : NULL);
- if (uj) {
- json_object_object_add(
- json_vrf, "vrf_id",
- json_object_new_int(
- isis->vrf_id));
- json_object_array_add(json, json_vrf);
- }
+ if (all_vrf) {
+ for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
+ if (all_algorithm)
+ show_isis_route_all_algos(vty, levels, isis,
+ prefix_sid, backup,
+ uj ? &json_vrf : NULL);
+ else
+ show_isis_route_common(vty, levels, isis,
+ prefix_sid, backup,
+ algorithm,
+ uj ? &json_vrf : NULL);
+ if (uj) {
+ json_object_object_add(json_vrf, "vrf_id",
+ json_object_new_int(
+ isis->vrf_id));
+ json_object_array_add(json, json_vrf);
}
- goto out;
}
- isis = isis_lookup_by_vrfname(vrf_name);
- if (isis != NULL) {
+ goto out;
+ }
+ isis = isis_lookup_by_vrfname(vrf_name);
+ if (isis != NULL) {
+ if (all_algorithm)
+ show_isis_route_all_algos(vty, levels, isis, prefix_sid,
+ backup, uj ? &json_vrf : NULL);
+ else
show_isis_route_common(vty, levels, isis, prefix_sid,
backup, algorithm,
uj ? &json_vrf : NULL);
- if (uj) {
- json_object_object_add(
- json_vrf, "vrf_id",
- json_object_new_int(isis->vrf_id));
- json_object_array_add(json, json_vrf);
- }
+ if (uj) {
+ json_object_object_add(json_vrf, "vrf_id",
+ json_object_new_int(isis->vrf_id));
+ json_object_array_add(json, json_vrf);
}
}
@@ -3315,16 +3384,14 @@ DEFUN(show_isis_frr_summary, show_isis_frr_summary_cmd,
}
ISIS_FIND_VRF_ARGS(argv, argc, idx, vrf_name, all_vrf);
- if (vrf_name) {
- if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
- show_isis_frr_summary_common(vty, levels, isis);
- return CMD_SUCCESS;
- }
- isis = isis_lookup_by_vrfname(vrf_name);
- if (isis != NULL)
+ if (all_vrf) {
+ for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
show_isis_frr_summary_common(vty, levels, isis);
+ return CMD_SUCCESS;
}
+ isis = isis_lookup_by_vrfname(vrf_name);
+ if (isis != NULL)
+ show_isis_frr_summary_common(vty, levels, isis);
return CMD_SUCCESS;
}