]> git.puffer.fish Git - mirror/frr.git/commitdiff
isisd: make algorithm id optional in show isis commands
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 15 Dec 2022 08:28:19 +0000 (09:28 +0100)
committerLouis Scalbert <louis.scalbert@6wind.com>
Mon, 19 Feb 2024 09:10:54 +0000 (10:10 +0100)
The following two isis commands have now the algorithm id
optional:

> # show isis segment-routing node algorithm
> # show isis topology algorithm

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
isisd/isis_spf.c
isisd/isis_sr.c

index 773136d03433b94f3277625f65cc545afb938b33..36986a19c5587b80e3f403b0ab32f66c5e827090 100644 (file)
@@ -2424,7 +2424,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
@@ -2443,8 +2443,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;
 
@@ -2453,8 +2455,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,14 +2471,34 @@ DEFUN(show_isis_topology, show_isis_topology_cmd,
 
        if (vrf_name) {
                if (all_vrf) {
-                       for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
-                               show_isis_topology_common(vty, levels, isis,
-                                                         algorithm);
+                       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,
+                                               (uint8_t)algorithm);
+                               }
+                       }
                        return CMD_SUCCESS;
                }
                isis = isis_lookup_by_vrfname(vrf_name);
-               if (isis != NULL)
-                       show_isis_topology_common(vty, levels, isis, algorithm);
+               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;
index 1d69dbbbfa418027ba85a24b16c43ca91db76b44..e8354fdf9226f895e8eb813e22b6e8b92429f2aa 100644 (file)
@@ -1074,7 +1074,7 @@ DEFUN(show_sr_node, show_sr_node_cmd,
       "show " PROTO_NAME
       " segment-routing node"
 #ifndef FABRICD
-      " [algorithm (128-255)]"
+      " [algorithm [(128-255)]]"
 #endif /* ifndef FABRICD */
       ,
       SHOW_STR PROTO_HELP
@@ -1088,13 +1088,18 @@ DEFUN(show_sr_node, show_sr_node_cmd,
 {
        struct listnode *node, *inode;
        struct isis_area *area;
-       uint8_t algorithm = SR_ALGORITHM_SPF;
+       uint16_t algorithm = SR_ALGORITHM_SPF;
+       bool all_algorithm = false;
        struct isis *isis;
 #ifndef FABRICD
        int idx = 0;
 
-       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 */
 
        for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) {
@@ -1106,8 +1111,17 @@ DEFUN(show_sr_node, show_sr_node_cmd,
                                continue;
                        }
                        for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS;
-                            level++)
-                               show_node(vty, area, level, algorithm);
+                            level++) {
+                               if (all_algorithm) {
+                                       for (algorithm = SR_ALGORITHM_FLEX_MIN;
+                                            algorithm <= SR_ALGORITHM_FLEX_MAX;
+                                            algorithm++)
+                                               show_node(vty, area, level,
+                                                         (uint8_t)algorithm);
+                               } else
+                                       show_node(vty, area, level,
+                                                 (uint8_t)algorithm);
+                       }
                }
        }