]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isisd.c
Merge pull request #3163 from donaldsharp/more_vty_errors
[mirror_frr.git] / isisd / isisd.c
1 /*
2 * IS-IS Rout(e)ing protocol - isisd.c
3 *
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
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
23 #include <zebra.h>
24
25 #include "thread.h"
26 #include "vty.h"
27 #include "command.h"
28 #include "log.h"
29 #include "memory.h"
30 #include "time.h"
31 #include "linklist.h"
32 #include "if.h"
33 #include "hash.h"
34 #include "stream.h"
35 #include "prefix.h"
36 #include "table.h"
37 #include "qobj.h"
38 #include "spf_backoff.h"
39
40 #include "isisd/dict.h"
41 #include "isisd/isis_constants.h"
42 #include "isisd/isis_common.h"
43 #include "isisd/isis_flags.h"
44 #include "isisd/isis_circuit.h"
45 #include "isisd/isis_csm.h"
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"
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"
57 #include "isisd/isis_te.h"
58 #include "isisd/isis_mt.h"
59 #include "isisd/fabricd.h"
60
61 struct isis *isis = NULL;
62
63 DEFINE_QOBJ_TYPE(isis)
64 DEFINE_QOBJ_TYPE(isis_area)
65
66 /*
67 * Prototypes.
68 */
69 int isis_area_get(struct vty *, const char *);
70 int isis_area_destroy(struct vty *, const char *);
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);
76 int isis_config_write(struct vty *);
77
78
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 */
99
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 /*
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
113 */
114 if (fabricd) {
115 area->is_type = IS_LEVEL_2;
116 } else if (listcount(isis->area_list) > 0)
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();
126 }
127 if (area->is_type & IS_LEVEL_2) {
128 area->lspdb[1] = lsp_db_init();
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);
156
157 area->area_tag = strdup(area_tag);
158 listnode_add(isis->area_list, area);
159 area->isis = isis;
160
161 if (fabricd)
162 area->fabricd = fabricd_new(area);
163 QOBJ_REG(area, isis_area);
164
165 return area;
166 }
167
168 struct isis_area *isis_area_lookup(const char *area_tag)
169 {
170 struct isis_area *area;
171 struct listnode *node;
172
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;
178
179 return NULL;
180 }
181
182 int isis_area_get(struct vty *vty, const char *area_tag)
183 {
184 struct isis_area *area;
185
186 area = isis_area_lookup(area_tag);
187
188 if (area) {
189 VTY_PUSH_CONTEXT(ROUTER_NODE, area);
190 return CMD_SUCCESS;
191 }
192
193 area = isis_area_create(area_tag);
194
195 if (isis->debugs & DEBUG_EVENTS)
196 zlog_debug("New IS-IS area instance %s", area->area_tag);
197
198 VTY_PUSH_CONTEXT(ROUTER_NODE, area);
199
200 return CMD_SUCCESS;
201 }
202
203 int isis_area_destroy(struct vty *vty, const char *area_tag)
204 {
205 struct isis_area *area;
206 struct listnode *node, *nnode;
207 struct isis_circuit *circuit;
208 struct area_addr *addr;
209
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
219 if (fabricd)
220 fabricd_finish(area->fabricd);
221
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 }
229 list_delete(&area->circuit_list);
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
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
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
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;
315
316 uint8_t buff[255];
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);
329 #ifdef EXTREME_DEBUG
330 zlog_debug("added area address %s for area %s (address length %d)",
331 net_title, area->area_tag, addr->addr_len);
332 #endif /* EXTREME_DEBUG */
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);
338 return CMD_WARNING_CONFIG_FAILED;
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);
345 return CMD_WARNING_CONFIG_FAILED;
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);
365 return CMD_WARNING_CONFIG_FAILED;
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;
403 uint8_t buff[255];
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);
410 return CMD_WARNING_CONFIG_FAILED;
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;
440 }
441
442 /*
443 * 'show isis interface' command
444 */
445
446 int show_isis_interface_common(struct vty *vty, const char *ifname, char detail)
447 {
448 struct listnode *anode, *cnode;
449 struct isis_area *area;
450 struct isis_circuit *circuit;
451
452 if (!isis) {
453 vty_out(vty, "IS-IS Routing Process not enabled\n");
454 return CMD_SUCCESS;
455 }
456
457 for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
458 vty_out(vty, "Area %s:\n", area->area_tag);
459
460 if (detail == ISIS_UI_LEVEL_BRIEF)
461 vty_out(vty,
462 " Interface CircId State Type Level\n");
463
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 }
470
471 return CMD_SUCCESS;
472 }
473
474 DEFUN (show_isis_interface,
475 show_isis_interface_cmd,
476 "show " PROTO_NAME " interface",
477 SHOW_STR
478 PROTO_HELP
479 "ISIS interface\n")
480 {
481 return show_isis_interface_common(vty, NULL, ISIS_UI_LEVEL_BRIEF);
482 }
483
484 DEFUN (show_isis_interface_detail,
485 show_isis_interface_detail_cmd,
486 "show " PROTO_NAME " interface detail",
487 SHOW_STR
488 PROTO_HELP
489 "ISIS interface\n"
490 "show detailed information\n")
491 {
492 return show_isis_interface_common(vty, NULL, ISIS_UI_LEVEL_DETAIL);
493 }
494
495 DEFUN (show_isis_interface_arg,
496 show_isis_interface_arg_cmd,
497 "show " PROTO_NAME " interface WORD",
498 SHOW_STR
499 PROTO_HELP
500 "ISIS interface\n"
501 "ISIS interface name\n")
502 {
503 int idx_word = 3;
504 return show_isis_interface_common(vty, argv[idx_word]->arg,
505 ISIS_UI_LEVEL_DETAIL);
506 }
507
508 /*
509 * 'show isis neighbor' command
510 */
511
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;
520 uint8_t sysid[ISIS_SYS_ID_LEN];
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;
576 }
577
578 /*
579 * 'clear isis neighbor' command
580 */
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;
589 uint8_t sysid[ISIS_SYS_ID_LEN];
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;
643 }
644
645 DEFUN (show_isis_neighbor,
646 show_isis_neighbor_cmd,
647 "show " PROTO_NAME " neighbor",
648 SHOW_STR
649 PROTO_HELP
650 "ISIS neighbor adjacencies\n")
651 {
652 return show_isis_neighbor_common(vty, NULL, ISIS_UI_LEVEL_BRIEF);
653 }
654
655 DEFUN (show_isis_neighbor_detail,
656 show_isis_neighbor_detail_cmd,
657 "show " PROTO_NAME " neighbor detail",
658 SHOW_STR
659 PROTO_HELP
660 "ISIS neighbor adjacencies\n"
661 "show detailed information\n")
662 {
663 return show_isis_neighbor_common(vty, NULL, ISIS_UI_LEVEL_DETAIL);
664 }
665
666 DEFUN (show_isis_neighbor_arg,
667 show_isis_neighbor_arg_cmd,
668 "show " PROTO_NAME " neighbor WORD",
669 SHOW_STR
670 PROTO_HELP
671 "ISIS neighbor adjacencies\n"
672 "System id\n")
673 {
674 int idx_word = 3;
675 return show_isis_neighbor_common(vty, argv[idx_word]->arg,
676 ISIS_UI_LEVEL_DETAIL);
677 }
678
679 DEFUN (clear_isis_neighbor,
680 clear_isis_neighbor_cmd,
681 "clear " PROTO_NAME " neighbor",
682 CLEAR_STR
683 PROTO_HELP
684 "ISIS neighbor adjacencies\n")
685 {
686 return clear_isis_neighbor_common(vty, NULL);
687 }
688
689 DEFUN (clear_isis_neighbor_arg,
690 clear_isis_neighbor_arg_cmd,
691 "clear " PROTO_NAME " neighbor WORD",
692 CLEAR_STR
693 PROTO_HELP
694 "ISIS neighbor adjacencies\n"
695 "System id\n")
696 {
697 int idx_word = 3;
698 return clear_isis_neighbor_common(vty, argv[idx_word]->arg);
699 }
700
701 /*
702 * 'isis debug', 'show debugging'
703 */
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);
747 if (flags & DEBUG_FABRICD_FLOODING)
748 vty_out(vty, "OpenFabric Flooding debugging is %s\n", onoffs);
749 if (flags & DEBUG_BFD)
750 vty_out(vty, "IS-IS BFD debugging is %s\n", onoffs);
751 }
752
753 DEFUN_NOSH (show_debugging,
754 show_debugging_isis_cmd,
755 "show debugging [" PROTO_NAME "]",
756 SHOW_STR
757 "State of each debugging option\n"
758 PROTO_HELP)
759 {
760 vty_out(vty, PROTO_NAME " debugging status:\n");
761
762 if (isis->debugs)
763 print_debug(vty, isis->debugs, 1);
764
765 return CMD_SUCCESS;
766 }
767
768 /* Debug node. */
769 static struct cmd_node debug_node = {DEBUG_NODE, "", 1};
770
771 static int config_write_debug(struct vty *vty)
772 {
773 int write = 0;
774 int flags = isis->debugs;
775
776 if (flags & DEBUG_ADJ_PACKETS) {
777 vty_out(vty, "debug " PROTO_NAME " adj-packets\n");
778 write++;
779 }
780 if (flags & DEBUG_CHECKSUM_ERRORS) {
781 vty_out(vty, "debug " PROTO_NAME " checksum-errors\n");
782 write++;
783 }
784 if (flags & DEBUG_LOCAL_UPDATES) {
785 vty_out(vty, "debug " PROTO_NAME " local-updates\n");
786 write++;
787 }
788 if (flags & DEBUG_PROTOCOL_ERRORS) {
789 vty_out(vty, "debug " PROTO_NAME " protocol-errors\n");
790 write++;
791 }
792 if (flags & DEBUG_SNP_PACKETS) {
793 vty_out(vty, "debug " PROTO_NAME " snp-packets\n");
794 write++;
795 }
796 if (flags & DEBUG_SPF_EVENTS) {
797 vty_out(vty, "debug " PROTO_NAME " spf-events\n");
798 write++;
799 }
800 if (flags & DEBUG_SPF_STATS) {
801 vty_out(vty, "debug " PROTO_NAME " spf-statistics\n");
802 write++;
803 }
804 if (flags & DEBUG_SPF_TRIGGERS) {
805 vty_out(vty, "debug " PROTO_NAME " spf-triggers\n");
806 write++;
807 }
808 if (flags & DEBUG_UPDATE_PACKETS) {
809 vty_out(vty, "debug " PROTO_NAME " update-packets\n");
810 write++;
811 }
812 if (flags & DEBUG_RTE_EVENTS) {
813 vty_out(vty, "debug " PROTO_NAME " route-events\n");
814 write++;
815 }
816 if (flags & DEBUG_EVENTS) {
817 vty_out(vty, "debug " PROTO_NAME " events\n");
818 write++;
819 }
820 if (flags & DEBUG_PACKET_DUMP) {
821 vty_out(vty, "debug " PROTO_NAME " packet-dump\n");
822 write++;
823 }
824 if (flags & DEBUG_LSP_GEN) {
825 vty_out(vty, "debug " PROTO_NAME " lsp-gen\n");
826 write++;
827 }
828 if (flags & DEBUG_LSP_SCHED) {
829 vty_out(vty, "debug " PROTO_NAME " lsp-sched\n");
830 write++;
831 }
832 if (flags & DEBUG_FABRICD_FLOODING) {
833 vty_out(vty, "debug " PROTO_NAME " flooding\n");
834 write++;
835 }
836 if (flags & DEBUG_BFD) {
837 vty_out(vty, "debug " PROTO_NAME " bfd\n");
838 write++;
839 }
840 write += spf_backoff_write_config(vty);
841
842 return write;
843 }
844
845 DEFUN (debug_isis_adj,
846 debug_isis_adj_cmd,
847 "debug " PROTO_NAME " adj-packets",
848 DEBUG_STR
849 PROTO_HELP
850 "IS-IS Adjacency related packets\n")
851 {
852 isis->debugs |= DEBUG_ADJ_PACKETS;
853 print_debug(vty, DEBUG_ADJ_PACKETS, 1);
854
855 return CMD_SUCCESS;
856 }
857
858 DEFUN (no_debug_isis_adj,
859 no_debug_isis_adj_cmd,
860 "no debug " PROTO_NAME " adj-packets",
861 NO_STR
862 UNDEBUG_STR
863 PROTO_HELP
864 "IS-IS Adjacency related packets\n")
865 {
866 isis->debugs &= ~DEBUG_ADJ_PACKETS;
867 print_debug(vty, DEBUG_ADJ_PACKETS, 0);
868
869 return CMD_SUCCESS;
870 }
871
872 DEFUN (debug_isis_csum,
873 debug_isis_csum_cmd,
874 "debug " PROTO_NAME " checksum-errors",
875 DEBUG_STR
876 PROTO_HELP
877 "IS-IS LSP checksum errors\n")
878 {
879 isis->debugs |= DEBUG_CHECKSUM_ERRORS;
880 print_debug(vty, DEBUG_CHECKSUM_ERRORS, 1);
881
882 return CMD_SUCCESS;
883 }
884
885 DEFUN (no_debug_isis_csum,
886 no_debug_isis_csum_cmd,
887 "no debug " PROTO_NAME " checksum-errors",
888 NO_STR
889 UNDEBUG_STR
890 PROTO_HELP
891 "IS-IS LSP checksum errors\n")
892 {
893 isis->debugs &= ~DEBUG_CHECKSUM_ERRORS;
894 print_debug(vty, DEBUG_CHECKSUM_ERRORS, 0);
895
896 return CMD_SUCCESS;
897 }
898
899 DEFUN (debug_isis_lupd,
900 debug_isis_lupd_cmd,
901 "debug " PROTO_NAME " local-updates",
902 DEBUG_STR
903 PROTO_HELP
904 "IS-IS local update packets\n")
905 {
906 isis->debugs |= DEBUG_LOCAL_UPDATES;
907 print_debug(vty, DEBUG_LOCAL_UPDATES, 1);
908
909 return CMD_SUCCESS;
910 }
911
912 DEFUN (no_debug_isis_lupd,
913 no_debug_isis_lupd_cmd,
914 "no debug " PROTO_NAME " local-updates",
915 NO_STR
916 UNDEBUG_STR
917 PROTO_HELP
918 "IS-IS local update packets\n")
919 {
920 isis->debugs &= ~DEBUG_LOCAL_UPDATES;
921 print_debug(vty, DEBUG_LOCAL_UPDATES, 0);
922
923 return CMD_SUCCESS;
924 }
925
926 DEFUN (debug_isis_err,
927 debug_isis_err_cmd,
928 "debug " PROTO_NAME " protocol-errors",
929 DEBUG_STR
930 PROTO_HELP
931 "IS-IS LSP protocol errors\n")
932 {
933 isis->debugs |= DEBUG_PROTOCOL_ERRORS;
934 print_debug(vty, DEBUG_PROTOCOL_ERRORS, 1);
935
936 return CMD_SUCCESS;
937 }
938
939 DEFUN (no_debug_isis_err,
940 no_debug_isis_err_cmd,
941 "no debug " PROTO_NAME " protocol-errors",
942 NO_STR
943 UNDEBUG_STR
944 PROTO_HELP
945 "IS-IS LSP protocol errors\n")
946 {
947 isis->debugs &= ~DEBUG_PROTOCOL_ERRORS;
948 print_debug(vty, DEBUG_PROTOCOL_ERRORS, 0);
949
950 return CMD_SUCCESS;
951 }
952
953 DEFUN (debug_isis_snp,
954 debug_isis_snp_cmd,
955 "debug " PROTO_NAME " snp-packets",
956 DEBUG_STR
957 PROTO_HELP
958 "IS-IS CSNP/PSNP packets\n")
959 {
960 isis->debugs |= DEBUG_SNP_PACKETS;
961 print_debug(vty, DEBUG_SNP_PACKETS, 1);
962
963 return CMD_SUCCESS;
964 }
965
966 DEFUN (no_debug_isis_snp,
967 no_debug_isis_snp_cmd,
968 "no debug " PROTO_NAME " snp-packets",
969 NO_STR
970 UNDEBUG_STR
971 PROTO_HELP
972 "IS-IS CSNP/PSNP packets\n")
973 {
974 isis->debugs &= ~DEBUG_SNP_PACKETS;
975 print_debug(vty, DEBUG_SNP_PACKETS, 0);
976
977 return CMD_SUCCESS;
978 }
979
980 DEFUN (debug_isis_upd,
981 debug_isis_upd_cmd,
982 "debug " PROTO_NAME " update-packets",
983 DEBUG_STR
984 PROTO_HELP
985 "IS-IS Update related packets\n")
986 {
987 isis->debugs |= DEBUG_UPDATE_PACKETS;
988 print_debug(vty, DEBUG_UPDATE_PACKETS, 1);
989
990 return CMD_SUCCESS;
991 }
992
993 DEFUN (no_debug_isis_upd,
994 no_debug_isis_upd_cmd,
995 "no debug " PROTO_NAME " update-packets",
996 NO_STR
997 UNDEBUG_STR
998 PROTO_HELP
999 "IS-IS Update related packets\n")
1000 {
1001 isis->debugs &= ~DEBUG_UPDATE_PACKETS;
1002 print_debug(vty, DEBUG_UPDATE_PACKETS, 0);
1003
1004 return CMD_SUCCESS;
1005 }
1006
1007 DEFUN (debug_isis_spfevents,
1008 debug_isis_spfevents_cmd,
1009 "debug " PROTO_NAME " spf-events",
1010 DEBUG_STR
1011 PROTO_HELP
1012 "IS-IS Shortest Path First Events\n")
1013 {
1014 isis->debugs |= DEBUG_SPF_EVENTS;
1015 print_debug(vty, DEBUG_SPF_EVENTS, 1);
1016
1017 return CMD_SUCCESS;
1018 }
1019
1020 DEFUN (no_debug_isis_spfevents,
1021 no_debug_isis_spfevents_cmd,
1022 "no debug " PROTO_NAME " spf-events",
1023 NO_STR
1024 UNDEBUG_STR
1025 PROTO_HELP
1026 "IS-IS Shortest Path First Events\n")
1027 {
1028 isis->debugs &= ~DEBUG_SPF_EVENTS;
1029 print_debug(vty, DEBUG_SPF_EVENTS, 0);
1030
1031 return CMD_SUCCESS;
1032 }
1033
1034 DEFUN (debug_isis_spfstats,
1035 debug_isis_spfstats_cmd,
1036 "debug " PROTO_NAME " spf-statistics ",
1037 DEBUG_STR
1038 PROTO_HELP
1039 "IS-IS SPF Timing and Statistic Data\n")
1040 {
1041 isis->debugs |= DEBUG_SPF_STATS;
1042 print_debug(vty, DEBUG_SPF_STATS, 1);
1043
1044 return CMD_SUCCESS;
1045 }
1046
1047 DEFUN (no_debug_isis_spfstats,
1048 no_debug_isis_spfstats_cmd,
1049 "no debug " PROTO_NAME " spf-statistics",
1050 NO_STR
1051 UNDEBUG_STR
1052 PROTO_HELP
1053 "IS-IS SPF Timing and Statistic Data\n")
1054 {
1055 isis->debugs &= ~DEBUG_SPF_STATS;
1056 print_debug(vty, DEBUG_SPF_STATS, 0);
1057
1058 return CMD_SUCCESS;
1059 }
1060
1061 DEFUN (debug_isis_spftrigg,
1062 debug_isis_spftrigg_cmd,
1063 "debug " PROTO_NAME " spf-triggers",
1064 DEBUG_STR
1065 PROTO_HELP
1066 "IS-IS SPF triggering events\n")
1067 {
1068 isis->debugs |= DEBUG_SPF_TRIGGERS;
1069 print_debug(vty, DEBUG_SPF_TRIGGERS, 1);
1070
1071 return CMD_SUCCESS;
1072 }
1073
1074 DEFUN (no_debug_isis_spftrigg,
1075 no_debug_isis_spftrigg_cmd,
1076 "no debug " PROTO_NAME " spf-triggers",
1077 NO_STR
1078 UNDEBUG_STR
1079 PROTO_HELP
1080 "IS-IS SPF triggering events\n")
1081 {
1082 isis->debugs &= ~DEBUG_SPF_TRIGGERS;
1083 print_debug(vty, DEBUG_SPF_TRIGGERS, 0);
1084
1085 return CMD_SUCCESS;
1086 }
1087
1088 DEFUN (debug_isis_rtevents,
1089 debug_isis_rtevents_cmd,
1090 "debug " PROTO_NAME " route-events",
1091 DEBUG_STR
1092 PROTO_HELP
1093 "IS-IS Route related events\n")
1094 {
1095 isis->debugs |= DEBUG_RTE_EVENTS;
1096 print_debug(vty, DEBUG_RTE_EVENTS, 1);
1097
1098 return CMD_SUCCESS;
1099 }
1100
1101 DEFUN (no_debug_isis_rtevents,
1102 no_debug_isis_rtevents_cmd,
1103 "no debug " PROTO_NAME " route-events",
1104 NO_STR
1105 UNDEBUG_STR
1106 PROTO_HELP
1107 "IS-IS Route related events\n")
1108 {
1109 isis->debugs &= ~DEBUG_RTE_EVENTS;
1110 print_debug(vty, DEBUG_RTE_EVENTS, 0);
1111
1112 return CMD_SUCCESS;
1113 }
1114
1115 DEFUN (debug_isis_events,
1116 debug_isis_events_cmd,
1117 "debug " PROTO_NAME " events",
1118 DEBUG_STR
1119 PROTO_HELP
1120 "IS-IS Events\n")
1121 {
1122 isis->debugs |= DEBUG_EVENTS;
1123 print_debug(vty, DEBUG_EVENTS, 1);
1124
1125 return CMD_SUCCESS;
1126 }
1127
1128 DEFUN (no_debug_isis_events,
1129 no_debug_isis_events_cmd,
1130 "no debug " PROTO_NAME " events",
1131 NO_STR
1132 UNDEBUG_STR
1133 PROTO_HELP
1134 "IS-IS Events\n")
1135 {
1136 isis->debugs &= ~DEBUG_EVENTS;
1137 print_debug(vty, DEBUG_EVENTS, 0);
1138
1139 return CMD_SUCCESS;
1140 }
1141
1142 DEFUN (debug_isis_packet_dump,
1143 debug_isis_packet_dump_cmd,
1144 "debug " PROTO_NAME " packet-dump",
1145 DEBUG_STR
1146 PROTO_HELP
1147 "IS-IS packet dump\n")
1148 {
1149 isis->debugs |= DEBUG_PACKET_DUMP;
1150 print_debug(vty, DEBUG_PACKET_DUMP, 1);
1151
1152 return CMD_SUCCESS;
1153 }
1154
1155 DEFUN (no_debug_isis_packet_dump,
1156 no_debug_isis_packet_dump_cmd,
1157 "no debug " PROTO_NAME " packet-dump",
1158 NO_STR
1159 UNDEBUG_STR
1160 PROTO_HELP
1161 "IS-IS packet dump\n")
1162 {
1163 isis->debugs &= ~DEBUG_PACKET_DUMP;
1164 print_debug(vty, DEBUG_PACKET_DUMP, 0);
1165
1166 return CMD_SUCCESS;
1167 }
1168
1169 DEFUN (debug_isis_lsp_gen,
1170 debug_isis_lsp_gen_cmd,
1171 "debug " PROTO_NAME " lsp-gen",
1172 DEBUG_STR
1173 PROTO_HELP
1174 "IS-IS generation of own LSPs\n")
1175 {
1176 isis->debugs |= DEBUG_LSP_GEN;
1177 print_debug(vty, DEBUG_LSP_GEN, 1);
1178
1179 return CMD_SUCCESS;
1180 }
1181
1182 DEFUN (no_debug_isis_lsp_gen,
1183 no_debug_isis_lsp_gen_cmd,
1184 "no debug " PROTO_NAME " lsp-gen",
1185 NO_STR
1186 UNDEBUG_STR
1187 PROTO_HELP
1188 "IS-IS generation of own LSPs\n")
1189 {
1190 isis->debugs &= ~DEBUG_LSP_GEN;
1191 print_debug(vty, DEBUG_LSP_GEN, 0);
1192
1193 return CMD_SUCCESS;
1194 }
1195
1196 DEFUN (debug_isis_lsp_sched,
1197 debug_isis_lsp_sched_cmd,
1198 "debug " PROTO_NAME " lsp-sched",
1199 DEBUG_STR
1200 PROTO_HELP
1201 "IS-IS scheduling of LSP generation\n")
1202 {
1203 isis->debugs |= DEBUG_LSP_SCHED;
1204 print_debug(vty, DEBUG_LSP_SCHED, 1);
1205
1206 return CMD_SUCCESS;
1207 }
1208
1209 DEFUN (no_debug_isis_lsp_sched,
1210 no_debug_isis_lsp_sched_cmd,
1211 "no debug " PROTO_NAME " lsp-sched",
1212 NO_STR
1213 UNDEBUG_STR
1214 PROTO_HELP
1215 "IS-IS scheduling of LSP generation\n")
1216 {
1217 isis->debugs &= ~DEBUG_LSP_SCHED;
1218 print_debug(vty, DEBUG_LSP_SCHED, 0);
1219
1220 return CMD_SUCCESS;
1221 }
1222
1223 DEFUN (debug_isis_bfd,
1224 debug_isis_bfd_cmd,
1225 "debug " PROTO_NAME " bfd",
1226 DEBUG_STR
1227 PROTO_HELP
1228 PROTO_NAME " interaction with BFD\n")
1229 {
1230 isis->debugs |= DEBUG_BFD;
1231 print_debug(vty, DEBUG_BFD, 1);
1232
1233 return CMD_SUCCESS;
1234 }
1235
1236 DEFUN (no_debug_isis_bfd,
1237 no_debug_isis_bfd_cmd,
1238 "no debug " PROTO_NAME " bfd",
1239 NO_STR
1240 UNDEBUG_STR
1241 PROTO_HELP
1242 PROTO_NAME " interaction with BFD\n")
1243 {
1244 isis->debugs &= ~DEBUG_BFD;
1245 print_debug(vty, DEBUG_BFD, 0);
1246
1247 return CMD_SUCCESS;
1248 }
1249
1250 DEFUN (show_hostname,
1251 show_hostname_cmd,
1252 "show " PROTO_NAME " hostname",
1253 SHOW_STR
1254 PROTO_HELP
1255 "IS-IS Dynamic hostname mapping\n")
1256 {
1257 dynhn_print_all(vty);
1258
1259 return CMD_SUCCESS;
1260 }
1261
1262 DEFUN (show_isis_spf_ietf,
1263 show_isis_spf_ietf_cmd,
1264 "show " PROTO_NAME " spf-delay-ietf",
1265 SHOW_STR
1266 PROTO_HELP
1267 "SPF delay IETF information\n")
1268 {
1269 if (!isis) {
1270 vty_out(vty, "ISIS is not running\n");
1271 return CMD_SUCCESS;
1272 }
1273
1274 struct listnode *node;
1275 struct isis_area *area;
1276
1277 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
1278 vty_out(vty, "Area %s:\n",
1279 area->area_tag ? area->area_tag : "null");
1280
1281 for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) {
1282 if ((area->is_type & level) == 0)
1283 continue;
1284
1285 vty_out(vty, " Level-%d:\n", level);
1286 vty_out(vty, " SPF delay status: ");
1287 if (area->spf_timer[level - 1]) {
1288 struct timeval remain = thread_timer_remain(
1289 area->spf_timer[level - 1]);
1290 vty_out(vty, "Pending, due in %lld msec\n",
1291 (long long)remain.tv_sec * 1000
1292 + remain.tv_usec / 1000);
1293 } else {
1294 vty_out(vty, "Not scheduled\n");
1295 }
1296
1297 if (area->spf_delay_ietf[level - 1]) {
1298 vty_out(vty,
1299 " Using draft-ietf-rtgwg-backoff-algo-04\n");
1300 spf_backoff_show(
1301 area->spf_delay_ietf[level - 1], vty,
1302 " ");
1303 } else {
1304 vty_out(vty, " Using legacy backoff algo\n");
1305 }
1306 }
1307 }
1308 return CMD_SUCCESS;
1309 }
1310
1311 DEFUN (show_isis_summary,
1312 show_isis_summary_cmd,
1313 "show " PROTO_NAME " summary",
1314 SHOW_STR PROTO_HELP "summary\n")
1315 {
1316 struct listnode *node, *node2;
1317 struct isis_area *area;
1318 int level;
1319
1320 if (isis == NULL) {
1321 vty_out(vty, PROTO_NAME " is not running\n");
1322 return CMD_SUCCESS;
1323 }
1324
1325 vty_out(vty, "Process Id : %ld\n", isis->process_id);
1326 if (isis->sysid_set)
1327 vty_out(vty, "System Id : %s\n",
1328 sysid_print(isis->sysid));
1329
1330 vty_out(vty, "Up time : ");
1331 vty_out_timestr(vty, isis->uptime);
1332 vty_out(vty, "\n");
1333
1334 if (isis->area_list)
1335 vty_out(vty, "Number of areas : %d\n", isis->area_list->count);
1336
1337 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
1338 vty_out(vty, "Area %s:\n",
1339 area->area_tag ? area->area_tag : "null");
1340
1341 if (fabricd) {
1342 uint8_t tier = fabricd_tier(area);
1343 if (tier == ISIS_TIER_UNDEFINED)
1344 vty_out(vty, " Tier: undefined\n");
1345 else
1346 vty_out(vty, " Tier: %" PRIu8 "\n", tier);
1347 }
1348
1349 if (listcount(area->area_addrs) > 0) {
1350 struct area_addr *area_addr;
1351 for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node2,
1352 area_addr)) {
1353 vty_out(vty, " Net: %s\n",
1354 isonet_print(area_addr->area_addr,
1355 area_addr->addr_len
1356 + ISIS_SYS_ID_LEN
1357 + 1));
1358 }
1359 }
1360
1361 for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) {
1362 if ((area->is_type & level) == 0)
1363 continue;
1364
1365 vty_out(vty, " Level-%d:\n", level);
1366 if (area->spf_timer[level - 1])
1367 vty_out(vty, " SPF: (pending)\n");
1368 else
1369 vty_out(vty, " SPF:\n");
1370
1371 vty_out(vty, " minimum interval : %d",
1372 area->min_spf_interval[level - 1]);
1373 if (area->spf_delay_ietf[level - 1])
1374 vty_out(vty,
1375 " (not used, IETF SPF delay activated)");
1376 vty_out(vty, "\n");
1377
1378 vty_out(vty, " IPv4 route computation:\n");
1379 isis_spf_print(area->spftree[SPFTREE_IPV4][level - 1],
1380 vty);
1381
1382 vty_out(vty, " IPv6 route computation:\n");
1383 isis_spf_print(area->spftree[SPFTREE_IPV6][level - 1],
1384 vty);
1385
1386 vty_out(vty, " IPv6 dst-src route computation:\n");
1387 isis_spf_print(area->spftree[SPFTREE_DSTSRC][level-1],
1388 vty);
1389 }
1390 }
1391 vty_out(vty, "\n");
1392
1393 return CMD_SUCCESS;
1394 }
1395
1396 /*
1397 * This function supports following display options:
1398 * [ show isis database [detail] ]
1399 * [ show isis database <sysid> [detail] ]
1400 * [ show isis database <hostname> [detail] ]
1401 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1402 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1403 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1404 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1405 * [ show isis database detail <sysid> ]
1406 * [ show isis database detail <hostname> ]
1407 * [ show isis database detail <sysid>.<pseudo-id> ]
1408 * [ show isis database detail <hostname>.<pseudo-id> ]
1409 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1410 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1411 */
1412 static int show_isis_database(struct vty *vty, const char *argv, int ui_level)
1413 {
1414 struct listnode *node;
1415 struct isis_area *area;
1416 struct isis_lsp *lsp;
1417 struct isis_dynhn *dynhn;
1418 const char *pos;
1419 uint8_t lspid[ISIS_SYS_ID_LEN + 2];
1420 char sysid[255];
1421 uint8_t number[3];
1422 int level, lsp_count;
1423
1424 if (isis->area_list->count == 0)
1425 return CMD_SUCCESS;
1426
1427 memset(&lspid, 0, ISIS_SYS_ID_LEN);
1428 memset(&sysid, 0, 255);
1429
1430 /*
1431 * extract fragment and pseudo id from the string argv
1432 * in the forms:
1433 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1434 * (b) <systemid/hostname>.<pseudo-id> or
1435 * (c) <systemid/hostname> or
1436 * Where systemid is in the form:
1437 * xxxx.xxxx.xxxx
1438 */
1439 if (argv)
1440 strncpy(sysid, argv, 254);
1441 if (argv && strlen(argv) > 3) {
1442 pos = argv + strlen(argv) - 3;
1443 if (strncmp(pos, "-", 1) == 0) {
1444 memcpy(number, ++pos, 2);
1445 lspid[ISIS_SYS_ID_LEN + 1] =
1446 (uint8_t)strtol((char *)number, NULL, 16);
1447 pos -= 4;
1448 if (strncmp(pos, ".", 1) != 0)
1449 return CMD_WARNING;
1450 }
1451 if (strncmp(pos, ".", 1) == 0) {
1452 memcpy(number, ++pos, 2);
1453 lspid[ISIS_SYS_ID_LEN] =
1454 (uint8_t)strtol((char *)number, NULL, 16);
1455 sysid[pos - argv - 1] = '\0';
1456 }
1457 }
1458
1459 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
1460 vty_out(vty, "Area %s:\n",
1461 area->area_tag ? area->area_tag : "null");
1462
1463 for (level = 0; level < ISIS_LEVELS; level++) {
1464 if (area->lspdb[level]
1465 && dict_count(area->lspdb[level]) > 0) {
1466 lsp = NULL;
1467 if (argv != NULL) {
1468 /*
1469 * Try to find the lsp-id if the argv
1470 * string is in
1471 * the form
1472 * hostname.<pseudo-id>-<fragment>
1473 */
1474 if (sysid2buff(lspid, sysid)) {
1475 lsp = lsp_search(
1476 lspid,
1477 area->lspdb[level]);
1478 } else if ((dynhn = dynhn_find_by_name(
1479 sysid))) {
1480 memcpy(lspid, dynhn->id,
1481 ISIS_SYS_ID_LEN);
1482 lsp = lsp_search(
1483 lspid,
1484 area->lspdb[level]);
1485 } else if (strncmp(cmd_hostname_get(),
1486 sysid, 15)
1487 == 0) {
1488 memcpy(lspid, isis->sysid,
1489 ISIS_SYS_ID_LEN);
1490 lsp = lsp_search(
1491 lspid,
1492 area->lspdb[level]);
1493 }
1494 }
1495
1496 if (lsp != NULL || argv == NULL) {
1497 vty_out(vty,
1498 "IS-IS Level-%d link-state database:\n",
1499 level + 1);
1500
1501 /* print the title in all cases */
1502 vty_out(vty,
1503 "LSP ID PduLen SeqNumber Chksum Holdtime ATT/P/OL\n");
1504 }
1505
1506 if (lsp) {
1507 if (ui_level == ISIS_UI_LEVEL_DETAIL)
1508 lsp_print_detail(
1509 lsp, vty,
1510 area->dynhostname);
1511 else
1512 lsp_print(lsp, vty,
1513 area->dynhostname);
1514 } else if (argv == NULL) {
1515 lsp_count = lsp_print_all(
1516 vty, area->lspdb[level],
1517 ui_level, area->dynhostname);
1518
1519 vty_out(vty, " %u LSPs\n\n",
1520 lsp_count);
1521 }
1522 }
1523 }
1524 }
1525
1526 return CMD_SUCCESS;
1527 }
1528
1529 DEFUN (show_database,
1530 show_database_cmd,
1531 "show " PROTO_NAME " database [detail] [WORD]",
1532 SHOW_STR
1533 PROTO_HELP
1534 "Link state database\n"
1535 "Detailed information\n"
1536 "LSP ID\n")
1537 {
1538 int idx = 0;
1539 int uilevel = argv_find(argv, argc, "detail", &idx)
1540 ? ISIS_UI_LEVEL_DETAIL
1541 : ISIS_UI_LEVEL_BRIEF;
1542 char *id = argv_find(argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL;
1543 return show_isis_database(vty, id, uilevel);
1544 }
1545
1546 /*
1547 * 'router isis' command
1548 */
1549 DEFUN_NOSH (router_isis,
1550 router_isis_cmd,
1551 "router " PROTO_NAME " WORD",
1552 ROUTER_STR
1553 PROTO_HELP
1554 "ISO Routing area tag\n")
1555 {
1556 int idx_word = 2;
1557 return isis_area_get(vty, argv[idx_word]->arg);
1558 }
1559
1560 /*
1561 *'no router isis' command
1562 */
1563 DEFUN (no_router_isis,
1564 no_router_isis_cmd,
1565 "no router " PROTO_NAME " WORD",
1566 NO_STR
1567 ROUTER_STR
1568 PROTO_HELP
1569 "ISO Routing area tag\n")
1570 {
1571 int idx_word = 3;
1572 return isis_area_destroy(vty, argv[idx_word]->arg);
1573 }
1574
1575 /*
1576 * 'net' command
1577 */
1578 DEFUN (net,
1579 net_cmd,
1580 "net WORD",
1581 "A Network Entity Title for this process (OSI only)\n"
1582 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1583 {
1584 int idx_word = 1;
1585 return area_net_title(vty, argv[idx_word]->arg);
1586 }
1587
1588 /*
1589 * 'no net' command
1590 */
1591 DEFUN (no_net,
1592 no_net_cmd,
1593 "no net WORD",
1594 NO_STR
1595 "A Network Entity Title for this process (OSI only)\n"
1596 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1597 {
1598 int idx_word = 2;
1599 return area_clear_net_title(vty, argv[idx_word]->arg);
1600 }
1601
1602 DEFUN (isis_topology,
1603 isis_topology_cmd,
1604 "topology " ISIS_MT_NAMES " [overload]",
1605 "Configure IS-IS topologies\n"
1606 ISIS_MT_DESCRIPTIONS
1607 "Set overload bit for topology\n")
1608 {
1609 VTY_DECLVAR_CONTEXT(isis_area, area);
1610
1611 const char *arg = argv[1]->arg;
1612 uint16_t mtid = isis_str2mtid(arg);
1613
1614 if (area->oldmetric) {
1615 vty_out(vty,
1616 "Multi topology IS-IS can only be used with wide metrics\n");
1617 return CMD_WARNING_CONFIG_FAILED;
1618 }
1619
1620 if (mtid == (uint16_t)-1) {
1621 vty_out(vty, "Don't know topology '%s'\n", arg);
1622 return CMD_WARNING_CONFIG_FAILED;
1623 }
1624 if (mtid == ISIS_MT_IPV4_UNICAST) {
1625 vty_out(vty, "Cannot configure IPv4 unicast topology\n");
1626 return CMD_WARNING_CONFIG_FAILED;
1627 }
1628
1629 area_set_mt_enabled(area, mtid, true);
1630 area_set_mt_overload(area, mtid, (argc == 3));
1631 return CMD_SUCCESS;
1632 }
1633
1634 DEFUN (no_isis_topology,
1635 no_isis_topology_cmd,
1636 "no topology " ISIS_MT_NAMES " [overload]",
1637 NO_STR
1638 "Configure IS-IS topologies\n"
1639 ISIS_MT_DESCRIPTIONS
1640 "Set overload bit for topology\n")
1641 {
1642 VTY_DECLVAR_CONTEXT(isis_area, area);
1643
1644 const char *arg = argv[2]->arg;
1645 uint16_t mtid = isis_str2mtid(arg);
1646
1647 if (area->oldmetric) {
1648 vty_out(vty,
1649 "Multi topology IS-IS can only be used with wide metrics\n");
1650 return CMD_WARNING_CONFIG_FAILED;
1651 }
1652
1653 if (mtid == (uint16_t)-1) {
1654 vty_out(vty, "Don't know topology '%s'\n", arg);
1655 return CMD_WARNING_CONFIG_FAILED;
1656 }
1657 if (mtid == ISIS_MT_IPV4_UNICAST) {
1658 vty_out(vty, "Cannot configure IPv4 unicast topology\n");
1659 return CMD_WARNING_CONFIG_FAILED;
1660 }
1661
1662 area_set_mt_enabled(area, mtid, false);
1663 area_set_mt_overload(area, mtid, false);
1664 return CMD_SUCCESS;
1665 }
1666
1667 void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu)
1668 {
1669 area->lsp_mtu = lsp_mtu;
1670 lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1);
1671 }
1672
1673 static int isis_area_passwd_set(struct isis_area *area, int level,
1674 uint8_t passwd_type, const char *passwd,
1675 uint8_t snp_auth)
1676 {
1677 struct isis_passwd *dest;
1678 struct isis_passwd modified;
1679 int len;
1680
1681 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
1682 dest = (level == IS_LEVEL_1) ? &area->area_passwd
1683 : &area->domain_passwd;
1684 memset(&modified, 0, sizeof(modified));
1685
1686 if (passwd_type != ISIS_PASSWD_TYPE_UNUSED) {
1687 if (!passwd)
1688 return -1;
1689
1690 len = strlen(passwd);
1691 if (len > 254)
1692 return -1;
1693
1694 modified.len = len;
1695 strncpy((char *)modified.passwd, passwd, 255);
1696 modified.type = passwd_type;
1697 modified.snp_auth = snp_auth;
1698 }
1699
1700 if (memcmp(&modified, dest, sizeof(modified))) {
1701 memcpy(dest, &modified, sizeof(modified));
1702 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1703 }
1704
1705 return 0;
1706 }
1707
1708 int isis_area_passwd_unset(struct isis_area *area, int level)
1709 {
1710 return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_UNUSED, NULL,
1711 0);
1712 }
1713
1714 int isis_area_passwd_cleartext_set(struct isis_area *area, int level,
1715 const char *passwd, uint8_t snp_auth)
1716 {
1717 return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_CLEARTXT,
1718 passwd, snp_auth);
1719 }
1720
1721 int isis_area_passwd_hmac_md5_set(struct isis_area *area, int level,
1722 const char *passwd, uint8_t snp_auth)
1723 {
1724 return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_HMAC_MD5,
1725 passwd, snp_auth);
1726 }
1727
1728 void isis_area_invalidate_routes(struct isis_area *area, int levels)
1729 {
1730 for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) {
1731 if (!(level & levels))
1732 continue;
1733 for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) {
1734 isis_spf_invalidate_routes(
1735 area->spftree[tree][level - 1]);
1736 }
1737 }
1738 }
1739
1740 void isis_area_verify_routes(struct isis_area *area)
1741 {
1742 for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++)
1743 isis_spf_verify_routes(area, area->spftree[tree]);
1744 }
1745
1746 static void area_resign_level(struct isis_area *area, int level)
1747 {
1748 isis_area_invalidate_routes(area, level);
1749 isis_area_verify_routes(area);
1750
1751 if (area->lspdb[level - 1]) {
1752 lsp_db_destroy(area->lspdb[level - 1]);
1753 area->lspdb[level - 1] = NULL;
1754 }
1755
1756 for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) {
1757 if (area->spftree[tree][level - 1]) {
1758 isis_spftree_del(area->spftree[tree][level - 1]);
1759 area->spftree[tree][level - 1] = NULL;
1760 }
1761 }
1762
1763 THREAD_TIMER_OFF(area->spf_timer[level - 1]);
1764
1765 sched_debug(
1766 "ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.",
1767 area->area_tag, level);
1768 THREAD_TIMER_OFF(area->t_lsp_refresh[level - 1]);
1769 area->lsp_regenerate_pending[level - 1] = 0;
1770 }
1771
1772 void isis_area_is_type_set(struct isis_area *area, int is_type)
1773 {
1774 struct listnode *node;
1775 struct isis_circuit *circuit;
1776
1777 if (isis->debugs & DEBUG_EVENTS)
1778 zlog_debug("ISIS-Evt (%s) system type change %s -> %s",
1779 area->area_tag, circuit_t2string(area->is_type),
1780 circuit_t2string(is_type));
1781
1782 if (area->is_type == is_type)
1783 return; /* No change */
1784
1785 switch (area->is_type) {
1786 case IS_LEVEL_1:
1787 if (is_type == IS_LEVEL_2)
1788 area_resign_level(area, IS_LEVEL_1);
1789
1790 if (area->lspdb[1] == NULL)
1791 area->lspdb[1] = lsp_db_init();
1792 break;
1793
1794 case IS_LEVEL_1_AND_2:
1795 if (is_type == IS_LEVEL_1)
1796 area_resign_level(area, IS_LEVEL_2);
1797 else
1798 area_resign_level(area, IS_LEVEL_1);
1799 break;
1800
1801 case IS_LEVEL_2:
1802 if (is_type == IS_LEVEL_1)
1803 area_resign_level(area, IS_LEVEL_2);
1804
1805 if (area->lspdb[0] == NULL)
1806 area->lspdb[0] = lsp_db_init();
1807 break;
1808
1809 default:
1810 break;
1811 }
1812
1813 area->is_type = is_type;
1814
1815 /* override circuit's is_type */
1816 if (area->is_type != IS_LEVEL_1_AND_2) {
1817 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit))
1818 isis_circuit_is_type_set(circuit, is_type);
1819 }
1820
1821 spftree_area_init(area);
1822
1823 if (listcount(area->area_addrs) > 0) {
1824 if (is_type & IS_LEVEL_1)
1825 lsp_generate(area, IS_LEVEL_1);
1826 if (is_type & IS_LEVEL_2)
1827 lsp_generate(area, IS_LEVEL_2);
1828 }
1829 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1830
1831 return;
1832 }
1833
1834 void isis_area_metricstyle_set(struct isis_area *area, bool old_metric,
1835 bool new_metric)
1836 {
1837 if (area->oldmetric != old_metric || area->newmetric != new_metric) {
1838 area->oldmetric = old_metric;
1839 area->newmetric = new_metric;
1840 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1841 }
1842 }
1843
1844 void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit)
1845 {
1846 char new_overload_bit = overload_bit ? LSPBIT_OL : 0;
1847
1848 if (new_overload_bit != area->overload_bit) {
1849 area->overload_bit = new_overload_bit;
1850 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1851 }
1852 }
1853
1854 void isis_area_attached_bit_set(struct isis_area *area, bool attached_bit)
1855 {
1856 char new_attached_bit = attached_bit ? LSPBIT_ATT : 0;
1857
1858 if (new_attached_bit != area->attached_bit) {
1859 area->attached_bit = new_attached_bit;
1860 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1861 }
1862 }
1863
1864 void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname)
1865 {
1866 if (area->dynhostname != dynhostname) {
1867 area->dynhostname = dynhostname;
1868 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
1869 }
1870 }
1871
1872 void isis_area_max_lsp_lifetime_set(struct isis_area *area, int level,
1873 uint16_t max_lsp_lifetime)
1874 {
1875 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
1876
1877 if (area->max_lsp_lifetime[level - 1] == max_lsp_lifetime)
1878 return;
1879
1880 area->max_lsp_lifetime[level - 1] = max_lsp_lifetime;
1881 lsp_regenerate_schedule(area, level, 1);
1882 }
1883
1884 void isis_area_lsp_refresh_set(struct isis_area *area, int level,
1885 uint16_t lsp_refresh)
1886 {
1887 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
1888
1889 if (area->lsp_refresh[level - 1] == lsp_refresh)
1890 return;
1891
1892 area->lsp_refresh[level - 1] = lsp_refresh;
1893 lsp_regenerate_schedule(area, level, 1);
1894 }
1895
1896 DEFUN (log_adj_changes,
1897 log_adj_changes_cmd,
1898 "log-adjacency-changes",
1899 "Log changes in adjacency state\n")
1900 {
1901 VTY_DECLVAR_CONTEXT(isis_area, area);
1902
1903 area->log_adj_changes = 1;
1904
1905 return CMD_SUCCESS;
1906 }
1907
1908 DEFUN (no_log_adj_changes,
1909 no_log_adj_changes_cmd,
1910 "no log-adjacency-changes",
1911 NO_STR
1912 "Stop logging changes in adjacency state\n")
1913 {
1914 VTY_DECLVAR_CONTEXT(isis_area, area);
1915
1916 area->log_adj_changes = 0;
1917
1918 return CMD_SUCCESS;
1919 }
1920
1921 /* IS-IS configuration write function */
1922 int isis_config_write(struct vty *vty)
1923 {
1924 int write = 0;
1925
1926 if (isis != NULL) {
1927 struct isis_area *area;
1928 struct listnode *node, *node2;
1929
1930 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
1931 /* ISIS - Area name */
1932 vty_out(vty, "router " PROTO_NAME " %s\n", area->area_tag);
1933 write++;
1934 /* ISIS - Net */
1935 if (listcount(area->area_addrs) > 0) {
1936 struct area_addr *area_addr;
1937 for (ALL_LIST_ELEMENTS_RO(area->area_addrs,
1938 node2, area_addr)) {
1939 vty_out(vty, " net %s\n",
1940 isonet_print(
1941 area_addr->area_addr,
1942 area_addr->addr_len
1943 + ISIS_SYS_ID_LEN
1944 + 1));
1945 write++;
1946 }
1947 }
1948 /* ISIS - Dynamic hostname - Defaults to true so only
1949 * display if
1950 * false. */
1951 if (!area->dynhostname) {
1952 vty_out(vty, " no hostname dynamic\n");
1953 write++;
1954 }
1955 /* ISIS - Metric-Style - when true displays wide */
1956 if (!fabricd) {
1957 if (area->newmetric) {
1958 if (!area->oldmetric)
1959 vty_out(vty, " metric-style wide\n");
1960 else
1961 vty_out(vty,
1962 " metric-style transition\n");
1963 write++;
1964 } else {
1965 vty_out(vty, " metric-style narrow\n");
1966 write++;
1967 }
1968 }
1969 /* ISIS - overload-bit */
1970 if (area->overload_bit) {
1971 vty_out(vty, " set-overload-bit\n");
1972 write++;
1973 }
1974 /* ISIS - Area is-type (level-1-2 is default) */
1975 if (!fabricd) {
1976 if (area->is_type == IS_LEVEL_1) {
1977 vty_out(vty, " is-type level-1\n");
1978 write++;
1979 } else if (area->is_type == IS_LEVEL_2) {
1980 vty_out(vty, " is-type level-2-only\n");
1981 write++;
1982 }
1983 }
1984 write += isis_redist_config_write(vty, area, AF_INET);
1985 write += isis_redist_config_write(vty, area, AF_INET6);
1986 /* ISIS - Lsp generation interval */
1987 if (area->lsp_gen_interval[0]
1988 == area->lsp_gen_interval[1]) {
1989 if (area->lsp_gen_interval[0]
1990 != DEFAULT_MIN_LSP_GEN_INTERVAL) {
1991 vty_out(vty, " lsp-gen-interval %d\n",
1992 area->lsp_gen_interval[0]);
1993 write++;
1994 }
1995 } else {
1996 if (area->lsp_gen_interval[0]
1997 != DEFAULT_MIN_LSP_GEN_INTERVAL) {
1998 vty_out(vty,
1999 " lsp-gen-interval level-1 %d\n",
2000 area->lsp_gen_interval[0]);
2001 write++;
2002 }
2003 if (area->lsp_gen_interval[1]
2004 != DEFAULT_MIN_LSP_GEN_INTERVAL) {
2005 vty_out(vty,
2006 " lsp-gen-interval level-2 %d\n",
2007 area->lsp_gen_interval[1]);
2008 write++;
2009 }
2010 }
2011 /* ISIS - LSP lifetime */
2012 if (area->max_lsp_lifetime[0]
2013 == area->max_lsp_lifetime[1]) {
2014 if (area->max_lsp_lifetime[0]
2015 != DEFAULT_LSP_LIFETIME) {
2016 vty_out(vty, " max-lsp-lifetime %u\n",
2017 area->max_lsp_lifetime[0]);
2018 write++;
2019 }
2020 } else {
2021 if (area->max_lsp_lifetime[0]
2022 != DEFAULT_LSP_LIFETIME) {
2023 vty_out(vty,
2024 " max-lsp-lifetime level-1 %u\n",
2025 area->max_lsp_lifetime[0]);
2026 write++;
2027 }
2028 if (area->max_lsp_lifetime[1]
2029 != DEFAULT_LSP_LIFETIME) {
2030 vty_out(vty,
2031 " max-lsp-lifetime level-2 %u\n",
2032 area->max_lsp_lifetime[1]);
2033 write++;
2034 }
2035 }
2036 /* ISIS - LSP refresh interval */
2037 if (area->lsp_refresh[0] == area->lsp_refresh[1]) {
2038 if (area->lsp_refresh[0]
2039 != DEFAULT_MAX_LSP_GEN_INTERVAL) {
2040 vty_out(vty,
2041 " lsp-refresh-interval %u\n",
2042 area->lsp_refresh[0]);
2043 write++;
2044 }
2045 } else {
2046 if (area->lsp_refresh[0]
2047 != DEFAULT_MAX_LSP_GEN_INTERVAL) {
2048 vty_out(vty,
2049 " lsp-refresh-interval level-1 %u\n",
2050 area->lsp_refresh[0]);
2051 write++;
2052 }
2053 if (area->lsp_refresh[1]
2054 != DEFAULT_MAX_LSP_GEN_INTERVAL) {
2055 vty_out(vty,
2056 " lsp-refresh-interval level-2 %u\n",
2057 area->lsp_refresh[1]);
2058 write++;
2059 }
2060 }
2061 if (area->lsp_mtu != DEFAULT_LSP_MTU) {
2062 vty_out(vty, " lsp-mtu %u\n", area->lsp_mtu);
2063 write++;
2064 }
2065 if (area->purge_originator) {
2066 vty_out(vty, " purge-originator\n");
2067 write++;
2068 }
2069
2070 /* Minimum SPF interval. */
2071 if (area->min_spf_interval[0]
2072 == area->min_spf_interval[1]) {
2073 if (area->min_spf_interval[0]
2074 != MINIMUM_SPF_INTERVAL) {
2075 vty_out(vty, " spf-interval %d\n",
2076 area->min_spf_interval[0]);
2077 write++;
2078 }
2079 } else {
2080 if (area->min_spf_interval[0]
2081 != MINIMUM_SPF_INTERVAL) {
2082 vty_out(vty,
2083 " spf-interval level-1 %d\n",
2084 area->min_spf_interval[0]);
2085 write++;
2086 }
2087 if (area->min_spf_interval[1]
2088 != MINIMUM_SPF_INTERVAL) {
2089 vty_out(vty,
2090 " spf-interval level-2 %d\n",
2091 area->min_spf_interval[1]);
2092 write++;
2093 }
2094 }
2095
2096 /* IETF SPF interval */
2097 if (area->spf_delay_ietf[0]) {
2098 vty_out(vty,
2099 " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld\n",
2100 spf_backoff_init_delay(
2101 area->spf_delay_ietf[0]),
2102 spf_backoff_short_delay(
2103 area->spf_delay_ietf[0]),
2104 spf_backoff_long_delay(
2105 area->spf_delay_ietf[0]),
2106 spf_backoff_holddown(
2107 area->spf_delay_ietf[0]),
2108 spf_backoff_timetolearn(
2109 area->spf_delay_ietf[0]));
2110 write++;
2111 }
2112
2113 /* Authentication passwords. */
2114 if (area->area_passwd.type
2115 == ISIS_PASSWD_TYPE_HMAC_MD5) {
2116 vty_out(vty, " area-password md5 %s",
2117 area->area_passwd.passwd);
2118 if (CHECK_FLAG(area->area_passwd.snp_auth,
2119 SNP_AUTH_SEND)) {
2120 vty_out(vty, " authenticate snp ");
2121 if (CHECK_FLAG(
2122 area->area_passwd.snp_auth,
2123 SNP_AUTH_RECV))
2124 vty_out(vty, "validate");
2125 else
2126 vty_out(vty, "send-only");
2127 }
2128 vty_out(vty, "\n");
2129 write++;
2130 } else if (area->area_passwd.type
2131 == ISIS_PASSWD_TYPE_CLEARTXT) {
2132 vty_out(vty, " area-password clear %s",
2133 area->area_passwd.passwd);
2134 if (CHECK_FLAG(area->area_passwd.snp_auth,
2135 SNP_AUTH_SEND)) {
2136 vty_out(vty, " authenticate snp ");
2137 if (CHECK_FLAG(
2138 area->area_passwd.snp_auth,
2139 SNP_AUTH_RECV))
2140 vty_out(vty, "validate");
2141 else
2142 vty_out(vty, "send-only");
2143 }
2144 vty_out(vty, "\n");
2145 write++;
2146 }
2147 if (area->domain_passwd.type
2148 == ISIS_PASSWD_TYPE_HMAC_MD5) {
2149 vty_out(vty, " domain-password md5 %s",
2150 area->domain_passwd.passwd);
2151 if (CHECK_FLAG(area->domain_passwd.snp_auth,
2152 SNP_AUTH_SEND)) {
2153 vty_out(vty, " authenticate snp ");
2154 if (CHECK_FLAG(area->domain_passwd
2155 .snp_auth,
2156 SNP_AUTH_RECV))
2157 vty_out(vty, "validate");
2158 else
2159 vty_out(vty, "send-only");
2160 }
2161 vty_out(vty, "\n");
2162 write++;
2163 } else if (area->domain_passwd.type
2164 == ISIS_PASSWD_TYPE_CLEARTXT) {
2165 vty_out(vty, " domain-password clear %s",
2166 area->domain_passwd.passwd);
2167 if (CHECK_FLAG(area->domain_passwd.snp_auth,
2168 SNP_AUTH_SEND)) {
2169 vty_out(vty, " authenticate snp ");
2170 if (CHECK_FLAG(area->domain_passwd
2171 .snp_auth,
2172 SNP_AUTH_RECV))
2173 vty_out(vty, "validate");
2174 else
2175 vty_out(vty, "send-only");
2176 }
2177 vty_out(vty, "\n");
2178 write++;
2179 }
2180
2181 if (area->log_adj_changes) {
2182 vty_out(vty, " log-adjacency-changes\n");
2183 write++;
2184 }
2185
2186 write += area_write_mt_settings(area, vty);
2187 write += fabricd_write_settings(area, vty);
2188 }
2189 isis_mpls_te_config_write_router(vty);
2190 }
2191
2192 return write;
2193 }
2194
2195 struct cmd_node router_node = {ROUTER_NODE, "%s(config-router)# ", 1};
2196
2197 void isis_init()
2198 {
2199 /* Install IS-IS top node */
2200 install_node(&router_node, isis_config_write);
2201
2202 install_element(VIEW_NODE, &show_isis_summary_cmd);
2203
2204 install_element(VIEW_NODE, &show_isis_spf_ietf_cmd);
2205
2206 install_element(VIEW_NODE, &show_isis_interface_cmd);
2207 install_element(VIEW_NODE, &show_isis_interface_detail_cmd);
2208 install_element(VIEW_NODE, &show_isis_interface_arg_cmd);
2209
2210 install_element(VIEW_NODE, &show_isis_neighbor_cmd);
2211 install_element(VIEW_NODE, &show_isis_neighbor_detail_cmd);
2212 install_element(VIEW_NODE, &show_isis_neighbor_arg_cmd);
2213 install_element(VIEW_NODE, &clear_isis_neighbor_cmd);
2214 install_element(VIEW_NODE, &clear_isis_neighbor_arg_cmd);
2215
2216 install_element(VIEW_NODE, &show_hostname_cmd);
2217 install_element(VIEW_NODE, &show_database_cmd);
2218
2219 install_element(ENABLE_NODE, &show_debugging_isis_cmd);
2220
2221 install_node(&debug_node, config_write_debug);
2222
2223 install_element(ENABLE_NODE, &debug_isis_adj_cmd);
2224 install_element(ENABLE_NODE, &no_debug_isis_adj_cmd);
2225 install_element(ENABLE_NODE, &debug_isis_csum_cmd);
2226 install_element(ENABLE_NODE, &no_debug_isis_csum_cmd);
2227 install_element(ENABLE_NODE, &debug_isis_lupd_cmd);
2228 install_element(ENABLE_NODE, &no_debug_isis_lupd_cmd);
2229 install_element(ENABLE_NODE, &debug_isis_err_cmd);
2230 install_element(ENABLE_NODE, &no_debug_isis_err_cmd);
2231 install_element(ENABLE_NODE, &debug_isis_snp_cmd);
2232 install_element(ENABLE_NODE, &no_debug_isis_snp_cmd);
2233 install_element(ENABLE_NODE, &debug_isis_upd_cmd);
2234 install_element(ENABLE_NODE, &no_debug_isis_upd_cmd);
2235 install_element(ENABLE_NODE, &debug_isis_spfevents_cmd);
2236 install_element(ENABLE_NODE, &no_debug_isis_spfevents_cmd);
2237 install_element(ENABLE_NODE, &debug_isis_spfstats_cmd);
2238 install_element(ENABLE_NODE, &no_debug_isis_spfstats_cmd);
2239 install_element(ENABLE_NODE, &debug_isis_spftrigg_cmd);
2240 install_element(ENABLE_NODE, &no_debug_isis_spftrigg_cmd);
2241 install_element(ENABLE_NODE, &debug_isis_rtevents_cmd);
2242 install_element(ENABLE_NODE, &no_debug_isis_rtevents_cmd);
2243 install_element(ENABLE_NODE, &debug_isis_events_cmd);
2244 install_element(ENABLE_NODE, &no_debug_isis_events_cmd);
2245 install_element(ENABLE_NODE, &debug_isis_packet_dump_cmd);
2246 install_element(ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
2247 install_element(ENABLE_NODE, &debug_isis_lsp_gen_cmd);
2248 install_element(ENABLE_NODE, &no_debug_isis_lsp_gen_cmd);
2249 install_element(ENABLE_NODE, &debug_isis_lsp_sched_cmd);
2250 install_element(ENABLE_NODE, &no_debug_isis_lsp_sched_cmd);
2251 install_element(ENABLE_NODE, &debug_isis_bfd_cmd);
2252 install_element(ENABLE_NODE, &no_debug_isis_bfd_cmd);
2253
2254 install_element(CONFIG_NODE, &debug_isis_adj_cmd);
2255 install_element(CONFIG_NODE, &no_debug_isis_adj_cmd);
2256 install_element(CONFIG_NODE, &debug_isis_csum_cmd);
2257 install_element(CONFIG_NODE, &no_debug_isis_csum_cmd);
2258 install_element(CONFIG_NODE, &debug_isis_lupd_cmd);
2259 install_element(CONFIG_NODE, &no_debug_isis_lupd_cmd);
2260 install_element(CONFIG_NODE, &debug_isis_err_cmd);
2261 install_element(CONFIG_NODE, &no_debug_isis_err_cmd);
2262 install_element(CONFIG_NODE, &debug_isis_snp_cmd);
2263 install_element(CONFIG_NODE, &no_debug_isis_snp_cmd);
2264 install_element(CONFIG_NODE, &debug_isis_upd_cmd);
2265 install_element(CONFIG_NODE, &no_debug_isis_upd_cmd);
2266 install_element(CONFIG_NODE, &debug_isis_spfevents_cmd);
2267 install_element(CONFIG_NODE, &no_debug_isis_spfevents_cmd);
2268 install_element(CONFIG_NODE, &debug_isis_spfstats_cmd);
2269 install_element(CONFIG_NODE, &no_debug_isis_spfstats_cmd);
2270 install_element(CONFIG_NODE, &debug_isis_spftrigg_cmd);
2271 install_element(CONFIG_NODE, &no_debug_isis_spftrigg_cmd);
2272 install_element(CONFIG_NODE, &debug_isis_rtevents_cmd);
2273 install_element(CONFIG_NODE, &no_debug_isis_rtevents_cmd);
2274 install_element(CONFIG_NODE, &debug_isis_events_cmd);
2275 install_element(CONFIG_NODE, &no_debug_isis_events_cmd);
2276 install_element(CONFIG_NODE, &debug_isis_packet_dump_cmd);
2277 install_element(CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
2278 install_element(CONFIG_NODE, &debug_isis_lsp_gen_cmd);
2279 install_element(CONFIG_NODE, &no_debug_isis_lsp_gen_cmd);
2280 install_element(CONFIG_NODE, &debug_isis_lsp_sched_cmd);
2281 install_element(CONFIG_NODE, &no_debug_isis_lsp_sched_cmd);
2282 install_element(CONFIG_NODE, &debug_isis_bfd_cmd);
2283 install_element(CONFIG_NODE, &no_debug_isis_bfd_cmd);
2284
2285 install_element(CONFIG_NODE, &router_isis_cmd);
2286 install_element(CONFIG_NODE, &no_router_isis_cmd);
2287
2288 install_default(ROUTER_NODE);
2289
2290 install_element(ROUTER_NODE, &net_cmd);
2291 install_element(ROUTER_NODE, &no_net_cmd);
2292
2293 install_element(ROUTER_NODE, &isis_topology_cmd);
2294 install_element(ROUTER_NODE, &no_isis_topology_cmd);
2295
2296 install_element(ROUTER_NODE, &log_adj_changes_cmd);
2297 install_element(ROUTER_NODE, &no_log_adj_changes_cmd);
2298
2299 spf_backoff_cmd_init();
2300 }