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