]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_vty_fabricd.c
Merge pull request #3454 from rodnymolina/isis_openfabric_enhacements
[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 DEFUN (triggered_csnp,
61 triggered_csnp_cmd,
62 "triggered-csnp-delay (100-10000) [always]",
63 "Configure the delay for triggered CSNPs\n"
64 "Delay in milliseconds\n"
65 "Trigger CSNP for all LSPs, not only circuit-scoped\n")
66 {
67 VTY_DECLVAR_CONTEXT(isis_area, area);
68
69 int csnp_delay = atoi(argv[1]->arg);
70 bool always_send_csnp = (argc == 3);
71
72 fabricd_configure_triggered_csnp(area, csnp_delay, always_send_csnp);
73 return CMD_SUCCESS;
74 }
75
76 DEFUN (no_triggered_csnp,
77 no_triggered_csnp_cmd,
78 "no triggered-csnp-delay [(100-10000) [always]]",
79 NO_STR
80 "Configure the delay for triggered CSNPs\n"
81 "Delay in milliseconds\n"
82 "Trigger CSNP for all LSPs, not only circuit-scoped\n")
83 {
84 VTY_DECLVAR_CONTEXT(isis_area, area);
85
86 fabricd_configure_triggered_csnp(area, FABRICD_DEFAULT_CSNP_DELAY,
87 false);
88 return CMD_SUCCESS;
89 }
90
91 static void lsp_print_flooding(struct vty *vty, struct isis_lsp *lsp)
92 {
93 char lspid[255];
94
95 lspid_print(lsp->hdr.lsp_id, lspid, true, true);
96 vty_out(vty, "Flooding information for %s\n", lspid);
97
98 if (!lsp->flooding_neighbors[TX_LSP_NORMAL]) {
99 vty_out(vty, " Never received.\n");
100 return;
101 }
102
103 vty_out(vty, " Last received on: %s (",
104 lsp->flooding_interface ?
105 lsp->flooding_interface : "(null)");
106
107 time_t uptime = time(NULL) - lsp->flooding_time;
108 struct tm *tm = gmtime(&uptime);
109
110 if (uptime < ONE_DAY_SECOND)
111 vty_out(vty, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
112 tm->tm_sec);
113 else if (uptime < ONE_WEEK_SECOND)
114 vty_out(vty, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour,
115 tm->tm_min);
116 else
117 vty_out(vty, "%02dw%dd%02dh", tm->tm_yday / 7,
118 tm->tm_yday - ((tm->tm_yday / 7) * 7),
119 tm->tm_hour);
120 vty_out(vty, " ago)\n");
121
122 if (lsp->flooding_circuit_scoped) {
123 vty_out(vty, " Received as circuit-scoped LSP, so not "
124 "flooded.\n");
125 return;
126 }
127
128 for (enum isis_tx_type type = TX_LSP_NORMAL;
129 type <= TX_LSP_CIRCUIT_SCOPED; type++) {
130 struct listnode *node;
131 uint8_t *neighbor_id;
132
133 vty_out(vty, " %s:\n",
134 (type == TX_LSP_NORMAL) ? "RF" : "DNR");
135 for (ALL_LIST_ELEMENTS_RO(lsp->flooding_neighbors[type],
136 node, neighbor_id)) {
137 vty_out(vty, " %s\n",
138 print_sys_hostname(neighbor_id));
139 }
140 }
141 }
142
143 DEFUN (show_lsp_flooding,
144 show_lsp_flooding_cmd,
145 "show openfabric flooding [WORD]",
146 SHOW_STR
147 PROTO_HELP
148 "Flooding information\n"
149 "LSP ID\n")
150 {
151 const char *lspid = NULL;
152
153 if (argc == 4)
154 lspid = argv[3]->arg;
155
156 struct listnode *node;
157 struct isis_area *area;
158
159 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
160 dict_t *lspdb = area->lspdb[ISIS_LEVEL2 - 1];
161
162 vty_out(vty, "Area %s:\n", area->area_tag ?
163 area->area_tag : "null");
164
165 if (lspid) {
166 struct isis_lsp *lsp = lsp_for_arg(lspid, lspdb);
167
168 if (lsp)
169 lsp_print_flooding(vty, lsp);
170
171 continue;
172 }
173
174 for (dnode_t *dnode = dict_first(lspdb); dnode;
175 dnode = dict_next(lspdb, dnode)) {
176 lsp_print_flooding(vty, dnode_get(dnode));
177 vty_out(vty, "\n");
178 }
179 }
180
181 return CMD_SUCCESS;
182 }
183
184 void isis_vty_daemon_init(void)
185 {
186 install_element(ROUTER_NODE, &fabric_tier_cmd);
187 install_element(ROUTER_NODE, &no_fabric_tier_cmd);
188 install_element(ROUTER_NODE, &triggered_csnp_cmd);
189 install_element(ROUTER_NODE, &no_triggered_csnp_cmd);
190
191 install_element(ENABLE_NODE, &show_lsp_flooding_cmd);
192 }