2 * IS-IS Rout(e)ing protocol - isis_vty_fabricd.c
4 * This file contains the CLI that is specific to OpenFabric
6 * Copyright (C) 2018 Christian Franke, for NetDEF, Inc.
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)
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
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
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"
36 "Statically configure the tier to advertise\n"
37 "Tier to advertise\n")
39 VTY_DECLVAR_CONTEXT(isis_area
, area
);
41 uint8_t tier
= atoi(argv
[1]->arg
);
43 fabricd_configure_tier(area
, tier
);
47 DEFUN (no_fabric_tier
,
49 "no fabric-tier [(0-14)]",
51 "Statically configure the tier to advertise\n"
52 "Tier to advertise\n")
54 VTY_DECLVAR_CONTEXT(isis_area
, area
);
56 fabricd_configure_tier(area
, ISIS_TIER_UNDEFINED
);
60 DEFUN (triggered_csnp
,
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")
67 VTY_DECLVAR_CONTEXT(isis_area
, area
);
69 int csnp_delay
= atoi(argv
[1]->arg
);
70 bool always_send_csnp
= (argc
== 3);
72 fabricd_configure_triggered_csnp(area
, csnp_delay
, always_send_csnp
);
76 DEFUN (no_triggered_csnp
,
77 no_triggered_csnp_cmd
,
78 "no triggered-csnp-delay [(100-10000) [always]]",
80 "Configure the delay for triggered CSNPs\n"
81 "Delay in milliseconds\n"
82 "Trigger CSNP for all LSPs, not only circuit-scoped\n")
84 VTY_DECLVAR_CONTEXT(isis_area
, area
);
86 fabricd_configure_triggered_csnp(area
, FABRICD_DEFAULT_CSNP_DELAY
,
91 static void lsp_print_flooding(struct vty
*vty
, struct isis_lsp
*lsp
)
95 lspid_print(lsp
->hdr
.lsp_id
, lspid
, true, true);
96 vty_out(vty
, "Flooding information for %s\n", lspid
);
98 if (!lsp
->flooding_neighbors
[TX_LSP_NORMAL
]) {
99 vty_out(vty
, " Never received.\n");
103 vty_out(vty
, " Last received on: %s (",
104 lsp
->flooding_interface
?
105 lsp
->flooding_interface
: "(null)");
107 time_t uptime
= time(NULL
) - lsp
->flooding_time
;
108 struct tm
*tm
= gmtime(&uptime
);
110 if (uptime
< ONE_DAY_SECOND
)
111 vty_out(vty
, "%02d:%02d:%02d", tm
->tm_hour
, tm
->tm_min
,
113 else if (uptime
< ONE_WEEK_SECOND
)
114 vty_out(vty
, "%dd%02dh%02dm", tm
->tm_yday
, tm
->tm_hour
,
117 vty_out(vty
, "%02dw%dd%02dh", tm
->tm_yday
/ 7,
118 tm
->tm_yday
- ((tm
->tm_yday
/ 7) * 7),
120 vty_out(vty
, " ago)\n");
122 if (lsp
->flooding_circuit_scoped
) {
123 vty_out(vty
, " Received as circuit-scoped LSP, so not "
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
;
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
));
143 DEFUN (show_lsp_flooding
,
144 show_lsp_flooding_cmd
,
145 "show openfabric flooding [WORD]",
148 "Flooding information\n"
151 const char *lspid
= NULL
;
154 lspid
= argv
[3]->arg
;
156 struct listnode
*node
;
157 struct isis_area
*area
;
159 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
160 dict_t
*lspdb
= area
->lspdb
[ISIS_LEVEL2
- 1];
162 vty_out(vty
, "Area %s:\n", area
->area_tag
?
163 area
->area_tag
: "null");
166 struct isis_lsp
*lsp
= lsp_for_arg(lspid
, lspdb
);
169 lsp_print_flooding(vty
, lsp
);
174 for (dnode_t
*dnode
= dict_first(lspdb
); dnode
;
175 dnode
= dict_next(lspdb
, dnode
)) {
176 lsp_print_flooding(vty
, dnode_get(dnode
));
184 void isis_vty_daemon_init(void)
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
);
191 install_element(ENABLE_NODE
, &show_lsp_flooding_cmd
);