]>
Commit | Line | Data |
---|---|---|
eb5d44eb | 1 | /* |
2 | * IS-IS Rout(e)ing protocol - isisd.c | |
3 | * | |
4 | * Copyright (C) 2001,2002 Sampo Saaristo | |
d62a17ae | 5 | * Tampere University of Technology |
eb5d44eb | 6 | * Institute of Communications Engineering |
7 | * | |
d62a17ae | 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) | |
eb5d44eb | 11 | * any later version. |
12 | * | |
d62a17ae | 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 | |
eb5d44eb | 16 | * more details. |
896014f4 DL |
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 | |
eb5d44eb | 21 | */ |
22 | ||
eb5d44eb | 23 | #include <zebra.h> |
eb5d44eb | 24 | |
25 | #include "thread.h" | |
26 | #include "vty.h" | |
27 | #include "command.h" | |
28 | #include "log.h" | |
29 | #include "memory.h" | |
3f045a08 | 30 | #include "time.h" |
eb5d44eb | 31 | #include "linklist.h" |
32 | #include "if.h" | |
33 | #include "hash.h" | |
34 | #include "stream.h" | |
35 | #include "prefix.h" | |
36 | #include "table.h" | |
676a4ea3 | 37 | #include "qobj.h" |
03f7e182 | 38 | #include "spf_backoff.h" |
eb5d44eb | 39 | |
40 | #include "isisd/dict.h" | |
eb5d44eb | 41 | #include "isisd/isis_constants.h" |
42 | #include "isisd/isis_common.h" | |
eb5d44eb | 43 | #include "isisd/isis_flags.h" |
3f045a08 JB |
44 | #include "isisd/isis_circuit.h" |
45 | #include "isisd/isis_csm.h" | |
eb5d44eb | 46 | #include "isisd/isisd.h" |
47 | #include "isisd/isis_dynhn.h" | |
48 | #include "isisd/isis_adjacency.h" | |
49 | #include "isisd/isis_pdu.h" | |
50 | #include "isisd/isis_misc.h" | |
51 | #include "isisd/isis_constants.h" | |
eb5d44eb | 52 | #include "isisd/isis_lsp.h" |
53 | #include "isisd/isis_spf.h" | |
54 | #include "isisd/isis_route.h" | |
55 | #include "isisd/isis_zebra.h" | |
56 | #include "isisd/isis_events.h" | |
f8c06e2c | 57 | #include "isisd/isis_te.h" |
064f4896 | 58 | #include "isisd/isis_mt.h" |
8e6fb83b | 59 | #include "isisd/fabricd.h" |
eb5d44eb | 60 | |
eb5d44eb | 61 | struct isis *isis = NULL; |
eb5d44eb | 62 | |
676a4ea3 DL |
63 | DEFINE_QOBJ_TYPE(isis) |
64 | DEFINE_QOBJ_TYPE(isis_area) | |
65 | ||
41b36e90 PJ |
66 | /* |
67 | * Prototypes. | |
68 | */ | |
41b36e90 PJ |
69 | int isis_area_get(struct vty *, const char *); |
70 | int isis_area_destroy(struct vty *, const char *); | |
3f045a08 JB |
71 | int area_net_title(struct vty *, const char *); |
72 | int area_clear_net_title(struct vty *, const char *); | |
73 | int show_isis_interface_common(struct vty *, const char *ifname, char); | |
74 | int show_isis_neighbor_common(struct vty *, const char *id, char); | |
75 | int clear_isis_neighbor_common(struct vty *, const char *id); | |
41b36e90 PJ |
76 | int isis_config_write(struct vty *); |
77 | ||
78 | ||
d62a17ae | 79 | void isis_new(unsigned long process_id) |
80 | { | |
81 | isis = XCALLOC(MTYPE_ISIS, sizeof(struct isis)); | |
82 | /* | |
83 | * Default values | |
84 | */ | |
85 | isis->max_area_addrs = 3; | |
86 | isis->process_id = process_id; | |
87 | isis->router_id = 0; | |
88 | isis->area_list = list_new(); | |
89 | isis->init_circ_list = list_new(); | |
90 | isis->uptime = time(NULL); | |
91 | isis->nexthops = list_new(); | |
92 | isis->nexthops6 = list_new(); | |
93 | dyn_cache_init(); | |
94 | /* | |
95 | * uncomment the next line for full debugs | |
96 | */ | |
97 | /* isis->debugs = 0xFFFF; */ | |
98 | isisMplsTE.status = disable; /* Only support TE metric */ | |
8e6fb83b | 99 | |
d62a17ae | 100 | QOBJ_REG(isis, isis); |
101 | } | |
102 | ||
103 | struct isis_area *isis_area_create(const char *area_tag) | |
104 | { | |
105 | struct isis_area *area; | |
106 | ||
107 | area = XCALLOC(MTYPE_ISIS_AREA, sizeof(struct isis_area)); | |
108 | ||
109 | /* | |
65f18157 CF |
110 | * Fabricd runs only as level-2. |
111 | * For IS-IS, the first instance is level-1-2 rest are level-1, | |
112 | * unless otherwise configured | |
d62a17ae | 113 | */ |
65f18157 CF |
114 | if (fabricd) { |
115 | area->is_type = IS_LEVEL_2; | |
116 | } else if (listcount(isis->area_list) > 0) | |
d62a17ae | 117 | area->is_type = IS_LEVEL_1; |
118 | else | |
119 | area->is_type = IS_LEVEL_1_AND_2; | |
120 | ||
121 | /* | |
122 | * intialize the databases | |
123 | */ | |
124 | if (area->is_type & IS_LEVEL_1) { | |
125 | area->lspdb[0] = lsp_db_init(); | |
d62a17ae | 126 | } |
127 | if (area->is_type & IS_LEVEL_2) { | |
128 | area->lspdb[1] = lsp_db_init(); | |
d62a17ae | 129 | } |
130 | ||
131 | spftree_area_init(area); | |
132 | ||
133 | area->circuit_list = list_new(); | |
134 | area->area_addrs = list_new(); | |
135 | thread_add_timer(master, lsp_tick, area, 1, &area->t_tick); | |
136 | flags_initialize(&area->flags); | |
137 | ||
138 | /* | |
139 | * Default values | |
140 | */ | |
141 | area->max_lsp_lifetime[0] = DEFAULT_LSP_LIFETIME; /* 1200 */ | |
142 | area->max_lsp_lifetime[1] = DEFAULT_LSP_LIFETIME; /* 1200 */ | |
143 | area->lsp_refresh[0] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */ | |
144 | area->lsp_refresh[1] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */ | |
145 | area->lsp_gen_interval[0] = DEFAULT_MIN_LSP_GEN_INTERVAL; | |
146 | area->lsp_gen_interval[1] = DEFAULT_MIN_LSP_GEN_INTERVAL; | |
147 | area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL; | |
148 | area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL; | |
149 | area->dynhostname = 1; | |
150 | area->oldmetric = 0; | |
151 | area->newmetric = 1; | |
152 | area->lsp_frag_threshold = 90; | |
153 | area->lsp_mtu = DEFAULT_LSP_MTU; | |
154 | ||
155 | area_mt_init(area); | |
41b36e90 | 156 | |
d62a17ae | 157 | area->area_tag = strdup(area_tag); |
158 | listnode_add(isis->area_list, area); | |
159 | area->isis = isis; | |
f390d2c7 | 160 | |
8e6fb83b | 161 | if (fabricd) |
b30e837b | 162 | area->fabricd = fabricd_new(area); |
d62a17ae | 163 | QOBJ_REG(area, isis_area); |
eb5d44eb | 164 | |
d62a17ae | 165 | return area; |
166 | } | |
3f045a08 | 167 | |
d62a17ae | 168 | struct isis_area *isis_area_lookup(const char *area_tag) |
169 | { | |
170 | struct isis_area *area; | |
171 | struct listnode *node; | |
3f045a08 | 172 | |
d62a17ae | 173 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) |
174 | if ((area->area_tag == NULL && area_tag == NULL) | |
175 | || (area->area_tag && area_tag | |
176 | && strcmp(area->area_tag, area_tag) == 0)) | |
177 | return area; | |
3f045a08 | 178 | |
d62a17ae | 179 | return NULL; |
180 | } | |
3f045a08 | 181 | |
d62a17ae | 182 | int isis_area_get(struct vty *vty, const char *area_tag) |
183 | { | |
184 | struct isis_area *area; | |
5475ecf7 | 185 | |
d62a17ae | 186 | area = isis_area_lookup(area_tag); |
03f7e182 | 187 | |
d62a17ae | 188 | if (area) { |
7c0cbd0e | 189 | VTY_PUSH_CONTEXT(ROUTER_NODE, area); |
d62a17ae | 190 | return CMD_SUCCESS; |
191 | } | |
192 | ||
193 | area = isis_area_create(area_tag); | |
3f045a08 | 194 | |
d62a17ae | 195 | if (isis->debugs & DEBUG_EVENTS) |
196 | zlog_debug("New IS-IS area instance %s", area->area_tag); | |
3f045a08 | 197 | |
7c0cbd0e | 198 | VTY_PUSH_CONTEXT(ROUTER_NODE, area); |
f3ccedaa | 199 | |
d62a17ae | 200 | return CMD_SUCCESS; |
201 | } | |
3f045a08 | 202 | |
d62a17ae | 203 | int isis_area_destroy(struct vty *vty, const char *area_tag) |
eb5d44eb | 204 | { |
d62a17ae | 205 | struct isis_area *area; |
206 | struct listnode *node, *nnode; | |
207 | struct isis_circuit *circuit; | |
208 | struct area_addr *addr; | |
eb5d44eb | 209 | |
d62a17ae | 210 | area = isis_area_lookup(area_tag); |
211 | ||
212 | if (area == NULL) { | |
213 | vty_out(vty, "Can't find ISIS instance \n"); | |
214 | return CMD_ERR_NO_MATCH; | |
215 | } | |
216 | ||
217 | QOBJ_UNREG(area); | |
218 | ||
b30e837b CF |
219 | if (fabricd) |
220 | fabricd_finish(area->fabricd); | |
221 | ||
d62a17ae | 222 | if (area->circuit_list) { |
223 | for (ALL_LIST_ELEMENTS(area->circuit_list, node, nnode, | |
224 | circuit)) { | |
225 | circuit->ip_router = 0; | |
226 | circuit->ipv6_router = 0; | |
227 | isis_csm_state_change(ISIS_DISABLE, circuit, area); | |
228 | } | |
affe9e99 | 229 | list_delete_and_null(&area->circuit_list); |
d62a17ae | 230 | } |
231 | ||
232 | if (area->lspdb[0] != NULL) { | |
233 | lsp_db_destroy(area->lspdb[0]); | |
234 | area->lspdb[0] = NULL; | |
235 | } | |
236 | if (area->lspdb[1] != NULL) { | |
237 | lsp_db_destroy(area->lspdb[1]); | |
238 | area->lspdb[1] = NULL; | |
239 | } | |
240 | ||
3dace42d CF |
241 | /* invalidate and verify to delete all routes from zebra */ |
242 | isis_area_invalidate_routes(area, ISIS_LEVEL1 & ISIS_LEVEL2); | |
243 | isis_area_verify_routes(area); | |
244 | ||
d62a17ae | 245 | spftree_area_del(area); |
246 | ||
247 | THREAD_TIMER_OFF(area->spf_timer[0]); | |
248 | THREAD_TIMER_OFF(area->spf_timer[1]); | |
249 | ||
250 | spf_backoff_free(area->spf_delay_ietf[0]); | |
251 | spf_backoff_free(area->spf_delay_ietf[1]); | |
252 | ||
d62a17ae | 253 | isis_redist_area_finish(area); |
254 | ||
255 | for (ALL_LIST_ELEMENTS(area->area_addrs, node, nnode, addr)) { | |
256 | list_delete_node(area->area_addrs, node); | |
257 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
258 | } | |
259 | area->area_addrs = NULL; | |
260 | ||
261 | THREAD_TIMER_OFF(area->t_tick); | |
262 | THREAD_TIMER_OFF(area->t_lsp_refresh[0]); | |
263 | THREAD_TIMER_OFF(area->t_lsp_refresh[1]); | |
264 | ||
265 | thread_cancel_event(master, area); | |
266 | ||
267 | listnode_delete(isis->area_list, area); | |
268 | ||
269 | free(area->area_tag); | |
270 | ||
271 | area_mt_finish(area); | |
272 | ||
273 | XFREE(MTYPE_ISIS_AREA, area); | |
274 | ||
275 | if (listcount(isis->area_list) == 0) { | |
276 | memset(isis->sysid, 0, ISIS_SYS_ID_LEN); | |
277 | isis->sysid_set = 0; | |
278 | } | |
279 | ||
280 | return CMD_SUCCESS; | |
281 | } | |
282 | ||
283 | static void area_set_mt_enabled(struct isis_area *area, uint16_t mtid, | |
284 | bool enabled) | |
285 | { | |
286 | struct isis_area_mt_setting *setting; | |
287 | ||
288 | setting = area_get_mt_setting(area, mtid); | |
289 | if (setting->enabled != enabled) { | |
290 | setting->enabled = enabled; | |
291 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
292 | } | |
293 | } | |
294 | ||
295 | static void area_set_mt_overload(struct isis_area *area, uint16_t mtid, | |
296 | bool overload) | |
297 | { | |
298 | struct isis_area_mt_setting *setting; | |
299 | ||
300 | setting = area_get_mt_setting(area, mtid); | |
301 | if (setting->overload != overload) { | |
302 | setting->overload = overload; | |
303 | if (setting->enabled) | |
304 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, | |
305 | 0); | |
306 | } | |
307 | } | |
308 | ||
309 | int area_net_title(struct vty *vty, const char *net_title) | |
310 | { | |
311 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
312 | struct area_addr *addr; | |
313 | struct area_addr *addrp; | |
314 | struct listnode *node; | |
eb5d44eb | 315 | |
d7c0a89a | 316 | uint8_t buff[255]; |
d62a17ae | 317 | |
318 | /* We check that we are not over the maximal number of addresses */ | |
319 | if (listcount(area->area_addrs) >= isis->max_area_addrs) { | |
320 | vty_out(vty, | |
321 | "Maximum of area addresses (%d) already reached \n", | |
322 | isis->max_area_addrs); | |
323 | return CMD_ERR_NOTHING_TODO; | |
324 | } | |
325 | ||
326 | addr = XMALLOC(MTYPE_ISIS_AREA_ADDR, sizeof(struct area_addr)); | |
327 | addr->addr_len = dotformat2buff(buff, net_title); | |
328 | memcpy(addr->area_addr, buff, addr->addr_len); | |
eb5d44eb | 329 | #ifdef EXTREME_DEBUG |
d62a17ae | 330 | zlog_debug("added area address %s for area %s (address length %d)", |
331 | net_title, area->area_tag, addr->addr_len); | |
eb5d44eb | 332 | #endif /* EXTREME_DEBUG */ |
d62a17ae | 333 | if (addr->addr_len < 8 || addr->addr_len > 20) { |
334 | vty_out(vty, | |
335 | "area address must be at least 8..20 octets long (%d)\n", | |
336 | addr->addr_len); | |
337 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
a5fdb4c5 | 338 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 339 | } |
340 | ||
341 | if (addr->area_addr[addr->addr_len - 1] != 0) { | |
342 | vty_out(vty, | |
343 | "nsel byte (last byte) in area address must be 0\n"); | |
344 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
a5fdb4c5 | 345 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 346 | } |
347 | ||
348 | if (isis->sysid_set == 0) { | |
349 | /* | |
350 | * First area address - get the SystemID for this router | |
351 | */ | |
352 | memcpy(isis->sysid, GETSYSID(addr), ISIS_SYS_ID_LEN); | |
353 | isis->sysid_set = 1; | |
354 | if (isis->debugs & DEBUG_EVENTS) | |
355 | zlog_debug("Router has SystemID %s", | |
356 | sysid_print(isis->sysid)); | |
357 | } else { | |
358 | /* | |
359 | * Check that the SystemID portions match | |
360 | */ | |
361 | if (memcmp(isis->sysid, GETSYSID(addr), ISIS_SYS_ID_LEN)) { | |
362 | vty_out(vty, | |
363 | "System ID must not change when defining additional area addresses\n"); | |
364 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
a5fdb4c5 | 365 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 366 | } |
367 | ||
368 | /* now we see that we don't already have this address */ | |
369 | for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) { | |
370 | if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) | |
371 | != (addr->addr_len)) | |
372 | continue; | |
373 | if (!memcmp(addrp->area_addr, addr->area_addr, | |
374 | addr->addr_len)) { | |
375 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
376 | return CMD_SUCCESS; /* silent fail */ | |
377 | } | |
378 | } | |
379 | } | |
380 | ||
381 | /* | |
382 | * Forget the systemID part of the address | |
383 | */ | |
384 | addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN); | |
385 | listnode_add(area->area_addrs, addr); | |
386 | ||
387 | /* only now we can safely generate our LSPs for this area */ | |
388 | if (listcount(area->area_addrs) > 0) { | |
389 | if (area->is_type & IS_LEVEL_1) | |
390 | lsp_generate(area, IS_LEVEL_1); | |
391 | if (area->is_type & IS_LEVEL_2) | |
392 | lsp_generate(area, IS_LEVEL_2); | |
393 | } | |
394 | ||
395 | return CMD_SUCCESS; | |
396 | } | |
397 | ||
398 | int area_clear_net_title(struct vty *vty, const char *net_title) | |
399 | { | |
400 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
401 | struct area_addr addr, *addrp = NULL; | |
402 | struct listnode *node; | |
d7c0a89a | 403 | uint8_t buff[255]; |
d62a17ae | 404 | |
405 | addr.addr_len = dotformat2buff(buff, net_title); | |
406 | if (addr.addr_len < 8 || addr.addr_len > 20) { | |
407 | vty_out(vty, | |
408 | "Unsupported area address length %d, should be 8...20 \n", | |
409 | addr.addr_len); | |
a5fdb4c5 | 410 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 411 | } |
412 | ||
413 | memcpy(addr.area_addr, buff, (int)addr.addr_len); | |
414 | ||
415 | for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) | |
416 | if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len | |
417 | && !memcmp(addrp->area_addr, addr.area_addr, addr.addr_len)) | |
418 | break; | |
419 | ||
420 | if (!addrp) { | |
421 | vty_out(vty, "No area address %s for area %s \n", net_title, | |
422 | area->area_tag); | |
423 | return CMD_ERR_NO_MATCH; | |
424 | } | |
425 | ||
426 | listnode_delete(area->area_addrs, addrp); | |
427 | XFREE(MTYPE_ISIS_AREA_ADDR, addrp); | |
428 | ||
429 | /* | |
430 | * Last area address - reset the SystemID for this router | |
431 | */ | |
432 | if (listcount(area->area_addrs) == 0) { | |
433 | memset(isis->sysid, 0, ISIS_SYS_ID_LEN); | |
434 | isis->sysid_set = 0; | |
435 | if (isis->debugs & DEBUG_EVENTS) | |
436 | zlog_debug("Router has no SystemID"); | |
437 | } | |
438 | ||
439 | return CMD_SUCCESS; | |
eb5d44eb | 440 | } |
441 | ||
eb5d44eb | 442 | /* |
3f045a08 | 443 | * 'show isis interface' command |
eb5d44eb | 444 | */ |
445 | ||
d62a17ae | 446 | int show_isis_interface_common(struct vty *vty, const char *ifname, char detail) |
eb5d44eb | 447 | { |
d62a17ae | 448 | struct listnode *anode, *cnode; |
449 | struct isis_area *area; | |
450 | struct isis_circuit *circuit; | |
eb5d44eb | 451 | |
d62a17ae | 452 | if (!isis) { |
453 | vty_out(vty, "IS-IS Routing Process not enabled\n"); | |
454 | return CMD_SUCCESS; | |
455 | } | |
eb5d44eb | 456 | |
d62a17ae | 457 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { |
458 | vty_out(vty, "Area %s:\n", area->area_tag); | |
f390d2c7 | 459 | |
d62a17ae | 460 | if (detail == ISIS_UI_LEVEL_BRIEF) |
461 | vty_out(vty, | |
462 | " Interface CircId State Type Level\n"); | |
f390d2c7 | 463 | |
d62a17ae | 464 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) |
465 | if (!ifname) | |
466 | isis_circuit_print_vty(circuit, vty, detail); | |
467 | else if (strcmp(circuit->interface->name, ifname) == 0) | |
468 | isis_circuit_print_vty(circuit, vty, detail); | |
469 | } | |
f390d2c7 | 470 | |
d62a17ae | 471 | return CMD_SUCCESS; |
eb5d44eb | 472 | } |
473 | ||
3f045a08 JB |
474 | DEFUN (show_isis_interface, |
475 | show_isis_interface_cmd, | |
7c0cbd0e | 476 | "show " PROTO_NAME " interface", |
eb5d44eb | 477 | SHOW_STR |
7c0cbd0e | 478 | PROTO_HELP |
3f045a08 | 479 | "ISIS interface\n") |
eb5d44eb | 480 | { |
d62a17ae | 481 | return show_isis_interface_common(vty, NULL, ISIS_UI_LEVEL_BRIEF); |
eb5d44eb | 482 | } |
483 | ||
3f045a08 JB |
484 | DEFUN (show_isis_interface_detail, |
485 | show_isis_interface_detail_cmd, | |
7c0cbd0e | 486 | "show " PROTO_NAME " interface detail", |
eb5d44eb | 487 | SHOW_STR |
7c0cbd0e | 488 | PROTO_HELP |
3f045a08 JB |
489 | "ISIS interface\n" |
490 | "show detailed information\n") | |
491 | { | |
d62a17ae | 492 | return show_isis_interface_common(vty, NULL, ISIS_UI_LEVEL_DETAIL); |
3f045a08 | 493 | } |
eb5d44eb | 494 | |
3f045a08 JB |
495 | DEFUN (show_isis_interface_arg, |
496 | show_isis_interface_arg_cmd, | |
7c0cbd0e | 497 | "show " PROTO_NAME " interface WORD", |
eb5d44eb | 498 | SHOW_STR |
7c0cbd0e | 499 | PROTO_HELP |
3f045a08 JB |
500 | "ISIS interface\n" |
501 | "ISIS interface name\n") | |
502 | { | |
d62a17ae | 503 | int idx_word = 3; |
504 | return show_isis_interface_common(vty, argv[idx_word]->arg, | |
505 | ISIS_UI_LEVEL_DETAIL); | |
3f045a08 JB |
506 | } |
507 | ||
508 | /* | |
509 | * 'show isis neighbor' command | |
510 | */ | |
511 | ||
d62a17ae | 512 | int show_isis_neighbor_common(struct vty *vty, const char *id, char detail) |
513 | { | |
514 | struct listnode *anode, *cnode, *node; | |
515 | struct isis_area *area; | |
516 | struct isis_circuit *circuit; | |
517 | struct list *adjdb; | |
518 | struct isis_adjacency *adj; | |
519 | struct isis_dynhn *dynhn; | |
d7c0a89a | 520 | uint8_t sysid[ISIS_SYS_ID_LEN]; |
d62a17ae | 521 | int i; |
522 | ||
523 | if (!isis) { | |
524 | vty_out(vty, "IS-IS Routing Process not enabled\n"); | |
525 | return CMD_SUCCESS; | |
526 | } | |
527 | ||
528 | memset(sysid, 0, ISIS_SYS_ID_LEN); | |
529 | if (id) { | |
530 | if (sysid2buff(sysid, id) == 0) { | |
531 | dynhn = dynhn_find_by_name(id); | |
532 | if (dynhn == NULL) { | |
533 | vty_out(vty, "Invalid system id %s\n", id); | |
534 | return CMD_SUCCESS; | |
535 | } | |
536 | memcpy(sysid, dynhn->id, ISIS_SYS_ID_LEN); | |
537 | } | |
538 | } | |
539 | ||
540 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { | |
541 | vty_out(vty, "Area %s:\n", area->area_tag); | |
542 | ||
543 | if (detail == ISIS_UI_LEVEL_BRIEF) | |
544 | vty_out(vty, | |
545 | " System Id Interface L State Holdtime SNPA\n"); | |
546 | ||
547 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) { | |
548 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { | |
549 | for (i = 0; i < 2; i++) { | |
550 | adjdb = circuit->u.bc.adjdb[i]; | |
551 | if (adjdb && adjdb->count) { | |
552 | for (ALL_LIST_ELEMENTS_RO( | |
553 | adjdb, node, adj)) | |
554 | if (!id | |
555 | || !memcmp(adj->sysid, | |
556 | sysid, | |
557 | ISIS_SYS_ID_LEN)) | |
558 | isis_adj_print_vty( | |
559 | adj, | |
560 | vty, | |
561 | detail); | |
562 | } | |
563 | } | |
564 | } else if (circuit->circ_type == CIRCUIT_T_P2P | |
565 | && circuit->u.p2p.neighbor) { | |
566 | adj = circuit->u.p2p.neighbor; | |
567 | if (!id | |
568 | || !memcmp(adj->sysid, sysid, | |
569 | ISIS_SYS_ID_LEN)) | |
570 | isis_adj_print_vty(adj, vty, detail); | |
571 | } | |
572 | } | |
573 | } | |
574 | ||
575 | return CMD_SUCCESS; | |
3f045a08 JB |
576 | } |
577 | ||
578 | /* | |
579 | * 'clear isis neighbor' command | |
580 | */ | |
d62a17ae | 581 | int clear_isis_neighbor_common(struct vty *vty, const char *id) |
582 | { | |
583 | struct listnode *anode, *cnode, *cnextnode, *node, *nnode; | |
584 | struct isis_area *area; | |
585 | struct isis_circuit *circuit; | |
586 | struct list *adjdb; | |
587 | struct isis_adjacency *adj; | |
588 | struct isis_dynhn *dynhn; | |
d7c0a89a | 589 | uint8_t sysid[ISIS_SYS_ID_LEN]; |
d62a17ae | 590 | int i; |
591 | ||
592 | if (!isis) { | |
593 | vty_out(vty, "IS-IS Routing Process not enabled\n"); | |
594 | return CMD_SUCCESS; | |
595 | } | |
596 | ||
597 | memset(sysid, 0, ISIS_SYS_ID_LEN); | |
598 | if (id) { | |
599 | if (sysid2buff(sysid, id) == 0) { | |
600 | dynhn = dynhn_find_by_name(id); | |
601 | if (dynhn == NULL) { | |
602 | vty_out(vty, "Invalid system id %s\n", id); | |
603 | return CMD_SUCCESS; | |
604 | } | |
605 | memcpy(sysid, dynhn->id, ISIS_SYS_ID_LEN); | |
606 | } | |
607 | } | |
608 | ||
609 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { | |
610 | for (ALL_LIST_ELEMENTS(area->circuit_list, cnode, cnextnode, | |
611 | circuit)) { | |
612 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { | |
613 | for (i = 0; i < 2; i++) { | |
614 | adjdb = circuit->u.bc.adjdb[i]; | |
615 | if (adjdb && adjdb->count) { | |
616 | for (ALL_LIST_ELEMENTS( | |
617 | adjdb, node, nnode, | |
618 | adj)) | |
619 | if (!id | |
620 | || !memcmp(adj->sysid, | |
621 | sysid, | |
622 | ISIS_SYS_ID_LEN)) | |
623 | isis_adj_state_change( | |
624 | adj, | |
625 | ISIS_ADJ_DOWN, | |
626 | "clear user request"); | |
627 | } | |
628 | } | |
629 | } else if (circuit->circ_type == CIRCUIT_T_P2P | |
630 | && circuit->u.p2p.neighbor) { | |
631 | adj = circuit->u.p2p.neighbor; | |
632 | if (!id | |
633 | || !memcmp(adj->sysid, sysid, | |
634 | ISIS_SYS_ID_LEN)) | |
635 | isis_adj_state_change( | |
636 | adj, ISIS_ADJ_DOWN, | |
637 | "clear user request"); | |
638 | } | |
639 | } | |
640 | } | |
641 | ||
642 | return CMD_SUCCESS; | |
3f045a08 JB |
643 | } |
644 | ||
645 | DEFUN (show_isis_neighbor, | |
646 | show_isis_neighbor_cmd, | |
7c0cbd0e | 647 | "show " PROTO_NAME " neighbor", |
3f045a08 | 648 | SHOW_STR |
7c0cbd0e | 649 | PROTO_HELP |
3f045a08 | 650 | "ISIS neighbor adjacencies\n") |
eb5d44eb | 651 | { |
d62a17ae | 652 | return show_isis_neighbor_common(vty, NULL, ISIS_UI_LEVEL_BRIEF); |
eb5d44eb | 653 | } |
654 | ||
3f045a08 JB |
655 | DEFUN (show_isis_neighbor_detail, |
656 | show_isis_neighbor_detail_cmd, | |
7c0cbd0e | 657 | "show " PROTO_NAME " neighbor detail", |
eb5d44eb | 658 | SHOW_STR |
7c0cbd0e | 659 | PROTO_HELP |
3f045a08 | 660 | "ISIS neighbor adjacencies\n" |
eb5d44eb | 661 | "show detailed information\n") |
3f045a08 | 662 | { |
d62a17ae | 663 | return show_isis_neighbor_common(vty, NULL, ISIS_UI_LEVEL_DETAIL); |
3f045a08 JB |
664 | } |
665 | ||
666 | DEFUN (show_isis_neighbor_arg, | |
667 | show_isis_neighbor_arg_cmd, | |
7c0cbd0e | 668 | "show " PROTO_NAME " neighbor WORD", |
3f045a08 | 669 | SHOW_STR |
7c0cbd0e | 670 | PROTO_HELP |
3f045a08 JB |
671 | "ISIS neighbor adjacencies\n" |
672 | "System id\n") | |
673 | { | |
d62a17ae | 674 | int idx_word = 3; |
675 | return show_isis_neighbor_common(vty, argv[idx_word]->arg, | |
676 | ISIS_UI_LEVEL_DETAIL); | |
3f045a08 JB |
677 | } |
678 | ||
679 | DEFUN (clear_isis_neighbor, | |
680 | clear_isis_neighbor_cmd, | |
7c0cbd0e | 681 | "clear " PROTO_NAME " neighbor", |
3f045a08 | 682 | CLEAR_STR |
7c0cbd0e CF |
683 | PROTO_HELP |
684 | "ISIS neighbor adjacencies\n") | |
3f045a08 | 685 | { |
d62a17ae | 686 | return clear_isis_neighbor_common(vty, NULL); |
3f045a08 JB |
687 | } |
688 | ||
689 | DEFUN (clear_isis_neighbor_arg, | |
690 | clear_isis_neighbor_arg_cmd, | |
7c0cbd0e | 691 | "clear " PROTO_NAME " neighbor WORD", |
3f045a08 | 692 | CLEAR_STR |
7c0cbd0e | 693 | PROTO_HELP |
3f045a08 JB |
694 | "ISIS neighbor adjacencies\n" |
695 | "System id\n") | |
696 | { | |
d62a17ae | 697 | int idx_word = 3; |
698 | return clear_isis_neighbor_common(vty, argv[idx_word]->arg); | |
3f045a08 JB |
699 | } |
700 | ||
eb5d44eb | 701 | /* |
702 | * 'isis debug', 'show debugging' | |
703 | */ | |
d62a17ae | 704 | void print_debug(struct vty *vty, int flags, int onoff) |
705 | { | |
706 | char onoffs[4]; | |
707 | if (onoff) | |
708 | strcpy(onoffs, "on"); | |
709 | else | |
710 | strcpy(onoffs, "off"); | |
711 | ||
712 | if (flags & DEBUG_ADJ_PACKETS) | |
713 | vty_out(vty, | |
714 | "IS-IS Adjacency related packets debugging is %s\n", | |
715 | onoffs); | |
716 | if (flags & DEBUG_CHECKSUM_ERRORS) | |
717 | vty_out(vty, "IS-IS checksum errors debugging is %s\n", onoffs); | |
718 | if (flags & DEBUG_LOCAL_UPDATES) | |
719 | vty_out(vty, "IS-IS local updates debugging is %s\n", onoffs); | |
720 | if (flags & DEBUG_PROTOCOL_ERRORS) | |
721 | vty_out(vty, "IS-IS protocol errors debugging is %s\n", onoffs); | |
722 | if (flags & DEBUG_SNP_PACKETS) | |
723 | vty_out(vty, "IS-IS CSNP/PSNP packets debugging is %s\n", | |
724 | onoffs); | |
725 | if (flags & DEBUG_SPF_EVENTS) | |
726 | vty_out(vty, "IS-IS SPF events debugging is %s\n", onoffs); | |
727 | if (flags & DEBUG_SPF_STATS) | |
728 | vty_out(vty, | |
729 | "IS-IS SPF Timing and Statistics Data debugging is %s\n", | |
730 | onoffs); | |
731 | if (flags & DEBUG_SPF_TRIGGERS) | |
732 | vty_out(vty, "IS-IS SPF triggering events debugging is %s\n", | |
733 | onoffs); | |
734 | if (flags & DEBUG_UPDATE_PACKETS) | |
735 | vty_out(vty, "IS-IS Update related packet debugging is %s\n", | |
736 | onoffs); | |
737 | if (flags & DEBUG_RTE_EVENTS) | |
738 | vty_out(vty, "IS-IS Route related debuggin is %s\n", onoffs); | |
739 | if (flags & DEBUG_EVENTS) | |
740 | vty_out(vty, "IS-IS Event debugging is %s\n", onoffs); | |
741 | if (flags & DEBUG_PACKET_DUMP) | |
742 | vty_out(vty, "IS-IS Packet dump debugging is %s\n", onoffs); | |
743 | if (flags & DEBUG_LSP_GEN) | |
744 | vty_out(vty, "IS-IS LSP generation debugging is %s\n", onoffs); | |
745 | if (flags & DEBUG_LSP_SCHED) | |
746 | vty_out(vty, "IS-IS LSP scheduling debugging is %s\n", onoffs); | |
eb5d44eb | 747 | } |
748 | ||
87f6dc50 DS |
749 | DEFUN_NOSH (show_debugging, |
750 | show_debugging_isis_cmd, | |
7c0cbd0e | 751 | "show debugging [" PROTO_NAME "]", |
87f6dc50 DS |
752 | SHOW_STR |
753 | "State of each debugging option\n" | |
7c0cbd0e | 754 | PROTO_HELP) |
eb5d44eb | 755 | { |
7c0cbd0e | 756 | vty_out(vty, PROTO_NAME " debugging status:\n"); |
87f6dc50 DS |
757 | |
758 | if (isis->debugs) | |
d62a17ae | 759 | print_debug(vty, isis->debugs, 1); |
87f6dc50 | 760 | |
d62a17ae | 761 | return CMD_SUCCESS; |
eb5d44eb | 762 | } |
763 | ||
9e867fe6 | 764 | /* Debug node. */ |
d62a17ae | 765 | static struct cmd_node debug_node = {DEBUG_NODE, "", 1}; |
766 | ||
767 | static int config_write_debug(struct vty *vty) | |
768 | { | |
769 | int write = 0; | |
770 | int flags = isis->debugs; | |
771 | ||
772 | if (flags & DEBUG_ADJ_PACKETS) { | |
7c0cbd0e | 773 | vty_out(vty, "debug " PROTO_NAME " adj-packets\n"); |
d62a17ae | 774 | write++; |
775 | } | |
776 | if (flags & DEBUG_CHECKSUM_ERRORS) { | |
7c0cbd0e | 777 | vty_out(vty, "debug " PROTO_NAME " checksum-errors\n"); |
d62a17ae | 778 | write++; |
779 | } | |
780 | if (flags & DEBUG_LOCAL_UPDATES) { | |
7c0cbd0e | 781 | vty_out(vty, "debug " PROTO_NAME " local-updates\n"); |
d62a17ae | 782 | write++; |
783 | } | |
784 | if (flags & DEBUG_PROTOCOL_ERRORS) { | |
7c0cbd0e | 785 | vty_out(vty, "debug " PROTO_NAME " protocol-errors\n"); |
d62a17ae | 786 | write++; |
787 | } | |
788 | if (flags & DEBUG_SNP_PACKETS) { | |
7c0cbd0e | 789 | vty_out(vty, "debug " PROTO_NAME " snp-packets\n"); |
d62a17ae | 790 | write++; |
791 | } | |
792 | if (flags & DEBUG_SPF_EVENTS) { | |
7c0cbd0e | 793 | vty_out(vty, "debug " PROTO_NAME " spf-events\n"); |
d62a17ae | 794 | write++; |
795 | } | |
796 | if (flags & DEBUG_SPF_STATS) { | |
7c0cbd0e | 797 | vty_out(vty, "debug " PROTO_NAME " spf-statistics\n"); |
d62a17ae | 798 | write++; |
799 | } | |
800 | if (flags & DEBUG_SPF_TRIGGERS) { | |
7c0cbd0e | 801 | vty_out(vty, "debug " PROTO_NAME " spf-triggers\n"); |
d62a17ae | 802 | write++; |
803 | } | |
804 | if (flags & DEBUG_UPDATE_PACKETS) { | |
7c0cbd0e | 805 | vty_out(vty, "debug " PROTO_NAME " update-packets\n"); |
d62a17ae | 806 | write++; |
807 | } | |
808 | if (flags & DEBUG_RTE_EVENTS) { | |
7c0cbd0e | 809 | vty_out(vty, "debug " PROTO_NAME " route-events\n"); |
d62a17ae | 810 | write++; |
811 | } | |
812 | if (flags & DEBUG_EVENTS) { | |
7c0cbd0e | 813 | vty_out(vty, "debug " PROTO_NAME " events\n"); |
d62a17ae | 814 | write++; |
815 | } | |
816 | if (flags & DEBUG_PACKET_DUMP) { | |
7c0cbd0e | 817 | vty_out(vty, "debug " PROTO_NAME " packet-dump\n"); |
d62a17ae | 818 | write++; |
819 | } | |
820 | if (flags & DEBUG_LSP_GEN) { | |
7c0cbd0e | 821 | vty_out(vty, "debug " PROTO_NAME " lsp-gen\n"); |
d62a17ae | 822 | write++; |
823 | } | |
824 | if (flags & DEBUG_LSP_SCHED) { | |
7c0cbd0e | 825 | vty_out(vty, "debug " PROTO_NAME " lsp-sched\n"); |
d62a17ae | 826 | write++; |
827 | } | |
828 | write += spf_backoff_write_config(vty); | |
829 | ||
830 | return write; | |
9e867fe6 | 831 | } |
832 | ||
eb5d44eb | 833 | DEFUN (debug_isis_adj, |
834 | debug_isis_adj_cmd, | |
7c0cbd0e | 835 | "debug " PROTO_NAME " adj-packets", |
eb5d44eb | 836 | DEBUG_STR |
7c0cbd0e | 837 | PROTO_HELP |
f390d2c7 | 838 | "IS-IS Adjacency related packets\n") |
eb5d44eb | 839 | { |
d62a17ae | 840 | isis->debugs |= DEBUG_ADJ_PACKETS; |
841 | print_debug(vty, DEBUG_ADJ_PACKETS, 1); | |
eb5d44eb | 842 | |
d62a17ae | 843 | return CMD_SUCCESS; |
eb5d44eb | 844 | } |
845 | ||
846 | DEFUN (no_debug_isis_adj, | |
847 | no_debug_isis_adj_cmd, | |
7c0cbd0e | 848 | "no debug " PROTO_NAME " adj-packets", |
16cedbb0 | 849 | NO_STR |
eb5d44eb | 850 | UNDEBUG_STR |
7c0cbd0e | 851 | PROTO_HELP |
f390d2c7 | 852 | "IS-IS Adjacency related packets\n") |
eb5d44eb | 853 | { |
d62a17ae | 854 | isis->debugs &= ~DEBUG_ADJ_PACKETS; |
855 | print_debug(vty, DEBUG_ADJ_PACKETS, 0); | |
eb5d44eb | 856 | |
d62a17ae | 857 | return CMD_SUCCESS; |
eb5d44eb | 858 | } |
859 | ||
eb5d44eb | 860 | DEFUN (debug_isis_csum, |
861 | debug_isis_csum_cmd, | |
7c0cbd0e | 862 | "debug " PROTO_NAME " checksum-errors", |
eb5d44eb | 863 | DEBUG_STR |
7c0cbd0e | 864 | PROTO_HELP |
f390d2c7 | 865 | "IS-IS LSP checksum errors\n") |
eb5d44eb | 866 | { |
d62a17ae | 867 | isis->debugs |= DEBUG_CHECKSUM_ERRORS; |
868 | print_debug(vty, DEBUG_CHECKSUM_ERRORS, 1); | |
eb5d44eb | 869 | |
d62a17ae | 870 | return CMD_SUCCESS; |
eb5d44eb | 871 | } |
872 | ||
873 | DEFUN (no_debug_isis_csum, | |
874 | no_debug_isis_csum_cmd, | |
7c0cbd0e | 875 | "no debug " PROTO_NAME " checksum-errors", |
16cedbb0 | 876 | NO_STR |
eb5d44eb | 877 | UNDEBUG_STR |
7c0cbd0e | 878 | PROTO_HELP |
f390d2c7 | 879 | "IS-IS LSP checksum errors\n") |
eb5d44eb | 880 | { |
d62a17ae | 881 | isis->debugs &= ~DEBUG_CHECKSUM_ERRORS; |
882 | print_debug(vty, DEBUG_CHECKSUM_ERRORS, 0); | |
f390d2c7 | 883 | |
d62a17ae | 884 | return CMD_SUCCESS; |
eb5d44eb | 885 | } |
886 | ||
887 | DEFUN (debug_isis_lupd, | |
888 | debug_isis_lupd_cmd, | |
7c0cbd0e | 889 | "debug " PROTO_NAME " local-updates", |
eb5d44eb | 890 | DEBUG_STR |
7c0cbd0e | 891 | PROTO_HELP |
f390d2c7 | 892 | "IS-IS local update packets\n") |
eb5d44eb | 893 | { |
d62a17ae | 894 | isis->debugs |= DEBUG_LOCAL_UPDATES; |
895 | print_debug(vty, DEBUG_LOCAL_UPDATES, 1); | |
eb5d44eb | 896 | |
d62a17ae | 897 | return CMD_SUCCESS; |
eb5d44eb | 898 | } |
899 | ||
900 | DEFUN (no_debug_isis_lupd, | |
901 | no_debug_isis_lupd_cmd, | |
7c0cbd0e | 902 | "no debug " PROTO_NAME " local-updates", |
16cedbb0 | 903 | NO_STR |
eb5d44eb | 904 | UNDEBUG_STR |
7c0cbd0e | 905 | PROTO_HELP |
f390d2c7 | 906 | "IS-IS local update packets\n") |
eb5d44eb | 907 | { |
d62a17ae | 908 | isis->debugs &= ~DEBUG_LOCAL_UPDATES; |
909 | print_debug(vty, DEBUG_LOCAL_UPDATES, 0); | |
f390d2c7 | 910 | |
d62a17ae | 911 | return CMD_SUCCESS; |
eb5d44eb | 912 | } |
913 | ||
914 | DEFUN (debug_isis_err, | |
915 | debug_isis_err_cmd, | |
7c0cbd0e | 916 | "debug " PROTO_NAME " protocol-errors", |
eb5d44eb | 917 | DEBUG_STR |
7c0cbd0e | 918 | PROTO_HELP |
f390d2c7 | 919 | "IS-IS LSP protocol errors\n") |
eb5d44eb | 920 | { |
d62a17ae | 921 | isis->debugs |= DEBUG_PROTOCOL_ERRORS; |
922 | print_debug(vty, DEBUG_PROTOCOL_ERRORS, 1); | |
eb5d44eb | 923 | |
d62a17ae | 924 | return CMD_SUCCESS; |
eb5d44eb | 925 | } |
926 | ||
927 | DEFUN (no_debug_isis_err, | |
928 | no_debug_isis_err_cmd, | |
7c0cbd0e | 929 | "no debug " PROTO_NAME " protocol-errors", |
16cedbb0 | 930 | NO_STR |
eb5d44eb | 931 | UNDEBUG_STR |
7c0cbd0e | 932 | PROTO_HELP |
f390d2c7 | 933 | "IS-IS LSP protocol errors\n") |
eb5d44eb | 934 | { |
d62a17ae | 935 | isis->debugs &= ~DEBUG_PROTOCOL_ERRORS; |
936 | print_debug(vty, DEBUG_PROTOCOL_ERRORS, 0); | |
f390d2c7 | 937 | |
d62a17ae | 938 | return CMD_SUCCESS; |
eb5d44eb | 939 | } |
940 | ||
941 | DEFUN (debug_isis_snp, | |
942 | debug_isis_snp_cmd, | |
7c0cbd0e | 943 | "debug " PROTO_NAME " snp-packets", |
eb5d44eb | 944 | DEBUG_STR |
7c0cbd0e | 945 | PROTO_HELP |
f390d2c7 | 946 | "IS-IS CSNP/PSNP packets\n") |
eb5d44eb | 947 | { |
d62a17ae | 948 | isis->debugs |= DEBUG_SNP_PACKETS; |
949 | print_debug(vty, DEBUG_SNP_PACKETS, 1); | |
eb5d44eb | 950 | |
d62a17ae | 951 | return CMD_SUCCESS; |
eb5d44eb | 952 | } |
953 | ||
954 | DEFUN (no_debug_isis_snp, | |
955 | no_debug_isis_snp_cmd, | |
7c0cbd0e | 956 | "no debug " PROTO_NAME " snp-packets", |
16cedbb0 | 957 | NO_STR |
eb5d44eb | 958 | UNDEBUG_STR |
7c0cbd0e | 959 | PROTO_HELP |
f390d2c7 | 960 | "IS-IS CSNP/PSNP packets\n") |
eb5d44eb | 961 | { |
d62a17ae | 962 | isis->debugs &= ~DEBUG_SNP_PACKETS; |
963 | print_debug(vty, DEBUG_SNP_PACKETS, 0); | |
f390d2c7 | 964 | |
d62a17ae | 965 | return CMD_SUCCESS; |
eb5d44eb | 966 | } |
967 | ||
eb5d44eb | 968 | DEFUN (debug_isis_upd, |
969 | debug_isis_upd_cmd, | |
7c0cbd0e | 970 | "debug " PROTO_NAME " update-packets", |
eb5d44eb | 971 | DEBUG_STR |
7c0cbd0e | 972 | PROTO_HELP |
f390d2c7 | 973 | "IS-IS Update related packets\n") |
eb5d44eb | 974 | { |
d62a17ae | 975 | isis->debugs |= DEBUG_UPDATE_PACKETS; |
976 | print_debug(vty, DEBUG_UPDATE_PACKETS, 1); | |
eb5d44eb | 977 | |
d62a17ae | 978 | return CMD_SUCCESS; |
eb5d44eb | 979 | } |
980 | ||
981 | DEFUN (no_debug_isis_upd, | |
982 | no_debug_isis_upd_cmd, | |
7c0cbd0e | 983 | "no debug " PROTO_NAME " update-packets", |
16cedbb0 | 984 | NO_STR |
eb5d44eb | 985 | UNDEBUG_STR |
7c0cbd0e | 986 | PROTO_HELP |
f390d2c7 | 987 | "IS-IS Update related packets\n") |
eb5d44eb | 988 | { |
d62a17ae | 989 | isis->debugs &= ~DEBUG_UPDATE_PACKETS; |
990 | print_debug(vty, DEBUG_UPDATE_PACKETS, 0); | |
f390d2c7 | 991 | |
d62a17ae | 992 | return CMD_SUCCESS; |
eb5d44eb | 993 | } |
994 | ||
eb5d44eb | 995 | DEFUN (debug_isis_spfevents, |
996 | debug_isis_spfevents_cmd, | |
7c0cbd0e | 997 | "debug " PROTO_NAME " spf-events", |
eb5d44eb | 998 | DEBUG_STR |
7c0cbd0e | 999 | PROTO_HELP |
f390d2c7 | 1000 | "IS-IS Shortest Path First Events\n") |
eb5d44eb | 1001 | { |
d62a17ae | 1002 | isis->debugs |= DEBUG_SPF_EVENTS; |
1003 | print_debug(vty, DEBUG_SPF_EVENTS, 1); | |
eb5d44eb | 1004 | |
d62a17ae | 1005 | return CMD_SUCCESS; |
eb5d44eb | 1006 | } |
1007 | ||
1008 | DEFUN (no_debug_isis_spfevents, | |
1009 | no_debug_isis_spfevents_cmd, | |
7c0cbd0e | 1010 | "no debug " PROTO_NAME " spf-events", |
16cedbb0 | 1011 | NO_STR |
eb5d44eb | 1012 | UNDEBUG_STR |
7c0cbd0e | 1013 | PROTO_HELP |
f390d2c7 | 1014 | "IS-IS Shortest Path First Events\n") |
eb5d44eb | 1015 | { |
d62a17ae | 1016 | isis->debugs &= ~DEBUG_SPF_EVENTS; |
1017 | print_debug(vty, DEBUG_SPF_EVENTS, 0); | |
f390d2c7 | 1018 | |
d62a17ae | 1019 | return CMD_SUCCESS; |
eb5d44eb | 1020 | } |
1021 | ||
eb5d44eb | 1022 | DEFUN (debug_isis_spfstats, |
1023 | debug_isis_spfstats_cmd, | |
7c0cbd0e | 1024 | "debug " PROTO_NAME " spf-statistics ", |
eb5d44eb | 1025 | DEBUG_STR |
7c0cbd0e | 1026 | PROTO_HELP |
f390d2c7 | 1027 | "IS-IS SPF Timing and Statistic Data\n") |
eb5d44eb | 1028 | { |
d62a17ae | 1029 | isis->debugs |= DEBUG_SPF_STATS; |
1030 | print_debug(vty, DEBUG_SPF_STATS, 1); | |
eb5d44eb | 1031 | |
d62a17ae | 1032 | return CMD_SUCCESS; |
eb5d44eb | 1033 | } |
1034 | ||
1035 | DEFUN (no_debug_isis_spfstats, | |
1036 | no_debug_isis_spfstats_cmd, | |
7c0cbd0e | 1037 | "no debug " PROTO_NAME " spf-statistics", |
16cedbb0 | 1038 | NO_STR |
eb5d44eb | 1039 | UNDEBUG_STR |
7c0cbd0e | 1040 | PROTO_HELP |
f390d2c7 | 1041 | "IS-IS SPF Timing and Statistic Data\n") |
eb5d44eb | 1042 | { |
d62a17ae | 1043 | isis->debugs &= ~DEBUG_SPF_STATS; |
1044 | print_debug(vty, DEBUG_SPF_STATS, 0); | |
f390d2c7 | 1045 | |
d62a17ae | 1046 | return CMD_SUCCESS; |
eb5d44eb | 1047 | } |
1048 | ||
1049 | DEFUN (debug_isis_spftrigg, | |
1050 | debug_isis_spftrigg_cmd, | |
7c0cbd0e | 1051 | "debug " PROTO_NAME " spf-triggers", |
eb5d44eb | 1052 | DEBUG_STR |
7c0cbd0e | 1053 | PROTO_HELP |
f390d2c7 | 1054 | "IS-IS SPF triggering events\n") |
eb5d44eb | 1055 | { |
d62a17ae | 1056 | isis->debugs |= DEBUG_SPF_TRIGGERS; |
1057 | print_debug(vty, DEBUG_SPF_TRIGGERS, 1); | |
eb5d44eb | 1058 | |
d62a17ae | 1059 | return CMD_SUCCESS; |
eb5d44eb | 1060 | } |
1061 | ||
1062 | DEFUN (no_debug_isis_spftrigg, | |
1063 | no_debug_isis_spftrigg_cmd, | |
7c0cbd0e | 1064 | "no debug " PROTO_NAME " spf-triggers", |
16cedbb0 | 1065 | NO_STR |
eb5d44eb | 1066 | UNDEBUG_STR |
7c0cbd0e | 1067 | PROTO_HELP |
f390d2c7 | 1068 | "IS-IS SPF triggering events\n") |
eb5d44eb | 1069 | { |
d62a17ae | 1070 | isis->debugs &= ~DEBUG_SPF_TRIGGERS; |
1071 | print_debug(vty, DEBUG_SPF_TRIGGERS, 0); | |
f390d2c7 | 1072 | |
d62a17ae | 1073 | return CMD_SUCCESS; |
eb5d44eb | 1074 | } |
1075 | ||
1076 | DEFUN (debug_isis_rtevents, | |
1077 | debug_isis_rtevents_cmd, | |
7c0cbd0e | 1078 | "debug " PROTO_NAME " route-events", |
eb5d44eb | 1079 | DEBUG_STR |
7c0cbd0e | 1080 | PROTO_HELP |
f390d2c7 | 1081 | "IS-IS Route related events\n") |
eb5d44eb | 1082 | { |
d62a17ae | 1083 | isis->debugs |= DEBUG_RTE_EVENTS; |
1084 | print_debug(vty, DEBUG_RTE_EVENTS, 1); | |
eb5d44eb | 1085 | |
d62a17ae | 1086 | return CMD_SUCCESS; |
eb5d44eb | 1087 | } |
1088 | ||
1089 | DEFUN (no_debug_isis_rtevents, | |
1090 | no_debug_isis_rtevents_cmd, | |
7c0cbd0e | 1091 | "no debug " PROTO_NAME " route-events", |
16cedbb0 | 1092 | NO_STR |
eb5d44eb | 1093 | UNDEBUG_STR |
7c0cbd0e | 1094 | PROTO_HELP |
f390d2c7 | 1095 | "IS-IS Route related events\n") |
eb5d44eb | 1096 | { |
d62a17ae | 1097 | isis->debugs &= ~DEBUG_RTE_EVENTS; |
1098 | print_debug(vty, DEBUG_RTE_EVENTS, 0); | |
f390d2c7 | 1099 | |
d62a17ae | 1100 | return CMD_SUCCESS; |
eb5d44eb | 1101 | } |
1102 | ||
1103 | DEFUN (debug_isis_events, | |
1104 | debug_isis_events_cmd, | |
7c0cbd0e | 1105 | "debug " PROTO_NAME " events", |
eb5d44eb | 1106 | DEBUG_STR |
7c0cbd0e | 1107 | PROTO_HELP |
f1082d19 | 1108 | "IS-IS Events\n") |
eb5d44eb | 1109 | { |
d62a17ae | 1110 | isis->debugs |= DEBUG_EVENTS; |
1111 | print_debug(vty, DEBUG_EVENTS, 1); | |
eb5d44eb | 1112 | |
d62a17ae | 1113 | return CMD_SUCCESS; |
eb5d44eb | 1114 | } |
1115 | ||
1116 | DEFUN (no_debug_isis_events, | |
1117 | no_debug_isis_events_cmd, | |
7c0cbd0e | 1118 | "no debug " PROTO_NAME " events", |
16cedbb0 | 1119 | NO_STR |
eb5d44eb | 1120 | UNDEBUG_STR |
7c0cbd0e | 1121 | PROTO_HELP |
f390d2c7 | 1122 | "IS-IS Events\n") |
eb5d44eb | 1123 | { |
d62a17ae | 1124 | isis->debugs &= ~DEBUG_EVENTS; |
1125 | print_debug(vty, DEBUG_EVENTS, 0); | |
f390d2c7 | 1126 | |
d62a17ae | 1127 | return CMD_SUCCESS; |
eb5d44eb | 1128 | } |
1129 | ||
3f045a08 JB |
1130 | DEFUN (debug_isis_packet_dump, |
1131 | debug_isis_packet_dump_cmd, | |
7c0cbd0e | 1132 | "debug " PROTO_NAME " packet-dump", |
3f045a08 | 1133 | DEBUG_STR |
7c0cbd0e | 1134 | PROTO_HELP |
3f045a08 JB |
1135 | "IS-IS packet dump\n") |
1136 | { | |
d62a17ae | 1137 | isis->debugs |= DEBUG_PACKET_DUMP; |
1138 | print_debug(vty, DEBUG_PACKET_DUMP, 1); | |
3f045a08 | 1139 | |
d62a17ae | 1140 | return CMD_SUCCESS; |
3f045a08 JB |
1141 | } |
1142 | ||
1143 | DEFUN (no_debug_isis_packet_dump, | |
1144 | no_debug_isis_packet_dump_cmd, | |
7c0cbd0e | 1145 | "no debug " PROTO_NAME " packet-dump", |
16cedbb0 | 1146 | NO_STR |
3f045a08 | 1147 | UNDEBUG_STR |
7c0cbd0e | 1148 | PROTO_HELP |
3f045a08 JB |
1149 | "IS-IS packet dump\n") |
1150 | { | |
d62a17ae | 1151 | isis->debugs &= ~DEBUG_PACKET_DUMP; |
1152 | print_debug(vty, DEBUG_PACKET_DUMP, 0); | |
3f045a08 | 1153 | |
d62a17ae | 1154 | return CMD_SUCCESS; |
3f045a08 JB |
1155 | } |
1156 | ||
14872644 CF |
1157 | DEFUN (debug_isis_lsp_gen, |
1158 | debug_isis_lsp_gen_cmd, | |
7c0cbd0e | 1159 | "debug " PROTO_NAME " lsp-gen", |
14872644 | 1160 | DEBUG_STR |
7c0cbd0e | 1161 | PROTO_HELP |
14872644 CF |
1162 | "IS-IS generation of own LSPs\n") |
1163 | { | |
d62a17ae | 1164 | isis->debugs |= DEBUG_LSP_GEN; |
1165 | print_debug(vty, DEBUG_LSP_GEN, 1); | |
14872644 | 1166 | |
d62a17ae | 1167 | return CMD_SUCCESS; |
14872644 CF |
1168 | } |
1169 | ||
1170 | DEFUN (no_debug_isis_lsp_gen, | |
1171 | no_debug_isis_lsp_gen_cmd, | |
7c0cbd0e | 1172 | "no debug " PROTO_NAME " lsp-gen", |
16cedbb0 | 1173 | NO_STR |
14872644 | 1174 | UNDEBUG_STR |
7c0cbd0e | 1175 | PROTO_HELP |
14872644 CF |
1176 | "IS-IS generation of own LSPs\n") |
1177 | { | |
d62a17ae | 1178 | isis->debugs &= ~DEBUG_LSP_GEN; |
1179 | print_debug(vty, DEBUG_LSP_GEN, 0); | |
14872644 | 1180 | |
d62a17ae | 1181 | return CMD_SUCCESS; |
14872644 CF |
1182 | } |
1183 | ||
414766a1 CF |
1184 | DEFUN (debug_isis_lsp_sched, |
1185 | debug_isis_lsp_sched_cmd, | |
7c0cbd0e | 1186 | "debug " PROTO_NAME " lsp-sched", |
414766a1 | 1187 | DEBUG_STR |
7c0cbd0e | 1188 | PROTO_HELP |
414766a1 CF |
1189 | "IS-IS scheduling of LSP generation\n") |
1190 | { | |
d62a17ae | 1191 | isis->debugs |= DEBUG_LSP_SCHED; |
1192 | print_debug(vty, DEBUG_LSP_SCHED, 1); | |
414766a1 | 1193 | |
d62a17ae | 1194 | return CMD_SUCCESS; |
414766a1 CF |
1195 | } |
1196 | ||
49d41a26 DS |
1197 | DEFUN (no_debug_isis_lsp_sched, |
1198 | no_debug_isis_lsp_sched_cmd, | |
7c0cbd0e | 1199 | "no debug " PROTO_NAME " lsp-sched", |
16cedbb0 | 1200 | NO_STR |
49d41a26 | 1201 | UNDEBUG_STR |
7c0cbd0e | 1202 | PROTO_HELP |
49d41a26 DS |
1203 | "IS-IS scheduling of LSP generation\n") |
1204 | { | |
d62a17ae | 1205 | isis->debugs &= ~DEBUG_LSP_SCHED; |
1206 | print_debug(vty, DEBUG_LSP_SCHED, 0); | |
49d41a26 | 1207 | |
d62a17ae | 1208 | return CMD_SUCCESS; |
49d41a26 DS |
1209 | } |
1210 | ||
eb5d44eb | 1211 | DEFUN (show_hostname, |
1212 | show_hostname_cmd, | |
7c0cbd0e | 1213 | "show " PROTO_NAME " hostname", |
eb5d44eb | 1214 | SHOW_STR |
7c0cbd0e | 1215 | PROTO_HELP |
eb5d44eb | 1216 | "IS-IS Dynamic hostname mapping\n") |
1217 | { | |
d62a17ae | 1218 | dynhn_print_all(vty); |
f390d2c7 | 1219 | |
d62a17ae | 1220 | return CMD_SUCCESS; |
eb5d44eb | 1221 | } |
1222 | ||
03f7e182 SL |
1223 | DEFUN (show_isis_spf_ietf, |
1224 | show_isis_spf_ietf_cmd, | |
7c0cbd0e | 1225 | "show " PROTO_NAME " spf-delay-ietf", |
03f7e182 | 1226 | SHOW_STR |
7c0cbd0e CF |
1227 | PROTO_HELP |
1228 | "SPF delay IETF information\n") | |
03f7e182 | 1229 | { |
d62a17ae | 1230 | if (!isis) { |
1231 | vty_out(vty, "ISIS is not running\n"); | |
1232 | return CMD_SUCCESS; | |
1233 | } | |
1234 | ||
1235 | struct listnode *node; | |
1236 | struct isis_area *area; | |
1237 | ||
1238 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { | |
1239 | vty_out(vty, "Area %s:\n", | |
1240 | area->area_tag ? area->area_tag : "null"); | |
1241 | ||
1242 | for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { | |
1243 | if ((area->is_type & level) == 0) | |
1244 | continue; | |
1245 | ||
1246 | vty_out(vty, " Level-%d:\n", level); | |
1247 | vty_out(vty, " SPF delay status: "); | |
1248 | if (area->spf_timer[level - 1]) { | |
1249 | struct timeval remain = thread_timer_remain( | |
1250 | area->spf_timer[level - 1]); | |
a97986ff DL |
1251 | vty_out(vty, "Pending, due in %lld msec\n", |
1252 | (long long)remain.tv_sec * 1000 | |
d62a17ae | 1253 | + remain.tv_usec / 1000); |
1254 | } else { | |
1255 | vty_out(vty, "Not scheduled\n"); | |
1256 | } | |
1257 | ||
1258 | if (area->spf_delay_ietf[level - 1]) { | |
1259 | vty_out(vty, | |
1260 | " Using draft-ietf-rtgwg-backoff-algo-04\n"); | |
1261 | spf_backoff_show( | |
1262 | area->spf_delay_ietf[level - 1], vty, | |
1263 | " "); | |
1264 | } else { | |
1265 | vty_out(vty, " Using legacy backoff algo\n"); | |
1266 | } | |
1267 | } | |
1268 | } | |
1269 | return CMD_SUCCESS; | |
03f7e182 SL |
1270 | } |
1271 | ||
3f045a08 JB |
1272 | DEFUN (show_isis_summary, |
1273 | show_isis_summary_cmd, | |
7c0cbd0e CF |
1274 | "show " PROTO_NAME " summary", |
1275 | SHOW_STR PROTO_HELP "summary\n") | |
3f045a08 | 1276 | { |
d62a17ae | 1277 | struct listnode *node, *node2; |
1278 | struct isis_area *area; | |
d62a17ae | 1279 | int level; |
1280 | ||
1281 | if (isis == NULL) { | |
7c0cbd0e | 1282 | vty_out(vty, PROTO_NAME " is not running\n"); |
d62a17ae | 1283 | return CMD_SUCCESS; |
1284 | } | |
1285 | ||
1286 | vty_out(vty, "Process Id : %ld\n", isis->process_id); | |
1287 | if (isis->sysid_set) | |
1288 | vty_out(vty, "System Id : %s\n", | |
1289 | sysid_print(isis->sysid)); | |
1290 | ||
1291 | vty_out(vty, "Up time : "); | |
1292 | vty_out_timestr(vty, isis->uptime); | |
1293 | vty_out(vty, "\n"); | |
1294 | ||
1295 | if (isis->area_list) | |
1296 | vty_out(vty, "Number of areas : %d\n", isis->area_list->count); | |
1297 | ||
1298 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { | |
1299 | vty_out(vty, "Area %s:\n", | |
1300 | area->area_tag ? area->area_tag : "null"); | |
1301 | ||
92ed0cde CF |
1302 | if (fabricd) { |
1303 | uint8_t tier = fabricd_tier(area); | |
1304 | if (tier == ISIS_TIER_UNDEFINED) | |
1305 | vty_out(vty, " Tier: undefined\n"); | |
1306 | else | |
1307 | vty_out(vty, " Tier: %" PRIu8 "\n", tier); | |
1308 | } | |
1309 | ||
d62a17ae | 1310 | if (listcount(area->area_addrs) > 0) { |
1311 | struct area_addr *area_addr; | |
1312 | for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node2, | |
1313 | area_addr)) { | |
1314 | vty_out(vty, " Net: %s\n", | |
1315 | isonet_print(area_addr->area_addr, | |
1316 | area_addr->addr_len | |
1317 | + ISIS_SYS_ID_LEN | |
1318 | + 1)); | |
1319 | } | |
1320 | } | |
1321 | ||
1322 | for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { | |
1323 | if ((area->is_type & level) == 0) | |
1324 | continue; | |
1325 | ||
1326 | vty_out(vty, " Level-%d:\n", level); | |
d62a17ae | 1327 | if (area->spf_timer[level - 1]) |
1328 | vty_out(vty, " SPF: (pending)\n"); | |
1329 | else | |
1330 | vty_out(vty, " SPF:\n"); | |
1331 | ||
1332 | vty_out(vty, " minimum interval : %d", | |
1333 | area->min_spf_interval[level - 1]); | |
1334 | if (area->spf_delay_ietf[level - 1]) | |
1335 | vty_out(vty, | |
1336 | " (not used, IETF SPF delay activated)"); | |
1337 | vty_out(vty, "\n"); | |
1338 | ||
1339 | vty_out(vty, " IPv4 route computation:\n"); | |
be985ba0 CF |
1340 | isis_spf_print(area->spftree[SPFTREE_IPV4][level - 1], |
1341 | vty); | |
d62a17ae | 1342 | |
d62a17ae | 1343 | vty_out(vty, " IPv6 route computation:\n"); |
be985ba0 CF |
1344 | isis_spf_print(area->spftree[SPFTREE_IPV6][level - 1], |
1345 | vty); | |
321c1bbb CF |
1346 | |
1347 | vty_out(vty, " IPv6 dst-src route computation:\n"); | |
1348 | isis_spf_print(area->spftree[SPFTREE_DSTSRC][level-1], | |
1349 | vty); | |
d62a17ae | 1350 | } |
1351 | } | |
1352 | vty_out(vty, "\n"); | |
1353 | ||
1354 | return CMD_SUCCESS; | |
eb5d44eb | 1355 | } |
1356 | ||
3f045a08 JB |
1357 | /* |
1358 | * This function supports following display options: | |
1359 | * [ show isis database [detail] ] | |
1360 | * [ show isis database <sysid> [detail] ] | |
1361 | * [ show isis database <hostname> [detail] ] | |
1362 | * [ show isis database <sysid>.<pseudo-id> [detail] ] | |
1363 | * [ show isis database <hostname>.<pseudo-id> [detail] ] | |
1364 | * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ] | |
1365 | * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ] | |
1366 | * [ show isis database detail <sysid> ] | |
1367 | * [ show isis database detail <hostname> ] | |
1368 | * [ show isis database detail <sysid>.<pseudo-id> ] | |
1369 | * [ show isis database detail <hostname>.<pseudo-id> ] | |
1370 | * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ] | |
1371 | * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ] | |
1372 | */ | |
d62a17ae | 1373 | static int show_isis_database(struct vty *vty, const char *argv, int ui_level) |
1374 | { | |
1375 | struct listnode *node; | |
1376 | struct isis_area *area; | |
1377 | struct isis_lsp *lsp; | |
1378 | struct isis_dynhn *dynhn; | |
a2b6e694 | 1379 | const char *pos; |
d7c0a89a | 1380 | uint8_t lspid[ISIS_SYS_ID_LEN + 2]; |
d62a17ae | 1381 | char sysid[255]; |
d7c0a89a | 1382 | uint8_t number[3]; |
d62a17ae | 1383 | int level, lsp_count; |
1384 | ||
1385 | if (isis->area_list->count == 0) | |
1386 | return CMD_SUCCESS; | |
1387 | ||
1388 | memset(&lspid, 0, ISIS_SYS_ID_LEN); | |
1389 | memset(&sysid, 0, 255); | |
1390 | ||
1391 | /* | |
1392 | * extract fragment and pseudo id from the string argv | |
1393 | * in the forms: | |
1394 | * (a) <systemid/hostname>.<pseudo-id>-<framenent> or | |
1395 | * (b) <systemid/hostname>.<pseudo-id> or | |
1396 | * (c) <systemid/hostname> or | |
1397 | * Where systemid is in the form: | |
1398 | * xxxx.xxxx.xxxx | |
1399 | */ | |
1400 | if (argv) | |
1401 | strncpy(sysid, argv, 254); | |
1402 | if (argv && strlen(argv) > 3) { | |
1403 | pos = argv + strlen(argv) - 3; | |
1404 | if (strncmp(pos, "-", 1) == 0) { | |
1405 | memcpy(number, ++pos, 2); | |
1406 | lspid[ISIS_SYS_ID_LEN + 1] = | |
d7c0a89a | 1407 | (uint8_t)strtol((char *)number, NULL, 16); |
d62a17ae | 1408 | pos -= 4; |
1409 | if (strncmp(pos, ".", 1) != 0) | |
a5fdb4c5 | 1410 | return CMD_WARNING; |
d62a17ae | 1411 | } |
1412 | if (strncmp(pos, ".", 1) == 0) { | |
1413 | memcpy(number, ++pos, 2); | |
1414 | lspid[ISIS_SYS_ID_LEN] = | |
d7c0a89a | 1415 | (uint8_t)strtol((char *)number, NULL, 16); |
d62a17ae | 1416 | sysid[pos - argv - 1] = '\0'; |
1417 | } | |
1418 | } | |
1419 | ||
1420 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { | |
1421 | vty_out(vty, "Area %s:\n", | |
1422 | area->area_tag ? area->area_tag : "null"); | |
1423 | ||
1424 | for (level = 0; level < ISIS_LEVELS; level++) { | |
1425 | if (area->lspdb[level] | |
1426 | && dict_count(area->lspdb[level]) > 0) { | |
1427 | lsp = NULL; | |
1428 | if (argv != NULL) { | |
1429 | /* | |
1430 | * Try to find the lsp-id if the argv | |
1431 | * string is in | |
1432 | * the form | |
1433 | * hostname.<pseudo-id>-<fragment> | |
1434 | */ | |
1435 | if (sysid2buff(lspid, sysid)) { | |
1436 | lsp = lsp_search( | |
1437 | lspid, | |
1438 | area->lspdb[level]); | |
1439 | } else if ((dynhn = dynhn_find_by_name( | |
1440 | sysid))) { | |
1441 | memcpy(lspid, dynhn->id, | |
1442 | ISIS_SYS_ID_LEN); | |
1443 | lsp = lsp_search( | |
1444 | lspid, | |
1445 | area->lspdb[level]); | |
6b3ee3a0 | 1446 | } else if (strncmp(cmd_hostname_get(), |
d62a17ae | 1447 | sysid, 15) |
1448 | == 0) { | |
1449 | memcpy(lspid, isis->sysid, | |
1450 | ISIS_SYS_ID_LEN); | |
1451 | lsp = lsp_search( | |
1452 | lspid, | |
1453 | area->lspdb[level]); | |
1454 | } | |
1455 | } | |
1456 | ||
1457 | if (lsp != NULL || argv == NULL) { | |
1458 | vty_out(vty, | |
1459 | "IS-IS Level-%d link-state database:\n", | |
1460 | level + 1); | |
1461 | ||
1462 | /* print the title in all cases */ | |
1463 | vty_out(vty, | |
1464 | "LSP ID PduLen SeqNumber Chksum Holdtime ATT/P/OL\n"); | |
1465 | } | |
1466 | ||
1467 | if (lsp) { | |
1468 | if (ui_level == ISIS_UI_LEVEL_DETAIL) | |
1469 | lsp_print_detail( | |
1470 | lsp, vty, | |
1471 | area->dynhostname); | |
1472 | else | |
1473 | lsp_print(lsp, vty, | |
1474 | area->dynhostname); | |
1475 | } else if (argv == NULL) { | |
1476 | lsp_count = lsp_print_all( | |
1477 | vty, area->lspdb[level], | |
1478 | ui_level, area->dynhostname); | |
1479 | ||
1480 | vty_out(vty, " %u LSPs\n\n", | |
1481 | lsp_count); | |
1482 | } | |
1483 | } | |
1484 | } | |
1485 | } | |
1486 | ||
1487 | return CMD_SUCCESS; | |
eb5d44eb | 1488 | } |
1489 | ||
3a2d747c | 1490 | DEFUN (show_database, |
3f045a08 | 1491 | show_database_cmd, |
7c0cbd0e | 1492 | "show " PROTO_NAME " database [detail] [WORD]", |
3f045a08 | 1493 | SHOW_STR |
7c0cbd0e CF |
1494 | PROTO_HELP |
1495 | "Link state database\n" | |
3f045a08 JB |
1496 | "Detailed information\n" |
1497 | "LSP ID\n") | |
1498 | { | |
d62a17ae | 1499 | int idx = 0; |
1500 | int uilevel = argv_find(argv, argc, "detail", &idx) | |
1501 | ? ISIS_UI_LEVEL_DETAIL | |
1502 | : ISIS_UI_LEVEL_BRIEF; | |
1503 | char *id = argv_find(argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; | |
1504 | return show_isis_database(vty, id, uilevel); | |
3f045a08 JB |
1505 | } |
1506 | ||
d62a17ae | 1507 | /* |
1508 | * 'router isis' command | |
3f045a08 | 1509 | */ |
505e5056 | 1510 | DEFUN_NOSH (router_isis, |
3f045a08 | 1511 | router_isis_cmd, |
7c0cbd0e | 1512 | "router " PROTO_NAME " WORD", |
3f045a08 | 1513 | ROUTER_STR |
7c0cbd0e | 1514 | PROTO_HELP |
efd7904e | 1515 | "ISO Routing area tag\n") |
3f045a08 | 1516 | { |
d62a17ae | 1517 | int idx_word = 2; |
1518 | return isis_area_get(vty, argv[idx_word]->arg); | |
3f045a08 JB |
1519 | } |
1520 | ||
d62a17ae | 1521 | /* |
1522 | *'no router isis' command | |
3f045a08 JB |
1523 | */ |
1524 | DEFUN (no_router_isis, | |
1525 | no_router_isis_cmd, | |
7c0cbd0e CF |
1526 | "no router " PROTO_NAME " WORD", |
1527 | NO_STR | |
1528 | ROUTER_STR | |
1529 | PROTO_HELP | |
1530 | "ISO Routing area tag\n") | |
eb5d44eb | 1531 | { |
d62a17ae | 1532 | int idx_word = 3; |
1533 | return isis_area_destroy(vty, argv[idx_word]->arg); | |
eb5d44eb | 1534 | } |
1535 | ||
1536 | /* | |
1537 | * 'net' command | |
1538 | */ | |
1539 | DEFUN (net, | |
1540 | net_cmd, | |
1541 | "net WORD", | |
1542 | "A Network Entity Title for this process (OSI only)\n" | |
f390d2c7 | 1543 | "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") |
eb5d44eb | 1544 | { |
d62a17ae | 1545 | int idx_word = 1; |
1546 | return area_net_title(vty, argv[idx_word]->arg); | |
eb5d44eb | 1547 | } |
1548 | ||
eb5d44eb | 1549 | /* |
1550 | * 'no net' command | |
1551 | */ | |
1552 | DEFUN (no_net, | |
1553 | no_net_cmd, | |
1554 | "no net WORD", | |
1555 | NO_STR | |
1556 | "A Network Entity Title for this process (OSI only)\n" | |
f390d2c7 | 1557 | "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") |
eb5d44eb | 1558 | { |
d62a17ae | 1559 | int idx_word = 2; |
1560 | return area_clear_net_title(vty, argv[idx_word]->arg); | |
eb5d44eb | 1561 | } |
1562 | ||
064f4896 CF |
1563 | DEFUN (isis_topology, |
1564 | isis_topology_cmd, | |
1565 | "topology " ISIS_MT_NAMES " [overload]", | |
1566 | "Configure IS-IS topologies\n" | |
1567 | ISIS_MT_DESCRIPTIONS | |
1568 | "Set overload bit for topology\n") | |
1569 | { | |
d62a17ae | 1570 | VTY_DECLVAR_CONTEXT(isis_area, area); |
064f4896 | 1571 | |
d62a17ae | 1572 | const char *arg = argv[1]->arg; |
1573 | uint16_t mtid = isis_str2mtid(arg); | |
c3ea3906 | 1574 | |
d62a17ae | 1575 | if (area->oldmetric) { |
1576 | vty_out(vty, | |
1577 | "Multi topology IS-IS can only be used with wide metrics\n"); | |
a5fdb4c5 | 1578 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1579 | } |
c3ea3906 | 1580 | |
d62a17ae | 1581 | if (mtid == (uint16_t)-1) { |
1582 | vty_out(vty, "Don't know topology '%s'\n", arg); | |
a5fdb4c5 | 1583 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1584 | } |
1585 | if (mtid == ISIS_MT_IPV4_UNICAST) { | |
1586 | vty_out(vty, "Cannot configure IPv4 unicast topology\n"); | |
a5fdb4c5 | 1587 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1588 | } |
064f4896 | 1589 | |
d62a17ae | 1590 | area_set_mt_enabled(area, mtid, true); |
1591 | area_set_mt_overload(area, mtid, (argc == 3)); | |
1592 | return CMD_SUCCESS; | |
064f4896 CF |
1593 | } |
1594 | ||
1595 | DEFUN (no_isis_topology, | |
1596 | no_isis_topology_cmd, | |
1597 | "no topology " ISIS_MT_NAMES " [overload]", | |
1598 | NO_STR | |
1599 | "Configure IS-IS topologies\n" | |
1600 | ISIS_MT_DESCRIPTIONS | |
1601 | "Set overload bit for topology\n") | |
1602 | { | |
d62a17ae | 1603 | VTY_DECLVAR_CONTEXT(isis_area, area); |
064f4896 | 1604 | |
d62a17ae | 1605 | const char *arg = argv[2]->arg; |
1606 | uint16_t mtid = isis_str2mtid(arg); | |
c3ea3906 | 1607 | |
d62a17ae | 1608 | if (area->oldmetric) { |
1609 | vty_out(vty, | |
1610 | "Multi topology IS-IS can only be used with wide metrics\n"); | |
a5fdb4c5 | 1611 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1612 | } |
c3ea3906 | 1613 | |
d62a17ae | 1614 | if (mtid == (uint16_t)-1) { |
1615 | vty_out(vty, "Don't know topology '%s'\n", arg); | |
a5fdb4c5 | 1616 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1617 | } |
1618 | if (mtid == ISIS_MT_IPV4_UNICAST) { | |
1619 | vty_out(vty, "Cannot configure IPv4 unicast topology\n"); | |
a5fdb4c5 | 1620 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1621 | } |
064f4896 | 1622 | |
d62a17ae | 1623 | area_set_mt_enabled(area, mtid, false); |
1624 | area_set_mt_overload(area, mtid, false); | |
1625 | return CMD_SUCCESS; | |
064f4896 CF |
1626 | } |
1627 | ||
6754fc66 | 1628 | void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu) |
b20ccb3a | 1629 | { |
d62a17ae | 1630 | area->lsp_mtu = lsp_mtu; |
1631 | lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1); | |
1632 | } | |
1633 | ||
1634 | static int isis_area_passwd_set(struct isis_area *area, int level, | |
d7c0a89a QY |
1635 | uint8_t passwd_type, const char *passwd, |
1636 | uint8_t snp_auth) | |
d62a17ae | 1637 | { |
1638 | struct isis_passwd *dest; | |
1639 | struct isis_passwd modified; | |
1640 | int len; | |
1641 | ||
1642 | assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2)); | |
1643 | dest = (level == IS_LEVEL_1) ? &area->area_passwd | |
1644 | : &area->domain_passwd; | |
1645 | memset(&modified, 0, sizeof(modified)); | |
1646 | ||
1647 | if (passwd_type != ISIS_PASSWD_TYPE_UNUSED) { | |
1648 | if (!passwd) | |
1649 | return -1; | |
1650 | ||
1651 | len = strlen(passwd); | |
1652 | if (len > 254) | |
1653 | return -1; | |
1654 | ||
1655 | modified.len = len; | |
1656 | strncpy((char *)modified.passwd, passwd, 255); | |
1657 | modified.type = passwd_type; | |
1658 | modified.snp_auth = snp_auth; | |
1659 | } | |
1660 | ||
1661 | if (memcmp(&modified, dest, sizeof(modified))) { | |
1662 | memcpy(dest, &modified, sizeof(modified)); | |
1663 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
1664 | } | |
1665 | ||
1666 | return 0; | |
1667 | } | |
1668 | ||
1669 | int isis_area_passwd_unset(struct isis_area *area, int level) | |
1670 | { | |
1671 | return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_UNUSED, NULL, | |
1672 | 0); | |
1673 | } | |
1674 | ||
1675 | int isis_area_passwd_cleartext_set(struct isis_area *area, int level, | |
d7c0a89a | 1676 | const char *passwd, uint8_t snp_auth) |
d62a17ae | 1677 | { |
1678 | return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_CLEARTXT, | |
1679 | passwd, snp_auth); | |
1680 | } | |
1681 | ||
1682 | int isis_area_passwd_hmac_md5_set(struct isis_area *area, int level, | |
d7c0a89a | 1683 | const char *passwd, uint8_t snp_auth) |
d62a17ae | 1684 | { |
1685 | return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_HMAC_MD5, | |
1686 | passwd, snp_auth); | |
b20ccb3a CF |
1687 | } |
1688 | ||
3dace42d CF |
1689 | void isis_area_invalidate_routes(struct isis_area *area, int levels) |
1690 | { | |
1691 | for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) { | |
1692 | if (!(level & levels)) | |
1693 | continue; | |
be985ba0 CF |
1694 | for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) { |
1695 | isis_spf_invalidate_routes( | |
1696 | area->spftree[tree][level - 1]); | |
1697 | } | |
3dace42d CF |
1698 | } |
1699 | } | |
1700 | ||
1701 | void isis_area_verify_routes(struct isis_area *area) | |
1702 | { | |
be985ba0 CF |
1703 | for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) |
1704 | isis_spf_verify_routes(area, area->spftree[tree]); | |
3dace42d CF |
1705 | } |
1706 | ||
d62a17ae | 1707 | static void area_resign_level(struct isis_area *area, int level) |
3f045a08 | 1708 | { |
3dace42d CF |
1709 | isis_area_invalidate_routes(area, level); |
1710 | isis_area_verify_routes(area); | |
1711 | ||
d62a17ae | 1712 | if (area->lspdb[level - 1]) { |
1713 | lsp_db_destroy(area->lspdb[level - 1]); | |
1714 | area->lspdb[level - 1] = NULL; | |
1715 | } | |
be985ba0 CF |
1716 | |
1717 | for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) { | |
1718 | if (area->spftree[tree][level - 1]) { | |
1719 | isis_spftree_del(area->spftree[tree][level - 1]); | |
1720 | area->spftree[tree][level - 1] = NULL; | |
1721 | } | |
d62a17ae | 1722 | } |
be985ba0 | 1723 | |
d62a17ae | 1724 | THREAD_TIMER_OFF(area->spf_timer[level - 1]); |
3f045a08 | 1725 | |
d62a17ae | 1726 | sched_debug( |
1727 | "ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.", | |
1728 | area->area_tag, level); | |
1729 | THREAD_TIMER_OFF(area->t_lsp_refresh[level - 1]); | |
1730 | area->lsp_regenerate_pending[level - 1] = 0; | |
1731 | } | |
3f045a08 | 1732 | |
d62a17ae | 1733 | void isis_area_is_type_set(struct isis_area *area, int is_type) |
1734 | { | |
1735 | struct listnode *node; | |
1736 | struct isis_circuit *circuit; | |
3f045a08 | 1737 | |
d62a17ae | 1738 | if (isis->debugs & DEBUG_EVENTS) |
1739 | zlog_debug("ISIS-Evt (%s) system type change %s -> %s", | |
1740 | area->area_tag, circuit_t2string(area->is_type), | |
1741 | circuit_t2string(is_type)); | |
f390d2c7 | 1742 | |
d62a17ae | 1743 | if (area->is_type == is_type) |
1744 | return; /* No change */ | |
1745 | ||
1746 | switch (area->is_type) { | |
1747 | case IS_LEVEL_1: | |
1748 | if (is_type == IS_LEVEL_2) | |
1749 | area_resign_level(area, IS_LEVEL_1); | |
1750 | ||
1751 | if (area->lspdb[1] == NULL) | |
1752 | area->lspdb[1] = lsp_db_init(); | |
d62a17ae | 1753 | break; |
1754 | ||
1755 | case IS_LEVEL_1_AND_2: | |
1756 | if (is_type == IS_LEVEL_1) | |
1757 | area_resign_level(area, IS_LEVEL_2); | |
1758 | else | |
1759 | area_resign_level(area, IS_LEVEL_1); | |
1760 | break; | |
1761 | ||
1762 | case IS_LEVEL_2: | |
1763 | if (is_type == IS_LEVEL_1) | |
1764 | area_resign_level(area, IS_LEVEL_2); | |
1765 | ||
1766 | if (area->lspdb[0] == NULL) | |
1767 | area->lspdb[0] = lsp_db_init(); | |
d62a17ae | 1768 | break; |
1769 | ||
1770 | default: | |
1771 | break; | |
1772 | } | |
1773 | ||
1774 | area->is_type = is_type; | |
1775 | ||
1776 | /* override circuit's is_type */ | |
1777 | if (area->is_type != IS_LEVEL_1_AND_2) { | |
1778 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) | |
1779 | isis_circuit_is_type_set(circuit, is_type); | |
1780 | } | |
1781 | ||
1782 | spftree_area_init(area); | |
1783 | ||
1784 | if (listcount(area->area_addrs) > 0) { | |
1785 | if (is_type & IS_LEVEL_1) | |
1786 | lsp_generate(area, IS_LEVEL_1); | |
1787 | if (is_type & IS_LEVEL_2) | |
1788 | lsp_generate(area, IS_LEVEL_2); | |
1789 | } | |
1790 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
1791 | ||
1792 | return; | |
eb5d44eb | 1793 | } |
1794 | ||
a38a72db CF |
1795 | void isis_area_metricstyle_set(struct isis_area *area, bool old_metric, |
1796 | bool new_metric) | |
e38e0df0 | 1797 | { |
d62a17ae | 1798 | if (area->oldmetric != old_metric || area->newmetric != new_metric) { |
1799 | area->oldmetric = old_metric; | |
1800 | area->newmetric = new_metric; | |
1801 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
1802 | } | |
e38e0df0 SV |
1803 | } |
1804 | ||
a38a72db | 1805 | void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit) |
eb5d44eb | 1806 | { |
d62a17ae | 1807 | char new_overload_bit = overload_bit ? LSPBIT_OL : 0; |
eb5d44eb | 1808 | |
d62a17ae | 1809 | if (new_overload_bit != area->overload_bit) { |
1810 | area->overload_bit = new_overload_bit; | |
1811 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
1812 | } | |
3f045a08 JB |
1813 | } |
1814 | ||
a38a72db | 1815 | void isis_area_attached_bit_set(struct isis_area *area, bool attached_bit) |
3f045a08 | 1816 | { |
d62a17ae | 1817 | char new_attached_bit = attached_bit ? LSPBIT_ATT : 0; |
3f045a08 | 1818 | |
d62a17ae | 1819 | if (new_attached_bit != area->attached_bit) { |
1820 | area->attached_bit = new_attached_bit; | |
1821 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
1822 | } | |
eb5d44eb | 1823 | } |
1824 | ||
a38a72db | 1825 | void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname) |
eb5d44eb | 1826 | { |
d62a17ae | 1827 | if (area->dynhostname != dynhostname) { |
1828 | area->dynhostname = dynhostname; | |
1829 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
1830 | } | |
eb5d44eb | 1831 | } |
1832 | ||
d62a17ae | 1833 | void isis_area_max_lsp_lifetime_set(struct isis_area *area, int level, |
1834 | uint16_t max_lsp_lifetime) | |
eb5d44eb | 1835 | { |
d62a17ae | 1836 | assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2)); |
eb5d44eb | 1837 | |
d62a17ae | 1838 | if (area->max_lsp_lifetime[level - 1] == max_lsp_lifetime) |
1839 | return; | |
3f045a08 | 1840 | |
d62a17ae | 1841 | area->max_lsp_lifetime[level - 1] = max_lsp_lifetime; |
1842 | lsp_regenerate_schedule(area, level, 1); | |
3f045a08 JB |
1843 | } |
1844 | ||
d62a17ae | 1845 | void isis_area_lsp_refresh_set(struct isis_area *area, int level, |
1846 | uint16_t lsp_refresh) | |
3f045a08 | 1847 | { |
d62a17ae | 1848 | assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2)); |
eb5d44eb | 1849 | |
d62a17ae | 1850 | if (area->lsp_refresh[level - 1] == lsp_refresh) |
1851 | return; | |
eb5d44eb | 1852 | |
d62a17ae | 1853 | area->lsp_refresh[level - 1] = lsp_refresh; |
1854 | lsp_regenerate_schedule(area, level, 1); | |
3f045a08 JB |
1855 | } |
1856 | ||
3f045a08 JB |
1857 | DEFUN (log_adj_changes, |
1858 | log_adj_changes_cmd, | |
1859 | "log-adjacency-changes", | |
1860 | "Log changes in adjacency state\n") | |
1861 | { | |
d62a17ae | 1862 | VTY_DECLVAR_CONTEXT(isis_area, area); |
eb5d44eb | 1863 | |
d62a17ae | 1864 | area->log_adj_changes = 1; |
eb5d44eb | 1865 | |
d62a17ae | 1866 | return CMD_SUCCESS; |
eb5d44eb | 1867 | } |
1868 | ||
3f045a08 JB |
1869 | DEFUN (no_log_adj_changes, |
1870 | no_log_adj_changes_cmd, | |
1871 | "no log-adjacency-changes", | |
d7fa34c1 | 1872 | NO_STR |
3f045a08 | 1873 | "Stop logging changes in adjacency state\n") |
eb5d44eb | 1874 | { |
d62a17ae | 1875 | VTY_DECLVAR_CONTEXT(isis_area, area); |
f390d2c7 | 1876 | |
d62a17ae | 1877 | area->log_adj_changes = 0; |
eb5d44eb | 1878 | |
d62a17ae | 1879 | return CMD_SUCCESS; |
eb5d44eb | 1880 | } |
1881 | ||
eb5d44eb | 1882 | /* IS-IS configuration write function */ |
d62a17ae | 1883 | int isis_config_write(struct vty *vty) |
1884 | { | |
1885 | int write = 0; | |
1886 | ||
1887 | if (isis != NULL) { | |
1888 | struct isis_area *area; | |
1889 | struct listnode *node, *node2; | |
1890 | ||
1891 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { | |
1892 | /* ISIS - Area name */ | |
7c0cbd0e | 1893 | vty_out(vty, "router " PROTO_NAME " %s\n", area->area_tag); |
d62a17ae | 1894 | write++; |
1895 | /* ISIS - Net */ | |
1896 | if (listcount(area->area_addrs) > 0) { | |
1897 | struct area_addr *area_addr; | |
1898 | for (ALL_LIST_ELEMENTS_RO(area->area_addrs, | |
1899 | node2, area_addr)) { | |
1900 | vty_out(vty, " net %s\n", | |
1901 | isonet_print( | |
1902 | area_addr->area_addr, | |
1903 | area_addr->addr_len | |
1904 | + ISIS_SYS_ID_LEN | |
1905 | + 1)); | |
1906 | write++; | |
1907 | } | |
1908 | } | |
1909 | /* ISIS - Dynamic hostname - Defaults to true so only | |
1910 | * display if | |
1911 | * false. */ | |
1912 | if (!area->dynhostname) { | |
1913 | vty_out(vty, " no hostname dynamic\n"); | |
1914 | write++; | |
1915 | } | |
1916 | /* ISIS - Metric-Style - when true displays wide */ | |
65f18157 CF |
1917 | if (!fabricd) { |
1918 | if (area->newmetric) { | |
1919 | if (!area->oldmetric) | |
1920 | vty_out(vty, " metric-style wide\n"); | |
1921 | else | |
1922 | vty_out(vty, | |
1923 | " metric-style transition\n"); | |
1924 | write++; | |
1925 | } else { | |
1926 | vty_out(vty, " metric-style narrow\n"); | |
1927 | write++; | |
1928 | } | |
d62a17ae | 1929 | } |
1930 | /* ISIS - overload-bit */ | |
1931 | if (area->overload_bit) { | |
1932 | vty_out(vty, " set-overload-bit\n"); | |
1933 | write++; | |
1934 | } | |
1935 | /* ISIS - Area is-type (level-1-2 is default) */ | |
65f18157 CF |
1936 | if (!fabricd) { |
1937 | if (area->is_type == IS_LEVEL_1) { | |
1938 | vty_out(vty, " is-type level-1\n"); | |
1939 | write++; | |
1940 | } else if (area->is_type == IS_LEVEL_2) { | |
1941 | vty_out(vty, " is-type level-2-only\n"); | |
1942 | write++; | |
1943 | } | |
d62a17ae | 1944 | } |
1945 | write += isis_redist_config_write(vty, area, AF_INET); | |
1946 | write += isis_redist_config_write(vty, area, AF_INET6); | |
1947 | /* ISIS - Lsp generation interval */ | |
1948 | if (area->lsp_gen_interval[0] | |
1949 | == area->lsp_gen_interval[1]) { | |
1950 | if (area->lsp_gen_interval[0] | |
1951 | != DEFAULT_MIN_LSP_GEN_INTERVAL) { | |
1952 | vty_out(vty, " lsp-gen-interval %d\n", | |
1953 | area->lsp_gen_interval[0]); | |
1954 | write++; | |
1955 | } | |
1956 | } else { | |
1957 | if (area->lsp_gen_interval[0] | |
1958 | != DEFAULT_MIN_LSP_GEN_INTERVAL) { | |
1959 | vty_out(vty, | |
1960 | " lsp-gen-interval level-1 %d\n", | |
1961 | area->lsp_gen_interval[0]); | |
1962 | write++; | |
1963 | } | |
1964 | if (area->lsp_gen_interval[1] | |
1965 | != DEFAULT_MIN_LSP_GEN_INTERVAL) { | |
1966 | vty_out(vty, | |
1967 | " lsp-gen-interval level-2 %d\n", | |
1968 | area->lsp_gen_interval[1]); | |
1969 | write++; | |
1970 | } | |
1971 | } | |
1972 | /* ISIS - LSP lifetime */ | |
1973 | if (area->max_lsp_lifetime[0] | |
1974 | == area->max_lsp_lifetime[1]) { | |
1975 | if (area->max_lsp_lifetime[0] | |
1976 | != DEFAULT_LSP_LIFETIME) { | |
1977 | vty_out(vty, " max-lsp-lifetime %u\n", | |
1978 | area->max_lsp_lifetime[0]); | |
1979 | write++; | |
1980 | } | |
1981 | } else { | |
1982 | if (area->max_lsp_lifetime[0] | |
1983 | != DEFAULT_LSP_LIFETIME) { | |
1984 | vty_out(vty, | |
1985 | " max-lsp-lifetime level-1 %u\n", | |
1986 | area->max_lsp_lifetime[0]); | |
1987 | write++; | |
1988 | } | |
1989 | if (area->max_lsp_lifetime[1] | |
1990 | != DEFAULT_LSP_LIFETIME) { | |
1991 | vty_out(vty, | |
1992 | " max-lsp-lifetime level-2 %u\n", | |
1993 | area->max_lsp_lifetime[1]); | |
1994 | write++; | |
1995 | } | |
1996 | } | |
1997 | /* ISIS - LSP refresh interval */ | |
1998 | if (area->lsp_refresh[0] == area->lsp_refresh[1]) { | |
1999 | if (area->lsp_refresh[0] | |
2000 | != DEFAULT_MAX_LSP_GEN_INTERVAL) { | |
2001 | vty_out(vty, | |
2002 | " lsp-refresh-interval %u\n", | |
2003 | area->lsp_refresh[0]); | |
2004 | write++; | |
2005 | } | |
2006 | } else { | |
2007 | if (area->lsp_refresh[0] | |
2008 | != DEFAULT_MAX_LSP_GEN_INTERVAL) { | |
2009 | vty_out(vty, | |
2010 | " lsp-refresh-interval level-1 %u\n", | |
2011 | area->lsp_refresh[0]); | |
2012 | write++; | |
2013 | } | |
2014 | if (area->lsp_refresh[1] | |
2015 | != DEFAULT_MAX_LSP_GEN_INTERVAL) { | |
2016 | vty_out(vty, | |
2017 | " lsp-refresh-interval level-2 %u\n", | |
2018 | area->lsp_refresh[1]); | |
2019 | write++; | |
2020 | } | |
2021 | } | |
2022 | if (area->lsp_mtu != DEFAULT_LSP_MTU) { | |
2023 | vty_out(vty, " lsp-mtu %u\n", area->lsp_mtu); | |
2024 | write++; | |
2025 | } | |
2026 | ||
2027 | /* Minimum SPF interval. */ | |
2028 | if (area->min_spf_interval[0] | |
2029 | == area->min_spf_interval[1]) { | |
2030 | if (area->min_spf_interval[0] | |
2031 | != MINIMUM_SPF_INTERVAL) { | |
2032 | vty_out(vty, " spf-interval %d\n", | |
2033 | area->min_spf_interval[0]); | |
2034 | write++; | |
2035 | } | |
2036 | } else { | |
2037 | if (area->min_spf_interval[0] | |
2038 | != MINIMUM_SPF_INTERVAL) { | |
2039 | vty_out(vty, | |
2040 | " spf-interval level-1 %d\n", | |
2041 | area->min_spf_interval[0]); | |
2042 | write++; | |
2043 | } | |
2044 | if (area->min_spf_interval[1] | |
2045 | != MINIMUM_SPF_INTERVAL) { | |
2046 | vty_out(vty, | |
2047 | " spf-interval level-2 %d\n", | |
2048 | area->min_spf_interval[1]); | |
2049 | write++; | |
2050 | } | |
2051 | } | |
2052 | ||
2053 | /* IETF SPF interval */ | |
2054 | if (area->spf_delay_ietf[0]) { | |
2055 | vty_out(vty, | |
2056 | " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld\n", | |
2057 | spf_backoff_init_delay( | |
2058 | area->spf_delay_ietf[0]), | |
2059 | spf_backoff_short_delay( | |
2060 | area->spf_delay_ietf[0]), | |
2061 | spf_backoff_long_delay( | |
2062 | area->spf_delay_ietf[0]), | |
2063 | spf_backoff_holddown( | |
2064 | area->spf_delay_ietf[0]), | |
2065 | spf_backoff_timetolearn( | |
2066 | area->spf_delay_ietf[0])); | |
2067 | write++; | |
2068 | } | |
2069 | ||
2070 | /* Authentication passwords. */ | |
2071 | if (area->area_passwd.type | |
2072 | == ISIS_PASSWD_TYPE_HMAC_MD5) { | |
2073 | vty_out(vty, " area-password md5 %s", | |
2074 | area->area_passwd.passwd); | |
2075 | if (CHECK_FLAG(area->area_passwd.snp_auth, | |
2076 | SNP_AUTH_SEND)) { | |
2077 | vty_out(vty, " authenticate snp "); | |
2078 | if (CHECK_FLAG( | |
2079 | area->area_passwd.snp_auth, | |
2080 | SNP_AUTH_RECV)) | |
2081 | vty_out(vty, "validate"); | |
2082 | else | |
2083 | vty_out(vty, "send-only"); | |
2084 | } | |
2085 | vty_out(vty, "\n"); | |
2086 | write++; | |
2087 | } else if (area->area_passwd.type | |
2088 | == ISIS_PASSWD_TYPE_CLEARTXT) { | |
2089 | vty_out(vty, " area-password clear %s", | |
2090 | area->area_passwd.passwd); | |
2091 | if (CHECK_FLAG(area->area_passwd.snp_auth, | |
2092 | SNP_AUTH_SEND)) { | |
2093 | vty_out(vty, " authenticate snp "); | |
2094 | if (CHECK_FLAG( | |
2095 | area->area_passwd.snp_auth, | |
2096 | SNP_AUTH_RECV)) | |
2097 | vty_out(vty, "validate"); | |
2098 | else | |
2099 | vty_out(vty, "send-only"); | |
2100 | } | |
2101 | vty_out(vty, "\n"); | |
2102 | write++; | |
2103 | } | |
2104 | if (area->domain_passwd.type | |
2105 | == ISIS_PASSWD_TYPE_HMAC_MD5) { | |
2106 | vty_out(vty, " domain-password md5 %s", | |
2107 | area->domain_passwd.passwd); | |
2108 | if (CHECK_FLAG(area->domain_passwd.snp_auth, | |
2109 | SNP_AUTH_SEND)) { | |
2110 | vty_out(vty, " authenticate snp "); | |
2111 | if (CHECK_FLAG(area->domain_passwd | |
2112 | .snp_auth, | |
2113 | SNP_AUTH_RECV)) | |
2114 | vty_out(vty, "validate"); | |
2115 | else | |
2116 | vty_out(vty, "send-only"); | |
2117 | } | |
2118 | vty_out(vty, "\n"); | |
2119 | write++; | |
2120 | } else if (area->domain_passwd.type | |
2121 | == ISIS_PASSWD_TYPE_CLEARTXT) { | |
2122 | vty_out(vty, " domain-password clear %s", | |
2123 | area->domain_passwd.passwd); | |
2124 | if (CHECK_FLAG(area->domain_passwd.snp_auth, | |
2125 | SNP_AUTH_SEND)) { | |
2126 | vty_out(vty, " authenticate snp "); | |
2127 | if (CHECK_FLAG(area->domain_passwd | |
2128 | .snp_auth, | |
2129 | SNP_AUTH_RECV)) | |
2130 | vty_out(vty, "validate"); | |
2131 | else | |
2132 | vty_out(vty, "send-only"); | |
2133 | } | |
2134 | vty_out(vty, "\n"); | |
2135 | write++; | |
2136 | } | |
2137 | ||
2138 | if (area->log_adj_changes) { | |
2139 | vty_out(vty, " log-adjacency-changes\n"); | |
2140 | write++; | |
2141 | } | |
2142 | ||
2143 | write += area_write_mt_settings(area, vty); | |
92ed0cde | 2144 | write += fabricd_write_settings(area, vty); |
d62a17ae | 2145 | } |
2146 | isis_mpls_te_config_write_router(vty); | |
2147 | } | |
2148 | ||
2149 | return write; | |
2150 | } | |
2151 | ||
7c0cbd0e | 2152 | struct cmd_node router_node = {ROUTER_NODE, "%s(config-router)# ", 1}; |
d62a17ae | 2153 | |
2154 | void isis_init() | |
2155 | { | |
2156 | /* Install IS-IS top node */ | |
7c0cbd0e | 2157 | install_node(&router_node, isis_config_write); |
d62a17ae | 2158 | |
2159 | install_element(VIEW_NODE, &show_isis_summary_cmd); | |
2160 | ||
2161 | install_element(VIEW_NODE, &show_isis_spf_ietf_cmd); | |
2162 | ||
2163 | install_element(VIEW_NODE, &show_isis_interface_cmd); | |
2164 | install_element(VIEW_NODE, &show_isis_interface_detail_cmd); | |
2165 | install_element(VIEW_NODE, &show_isis_interface_arg_cmd); | |
2166 | ||
2167 | install_element(VIEW_NODE, &show_isis_neighbor_cmd); | |
2168 | install_element(VIEW_NODE, &show_isis_neighbor_detail_cmd); | |
2169 | install_element(VIEW_NODE, &show_isis_neighbor_arg_cmd); | |
2170 | install_element(VIEW_NODE, &clear_isis_neighbor_cmd); | |
2171 | install_element(VIEW_NODE, &clear_isis_neighbor_arg_cmd); | |
2172 | ||
2173 | install_element(VIEW_NODE, &show_hostname_cmd); | |
2174 | install_element(VIEW_NODE, &show_database_cmd); | |
2175 | ||
2176 | install_element(ENABLE_NODE, &show_debugging_isis_cmd); | |
2177 | ||
2178 | install_node(&debug_node, config_write_debug); | |
2179 | ||
2180 | install_element(ENABLE_NODE, &debug_isis_adj_cmd); | |
2181 | install_element(ENABLE_NODE, &no_debug_isis_adj_cmd); | |
2182 | install_element(ENABLE_NODE, &debug_isis_csum_cmd); | |
2183 | install_element(ENABLE_NODE, &no_debug_isis_csum_cmd); | |
2184 | install_element(ENABLE_NODE, &debug_isis_lupd_cmd); | |
2185 | install_element(ENABLE_NODE, &no_debug_isis_lupd_cmd); | |
2186 | install_element(ENABLE_NODE, &debug_isis_err_cmd); | |
2187 | install_element(ENABLE_NODE, &no_debug_isis_err_cmd); | |
2188 | install_element(ENABLE_NODE, &debug_isis_snp_cmd); | |
2189 | install_element(ENABLE_NODE, &no_debug_isis_snp_cmd); | |
2190 | install_element(ENABLE_NODE, &debug_isis_upd_cmd); | |
2191 | install_element(ENABLE_NODE, &no_debug_isis_upd_cmd); | |
2192 | install_element(ENABLE_NODE, &debug_isis_spfevents_cmd); | |
2193 | install_element(ENABLE_NODE, &no_debug_isis_spfevents_cmd); | |
2194 | install_element(ENABLE_NODE, &debug_isis_spfstats_cmd); | |
2195 | install_element(ENABLE_NODE, &no_debug_isis_spfstats_cmd); | |
2196 | install_element(ENABLE_NODE, &debug_isis_spftrigg_cmd); | |
2197 | install_element(ENABLE_NODE, &no_debug_isis_spftrigg_cmd); | |
2198 | install_element(ENABLE_NODE, &debug_isis_rtevents_cmd); | |
2199 | install_element(ENABLE_NODE, &no_debug_isis_rtevents_cmd); | |
2200 | install_element(ENABLE_NODE, &debug_isis_events_cmd); | |
2201 | install_element(ENABLE_NODE, &no_debug_isis_events_cmd); | |
2202 | install_element(ENABLE_NODE, &debug_isis_packet_dump_cmd); | |
2203 | install_element(ENABLE_NODE, &no_debug_isis_packet_dump_cmd); | |
2204 | install_element(ENABLE_NODE, &debug_isis_lsp_gen_cmd); | |
2205 | install_element(ENABLE_NODE, &no_debug_isis_lsp_gen_cmd); | |
2206 | install_element(ENABLE_NODE, &debug_isis_lsp_sched_cmd); | |
2207 | install_element(ENABLE_NODE, &no_debug_isis_lsp_sched_cmd); | |
2208 | ||
2209 | install_element(CONFIG_NODE, &debug_isis_adj_cmd); | |
2210 | install_element(CONFIG_NODE, &no_debug_isis_adj_cmd); | |
2211 | install_element(CONFIG_NODE, &debug_isis_csum_cmd); | |
2212 | install_element(CONFIG_NODE, &no_debug_isis_csum_cmd); | |
2213 | install_element(CONFIG_NODE, &debug_isis_lupd_cmd); | |
2214 | install_element(CONFIG_NODE, &no_debug_isis_lupd_cmd); | |
2215 | install_element(CONFIG_NODE, &debug_isis_err_cmd); | |
2216 | install_element(CONFIG_NODE, &no_debug_isis_err_cmd); | |
2217 | install_element(CONFIG_NODE, &debug_isis_snp_cmd); | |
2218 | install_element(CONFIG_NODE, &no_debug_isis_snp_cmd); | |
2219 | install_element(CONFIG_NODE, &debug_isis_upd_cmd); | |
2220 | install_element(CONFIG_NODE, &no_debug_isis_upd_cmd); | |
2221 | install_element(CONFIG_NODE, &debug_isis_spfevents_cmd); | |
2222 | install_element(CONFIG_NODE, &no_debug_isis_spfevents_cmd); | |
2223 | install_element(CONFIG_NODE, &debug_isis_spfstats_cmd); | |
2224 | install_element(CONFIG_NODE, &no_debug_isis_spfstats_cmd); | |
2225 | install_element(CONFIG_NODE, &debug_isis_spftrigg_cmd); | |
2226 | install_element(CONFIG_NODE, &no_debug_isis_spftrigg_cmd); | |
2227 | install_element(CONFIG_NODE, &debug_isis_rtevents_cmd); | |
2228 | install_element(CONFIG_NODE, &no_debug_isis_rtevents_cmd); | |
2229 | install_element(CONFIG_NODE, &debug_isis_events_cmd); | |
2230 | install_element(CONFIG_NODE, &no_debug_isis_events_cmd); | |
2231 | install_element(CONFIG_NODE, &debug_isis_packet_dump_cmd); | |
2232 | install_element(CONFIG_NODE, &no_debug_isis_packet_dump_cmd); | |
2233 | install_element(CONFIG_NODE, &debug_isis_lsp_gen_cmd); | |
2234 | install_element(CONFIG_NODE, &no_debug_isis_lsp_gen_cmd); | |
2235 | install_element(CONFIG_NODE, &debug_isis_lsp_sched_cmd); | |
2236 | install_element(CONFIG_NODE, &no_debug_isis_lsp_sched_cmd); | |
2237 | ||
2238 | install_element(CONFIG_NODE, &router_isis_cmd); | |
2239 | install_element(CONFIG_NODE, &no_router_isis_cmd); | |
2240 | ||
7c0cbd0e | 2241 | install_default(ROUTER_NODE); |
d62a17ae | 2242 | |
7c0cbd0e CF |
2243 | install_element(ROUTER_NODE, &net_cmd); |
2244 | install_element(ROUTER_NODE, &no_net_cmd); | |
d62a17ae | 2245 | |
7c0cbd0e CF |
2246 | install_element(ROUTER_NODE, &isis_topology_cmd); |
2247 | install_element(ROUTER_NODE, &no_isis_topology_cmd); | |
d62a17ae | 2248 | |
7c0cbd0e CF |
2249 | install_element(ROUTER_NODE, &log_adj_changes_cmd); |
2250 | install_element(ROUTER_NODE, &no_log_adj_changes_cmd); | |
d62a17ae | 2251 | |
2252 | spf_backoff_cmd_init(); | |
eb5d44eb | 2253 | } |