]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_vty_fabricd.c
fabricd: Add `show openfabric flooding` command
[mirror_frr.git] / isisd / isis_vty_fabricd.c
1 /*
2 * IS-IS Rout(e)ing protocol - isis_vty_fabricd.c
3 *
4 * This file contains the CLI that is specific to OpenFabric
5 *
6 * Copyright (C) 2018 Christian Franke, for NetDEF, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public Licenseas published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22 #include <zebra.h>
23
24 #include "command.h"
25
26 #include "isisd/isisd.h"
27 #include "isisd/isis_vty_common.h"
28 #include "isisd/fabricd.h"
29 #include "isisd/isis_tlvs.h"
30 #include "isisd/isis_misc.h"
31 #include "isisd/isis_lsp.h"
32
33 DEFUN (fabric_tier,
34 fabric_tier_cmd,
35 "fabric-tier (0-14)",
36 "Statically configure the tier to advertise\n"
37 "Tier to advertise\n")
38 {
39 VTY_DECLVAR_CONTEXT(isis_area, area);
40
41 uint8_t tier = atoi(argv[1]->arg);
42
43 fabricd_configure_tier(area, tier);
44 return CMD_SUCCESS;
45 }
46
47 DEFUN (no_fabric_tier,
48 no_fabric_tier_cmd,
49 "no fabric-tier [(0-14)]",
50 NO_STR
51 "Statically configure the tier to advertise\n"
52 "Tier to advertise\n")
53 {
54 VTY_DECLVAR_CONTEXT(isis_area, area);
55
56 fabricd_configure_tier(area, ISIS_TIER_UNDEFINED);
57 return CMD_SUCCESS;
58 }
59
60 static void lsp_print_flooding(struct vty *vty, struct isis_lsp *lsp)
61 {
62 char lspid[255];
63
64 lspid_print(lsp->hdr.lsp_id, lspid, true, true);
65 vty_out(vty, "Flooding information for %s\n", lspid);
66
67 if (!lsp->flooding_neighbors[TX_LSP_NORMAL]) {
68 vty_out(vty, " Never flooded.\n");
69 return;
70 }
71
72 vty_out(vty, " Last received on: %s\n",
73 lsp->flooding_interface ?
74 lsp->flooding_interface : "(null)");
75
76 for (enum isis_tx_type type = TX_LSP_NORMAL;
77 type <= TX_LSP_CIRCUIT_SCOPED; type++) {
78 struct listnode *node;
79 uint8_t *neighbor_id;
80
81 vty_out(vty, " %s:\n",
82 (type == TX_LSP_NORMAL) ? "RF" : "DNR");
83 for (ALL_LIST_ELEMENTS_RO(lsp->flooding_neighbors[type],
84 node, neighbor_id)) {
85 vty_out(vty, " %s\n",
86 print_sys_hostname(neighbor_id));
87 }
88 }
89 }
90
91 DEFUN (show_lsp_flooding,
92 show_lsp_flooding_cmd,
93 "show openfabric flooding [WORD]",
94 SHOW_STR
95 PROTO_HELP
96 "Flooding information\n"
97 "LSP ID\n")
98 {
99 const char *lspid = NULL;
100
101 if (argc == 4) {
102 lspid = argv[3]->arg;
103 }
104
105 struct listnode *node;
106 struct isis_area *area;
107
108 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
109 dict_t *lspdb = area->lspdb[ISIS_LEVEL2 - 1];
110
111 vty_out(vty, "Area %s:\n", area->area_tag ?
112 area->area_tag : "null");
113
114 if (lspid) {
115 struct isis_lsp *lsp = lsp_for_arg(lspid, lspdb);
116
117 if (lsp)
118 lsp_print_flooding(vty, lsp);
119
120 continue;
121 }
122
123 for (dnode_t *dnode = dict_first(lspdb); dnode;
124 dnode = dict_next(lspdb, dnode)) {
125 lsp_print_flooding(vty, dnode_get(dnode));
126 vty_out(vty, "\n");
127 }
128 }
129
130 return CMD_SUCCESS;
131 }
132
133 void isis_vty_daemon_init(void)
134 {
135 install_element(ROUTER_NODE, &fabric_tier_cmd);
136 install_element(ROUTER_NODE, &no_fabric_tier_cmd);
137
138 install_element(ENABLE_NODE, &show_lsp_flooding_cmd);
139 }