mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-28 15:36:25 +00:00
isisd: add an algorithm argument to show isis route
Add an optional algorithm argument to "show isis route" command. Signed-off-by: Eric Kinzie <ekinzie@labn.net> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This commit is contained in:
parent
1610e215d9
commit
0833c25180
115
isisd/isis_spf.c
115
isisd/isis_spf.c
@ -2624,9 +2624,15 @@ void isis_print_routes(struct vty *vty, struct isis_spftree *spftree,
|
||||
|
||||
static void show_isis_route_common(struct vty *vty, int levels,
|
||||
struct isis *isis, bool prefix_sid,
|
||||
bool backup, json_object **json)
|
||||
bool backup, uint8_t algo,
|
||||
json_object **json)
|
||||
{
|
||||
json_object *json_level = NULL, *jstr = NULL, *json_val;
|
||||
#ifndef FABRICD
|
||||
struct isis_flex_algo_data *fa_data;
|
||||
struct flex_algo *fa;
|
||||
#endif /* ifndef FABRICD */
|
||||
struct isis_spftree *spftree;
|
||||
struct listnode *node;
|
||||
struct isis_area *area;
|
||||
char key[8];
|
||||
@ -2638,13 +2644,36 @@ static void show_isis_route_common(struct vty *vty, int levels,
|
||||
*json = json_object_new_object();
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
|
||||
#ifndef FABRICD
|
||||
/*
|
||||
* The shapes of the flex algo spftree 2-dimensional array
|
||||
* and the area spftree 2-dimensional array are not guaranteed
|
||||
* to be identical.
|
||||
*/
|
||||
fa = NULL;
|
||||
if (flex_algo_id_valid(algo)) {
|
||||
fa = flex_algo_lookup(area->flex_algos, algo);
|
||||
if (!fa)
|
||||
continue;
|
||||
fa_data = (struct isis_flex_algo_data *)fa->data;
|
||||
} else {
|
||||
fa_data = NULL;
|
||||
}
|
||||
#endif /* ifndef FABRICD */
|
||||
|
||||
if (json) {
|
||||
jstr = json_object_new_string(
|
||||
area->area_tag ? area->area_tag : "null");
|
||||
json_object_object_add(*json, "area", jstr);
|
||||
} else {
|
||||
vty_out(vty, "Area %s:\n",
|
||||
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
|
||||
#endif /* ifndef FABRICD */
|
||||
vty_out(vty, "\n");
|
||||
}
|
||||
|
||||
for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) {
|
||||
@ -2662,11 +2691,20 @@ static void show_isis_route_common(struct vty *vty, int levels,
|
||||
|
||||
if (area->ip_circuits > 0) {
|
||||
json_val = NULL;
|
||||
isis_print_routes(
|
||||
vty,
|
||||
area->spftree[SPFTREE_IPV4][level - 1],
|
||||
json ? &json_val : NULL, prefix_sid,
|
||||
backup);
|
||||
#ifndef FABRICD
|
||||
if (fa_data)
|
||||
spftree = fa_data->spftree[SPFTREE_IPV4]
|
||||
[level - 1];
|
||||
else
|
||||
#endif /* ifndef FABRICD */
|
||||
spftree = area->spftree[SPFTREE_IPV4]
|
||||
[level - 1];
|
||||
|
||||
isis_print_spftree(vty, spftree);
|
||||
|
||||
isis_print_routes(vty, spftree,
|
||||
json ? &json_val : NULL,
|
||||
prefix_sid, backup);
|
||||
if (json && json_val) {
|
||||
json_object_object_add(
|
||||
json_level, "ipv4", json_val);
|
||||
@ -2674,11 +2712,20 @@ static void show_isis_route_common(struct vty *vty, int levels,
|
||||
}
|
||||
if (area->ipv6_circuits > 0) {
|
||||
json_val = NULL;
|
||||
isis_print_routes(
|
||||
vty,
|
||||
area->spftree[SPFTREE_IPV6][level - 1],
|
||||
json ? &json_val : NULL, prefix_sid,
|
||||
backup);
|
||||
#ifndef FABRICD
|
||||
if (fa_data)
|
||||
spftree = fa_data->spftree[SPFTREE_IPV6]
|
||||
[level - 1];
|
||||
else
|
||||
#endif /* ifndef FABRICD */
|
||||
spftree = area->spftree[SPFTREE_IPV6]
|
||||
[level - 1];
|
||||
|
||||
isis_print_spftree(vty, spftree);
|
||||
|
||||
isis_print_routes(vty, spftree,
|
||||
json ? &json_val : NULL,
|
||||
prefix_sid, backup);
|
||||
if (json && json_val) {
|
||||
json_object_object_add(
|
||||
json_level, "ipv6", json_val);
|
||||
@ -2686,9 +2733,18 @@ static void show_isis_route_common(struct vty *vty, int levels,
|
||||
}
|
||||
if (isis_area_ipv6_dstsrc_enabled(area)) {
|
||||
json_val = NULL;
|
||||
isis_print_routes(vty,
|
||||
area->spftree[SPFTREE_DSTSRC]
|
||||
[level - 1],
|
||||
#ifndef FABRICD
|
||||
if (fa_data)
|
||||
spftree =
|
||||
fa_data->spftree[SPFTREE_DSTSRC]
|
||||
[level - 1];
|
||||
else
|
||||
#endif /* ifndef FABRICD */
|
||||
spftree = area->spftree[SPFTREE_DSTSRC]
|
||||
[level - 1];
|
||||
|
||||
isis_print_spftree(vty, spftree);
|
||||
isis_print_routes(vty, spftree,
|
||||
json ? &json_val : NULL,
|
||||
prefix_sid, backup);
|
||||
if (json && json_val) {
|
||||
@ -2710,17 +2766,25 @@ DEFUN(show_isis_route, show_isis_route_cmd,
|
||||
" [vrf <NAME|all>] route"
|
||||
#ifndef FABRICD
|
||||
" [<level-1|level-2>]"
|
||||
#endif
|
||||
#endif /* ifndef FABRICD */
|
||||
" [<prefix-sid|backup>]"
|
||||
#ifndef FABRICD
|
||||
" [algorithm (128-255)]"
|
||||
#endif /* ifndef FABRICD */
|
||||
" [json$uj]",
|
||||
SHOW_STR PROTO_HELP VRF_FULL_CMD_HELP_STR
|
||||
"IS-IS routing table\n"
|
||||
#ifndef FABRICD
|
||||
"level-1 routes\n"
|
||||
"level-2 routes\n"
|
||||
#endif
|
||||
#endif /* ifndef FABRICD */
|
||||
"Show Prefix-SID information\n"
|
||||
"Show backup routes\n" JSON_STR)
|
||||
"Show backup routes\n"
|
||||
#ifndef FABRICD
|
||||
"Show Flex-algo routes\n"
|
||||
"Algorithm number\n"
|
||||
#endif /* ifndef FABRICD */
|
||||
JSON_STR)
|
||||
{
|
||||
int levels;
|
||||
struct isis *isis;
|
||||
@ -2732,6 +2796,7 @@ DEFUN(show_isis_route, show_isis_route_cmd,
|
||||
bool uj = use_json(argc, argv);
|
||||
int idx = 0;
|
||||
json_object *json = NULL, *json_vrf = NULL;
|
||||
uint8_t algorithm = SR_ALGORITHM_SPF;
|
||||
|
||||
if (argv_find(argv, argc, "level-1", &idx))
|
||||
levels = ISIS_LEVEL1;
|
||||
@ -2751,15 +2816,20 @@ DEFUN(show_isis_route, show_isis_route_cmd,
|
||||
if (argv_find(argv, argc, "backup", &idx))
|
||||
backup = true;
|
||||
|
||||
#ifndef FABRICD
|
||||
if (argv_find(argv, argc, "algorithm", &idx))
|
||||
algorithm = (uint8_t)strtoul(argv[idx + 1]->arg, NULL, 10);
|
||||
#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,
|
||||
uj ? &json_vrf : NULL);
|
||||
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",
|
||||
@ -2773,7 +2843,8 @@ DEFUN(show_isis_route, show_isis_route_cmd,
|
||||
isis = isis_lookup_by_vrfname(vrf_name);
|
||||
if (isis != NULL) {
|
||||
show_isis_route_common(vty, levels, isis, prefix_sid,
|
||||
backup, uj ? &json_vrf : NULL);
|
||||
backup, algorithm,
|
||||
uj ? &json_vrf : NULL);
|
||||
if (uj) {
|
||||
json_object_object_add(
|
||||
json_vrf, "vrf_id",
|
||||
|
Loading…
Reference in New Issue
Block a user