]> git.puffer.fish Git - matthieu/frr.git/commitdiff
isisd: add algorithm argument to show isis segment-routing node
authorLouis Scalbert <louis.scalbert@6wind.com>
Mon, 12 Dec 2022 14:59:19 +0000 (15:59 +0100)
committerLouis Scalbert <louis.scalbert@6wind.com>
Tue, 18 Apr 2023 09:33:15 +0000 (11:33 +0200)
Add algorithm argument to show isis segment-routing node

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

index 87b6f08670a5a8515aaed49757df719667b7b82c..f928185ffbc4aedfd88a76812fdc688d28339967 100644 (file)
@@ -1020,10 +1020,12 @@ char *sr_op2str(char *buf, size_t size, mpls_label_t label_in,
  * @param area IS-IS area
  * @param level        IS-IS level
  */
-static void show_node(struct vty *vty, struct isis_area *area, int level)
+static void show_node(struct vty *vty, struct isis_area *area, int level,
+                     uint8_t algo)
 {
        struct isis_lsp *lsp;
        struct ttable *tt;
+       char buf[128];
 
        vty_out(vty, " IS-IS %s SR-Nodes:\n\n", circuit_t2string(level));
 
@@ -1043,15 +1045,24 @@ static void show_node(struct vty *vty, struct isis_area *area, int level)
                cap = lsp->tlvs->router_cap;
                if (!cap)
                        continue;
+               if (cap->algo[algo] == SR_ALGORITHM_UNSET)
+                       continue;
+
+               if (cap->algo[algo] == SR_ALGORITHM_SPF)
+                       snprintf(buf, sizeof(buf), "SPF");
+               else if (cap->algo[algo] == SR_ALGORITHM_STRICT_SPF)
+                       snprintf(buf, sizeof(buf), "S-SPF");
+#ifndef FABRICD
+               else
+                       snprintf(buf, sizeof(buf), "Flex-Algo %d", algo);
+#endif /* ifndef FABRICD */
 
                ttable_add_row(tt, "%pSY|%u - %u|%u - %u|%s|%u",
                               lsp->hdr.lsp_id, cap->srgb.lower_bound,
                               cap->srgb.lower_bound + cap->srgb.range_size - 1,
                               cap->srlb.lower_bound,
                               cap->srlb.lower_bound + cap->srlb.range_size - 1,
-                              cap->algo[0] == SR_ALGORITHM_SPF ? "SPF"
-                                                               : "S-SPF",
-                              cap->msd);
+                              buf, cap->msd);
        }
 
        /* Dump the generated table. */
@@ -1066,15 +1077,31 @@ static void show_node(struct vty *vty, struct isis_area *area, int level)
 }
 
 DEFUN(show_sr_node, show_sr_node_cmd,
-      "show " PROTO_NAME " segment-routing node",
-      SHOW_STR
-      PROTO_HELP
+      "show " PROTO_NAME
+      " segment-routing node"
+#ifndef FABRICD
+      " [algorithm (128-255)]"
+#endif /* ifndef FABRICD */
+      ,
+      SHOW_STR PROTO_HELP
       "Segment-Routing\n"
-      "Segment-Routing node\n")
+      "Segment-Routing node\n"
+#ifndef FABRICD
+      "Show Flex-algo nodes\n"
+      "Algorithm number\n"
+#endif /* ifndef FABRICD */
+)
 {
        struct listnode *node, *inode;
        struct isis_area *area;
+       uint8_t algorithm = SR_ALGORITHM_SPF;
        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);
+#endif /* ifndef FABRICD */
 
        for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) {
                for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
@@ -1086,7 +1113,7 @@ DEFUN(show_sr_node, show_sr_node_cmd,
                        }
                        for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS;
                             level++)
-                               show_node(vty, area, level);
+                               show_node(vty, area, level, algorithm);
                }
        }