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