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