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