From: Carmine Scarpitta Date: Thu, 2 Feb 2023 10:29:09 +0000 (+0100) Subject: isisd: Add CLI command to show SRv6 node info X-Git-Tag: base_9.1~88^2~134 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=fb9eb231f4eb130c6c11b4108faf69af37bcb56d;p=matthieu%2Ffrr.git isisd: Add CLI command to show SRv6 node info Add a CLI command to print SRv6 capabilities, algorithms and MSDs supported by the IS-IS nodes. Example: r1# show isis segment-routing srv6 node Area FOO: IS-IS L1 SRv6-Nodes: IS-IS L2 SRv6-Nodes: System ID Algorithm SRH Max SL SRH Max End Pop SRH Max H.encaps SRH Max End D ----------------------------------------------------------------------------------------- 1111.1111.1111 SPF 16 0 1 2 2222.2222.2222 SPF 16 0 1 2 Signed-off-by: Carmine Scarpitta --- diff --git a/isisd/isis_srv6.c b/isisd/isis_srv6.c index 564fd04285..1397ea4d0b 100644 --- a/isisd/isis_srv6.c +++ b/isisd/isis_srv6.c @@ -9,9 +9,94 @@ #include +#include "termtable.h" + #include "isisd/isisd.h" +#include "isisd/isis_misc.h" #include "isisd/isis_srv6.h" +/** + * Show Segment Routing over IPv6 (SRv6) Node. + * + * @param vty VTY output + * @param area IS-IS area + * @param level IS-IS level + */ +static void show_node(struct vty *vty, struct isis_area *area, int level) +{ + struct isis_lsp *lsp; + struct ttable *tt; + + vty_out(vty, " IS-IS %s SRv6-Nodes:\n\n", circuit_t2string(level)); + + /* Prepare table. */ + tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]); + ttable_add_row( + tt, + "System ID|Algorithm|SRH Max SL|SRH Max End Pop|SRH Max H.encaps|SRH Max End D"); + tt->style.cell.rpad = 2; + tt->style.corner = '+'; + ttable_restyle(tt); + ttable_rowseps(tt, 0, BOTTOM, true, '-'); + + frr_each (lspdb, &area->lspdb[level - 1], lsp) { + struct isis_router_cap *cap; + + if (!lsp->tlvs) + continue; + cap = lsp->tlvs->router_cap; + if (!cap) + continue; + + ttable_add_row(tt, "%pSY|%s|%u|%u|%u|%u", lsp->hdr.lsp_id, + cap->algo[0] == SR_ALGORITHM_SPF ? "SPF" + : "S-SPF", + cap->srv6_msd.max_seg_left_msd, + cap->srv6_msd.max_end_pop_msd, + cap->srv6_msd.max_h_encaps_msd, + cap->srv6_msd.max_end_d_msd); + } + + /* Dump the generated table. */ + if (tt->nrows > 1) { + char *table; + + table = ttable_dump(tt, "\n"); + vty_out(vty, "%s\n", table); + XFREE(MTYPE_TMP, table); + } + ttable_del(tt); +} + +DEFUN(show_srv6_node, show_srv6_node_cmd, + "show " PROTO_NAME " segment-routing srv6 node", + SHOW_STR + PROTO_HELP + "Segment-Routing\n" + "Segment-Routing over IPv6 (SRv6)\n" + "SRv6 node\n") +{ + struct listnode *node, *inode; + struct isis_area *area; + struct isis *isis; + + for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { + for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + vty_out(vty, "Area %s:\n", + area->area_tag ? area->area_tag : "null"); + if (!area->srv6db.config.enabled) { + vty_out(vty, " SRv6 is disabled\n"); + continue; + } + for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; + level++) + show_node(vty, area, level); + } + } + + return CMD_SUCCESS; +} + /** * IS-IS SRv6 initialization for given area. * @@ -56,6 +141,7 @@ void isis_srv6_area_term(struct isis_area *area) */ void isis_srv6_init(void) { + install_element(VIEW_NODE, &show_srv6_node_cmd); } /**