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