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