]>
Commit | Line | Data |
---|---|---|
ef020087 CF |
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 | ||
1eb7c3a1 CF |
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" | |
aaf2fd21 | 32 | #include "isisd/isis_csm.h" |
92ed0cde CF |
33 | |
34 | DEFUN (fabric_tier, | |
35 | fabric_tier_cmd, | |
36 | "fabric-tier (0-14)", | |
37 | "Statically configure the tier to advertise\n" | |
38 | "Tier to advertise\n") | |
39 | { | |
40 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
41 | ||
42 | uint8_t tier = atoi(argv[1]->arg); | |
43 | ||
44 | fabricd_configure_tier(area, tier); | |
45 | return CMD_SUCCESS; | |
46 | } | |
47 | ||
48 | DEFUN (no_fabric_tier, | |
49 | no_fabric_tier_cmd, | |
50 | "no fabric-tier [(0-14)]", | |
51 | NO_STR | |
52 | "Statically configure the tier to advertise\n" | |
53 | "Tier to advertise\n") | |
54 | { | |
55 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
56 | ||
57 | fabricd_configure_tier(area, ISIS_TIER_UNDEFINED); | |
58 | return CMD_SUCCESS; | |
59 | } | |
ef020087 | 60 | |
e923107c CF |
61 | DEFUN (triggered_csnp, |
62 | triggered_csnp_cmd, | |
63 | "triggered-csnp-delay (100-10000) [always]", | |
64 | "Configure the delay for triggered CSNPs\n" | |
65 | "Delay in milliseconds\n" | |
66 | "Trigger CSNP for all LSPs, not only circuit-scoped\n") | |
67 | { | |
68 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
69 | ||
70 | int csnp_delay = atoi(argv[1]->arg); | |
71 | bool always_send_csnp = (argc == 3); | |
72 | ||
73 | fabricd_configure_triggered_csnp(area, csnp_delay, always_send_csnp); | |
74 | return CMD_SUCCESS; | |
75 | } | |
76 | ||
77 | DEFUN (no_triggered_csnp, | |
78 | no_triggered_csnp_cmd, | |
79 | "no triggered-csnp-delay [(100-10000) [always]]", | |
80 | NO_STR | |
81 | "Configure the delay for triggered CSNPs\n" | |
82 | "Delay in milliseconds\n" | |
83 | "Trigger CSNP for all LSPs, not only circuit-scoped\n") | |
84 | { | |
85 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
86 | ||
87 | fabricd_configure_triggered_csnp(area, FABRICD_DEFAULT_CSNP_DELAY, | |
88 | false); | |
89 | return CMD_SUCCESS; | |
90 | } | |
91 | ||
1eb7c3a1 CF |
92 | static void lsp_print_flooding(struct vty *vty, struct isis_lsp *lsp) |
93 | { | |
94 | char lspid[255]; | |
95 | ||
96 | lspid_print(lsp->hdr.lsp_id, lspid, true, true); | |
97 | vty_out(vty, "Flooding information for %s\n", lspid); | |
98 | ||
99 | if (!lsp->flooding_neighbors[TX_LSP_NORMAL]) { | |
a6b60da9 | 100 | vty_out(vty, " Never received.\n"); |
1eb7c3a1 CF |
101 | return; |
102 | } | |
103 | ||
a6b60da9 | 104 | vty_out(vty, " Last received on: %s (", |
1eb7c3a1 CF |
105 | lsp->flooding_interface ? |
106 | lsp->flooding_interface : "(null)"); | |
107 | ||
a6b60da9 CF |
108 | time_t uptime = time(NULL) - lsp->flooding_time; |
109 | struct tm *tm = gmtime(&uptime); | |
110 | ||
111 | if (uptime < ONE_DAY_SECOND) | |
112 | vty_out(vty, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, | |
113 | tm->tm_sec); | |
114 | else if (uptime < ONE_WEEK_SECOND) | |
115 | vty_out(vty, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, | |
116 | tm->tm_min); | |
117 | else | |
118 | vty_out(vty, "%02dw%dd%02dh", tm->tm_yday / 7, | |
119 | tm->tm_yday - ((tm->tm_yday / 7) * 7), | |
120 | tm->tm_hour); | |
121 | vty_out(vty, " ago)\n"); | |
122 | ||
123 | if (lsp->flooding_circuit_scoped) { | |
89cdc4df RM |
124 | vty_out(vty, " Received as circuit-scoped LSP, so not " |
125 | "flooded.\n"); | |
a6b60da9 CF |
126 | return; |
127 | } | |
128 | ||
1eb7c3a1 CF |
129 | for (enum isis_tx_type type = TX_LSP_NORMAL; |
130 | type <= TX_LSP_CIRCUIT_SCOPED; type++) { | |
131 | struct listnode *node; | |
132 | uint8_t *neighbor_id; | |
133 | ||
134 | vty_out(vty, " %s:\n", | |
135 | (type == TX_LSP_NORMAL) ? "RF" : "DNR"); | |
136 | for (ALL_LIST_ELEMENTS_RO(lsp->flooding_neighbors[type], | |
137 | node, neighbor_id)) { | |
138 | vty_out(vty, " %s\n", | |
139 | print_sys_hostname(neighbor_id)); | |
140 | } | |
141 | } | |
142 | } | |
143 | ||
144 | DEFUN (show_lsp_flooding, | |
145 | show_lsp_flooding_cmd, | |
146 | "show openfabric flooding [WORD]", | |
147 | SHOW_STR | |
148 | PROTO_HELP | |
149 | "Flooding information\n" | |
150 | "LSP ID\n") | |
151 | { | |
152 | const char *lspid = NULL; | |
153 | ||
89cdc4df | 154 | if (argc == 4) |
1eb7c3a1 | 155 | lspid = argv[3]->arg; |
1eb7c3a1 CF |
156 | |
157 | struct listnode *node; | |
158 | struct isis_area *area; | |
159 | ||
160 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { | |
161 | dict_t *lspdb = area->lspdb[ISIS_LEVEL2 - 1]; | |
162 | ||
163 | vty_out(vty, "Area %s:\n", area->area_tag ? | |
164 | area->area_tag : "null"); | |
165 | ||
166 | if (lspid) { | |
167 | struct isis_lsp *lsp = lsp_for_arg(lspid, lspdb); | |
168 | ||
169 | if (lsp) | |
170 | lsp_print_flooding(vty, lsp); | |
171 | ||
172 | continue; | |
173 | } | |
174 | ||
175 | for (dnode_t *dnode = dict_first(lspdb); dnode; | |
176 | dnode = dict_next(lspdb, dnode)) { | |
177 | lsp_print_flooding(vty, dnode_get(dnode)); | |
178 | vty_out(vty, "\n"); | |
179 | } | |
180 | } | |
181 | ||
182 | return CMD_SUCCESS; | |
183 | } | |
184 | ||
aaf2fd21 EDP |
185 | DEFUN (ip_router_isis, |
186 | ip_router_isis_cmd, | |
187 | "ip router " PROTO_NAME " WORD", | |
188 | "Interface Internet Protocol config commands\n" | |
189 | "IP router interface commands\n" | |
190 | PROTO_HELP | |
191 | "Routing process tag\n") | |
192 | { | |
193 | int idx_afi = 0; | |
194 | int idx_word = 3; | |
195 | VTY_DECLVAR_CONTEXT(interface, ifp); | |
196 | struct isis_circuit *circuit; | |
197 | struct isis_area *area; | |
198 | const char *af = argv[idx_afi]->arg; | |
199 | const char *area_tag = argv[idx_word]->arg; | |
200 | ||
201 | /* Prevent more than one area per circuit */ | |
202 | circuit = circuit_scan_by_ifp(ifp); | |
203 | if (circuit && circuit->area) { | |
204 | if (strcmp(circuit->area->area_tag, area_tag)) { | |
205 | vty_out(vty, "ISIS circuit is already defined on %s\n", | |
206 | circuit->area->area_tag); | |
207 | return CMD_ERR_NOTHING_TODO; | |
208 | } | |
209 | } | |
210 | ||
211 | area = isis_area_lookup(area_tag); | |
212 | if (!area) | |
213 | area = isis_area_create(area_tag); | |
214 | ||
215 | if (!circuit || !circuit->area) { | |
216 | circuit = isis_circuit_create(area, ifp); | |
217 | ||
218 | if (circuit->state != C_STATE_CONF | |
219 | && circuit->state != C_STATE_UP) { | |
220 | vty_out(vty, | |
221 | "Couldn't bring up interface, please check log.\n"); | |
222 | return CMD_WARNING_CONFIG_FAILED; | |
223 | } | |
224 | } | |
225 | ||
226 | bool ip = circuit->ip_router, ipv6 = circuit->ipv6_router; | |
227 | if (af[2] != '\0') | |
228 | ipv6 = true; | |
229 | else | |
230 | ip = true; | |
231 | ||
232 | isis_circuit_af_set(circuit, ip, ipv6); | |
233 | return CMD_SUCCESS; | |
234 | } | |
235 | ||
236 | DEFUN (ip6_router_isis, | |
237 | ip6_router_isis_cmd, | |
238 | "ipv6 router " PROTO_NAME " WORD", | |
239 | "Interface Internet Protocol config commands\n" | |
240 | "IP router interface commands\n" | |
241 | PROTO_HELP | |
242 | "Routing process tag\n") | |
243 | { | |
244 | return ip_router_isis(self, vty, argc, argv); | |
245 | } | |
246 | ||
247 | DEFUN (no_ip_router_isis, | |
248 | no_ip_router_isis_cmd, | |
249 | "no <ip|ipv6> router " PROTO_NAME " WORD", | |
250 | NO_STR | |
251 | "Interface Internet Protocol config commands\n" | |
252 | "IP router interface commands\n" | |
253 | "IP router interface commands\n" | |
254 | PROTO_HELP | |
255 | "Routing process tag\n") | |
256 | { | |
257 | int idx_afi = 1; | |
258 | int idx_word = 4; | |
259 | VTY_DECLVAR_CONTEXT(interface, ifp); | |
260 | struct isis_area *area; | |
261 | struct isis_circuit *circuit; | |
262 | const char *af = argv[idx_afi]->arg; | |
263 | const char *area_tag = argv[idx_word]->arg; | |
264 | ||
265 | area = isis_area_lookup(area_tag); | |
266 | if (!area) { | |
267 | vty_out(vty, "Can't find ISIS instance %s\n", | |
268 | area_tag); | |
269 | return CMD_ERR_NO_MATCH; | |
270 | } | |
271 | ||
272 | circuit = circuit_lookup_by_ifp(ifp, area->circuit_list); | |
273 | if (!circuit) { | |
274 | vty_out(vty, "ISIS is not enabled on circuit %s\n", ifp->name); | |
275 | return CMD_ERR_NO_MATCH; | |
276 | } | |
277 | ||
278 | bool ip = circuit->ip_router, ipv6 = circuit->ipv6_router; | |
279 | if (af[2] != '\0') | |
280 | ipv6 = false; | |
281 | else | |
282 | ip = false; | |
283 | ||
284 | isis_circuit_af_set(circuit, ip, ipv6); | |
285 | return CMD_SUCCESS; | |
286 | } | |
287 | ||
ef020087 CF |
288 | void isis_vty_daemon_init(void) |
289 | { | |
92ed0cde CF |
290 | install_element(ROUTER_NODE, &fabric_tier_cmd); |
291 | install_element(ROUTER_NODE, &no_fabric_tier_cmd); | |
e923107c CF |
292 | install_element(ROUTER_NODE, &triggered_csnp_cmd); |
293 | install_element(ROUTER_NODE, &no_triggered_csnp_cmd); | |
1eb7c3a1 CF |
294 | |
295 | install_element(ENABLE_NODE, &show_lsp_flooding_cmd); | |
aaf2fd21 EDP |
296 | |
297 | install_element(INTERFACE_NODE, &ip_router_isis_cmd); | |
298 | install_element(INTERFACE_NODE, &ip6_router_isis_cmd); | |
299 | install_element(INTERFACE_NODE, &no_ip_router_isis_cmd); | |
ef020087 | 300 | } |