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