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