]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isisd.c
Merge pull request #13250 from chiragshah6/fdev1
[mirror_frr.git] / isisd / isisd.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * IS-IS Rout(e)ing protocol - isisd.c
4 *
5 * Copyright (C) 2001,2002 Sampo Saaristo
6 * Tampere University of Technology
7 * Institute of Communications Engineering
8 */
9
10 #include <zebra.h>
11
12 #include "frrevent.h"
13 #include "vty.h"
14 #include "command.h"
15 #include "log.h"
16 #include "memory.h"
17 #include "time.h"
18 #include "linklist.h"
19 #include "if.h"
20 #include "hash.h"
21 #include "filter.h"
22 #include "plist.h"
23 #include "stream.h"
24 #include "prefix.h"
25 #include "table.h"
26 #include "qobj.h"
27 #include "zclient.h"
28 #include "vrf.h"
29 #include "spf_backoff.h"
30 #include "lib/northbound_cli.h"
31 #include "bfd.h"
32
33 #include "isisd/isis_constants.h"
34 #include "isisd/isis_common.h"
35 #include "isisd/isis_flags.h"
36 #include "isisd/isis_circuit.h"
37 #include "isisd/isis_csm.h"
38 #include "isisd/isisd.h"
39 #include "isisd/isis_dynhn.h"
40 #include "isisd/isis_adjacency.h"
41 #include "isisd/isis_pdu.h"
42 #include "isisd/isis_misc.h"
43 #include "isisd/isis_constants.h"
44 #include "isisd/isis_lsp.h"
45 #include "isisd/isis_spf.h"
46 #include "isisd/isis_route.h"
47 #include "isisd/isis_zebra.h"
48 #include "isisd/isis_events.h"
49 #include "isisd/isis_te.h"
50 #include "isisd/isis_mt.h"
51 #include "isisd/isis_sr.h"
52 #include "isisd/fabricd.h"
53 #include "isisd/isis_nb.h"
54
55 /* For debug statement. */
56 unsigned long debug_adj_pkt;
57 unsigned long debug_snp_pkt;
58 unsigned long debug_update_pkt;
59 unsigned long debug_spf_events;
60 unsigned long debug_rte_events;
61 unsigned long debug_events;
62 unsigned long debug_pkt_dump;
63 unsigned long debug_lsp_gen;
64 unsigned long debug_lsp_sched;
65 unsigned long debug_flooding;
66 unsigned long debug_bfd;
67 unsigned long debug_tx_queue;
68 unsigned long debug_sr;
69 unsigned long debug_ldp_sync;
70 unsigned long debug_lfa;
71 unsigned long debug_te;
72
73 DEFINE_MGROUP(ISISD, "isisd");
74
75 DEFINE_MTYPE_STATIC(ISISD, ISIS, "ISIS process");
76 DEFINE_MTYPE_STATIC(ISISD, ISIS_NAME, "ISIS process name");
77 DEFINE_MTYPE_STATIC(ISISD, ISIS_AREA, "ISIS area");
78 DEFINE_MTYPE(ISISD, ISIS_AREA_ADDR, "ISIS area address");
79 DEFINE_MTYPE(ISISD, ISIS_ACL_NAME, "ISIS access-list name");
80 DEFINE_MTYPE(ISISD, ISIS_PLIST_NAME, "ISIS prefix-list name");
81
82 DEFINE_QOBJ_TYPE(isis_area);
83
84 /* ISIS process wide configuration. */
85 static struct isis_master isis_master;
86
87 /* ISIS process wide configuration pointer to export. */
88 struct isis_master *im;
89
90 /* ISIS config processing thread */
91 struct event *t_isis_cfg;
92
93 #ifndef FABRICD
94 DEFINE_HOOK(isis_hook_db_overload, (const struct isis_area *area), (area));
95 #endif /* ifndef FABRICD */
96
97 /*
98 * Prototypes.
99 */
100 int isis_area_get(struct vty *, const char *);
101 int area_net_title(struct vty *, const char *);
102 int area_clear_net_title(struct vty *, const char *);
103 int show_isis_interface_common(struct vty *, struct json_object *json,
104 const char *ifname, char, const char *vrf_name,
105 bool all_vrf);
106 int show_isis_interface_common_vty(struct vty *, const char *ifname, char,
107 const char *vrf_name, bool all_vrf);
108 int show_isis_interface_common_json(struct json_object *json,
109 const char *ifname, char,
110 const char *vrf_name, bool all_vrf);
111 int show_isis_neighbor_common(struct vty *, struct json_object *json,
112 const char *id, char, const char *vrf_name,
113 bool all_vrf);
114 int clear_isis_neighbor_common(struct vty *, const char *id,
115 const char *vrf_name, bool all_vrf);
116
117 /* Link ISIS instance to VRF. */
118 void isis_vrf_link(struct isis *isis, struct vrf *vrf)
119 {
120 isis->vrf_id = vrf->vrf_id;
121 if (vrf->info != (void *)isis)
122 vrf->info = (void *)isis;
123 }
124
125 /* Unlink ISIS instance to VRF. */
126 void isis_vrf_unlink(struct isis *isis, struct vrf *vrf)
127 {
128 if (vrf->info == (void *)isis)
129 vrf->info = NULL;
130 isis->vrf_id = VRF_UNKNOWN;
131 }
132
133 struct isis *isis_lookup_by_vrfid(vrf_id_t vrf_id)
134 {
135 struct isis *isis;
136 struct listnode *node;
137
138 for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
139 if (isis->vrf_id == vrf_id)
140 return isis;
141
142 return NULL;
143 }
144
145 struct isis *isis_lookup_by_vrfname(const char *vrfname)
146 {
147 struct isis *isis;
148 struct listnode *node;
149
150 for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
151 if (isis->name && vrfname && strcmp(isis->name, vrfname) == 0)
152 return isis;
153
154 return NULL;
155 }
156
157 struct isis *isis_lookup_by_sysid(const uint8_t *sysid)
158 {
159 struct isis *isis;
160 struct listnode *node;
161
162 for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
163 if (!memcmp(isis->sysid, sysid, ISIS_SYS_ID_LEN))
164 return isis;
165
166 return NULL;
167 }
168
169 void isis_master_init(struct event_loop *master)
170 {
171 memset(&isis_master, 0, sizeof(isis_master));
172 im = &isis_master;
173 im->isis = list_new();
174 im->master = master;
175 }
176
177 struct isis *isis_new(const char *vrf_name)
178 {
179 struct vrf *vrf;
180 struct isis *isis;
181
182 isis = XCALLOC(MTYPE_ISIS, sizeof(struct isis));
183
184 isis->name = XSTRDUP(MTYPE_ISIS_NAME, vrf_name);
185
186 vrf = vrf_lookup_by_name(vrf_name);
187
188 if (vrf)
189 isis_vrf_link(isis, vrf);
190 else
191 isis->vrf_id = VRF_UNKNOWN;
192
193 isis_zebra_vrf_register(isis);
194
195 if (IS_DEBUG_EVENTS)
196 zlog_debug(
197 "%s: Create new isis instance with vrf_name %s vrf_id %u",
198 __func__, isis->name, isis->vrf_id);
199
200 /*
201 * Default values
202 */
203 isis->max_area_addrs = ISIS_DEFAULT_MAX_AREA_ADDRESSES;
204 isis->process_id = getpid();
205 isis->router_id = 0;
206 isis->area_list = list_new();
207 isis->uptime = time(NULL);
208 isis->snmp_notifications = 1;
209 dyn_cache_init(isis);
210
211 listnode_add(im->isis, isis);
212
213 return isis;
214 }
215
216 void isis_finish(struct isis *isis)
217 {
218 struct isis_area *area;
219 struct listnode *node, *nnode;
220
221 for (ALL_LIST_ELEMENTS(isis->area_list, node, nnode, area))
222 isis_area_destroy(area);
223
224 struct vrf *vrf = NULL;
225
226 listnode_delete(im->isis, isis);
227
228 isis_zebra_vrf_deregister(isis);
229
230 vrf = vrf_lookup_by_name(isis->name);
231 if (vrf)
232 isis_vrf_unlink(isis, vrf);
233 XFREE(MTYPE_ISIS_NAME, isis->name);
234
235 isis_redist_free(isis);
236 list_delete(&isis->area_list);
237 dyn_cache_finish(isis);
238 XFREE(MTYPE_ISIS, isis);
239 }
240
241 void isis_area_add_circuit(struct isis_area *area, struct isis_circuit *circuit)
242 {
243 isis_csm_state_change(ISIS_ENABLE, circuit, area);
244
245 area->ip_circuits += circuit->ip_router;
246 area->ipv6_circuits += circuit->ipv6_router;
247
248 area->lfa_protected_links[0] += circuit->lfa_protection[0];
249 area->rlfa_protected_links[0] += circuit->rlfa_protection[0];
250 area->tilfa_protected_links[0] += circuit->tilfa_protection[0];
251
252 area->lfa_protected_links[1] += circuit->lfa_protection[1];
253 area->rlfa_protected_links[1] += circuit->rlfa_protection[1];
254 area->tilfa_protected_links[1] += circuit->tilfa_protection[1];
255 }
256
257 void isis_area_del_circuit(struct isis_area *area, struct isis_circuit *circuit)
258 {
259 area->ip_circuits -= circuit->ip_router;
260 area->ipv6_circuits -= circuit->ipv6_router;
261
262 area->lfa_protected_links[0] -= circuit->lfa_protection[0];
263 area->rlfa_protected_links[0] -= circuit->rlfa_protection[0];
264 area->tilfa_protected_links[0] -= circuit->tilfa_protection[0];
265
266 area->lfa_protected_links[1] -= circuit->lfa_protection[1];
267 area->rlfa_protected_links[1] -= circuit->rlfa_protection[1];
268 area->tilfa_protected_links[1] -= circuit->tilfa_protection[1];
269
270 isis_csm_state_change(ISIS_DISABLE, circuit, area);
271 }
272
273 static void delete_area_addr(void *arg)
274 {
275 struct iso_address *addr = (struct iso_address *)arg;
276
277 XFREE(MTYPE_ISIS_AREA_ADDR, addr);
278 }
279
280 struct isis_area *isis_area_create(const char *area_tag, const char *vrf_name)
281 {
282 struct isis_area *area;
283 struct isis *isis = NULL;
284 struct vrf *vrf = NULL;
285 struct interface *ifp;
286 struct isis_circuit *circuit;
287
288 area = XCALLOC(MTYPE_ISIS_AREA, sizeof(struct isis_area));
289
290 if (!vrf_name)
291 vrf_name = VRF_DEFAULT_NAME;
292
293 vrf = vrf_lookup_by_name(vrf_name);
294 isis = isis_lookup_by_vrfname(vrf_name);
295
296 if (isis == NULL)
297 isis = isis_new(vrf_name);
298
299 listnode_add(isis->area_list, area);
300 area->isis = isis;
301
302 /*
303 * Fabricd runs only as level-2.
304 * For IS-IS, the default is level-1-2
305 */
306 if (fabricd)
307 area->is_type = IS_LEVEL_2;
308 else
309 area->is_type = yang_get_default_enum(
310 "/frr-isisd:isis/instance/is-type");
311
312 /*
313 * intialize the databases
314 */
315 if (area->is_type & IS_LEVEL_1)
316 lsp_db_init(&area->lspdb[0]);
317 if (area->is_type & IS_LEVEL_2)
318 lsp_db_init(&area->lspdb[1]);
319
320 spftree_area_init(area);
321
322 area->circuit_list = list_new();
323 area->adjacency_list = list_new();
324 area->area_addrs = list_new();
325 area->area_addrs->del = delete_area_addr;
326
327 if (!CHECK_FLAG(im->options, F_ISIS_UNIT_TEST))
328 event_add_timer(master, lsp_tick, area, 1, &area->t_tick);
329 flags_initialize(&area->flags);
330
331 isis_sr_area_init(area);
332
333 /*
334 * Default values
335 */
336 #ifndef FABRICD
337 enum isis_metric_style default_style;
338
339 area->max_lsp_lifetime[0] = yang_get_default_uint16(
340 "/frr-isisd:isis/instance/lsp/timers/level-1/maximum-lifetime");
341 area->max_lsp_lifetime[1] = yang_get_default_uint16(
342 "/frr-isisd:isis/instance/lsp/timers/level-2/maximum-lifetime");
343 area->lsp_refresh[0] = yang_get_default_uint16(
344 "/frr-isisd:isis/instance/lsp/timers/level-1/refresh-interval");
345 area->lsp_refresh[1] = yang_get_default_uint16(
346 "/frr-isisd:isis/instance/lsp/timers/level-2/refresh-interval");
347 area->lsp_gen_interval[0] = yang_get_default_uint16(
348 "/frr-isisd:isis/instance/lsp/timers/level-1/generation-interval");
349 area->lsp_gen_interval[1] = yang_get_default_uint16(
350 "/frr-isisd:isis/instance/lsp/timers/level-2/generation-interval");
351 area->min_spf_interval[0] = yang_get_default_uint16(
352 "/frr-isisd:isis/instance/spf/minimum-interval/level-1");
353 area->min_spf_interval[1] = yang_get_default_uint16(
354 "/frr-isisd:isis/instance/spf/minimum-interval/level-1");
355 area->dynhostname = yang_get_default_bool(
356 "/frr-isisd:isis/instance/dynamic-hostname");
357 default_style =
358 yang_get_default_enum("/frr-isisd:isis/instance/metric-style");
359 area->oldmetric = default_style == ISIS_WIDE_METRIC ? 0 : 1;
360 area->newmetric = default_style == ISIS_NARROW_METRIC ? 0 : 1;
361 area->lsp_frag_threshold = 90; /* not currently configurable */
362 area->lsp_mtu =
363 yang_get_default_uint16("/frr-isisd:isis/instance/lsp/mtu");
364 area->lfa_load_sharing[0] = yang_get_default_bool(
365 "/frr-isisd:isis/instance/fast-reroute/level-1/lfa/load-sharing");
366 area->lfa_load_sharing[1] = yang_get_default_bool(
367 "/frr-isisd:isis/instance/fast-reroute/level-2/lfa/load-sharing");
368 area->attached_bit_send =
369 yang_get_default_bool("/frr-isisd:isis/instance/attach-send");
370 area->attached_bit_rcv_ignore = yang_get_default_bool(
371 "/frr-isisd:isis/instance/attach-receive-ignore");
372
373 #else
374 area->max_lsp_lifetime[0] = DEFAULT_LSP_LIFETIME; /* 1200 */
375 area->max_lsp_lifetime[1] = DEFAULT_LSP_LIFETIME; /* 1200 */
376 area->lsp_refresh[0] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
377 area->lsp_refresh[1] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
378 area->lsp_gen_interval[0] = DEFAULT_MIN_LSP_GEN_INTERVAL;
379 area->lsp_gen_interval[1] = DEFAULT_MIN_LSP_GEN_INTERVAL;
380 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
381 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
382 area->dynhostname = 1;
383 area->oldmetric = 0;
384 area->newmetric = 1;
385 area->lsp_frag_threshold = 90;
386 area->lsp_mtu = DEFAULT_LSP_MTU;
387 area->lfa_load_sharing[0] = true;
388 area->lfa_load_sharing[1] = true;
389 area->attached_bit_send = true;
390 area->attached_bit_rcv_ignore = false;
391 #endif /* ifndef FABRICD */
392 area->lfa_priority_limit[0] = SPF_PREFIX_PRIO_LOW;
393 area->lfa_priority_limit[1] = SPF_PREFIX_PRIO_LOW;
394 isis_lfa_tiebreakers_init(area, ISIS_LEVEL1);
395 isis_lfa_tiebreakers_init(area, ISIS_LEVEL2);
396
397 area_mt_init(area);
398
399 area->area_tag = strdup(area_tag);
400
401 if (fabricd)
402 area->fabricd = fabricd_new(area);
403
404 area->lsp_refresh_arg[0].area = area;
405 area->lsp_refresh_arg[0].level = IS_LEVEL_1;
406 area->lsp_refresh_arg[1].area = area;
407 area->lsp_refresh_arg[1].level = IS_LEVEL_2;
408
409 area->bfd_signalled_down = false;
410 area->bfd_force_spf_refresh = false;
411
412 QOBJ_REG(area, isis_area);
413
414 if (vrf) {
415 FOR_ALL_INTERFACES (vrf, ifp) {
416 if (ifp->ifindex == IFINDEX_INTERNAL)
417 continue;
418
419 circuit = ifp->info;
420 if (circuit && strmatch(circuit->tag, area->area_tag))
421 isis_area_add_circuit(area, circuit);
422 }
423 }
424
425 return area;
426 }
427
428 struct isis_area *isis_area_lookup_by_vrf(const char *area_tag,
429 const char *vrf_name)
430 {
431 struct isis_area *area;
432 struct listnode *node;
433 struct isis *isis = NULL;
434
435 isis = isis_lookup_by_vrfname(vrf_name);
436 if (isis == NULL)
437 return NULL;
438
439 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area))
440 if (strcmp(area->area_tag, area_tag) == 0)
441 return area;
442
443 return NULL;
444 }
445
446 struct isis_area *isis_area_lookup(const char *area_tag, vrf_id_t vrf_id)
447 {
448 struct isis_area *area;
449 struct listnode *node;
450 struct isis *isis;
451
452 isis = isis_lookup_by_vrfid(vrf_id);
453 if (isis == NULL)
454 return NULL;
455
456 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area))
457 if ((area->area_tag == NULL && area_tag == NULL)
458 || (area->area_tag && area_tag
459 && strcmp(area->area_tag, area_tag) == 0))
460 return area;
461
462 return NULL;
463 }
464
465 int isis_area_get(struct vty *vty, const char *area_tag)
466 {
467 struct isis_area *area;
468
469 area = isis_area_lookup(area_tag, VRF_DEFAULT);
470
471 if (area) {
472 VTY_PUSH_CONTEXT(ROUTER_NODE, area);
473 return CMD_SUCCESS;
474 }
475
476 area = isis_area_create(area_tag, VRF_DEFAULT_NAME);
477
478 if (IS_DEBUG_EVENTS)
479 zlog_debug("New IS-IS area instance %s", area->area_tag);
480
481 VTY_PUSH_CONTEXT(ROUTER_NODE, area);
482
483 return CMD_SUCCESS;
484 }
485
486 void isis_area_destroy(struct isis_area *area)
487 {
488 struct listnode *node, *nnode;
489 struct isis_circuit *circuit;
490
491 QOBJ_UNREG(area);
492
493 if (fabricd)
494 fabricd_finish(area->fabricd);
495
496 if (area->circuit_list) {
497 for (ALL_LIST_ELEMENTS(area->circuit_list, node, nnode,
498 circuit))
499 isis_area_del_circuit(area, circuit);
500
501 list_delete(&area->circuit_list);
502 }
503 if (area->flags.free_idcs)
504 list_delete(&area->flags.free_idcs);
505
506 list_delete(&area->adjacency_list);
507
508 lsp_db_fini(&area->lspdb[0]);
509 lsp_db_fini(&area->lspdb[1]);
510
511 /* invalidate and verify to delete all routes from zebra */
512 isis_area_invalidate_routes(area, area->is_type);
513 isis_area_verify_routes(area);
514
515 isis_sr_area_term(area);
516
517 isis_mpls_te_term(area);
518
519 spftree_area_del(area);
520
521 if (area->spf_timer[0])
522 isis_spf_timer_free(EVENT_ARG(area->spf_timer[0]));
523 EVENT_OFF(area->spf_timer[0]);
524 if (area->spf_timer[1])
525 isis_spf_timer_free(EVENT_ARG(area->spf_timer[1]));
526 EVENT_OFF(area->spf_timer[1]);
527
528 spf_backoff_free(area->spf_delay_ietf[0]);
529 spf_backoff_free(area->spf_delay_ietf[1]);
530
531 if (!CHECK_FLAG(im->options, F_ISIS_UNIT_TEST))
532 isis_redist_area_finish(area);
533
534 list_delete(&area->area_addrs);
535
536 for (int i = SPF_PREFIX_PRIO_CRITICAL; i <= SPF_PREFIX_PRIO_MEDIUM;
537 i++) {
538 struct spf_prefix_priority_acl *ppa;
539
540 ppa = &area->spf_prefix_priorities[i];
541 XFREE(MTYPE_ISIS_ACL_NAME, ppa->name);
542 }
543 isis_lfa_tiebreakers_clear(area, ISIS_LEVEL1);
544 isis_lfa_tiebreakers_clear(area, ISIS_LEVEL2);
545
546 EVENT_OFF(area->t_tick);
547 EVENT_OFF(area->t_lsp_refresh[0]);
548 EVENT_OFF(area->t_lsp_refresh[1]);
549 EVENT_OFF(area->t_rlfa_rib_update);
550
551 event_cancel_event(master, area);
552
553 listnode_delete(area->isis->area_list, area);
554
555 free(area->area_tag);
556
557 area_mt_finish(area);
558
559 if (area->rlfa_plist_name[0])
560 XFREE(MTYPE_ISIS_PLIST_NAME, area->rlfa_plist_name[0]);
561 if (area->rlfa_plist_name[1])
562 XFREE(MTYPE_ISIS_PLIST_NAME, area->rlfa_plist_name[1]);
563
564 XFREE(MTYPE_ISIS_AREA, area);
565
566 }
567
568 /* This is hook function for vrf create called as part of vrf_init */
569 static int isis_vrf_new(struct vrf *vrf)
570 {
571 if (IS_DEBUG_EVENTS)
572 zlog_debug("%s: VRF Created: %s(%u)", __func__, vrf->name,
573 vrf->vrf_id);
574
575 return 0;
576 }
577
578 /* This is hook function for vrf delete call as part of vrf_init */
579 static int isis_vrf_delete(struct vrf *vrf)
580 {
581 if (IS_DEBUG_EVENTS)
582 zlog_debug("%s: VRF Deletion: %s(%u)", __func__, vrf->name,
583 vrf->vrf_id);
584
585 return 0;
586 }
587
588 static void isis_set_redist_vrf_bitmaps(struct isis *isis, bool set)
589 {
590 struct listnode *node;
591 struct isis_area *area;
592 int type;
593 int level;
594 int protocol;
595
596 char do_subscribe[REDIST_PROTOCOL_COUNT][ZEBRA_ROUTE_MAX + 1];
597
598 memset(do_subscribe, 0, sizeof(do_subscribe));
599
600 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area))
601 for (protocol = 0; protocol < REDIST_PROTOCOL_COUNT; protocol++)
602 for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++)
603 for (level = 0; level < ISIS_LEVELS; level++)
604 if (area->redist_settings[protocol]
605 [type][level]
606 .redist
607 == 1)
608 do_subscribe[protocol][type] =
609 1;
610
611 for (protocol = 0; protocol < REDIST_PROTOCOL_COUNT; protocol++)
612 for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++) {
613 /* This field is actually controlling transmission of
614 * the IS-IS
615 * routes to Zebra and has nothing to do with
616 * redistribution,
617 * so skip it. */
618 if (type == PROTO_TYPE)
619 continue;
620
621 if (!do_subscribe[protocol][type])
622 continue;
623
624 afi_t afi = afi_for_redist_protocol(protocol);
625
626 if (type == DEFAULT_ROUTE) {
627 if (set)
628 vrf_bitmap_set(
629 zclient->default_information
630 [afi],
631 isis->vrf_id);
632 else
633 vrf_bitmap_unset(
634 zclient->default_information
635 [afi],
636 isis->vrf_id);
637 } else {
638 if (set)
639 vrf_bitmap_set(
640 zclient->redist[afi][type],
641 isis->vrf_id);
642 else
643 vrf_bitmap_unset(
644 zclient->redist[afi][type],
645 isis->vrf_id);
646 }
647 }
648 }
649
650 static int isis_vrf_enable(struct vrf *vrf)
651 {
652 struct isis *isis;
653 vrf_id_t old_vrf_id;
654
655 if (IS_DEBUG_EVENTS)
656 zlog_debug("%s: VRF %s id %u enabled", __func__, vrf->name,
657 vrf->vrf_id);
658
659 isis = isis_lookup_by_vrfname(vrf->name);
660 if (isis && isis->vrf_id != vrf->vrf_id) {
661 old_vrf_id = isis->vrf_id;
662 /* We have instance configured, link to VRF and make it "up". */
663 isis_vrf_link(isis, vrf);
664 if (IS_DEBUG_EVENTS)
665 zlog_debug(
666 "%s: isis linked to vrf %s vrf_id %u (old id %u)",
667 __func__, vrf->name, isis->vrf_id, old_vrf_id);
668 /* start zebra redist to us for new vrf */
669 isis_set_redist_vrf_bitmaps(isis, true);
670
671 isis_zebra_vrf_register(isis);
672 }
673
674 return 0;
675 }
676
677 static int isis_vrf_disable(struct vrf *vrf)
678 {
679 struct isis *isis;
680 vrf_id_t old_vrf_id = VRF_UNKNOWN;
681
682 if (vrf->vrf_id == VRF_DEFAULT)
683 return 0;
684
685 if (IS_DEBUG_EVENTS)
686 zlog_debug("%s: VRF %s id %d disabled.", __func__, vrf->name,
687 vrf->vrf_id);
688 isis = isis_lookup_by_vrfname(vrf->name);
689 if (isis) {
690 old_vrf_id = isis->vrf_id;
691
692 isis_zebra_vrf_deregister(isis);
693
694 isis_set_redist_vrf_bitmaps(isis, false);
695
696 /* We have instance configured, unlink
697 * from VRF and make it "down".
698 */
699 isis_vrf_unlink(isis, vrf);
700 if (IS_DEBUG_EVENTS)
701 zlog_debug("%s: isis old_vrf_id %d unlinked", __func__,
702 old_vrf_id);
703 }
704
705 return 0;
706 }
707
708 void isis_vrf_init(void)
709 {
710 vrf_init(isis_vrf_new, isis_vrf_enable, isis_vrf_disable,
711 isis_vrf_delete);
712
713 vrf_cmd_init(NULL);
714 }
715
716 void isis_terminate(void)
717 {
718 struct isis *isis;
719 struct listnode *node, *nnode;
720
721 bfd_protocol_integration_set_shutdown(true);
722
723 if (listcount(im->isis) == 0)
724 return;
725
726 for (ALL_LIST_ELEMENTS(im->isis, node, nnode, isis))
727 isis_finish(isis);
728 }
729
730 void isis_filter_update(struct access_list *access)
731 {
732 struct isis *isis;
733 struct isis_area *area;
734 struct listnode *node, *anode;
735
736 for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
737 for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
738 for (int i = SPF_PREFIX_PRIO_CRITICAL;
739 i <= SPF_PREFIX_PRIO_MEDIUM; i++) {
740 struct spf_prefix_priority_acl *ppa;
741
742 ppa = &area->spf_prefix_priorities[i];
743 ppa->list_v4 =
744 access_list_lookup(AFI_IP, ppa->name);
745 ppa->list_v6 =
746 access_list_lookup(AFI_IP6, ppa->name);
747 }
748 lsp_regenerate_schedule(area, area->is_type, 0);
749 }
750 }
751 }
752
753 void isis_prefix_list_update(struct prefix_list *plist)
754 {
755 struct isis *isis;
756 struct isis_area *area;
757 struct listnode *node, *anode;
758
759 for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
760 for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
761 for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS;
762 level++) {
763 const char *plist_name =
764 prefix_list_name(plist);
765
766 if (!area->rlfa_plist_name[level - 1])
767 continue;
768
769 if (!strmatch(area->rlfa_plist_name[level - 1],
770 plist_name))
771 continue;
772
773 area->rlfa_plist[level - 1] =
774 prefix_list_lookup(AFI_IP, plist_name);
775 lsp_regenerate_schedule(area, area->is_type, 0);
776 }
777 }
778 }
779 }
780
781 #ifdef FABRICD
782 static void area_set_mt_enabled(struct isis_area *area, uint16_t mtid,
783 bool enabled)
784 {
785 struct isis_area_mt_setting *setting;
786
787 setting = area_get_mt_setting(area, mtid);
788 if (setting->enabled != enabled) {
789 setting->enabled = enabled;
790 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
791 }
792 }
793
794 static void area_set_mt_overload(struct isis_area *area, uint16_t mtid,
795 bool overload)
796 {
797 struct isis_area_mt_setting *setting;
798
799 setting = area_get_mt_setting(area, mtid);
800 if (setting->overload != overload) {
801 setting->overload = overload;
802 if (setting->enabled)
803 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2,
804 0);
805 }
806 }
807 #endif /* ifdef FABRICD */
808
809 int area_net_title(struct vty *vty, const char *net_title)
810 {
811 VTY_DECLVAR_CONTEXT(isis_area, area);
812 struct iso_address *addr;
813 struct iso_address *addrp;
814 struct listnode *node;
815
816 uint8_t buff[255];
817
818 /* We check that we are not over the maximal number of addresses */
819 if (listcount(area->area_addrs) >= area->isis->max_area_addrs) {
820 vty_out(vty,
821 "Maximum of area addresses (%d) already reached \n",
822 area->isis->max_area_addrs);
823 return CMD_ERR_NOTHING_TODO;
824 }
825
826 addr = XMALLOC(MTYPE_ISIS_AREA_ADDR, sizeof(struct iso_address));
827 addr->addr_len = dotformat2buff(buff, net_title);
828 memcpy(addr->area_addr, buff, addr->addr_len);
829 #ifdef EXTREME_DEBUG
830 zlog_debug("added area address %s for area %s (address length %d)",
831 net_title, area->area_tag, addr->addr_len);
832 #endif /* EXTREME_DEBUG */
833 if (addr->addr_len < ISO_ADDR_MIN || addr->addr_len > ISO_ADDR_SIZE) {
834 vty_out(vty,
835 "area address must be at least 8..20 octets long (%d)\n",
836 addr->addr_len);
837 XFREE(MTYPE_ISIS_AREA_ADDR, addr);
838 return CMD_WARNING_CONFIG_FAILED;
839 }
840
841 if (addr->area_addr[addr->addr_len - 1] != 0) {
842 vty_out(vty,
843 "nsel byte (last byte) in area address must be 0\n");
844 XFREE(MTYPE_ISIS_AREA_ADDR, addr);
845 return CMD_WARNING_CONFIG_FAILED;
846 }
847
848 if (area->isis->sysid_set == 0) {
849 /*
850 * First area address - get the SystemID for this router
851 */
852 memcpy(area->isis->sysid, GETSYSID(addr), ISIS_SYS_ID_LEN);
853 area->isis->sysid_set = 1;
854 if (IS_DEBUG_EVENTS)
855 zlog_debug("Router has SystemID %pSY",
856 area->isis->sysid);
857 } else {
858 /*
859 * Check that the SystemID portions match
860 */
861 if (memcmp(area->isis->sysid, GETSYSID(addr),
862 ISIS_SYS_ID_LEN)) {
863 vty_out(vty,
864 "System ID must not change when defining additional area addresses\n");
865 XFREE(MTYPE_ISIS_AREA_ADDR, addr);
866 return CMD_WARNING_CONFIG_FAILED;
867 }
868
869 /* now we see that we don't already have this address */
870 for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) {
871 if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN)
872 != (addr->addr_len))
873 continue;
874 if (!memcmp(addrp->area_addr, addr->area_addr,
875 addr->addr_len)) {
876 XFREE(MTYPE_ISIS_AREA_ADDR, addr);
877 return CMD_SUCCESS; /* silent fail */
878 }
879 }
880 }
881
882 /*
883 * Forget the systemID part of the address
884 */
885 addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN);
886 listnode_add(area->area_addrs, addr);
887
888 /* only now we can safely generate our LSPs for this area */
889 if (listcount(area->area_addrs) > 0) {
890 if (area->is_type & IS_LEVEL_1)
891 lsp_generate(area, IS_LEVEL_1);
892 if (area->is_type & IS_LEVEL_2)
893 lsp_generate(area, IS_LEVEL_2);
894 }
895
896 return CMD_SUCCESS;
897 }
898
899 int area_clear_net_title(struct vty *vty, const char *net_title)
900 {
901 VTY_DECLVAR_CONTEXT(isis_area, area);
902 struct iso_address addr, *addrp = NULL;
903 struct listnode *node;
904 uint8_t buff[255];
905
906 addr.addr_len = dotformat2buff(buff, net_title);
907 if (addr.addr_len < ISO_ADDR_MIN || addr.addr_len > ISO_ADDR_SIZE) {
908 vty_out(vty,
909 "Unsupported area address length %d, should be 8...20 \n",
910 addr.addr_len);
911 return CMD_WARNING_CONFIG_FAILED;
912 }
913
914 memcpy(addr.area_addr, buff, (int)addr.addr_len);
915
916 for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp))
917 if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len
918 && !memcmp(addrp->area_addr, addr.area_addr, addr.addr_len))
919 break;
920
921 if (!addrp) {
922 vty_out(vty, "No area address %s for area %s \n", net_title,
923 area->area_tag);
924 return CMD_ERR_NO_MATCH;
925 }
926
927 listnode_delete(area->area_addrs, addrp);
928 XFREE(MTYPE_ISIS_AREA_ADDR, addrp);
929
930 /*
931 * Last area address - reset the SystemID for this router
932 */
933 if (listcount(area->area_addrs) == 0) {
934 memset(area->isis->sysid, 0, ISIS_SYS_ID_LEN);
935 area->isis->sysid_set = 0;
936 if (IS_DEBUG_EVENTS)
937 zlog_debug("Router has no SystemID");
938 }
939
940 return CMD_SUCCESS;
941 }
942
943 /*
944 * 'show isis interface' command
945 */
946 int show_isis_interface_common(struct vty *vty, struct json_object *json,
947 const char *ifname, char detail,
948 const char *vrf_name, bool all_vrf)
949 {
950 if (json) {
951 return show_isis_interface_common_json(json, ifname, detail,
952 vrf_name, all_vrf);
953 } else {
954 return show_isis_interface_common_vty(vty, ifname, detail,
955 vrf_name, all_vrf);
956 }
957 }
958
959 int show_isis_interface_common_json(struct json_object *json,
960 const char *ifname, char detail,
961 const char *vrf_name, bool all_vrf)
962 {
963 struct listnode *anode, *cnode, *inode;
964 struct isis_area *area;
965 struct isis_circuit *circuit;
966 struct isis *isis;
967 struct json_object *areas_json, *area_json;
968 struct json_object *circuits_json, *circuit_json;
969 if (!im) {
970 // IS-IS Routing Process not enabled
971 json_object_string_add(json, "is-is-routing-process-enabled",
972 "no");
973 return CMD_SUCCESS;
974 }
975 if (vrf_name) {
976 if (all_vrf) {
977 for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) {
978 areas_json = json_object_new_array();
979 json_object_object_add(json, "areas",
980 areas_json);
981 for (ALL_LIST_ELEMENTS_RO(isis->area_list,
982 anode, area)) {
983 area_json = json_object_new_object();
984 json_object_string_add(
985 area_json, "area",
986 area->area_tag ? area->area_tag
987 : "null");
988 circuits_json = json_object_new_array();
989 json_object_object_add(area_json,
990 "circuits",
991 circuits_json);
992 for (ALL_LIST_ELEMENTS_RO(
993 area->circuit_list, cnode,
994 circuit)) {
995 circuit_json =
996 json_object_new_object();
997 json_object_int_add(
998 circuit_json, "circuit",
999 circuit->circuit_id);
1000 if (!ifname)
1001 isis_circuit_print_json(
1002 circuit,
1003 circuit_json,
1004 detail);
1005 else if (strcmp(circuit->interface->name, ifname) == 0)
1006 isis_circuit_print_json(
1007 circuit,
1008 circuit_json,
1009 detail);
1010 json_object_array_add(
1011 circuits_json,
1012 circuit_json);
1013 }
1014 json_object_array_add(areas_json,
1015 area_json);
1016 }
1017 }
1018 return CMD_SUCCESS;
1019 }
1020 isis = isis_lookup_by_vrfname(vrf_name);
1021 if (isis != NULL) {
1022 areas_json = json_object_new_array();
1023 json_object_object_add(json, "areas", areas_json);
1024 for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode,
1025 area)) {
1026 area_json = json_object_new_object();
1027 json_object_string_add(area_json, "area",
1028 area->area_tag
1029 ? area->area_tag
1030 : "null");
1031
1032 circuits_json = json_object_new_array();
1033 json_object_object_add(area_json, "circuits",
1034 circuits_json);
1035 for (ALL_LIST_ELEMENTS_RO(area->circuit_list,
1036 cnode, circuit)) {
1037 circuit_json = json_object_new_object();
1038 json_object_int_add(
1039 circuit_json, "circuit",
1040 circuit->circuit_id);
1041 if (!ifname)
1042 isis_circuit_print_json(
1043 circuit, circuit_json,
1044 detail);
1045 else if (
1046 strcmp(circuit->interface->name,
1047 ifname) == 0)
1048 isis_circuit_print_json(
1049 circuit, circuit_json,
1050 detail);
1051 json_object_array_add(circuits_json,
1052 circuit_json);
1053 }
1054 json_object_array_add(areas_json, area_json);
1055 }
1056 }
1057 }
1058 return CMD_SUCCESS;
1059 }
1060
1061 int show_isis_interface_common_vty(struct vty *vty, const char *ifname,
1062 char detail, const char *vrf_name,
1063 bool all_vrf)
1064 {
1065 struct listnode *anode, *cnode, *inode;
1066 struct isis_area *area;
1067 struct isis_circuit *circuit;
1068 struct isis *isis;
1069
1070 if (!im) {
1071 vty_out(vty, "IS-IS Routing Process not enabled\n");
1072 return CMD_SUCCESS;
1073 }
1074 if (vrf_name) {
1075 if (all_vrf) {
1076 for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) {
1077 for (ALL_LIST_ELEMENTS_RO(isis->area_list,
1078 anode, area)) {
1079 vty_out(vty, "Area %s:\n",
1080 area->area_tag);
1081
1082 if (detail == ISIS_UI_LEVEL_BRIEF)
1083 vty_out(vty,
1084 " Interface CircId State Type Level\n");
1085
1086 for (ALL_LIST_ELEMENTS_RO(
1087 area->circuit_list, cnode,
1088 circuit))
1089 if (!ifname)
1090 isis_circuit_print_vty(
1091 circuit, vty,
1092 detail);
1093 else if (strcmp(circuit->interface->name, ifname) == 0)
1094 isis_circuit_print_vty(
1095 circuit, vty,
1096 detail);
1097 }
1098 }
1099 return CMD_SUCCESS;
1100 }
1101 isis = isis_lookup_by_vrfname(vrf_name);
1102 if (isis != NULL) {
1103 for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode,
1104 area)) {
1105 vty_out(vty, "Area %s:\n", area->area_tag);
1106
1107 if (detail == ISIS_UI_LEVEL_BRIEF)
1108 vty_out(vty,
1109 " Interface CircId State Type Level\n");
1110
1111 for (ALL_LIST_ELEMENTS_RO(area->circuit_list,
1112 cnode, circuit))
1113 if (!ifname)
1114 isis_circuit_print_vty(
1115 circuit, vty, detail);
1116 else if (
1117 strcmp(circuit->interface->name,
1118 ifname) == 0)
1119 isis_circuit_print_vty(
1120 circuit, vty, detail);
1121 }
1122 }
1123 }
1124
1125 return CMD_SUCCESS;
1126 }
1127
1128 DEFUN(show_isis_interface,
1129 show_isis_interface_cmd,
1130 "show " PROTO_NAME " [vrf <NAME|all>] interface [json]",
1131 SHOW_STR
1132 PROTO_HELP
1133 VRF_CMD_HELP_STR
1134 "All VRFs\n"
1135 "json output\n"
1136 "IS-IS interface\n")
1137 {
1138 int res = CMD_SUCCESS;
1139 const char *vrf_name = VRF_DEFAULT_NAME;
1140 bool all_vrf = false;
1141 int idx_vrf = 0;
1142 bool uj = use_json(argc, argv);
1143 json_object *json = NULL;
1144
1145 ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1146 if (uj)
1147 json = json_object_new_object();
1148 res = show_isis_interface_common(vty, json, NULL, ISIS_UI_LEVEL_BRIEF,
1149 vrf_name, all_vrf);
1150 if (uj)
1151 vty_json(vty, json);
1152 return res;
1153 }
1154
1155 DEFUN(show_isis_interface_detail,
1156 show_isis_interface_detail_cmd,
1157 "show " PROTO_NAME " [vrf <NAME|all>] interface detail [json]",
1158 SHOW_STR
1159 PROTO_HELP
1160 VRF_CMD_HELP_STR
1161 "All VRFs\n"
1162 "IS-IS interface\n"
1163 "show detailed information\n"
1164 "json output\n")
1165 {
1166 int res = CMD_SUCCESS;
1167 const char *vrf_name = VRF_DEFAULT_NAME;
1168 bool all_vrf = false;
1169 int idx_vrf = 0;
1170 bool uj = use_json(argc, argv);
1171 json_object *json = NULL;
1172
1173 ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1174 if (uj)
1175 json = json_object_new_object();
1176 res = show_isis_interface_common(vty, json, NULL, ISIS_UI_LEVEL_DETAIL,
1177 vrf_name, all_vrf);
1178 if (uj)
1179 vty_json(vty, json);
1180 return res;
1181 }
1182
1183 DEFUN(show_isis_interface_arg,
1184 show_isis_interface_arg_cmd,
1185 "show " PROTO_NAME " [vrf <NAME|all>] interface WORD [json]",
1186 SHOW_STR
1187 PROTO_HELP
1188 VRF_CMD_HELP_STR
1189 "All VRFs\n"
1190 "IS-IS interface\n"
1191 "IS-IS interface name\n"
1192 "json output\n")
1193 {
1194 int res = CMD_SUCCESS;
1195 int idx_word = 0;
1196 const char *vrf_name = VRF_DEFAULT_NAME;
1197 bool all_vrf = false;
1198 int idx_vrf = 0;
1199 bool uj = use_json(argc, argv);
1200 json_object *json = NULL;
1201
1202 ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1203 if (uj)
1204 json = json_object_new_object();
1205
1206 char *ifname = argv_find(argv, argc, "WORD", &idx_word)
1207 ? argv[idx_word]->arg
1208 : NULL;
1209 res = show_isis_interface_common(
1210 vty, json, ifname, ISIS_UI_LEVEL_DETAIL, vrf_name, all_vrf);
1211 if (uj)
1212 vty_json(vty, json);
1213 return res;
1214 }
1215
1216 static int id_to_sysid(struct isis *isis, const char *id, uint8_t *sysid)
1217 {
1218 struct isis_dynhn *dynhn;
1219
1220 memset(sysid, 0, ISIS_SYS_ID_LEN);
1221 if (id) {
1222 if (sysid2buff(sysid, id) == 0) {
1223 dynhn = dynhn_find_by_name(isis, id);
1224 if (dynhn == NULL)
1225 return -1;
1226 memcpy(sysid, dynhn->id, ISIS_SYS_ID_LEN);
1227 }
1228 }
1229
1230 return 0;
1231 }
1232
1233 static void isis_neighbor_common_json(struct json_object *json, const char *id,
1234 char detail, struct isis *isis,
1235 uint8_t *sysid)
1236 {
1237 struct listnode *anode, *cnode, *node;
1238 struct isis_area *area;
1239 struct isis_circuit *circuit;
1240 struct list *adjdb;
1241 struct isis_adjacency *adj;
1242 struct json_object *areas_json, *area_json;
1243 struct json_object *circuits_json, *circuit_json;
1244 int i;
1245
1246 areas_json = json_object_new_array();
1247 json_object_object_add(json, "areas", areas_json);
1248 for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
1249 area_json = json_object_new_object();
1250 json_object_string_add(area_json, "area",
1251 area->area_tag ? area->area_tag
1252 : "null");
1253 circuits_json = json_object_new_array();
1254 json_object_object_add(area_json, "circuits", circuits_json);
1255 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) {
1256 circuit_json = json_object_new_object();
1257 json_object_int_add(circuit_json, "circuit",
1258 circuit->circuit_id);
1259 if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
1260 for (i = 0; i < 2; i++) {
1261 adjdb = circuit->u.bc.adjdb[i];
1262 if (adjdb && adjdb->count) {
1263 for (ALL_LIST_ELEMENTS_RO(
1264 adjdb, node, adj))
1265 if (!id ||
1266 !memcmp(adj->sysid,
1267 sysid,
1268 ISIS_SYS_ID_LEN))
1269 isis_adj_print_json(
1270 adj,
1271 circuit_json,
1272 detail);
1273 }
1274 }
1275 } else if (circuit->circ_type == CIRCUIT_T_P2P &&
1276 circuit->u.p2p.neighbor) {
1277 adj = circuit->u.p2p.neighbor;
1278 if (!id ||
1279 !memcmp(adj->sysid, sysid, ISIS_SYS_ID_LEN))
1280 isis_adj_print_json(adj, circuit_json,
1281 detail);
1282 }
1283 json_object_array_add(circuits_json, circuit_json);
1284 }
1285 json_object_array_add(areas_json, area_json);
1286 }
1287 }
1288
1289 static void isis_neighbor_common_vty(struct vty *vty, const char *id,
1290 char detail, struct isis *isis,
1291 uint8_t *sysid)
1292 {
1293 struct listnode *anode, *cnode, *node;
1294 struct isis_area *area;
1295 struct isis_circuit *circuit;
1296 struct list *adjdb;
1297 struct isis_adjacency *adj;
1298 int i;
1299
1300 for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
1301 vty_out(vty, "Area %s:\n", area->area_tag);
1302
1303 if (detail == ISIS_UI_LEVEL_BRIEF)
1304 vty_out(vty,
1305 " System Id Interface L State Holdtime SNPA\n");
1306
1307 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) {
1308 if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
1309 for (i = 0; i < 2; i++) {
1310 adjdb = circuit->u.bc.adjdb[i];
1311 if (adjdb && adjdb->count) {
1312 for (ALL_LIST_ELEMENTS_RO(
1313 adjdb, node, adj))
1314 if (!id ||
1315 !memcmp(adj->sysid,
1316 sysid,
1317 ISIS_SYS_ID_LEN))
1318 isis_adj_print_vty(
1319 adj,
1320 vty,
1321 detail);
1322 }
1323 }
1324 } else if (circuit->circ_type == CIRCUIT_T_P2P &&
1325 circuit->u.p2p.neighbor) {
1326 adj = circuit->u.p2p.neighbor;
1327 if (!id ||
1328 !memcmp(adj->sysid, sysid, ISIS_SYS_ID_LEN))
1329 isis_adj_print_vty(adj, vty, detail);
1330 }
1331 }
1332 }
1333 }
1334
1335 static void isis_neighbor_common(struct vty *vty, struct json_object *json,
1336 const char *id, char detail, struct isis *isis,
1337 uint8_t *sysid)
1338 {
1339 if (json) {
1340 isis_neighbor_common_json(json, id, detail,isis,sysid);
1341 } else {
1342 isis_neighbor_common_vty(vty, id, detail,isis,sysid);
1343 }
1344 }
1345
1346 /*
1347 * 'show isis neighbor' command
1348 */
1349
1350 int show_isis_neighbor_common(struct vty *vty, struct json_object *json,
1351 const char *id, char detail, const char *vrf_name,
1352 bool all_vrf)
1353 {
1354 struct listnode *node;
1355 uint8_t sysid[ISIS_SYS_ID_LEN];
1356 struct isis *isis;
1357
1358 if (!im) {
1359 vty_out(vty, "IS-IS Routing Process not enabled\n");
1360 return CMD_SUCCESS;
1361 }
1362
1363 if (vrf_name) {
1364 if (all_vrf) {
1365 for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
1366 if (id_to_sysid(isis, id, sysid)) {
1367 vty_out(vty, "Invalid system id %s\n",
1368 id);
1369 return CMD_SUCCESS;
1370 }
1371 isis_neighbor_common(vty, json, id, detail,
1372 isis, sysid);
1373 }
1374 return CMD_SUCCESS;
1375 }
1376 isis = isis_lookup_by_vrfname(vrf_name);
1377 if (isis != NULL) {
1378 if (id_to_sysid(isis, id, sysid)) {
1379 vty_out(vty, "Invalid system id %s\n", id);
1380 return CMD_SUCCESS;
1381 }
1382 isis_neighbor_common(vty, json, id, detail, isis,
1383 sysid);
1384 }
1385 }
1386
1387 return CMD_SUCCESS;
1388 }
1389
1390 static void isis_neighbor_common_clear(struct vty *vty, const char *id,
1391 uint8_t *sysid, struct isis *isis)
1392 {
1393 struct listnode *anode, *cnode, *node, *nnode;
1394 struct isis_area *area;
1395 struct isis_circuit *circuit;
1396 struct list *adjdb;
1397 struct isis_adjacency *adj;
1398 int i;
1399
1400 for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
1401 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) {
1402 if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
1403 for (i = 0; i < 2; i++) {
1404 adjdb = circuit->u.bc.adjdb[i];
1405 if (adjdb && adjdb->count) {
1406 for (ALL_LIST_ELEMENTS(
1407 adjdb, node, nnode,
1408 adj))
1409 if (!id
1410 || !memcmp(
1411 adj->sysid,
1412 sysid,
1413 ISIS_SYS_ID_LEN))
1414 isis_adj_state_change(
1415 &adj,
1416 ISIS_ADJ_DOWN,
1417 "clear user request");
1418 }
1419 }
1420 } else if (circuit->circ_type == CIRCUIT_T_P2P
1421 && circuit->u.p2p.neighbor) {
1422 adj = circuit->u.p2p.neighbor;
1423 if (!id
1424 || !memcmp(adj->sysid, sysid,
1425 ISIS_SYS_ID_LEN))
1426 isis_adj_state_change(
1427 &adj, ISIS_ADJ_DOWN,
1428 "clear user request");
1429 }
1430 }
1431 }
1432 }
1433 /*
1434 * 'clear isis neighbor' command
1435 */
1436 int clear_isis_neighbor_common(struct vty *vty, const char *id, const char *vrf_name,
1437 bool all_vrf)
1438 {
1439 struct listnode *node;
1440 uint8_t sysid[ISIS_SYS_ID_LEN];
1441 struct isis *isis;
1442
1443 if (!im) {
1444 vty_out(vty, "IS-IS Routing Process not enabled\n");
1445 return CMD_SUCCESS;
1446 }
1447
1448 if (vrf_name) {
1449 if (all_vrf) {
1450 for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
1451 if (id_to_sysid(isis, id, sysid)) {
1452 vty_out(vty, "Invalid system id %s\n",
1453 id);
1454 return CMD_SUCCESS;
1455 }
1456 isis_neighbor_common_clear(vty, id, sysid,
1457 isis);
1458 }
1459 return CMD_SUCCESS;
1460 }
1461 isis = isis_lookup_by_vrfname(vrf_name);
1462 if (isis != NULL) {
1463 if (id_to_sysid(isis, id, sysid)) {
1464 vty_out(vty, "Invalid system id %s\n", id);
1465 return CMD_SUCCESS;
1466 }
1467 isis_neighbor_common_clear(vty, id, sysid, isis);
1468 }
1469 }
1470
1471 return CMD_SUCCESS;
1472 }
1473
1474 DEFUN(show_isis_neighbor,
1475 show_isis_neighbor_cmd,
1476 "show " PROTO_NAME " [vrf <NAME|all>] neighbor [json]",
1477 SHOW_STR
1478 PROTO_HELP
1479 VRF_CMD_HELP_STR
1480 "All vrfs\n"
1481 "IS-IS neighbor adjacencies\n"
1482 "json output\n")
1483 {
1484 int res = CMD_SUCCESS;
1485 const char *vrf_name = VRF_DEFAULT_NAME;
1486 bool all_vrf = false;
1487 int idx_vrf = 0;
1488 bool uj = use_json(argc, argv);
1489 json_object *json = NULL;
1490
1491 ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1492 if (uj)
1493 json = json_object_new_object();
1494 res = show_isis_neighbor_common(vty, json, NULL, ISIS_UI_LEVEL_BRIEF,
1495 vrf_name, all_vrf);
1496 if (uj)
1497 vty_json(vty, json);
1498 return res;
1499 }
1500
1501 DEFUN(show_isis_neighbor_detail,
1502 show_isis_neighbor_detail_cmd,
1503 "show " PROTO_NAME " [vrf <NAME|all>] neighbor detail [json]",
1504 SHOW_STR
1505 PROTO_HELP
1506 VRF_CMD_HELP_STR
1507 "all vrfs\n"
1508 "IS-IS neighbor adjacencies\n"
1509 "show detailed information\n"
1510 "json output\n")
1511 {
1512 int res = CMD_SUCCESS;
1513 const char *vrf_name = VRF_DEFAULT_NAME;
1514 bool all_vrf = false;
1515 int idx_vrf = 0;
1516 bool uj = use_json(argc, argv);
1517 json_object *json = NULL;
1518
1519 ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1520 if (uj)
1521 json = json_object_new_object();
1522
1523 res = show_isis_neighbor_common(vty, json, NULL, ISIS_UI_LEVEL_DETAIL,
1524 vrf_name, all_vrf);
1525 if (uj)
1526 vty_json(vty, json);
1527 return res;
1528 }
1529
1530 DEFUN(show_isis_neighbor_arg,
1531 show_isis_neighbor_arg_cmd,
1532 "show " PROTO_NAME " [vrf <NAME|all>] neighbor WORD [json]",
1533 SHOW_STR
1534 PROTO_HELP
1535 VRF_CMD_HELP_STR
1536 "All vrfs\n"
1537 "IS-IS neighbor adjacencies\n"
1538 "System id\n"
1539 "json output\n")
1540 {
1541 int res = CMD_SUCCESS;
1542 int idx_word = 0;
1543 const char *vrf_name = VRF_DEFAULT_NAME;
1544 bool all_vrf = false;
1545 int idx_vrf = 0;
1546 bool uj = use_json(argc, argv);
1547 json_object *json = NULL;
1548
1549 ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1550 if (uj)
1551 json = json_object_new_object();
1552 char *id = argv_find(argv, argc, "WORD", &idx_word)
1553 ? argv[idx_word]->arg
1554 : NULL;
1555
1556 res = show_isis_neighbor_common(vty, json, id, ISIS_UI_LEVEL_DETAIL,
1557 vrf_name, all_vrf);
1558 if (uj)
1559 vty_json(vty, json);
1560 return res;
1561 }
1562
1563 DEFUN(clear_isis_neighbor,
1564 clear_isis_neighbor_cmd,
1565 "clear " PROTO_NAME " [vrf <NAME|all>] neighbor",
1566 CLEAR_STR
1567 PROTO_HELP
1568 VRF_CMD_HELP_STR
1569 "All vrfs\n"
1570 "IS-IS neighbor adjacencies\n")
1571 {
1572 const char *vrf_name = VRF_DEFAULT_NAME;
1573 bool all_vrf = false;
1574 int idx_vrf = 0;
1575
1576 ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1577 return clear_isis_neighbor_common(vty, NULL, vrf_name, all_vrf);
1578 }
1579
1580 DEFUN(clear_isis_neighbor_arg,
1581 clear_isis_neighbor_arg_cmd,
1582 "clear " PROTO_NAME " [vrf <NAME|all>] neighbor WORD",
1583 CLEAR_STR
1584 PROTO_HELP
1585 VRF_CMD_HELP_STR
1586 "All vrfs\n"
1587 "IS-IS neighbor adjacencies\n"
1588 "System id\n")
1589 {
1590 int idx_word = 0;
1591 const char *vrf_name = VRF_DEFAULT_NAME;
1592 bool all_vrf = false;
1593 int idx_vrf = 0;
1594
1595 char *id = argv_find(argv, argc, "WORD", &idx_word)
1596 ? argv[idx_word]->arg
1597 : NULL;
1598 ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1599 return clear_isis_neighbor_common(vty, id, vrf_name, all_vrf);
1600 }
1601
1602 /*
1603 * 'isis debug', 'show debugging'
1604 */
1605 void print_debug(struct vty *vty, int flags, int onoff)
1606 {
1607 const char *onoffs = onoff ? "on" : "off";
1608
1609 if (flags & DEBUG_ADJ_PACKETS)
1610 vty_out(vty,
1611 "IS-IS Adjacency related packets debugging is %s\n",
1612 onoffs);
1613 if (flags & DEBUG_TX_QUEUE)
1614 vty_out(vty, "IS-IS TX queue debugging is %s\n",
1615 onoffs);
1616 if (flags & DEBUG_SNP_PACKETS)
1617 vty_out(vty, "IS-IS CSNP/PSNP packets debugging is %s\n",
1618 onoffs);
1619 if (flags & DEBUG_SPF_EVENTS)
1620 vty_out(vty, "IS-IS SPF events debugging is %s\n", onoffs);
1621 if (flags & DEBUG_SR)
1622 vty_out(vty, "IS-IS Segment Routing events debugging is %s\n",
1623 onoffs);
1624 if (flags & DEBUG_TE)
1625 vty_out(vty,
1626 "IS-IS Traffic Engineering events debugging is %s\n",
1627 onoffs);
1628 if (flags & DEBUG_LFA)
1629 vty_out(vty, "IS-IS LFA events debugging is %s\n", onoffs);
1630 if (flags & DEBUG_UPDATE_PACKETS)
1631 vty_out(vty, "IS-IS Update related packet debugging is %s\n",
1632 onoffs);
1633 if (flags & DEBUG_RTE_EVENTS)
1634 vty_out(vty, "IS-IS Route related debugging is %s\n", onoffs);
1635 if (flags & DEBUG_EVENTS)
1636 vty_out(vty, "IS-IS Event debugging is %s\n", onoffs);
1637 if (flags & DEBUG_PACKET_DUMP)
1638 vty_out(vty, "IS-IS Packet dump debugging is %s\n", onoffs);
1639 if (flags & DEBUG_LSP_GEN)
1640 vty_out(vty, "IS-IS LSP generation debugging is %s\n", onoffs);
1641 if (flags & DEBUG_LSP_SCHED)
1642 vty_out(vty, "IS-IS LSP scheduling debugging is %s\n", onoffs);
1643 if (flags & DEBUG_FLOODING)
1644 vty_out(vty, "IS-IS Flooding debugging is %s\n", onoffs);
1645 if (flags & DEBUG_BFD)
1646 vty_out(vty, "IS-IS BFD debugging is %s\n", onoffs);
1647 if (flags & DEBUG_LDP_SYNC)
1648 vty_out(vty, "IS-IS ldp-sync debugging is %s\n", onoffs);
1649 }
1650
1651 DEFUN_NOSH (show_debugging,
1652 show_debugging_isis_cmd,
1653 "show debugging [" PROTO_NAME "]",
1654 SHOW_STR
1655 "State of each debugging option\n"
1656 PROTO_HELP)
1657 {
1658 vty_out(vty, PROTO_NAME " debugging status:\n");
1659
1660 if (IS_DEBUG_ADJ_PACKETS)
1661 print_debug(vty, DEBUG_ADJ_PACKETS, 1);
1662 if (IS_DEBUG_TX_QUEUE)
1663 print_debug(vty, DEBUG_TX_QUEUE, 1);
1664 if (IS_DEBUG_SNP_PACKETS)
1665 print_debug(vty, DEBUG_SNP_PACKETS, 1);
1666 if (IS_DEBUG_SPF_EVENTS)
1667 print_debug(vty, DEBUG_SPF_EVENTS, 1);
1668 if (IS_DEBUG_SR)
1669 print_debug(vty, DEBUG_SR, 1);
1670 if (IS_DEBUG_TE)
1671 print_debug(vty, DEBUG_TE, 1);
1672 if (IS_DEBUG_UPDATE_PACKETS)
1673 print_debug(vty, DEBUG_UPDATE_PACKETS, 1);
1674 if (IS_DEBUG_RTE_EVENTS)
1675 print_debug(vty, DEBUG_RTE_EVENTS, 1);
1676 if (IS_DEBUG_EVENTS)
1677 print_debug(vty, DEBUG_EVENTS, 1);
1678 if (IS_DEBUG_PACKET_DUMP)
1679 print_debug(vty, DEBUG_PACKET_DUMP, 1);
1680 if (IS_DEBUG_LSP_GEN)
1681 print_debug(vty, DEBUG_LSP_GEN, 1);
1682 if (IS_DEBUG_LSP_SCHED)
1683 print_debug(vty, DEBUG_LSP_SCHED, 1);
1684 if (IS_DEBUG_FLOODING)
1685 print_debug(vty, DEBUG_FLOODING, 1);
1686 if (IS_DEBUG_BFD)
1687 print_debug(vty, DEBUG_BFD, 1);
1688 if (IS_DEBUG_LDP_SYNC)
1689 print_debug(vty, DEBUG_LDP_SYNC, 1);
1690 if (IS_DEBUG_LFA)
1691 print_debug(vty, DEBUG_LFA, 1);
1692
1693 cmd_show_lib_debugs(vty);
1694
1695 return CMD_SUCCESS;
1696 }
1697
1698 static int config_write_debug(struct vty *vty);
1699 /* Debug node. */
1700 static struct cmd_node debug_node = {
1701 .name = "debug",
1702 .node = DEBUG_NODE,
1703 .prompt = "",
1704 .config_write = config_write_debug,
1705 };
1706
1707 static int config_write_debug(struct vty *vty)
1708 {
1709 int write = 0;
1710
1711 if (IS_DEBUG_ADJ_PACKETS) {
1712 vty_out(vty, "debug " PROTO_NAME " adj-packets\n");
1713 write++;
1714 }
1715 if (IS_DEBUG_TX_QUEUE) {
1716 vty_out(vty, "debug " PROTO_NAME " tx-queue\n");
1717 write++;
1718 }
1719 if (IS_DEBUG_SNP_PACKETS) {
1720 vty_out(vty, "debug " PROTO_NAME " snp-packets\n");
1721 write++;
1722 }
1723 if (IS_DEBUG_SPF_EVENTS) {
1724 vty_out(vty, "debug " PROTO_NAME " spf-events\n");
1725 write++;
1726 }
1727 if (IS_DEBUG_SR) {
1728 vty_out(vty, "debug " PROTO_NAME " sr-events\n");
1729 write++;
1730 }
1731 if (IS_DEBUG_TE) {
1732 vty_out(vty, "debug " PROTO_NAME " te-events\n");
1733 write++;
1734 }
1735 if (IS_DEBUG_LFA) {
1736 vty_out(vty, "debug " PROTO_NAME " lfa\n");
1737 write++;
1738 }
1739 if (IS_DEBUG_UPDATE_PACKETS) {
1740 vty_out(vty, "debug " PROTO_NAME " update-packets\n");
1741 write++;
1742 }
1743 if (IS_DEBUG_RTE_EVENTS) {
1744 vty_out(vty, "debug " PROTO_NAME " route-events\n");
1745 write++;
1746 }
1747 if (IS_DEBUG_EVENTS) {
1748 vty_out(vty, "debug " PROTO_NAME " events\n");
1749 write++;
1750 }
1751 if (IS_DEBUG_PACKET_DUMP) {
1752 vty_out(vty, "debug " PROTO_NAME " packet-dump\n");
1753 write++;
1754 }
1755 if (IS_DEBUG_LSP_GEN) {
1756 vty_out(vty, "debug " PROTO_NAME " lsp-gen\n");
1757 write++;
1758 }
1759 if (IS_DEBUG_LSP_SCHED) {
1760 vty_out(vty, "debug " PROTO_NAME " lsp-sched\n");
1761 write++;
1762 }
1763 if (IS_DEBUG_FLOODING) {
1764 vty_out(vty, "debug " PROTO_NAME " flooding\n");
1765 write++;
1766 }
1767 if (IS_DEBUG_BFD) {
1768 vty_out(vty, "debug " PROTO_NAME " bfd\n");
1769 write++;
1770 }
1771 if (IS_DEBUG_LDP_SYNC) {
1772 vty_out(vty, "debug " PROTO_NAME " ldp-sync\n");
1773 write++;
1774 }
1775 write += spf_backoff_write_config(vty);
1776
1777 return write;
1778 }
1779
1780 DEFUN (debug_isis_adj,
1781 debug_isis_adj_cmd,
1782 "debug " PROTO_NAME " adj-packets",
1783 DEBUG_STR
1784 PROTO_HELP
1785 "IS-IS Adjacency related packets\n")
1786 {
1787 debug_adj_pkt |= DEBUG_ADJ_PACKETS;
1788 print_debug(vty, DEBUG_ADJ_PACKETS, 1);
1789
1790 return CMD_SUCCESS;
1791 }
1792
1793 DEFUN (no_debug_isis_adj,
1794 no_debug_isis_adj_cmd,
1795 "no debug " PROTO_NAME " adj-packets",
1796 NO_STR
1797 UNDEBUG_STR
1798 PROTO_HELP
1799 "IS-IS Adjacency related packets\n")
1800 {
1801 debug_adj_pkt &= ~DEBUG_ADJ_PACKETS;
1802 print_debug(vty, DEBUG_ADJ_PACKETS, 0);
1803
1804 return CMD_SUCCESS;
1805 }
1806
1807 DEFUN (debug_isis_tx_queue,
1808 debug_isis_tx_queue_cmd,
1809 "debug " PROTO_NAME " tx-queue",
1810 DEBUG_STR
1811 PROTO_HELP
1812 "IS-IS TX queues\n")
1813 {
1814 debug_tx_queue |= DEBUG_TX_QUEUE;
1815 print_debug(vty, DEBUG_TX_QUEUE, 1);
1816
1817 return CMD_SUCCESS;
1818 }
1819
1820 DEFUN (no_debug_isis_tx_queue,
1821 no_debug_isis_tx_queue_cmd,
1822 "no debug " PROTO_NAME " tx-queue",
1823 NO_STR
1824 UNDEBUG_STR
1825 PROTO_HELP
1826 "IS-IS TX queues\n")
1827 {
1828 debug_tx_queue &= ~DEBUG_TX_QUEUE;
1829 print_debug(vty, DEBUG_TX_QUEUE, 0);
1830
1831 return CMD_SUCCESS;
1832 }
1833
1834 DEFUN (debug_isis_flooding,
1835 debug_isis_flooding_cmd,
1836 "debug " PROTO_NAME " flooding",
1837 DEBUG_STR
1838 PROTO_HELP
1839 "Flooding algorithm\n")
1840 {
1841 debug_flooding |= DEBUG_FLOODING;
1842 print_debug(vty, DEBUG_FLOODING, 1);
1843
1844 return CMD_SUCCESS;
1845 }
1846
1847 DEFUN (no_debug_isis_flooding,
1848 no_debug_isis_flooding_cmd,
1849 "no debug " PROTO_NAME " flooding",
1850 NO_STR
1851 UNDEBUG_STR
1852 PROTO_HELP
1853 "Flooding algorithm\n")
1854 {
1855 debug_flooding &= ~DEBUG_FLOODING;
1856 print_debug(vty, DEBUG_FLOODING, 0);
1857
1858 return CMD_SUCCESS;
1859 }
1860
1861 DEFUN (debug_isis_snp,
1862 debug_isis_snp_cmd,
1863 "debug " PROTO_NAME " snp-packets",
1864 DEBUG_STR
1865 PROTO_HELP
1866 "IS-IS CSNP/PSNP packets\n")
1867 {
1868 debug_snp_pkt |= DEBUG_SNP_PACKETS;
1869 print_debug(vty, DEBUG_SNP_PACKETS, 1);
1870
1871 return CMD_SUCCESS;
1872 }
1873
1874 DEFUN (no_debug_isis_snp,
1875 no_debug_isis_snp_cmd,
1876 "no debug " PROTO_NAME " snp-packets",
1877 NO_STR
1878 UNDEBUG_STR
1879 PROTO_HELP
1880 "IS-IS CSNP/PSNP packets\n")
1881 {
1882 debug_snp_pkt &= ~DEBUG_SNP_PACKETS;
1883 print_debug(vty, DEBUG_SNP_PACKETS, 0);
1884
1885 return CMD_SUCCESS;
1886 }
1887
1888 DEFUN (debug_isis_upd,
1889 debug_isis_upd_cmd,
1890 "debug " PROTO_NAME " update-packets",
1891 DEBUG_STR
1892 PROTO_HELP
1893 "IS-IS Update related packets\n")
1894 {
1895 debug_update_pkt |= DEBUG_UPDATE_PACKETS;
1896 print_debug(vty, DEBUG_UPDATE_PACKETS, 1);
1897
1898 return CMD_SUCCESS;
1899 }
1900
1901 DEFUN (no_debug_isis_upd,
1902 no_debug_isis_upd_cmd,
1903 "no debug " PROTO_NAME " update-packets",
1904 NO_STR
1905 UNDEBUG_STR
1906 PROTO_HELP
1907 "IS-IS Update related packets\n")
1908 {
1909 debug_update_pkt &= ~DEBUG_UPDATE_PACKETS;
1910 print_debug(vty, DEBUG_UPDATE_PACKETS, 0);
1911
1912 return CMD_SUCCESS;
1913 }
1914
1915 DEFUN (debug_isis_spfevents,
1916 debug_isis_spfevents_cmd,
1917 "debug " PROTO_NAME " spf-events",
1918 DEBUG_STR
1919 PROTO_HELP
1920 "IS-IS Shortest Path First Events\n")
1921 {
1922 debug_spf_events |= DEBUG_SPF_EVENTS;
1923 print_debug(vty, DEBUG_SPF_EVENTS, 1);
1924
1925 return CMD_SUCCESS;
1926 }
1927
1928 DEFUN (no_debug_isis_spfevents,
1929 no_debug_isis_spfevents_cmd,
1930 "no debug " PROTO_NAME " spf-events",
1931 NO_STR
1932 UNDEBUG_STR
1933 PROTO_HELP
1934 "IS-IS Shortest Path First Events\n")
1935 {
1936 debug_spf_events &= ~DEBUG_SPF_EVENTS;
1937 print_debug(vty, DEBUG_SPF_EVENTS, 0);
1938
1939 return CMD_SUCCESS;
1940 }
1941
1942 DEFUN (debug_isis_srevents,
1943 debug_isis_srevents_cmd,
1944 "debug " PROTO_NAME " sr-events",
1945 DEBUG_STR
1946 PROTO_HELP
1947 "IS-IS Segment Routing Events\n")
1948 {
1949 debug_sr |= DEBUG_SR;
1950 print_debug(vty, DEBUG_SR, 1);
1951
1952 return CMD_SUCCESS;
1953 }
1954
1955 DEFUN (no_debug_isis_srevents,
1956 no_debug_isis_srevents_cmd,
1957 "no debug " PROTO_NAME " sr-events",
1958 NO_STR
1959 UNDEBUG_STR
1960 PROTO_HELP
1961 "IS-IS Segment Routing Events\n")
1962 {
1963 debug_sr &= ~DEBUG_SR;
1964 print_debug(vty, DEBUG_SR, 0);
1965
1966 return CMD_SUCCESS;
1967 }
1968
1969 DEFUN (debug_isis_teevents,
1970 debug_isis_teevents_cmd,
1971 "debug " PROTO_NAME " te-events",
1972 DEBUG_STR
1973 PROTO_HELP
1974 "IS-IS Traffic Engineering Events\n")
1975 {
1976 debug_te |= DEBUG_TE;
1977 print_debug(vty, DEBUG_TE, 1);
1978
1979 return CMD_SUCCESS;
1980 }
1981
1982 DEFUN (no_debug_isis_teevents,
1983 no_debug_isis_teevents_cmd,
1984 "no debug " PROTO_NAME " te-events",
1985 NO_STR
1986 UNDEBUG_STR
1987 PROTO_HELP
1988 "IS-IS Traffic Engineering Events\n")
1989 {
1990 debug_te &= ~DEBUG_TE;
1991 print_debug(vty, DEBUG_TE, 0);
1992
1993 return CMD_SUCCESS;
1994 }
1995
1996 DEFUN (debug_isis_lfa,
1997 debug_isis_lfa_cmd,
1998 "debug " PROTO_NAME " lfa",
1999 DEBUG_STR
2000 PROTO_HELP
2001 "IS-IS LFA Events\n")
2002 {
2003 debug_lfa |= DEBUG_LFA;
2004 print_debug(vty, DEBUG_LFA, 1);
2005
2006 return CMD_SUCCESS;
2007 }
2008
2009 DEFUN (no_debug_isis_lfa,
2010 no_debug_isis_lfa_cmd,
2011 "no debug " PROTO_NAME " lfa",
2012 NO_STR
2013 UNDEBUG_STR
2014 PROTO_HELP
2015 "IS-IS LFA Events\n")
2016 {
2017 debug_lfa &= ~DEBUG_LFA;
2018 print_debug(vty, DEBUG_LFA, 0);
2019
2020 return CMD_SUCCESS;
2021 }
2022
2023 DEFUN (debug_isis_rtevents,
2024 debug_isis_rtevents_cmd,
2025 "debug " PROTO_NAME " route-events",
2026 DEBUG_STR
2027 PROTO_HELP
2028 "IS-IS Route related events\n")
2029 {
2030 debug_rte_events |= DEBUG_RTE_EVENTS;
2031 print_debug(vty, DEBUG_RTE_EVENTS, 1);
2032
2033 return CMD_SUCCESS;
2034 }
2035
2036 DEFUN (no_debug_isis_rtevents,
2037 no_debug_isis_rtevents_cmd,
2038 "no debug " PROTO_NAME " route-events",
2039 NO_STR
2040 UNDEBUG_STR
2041 PROTO_HELP
2042 "IS-IS Route related events\n")
2043 {
2044 debug_rte_events &= ~DEBUG_RTE_EVENTS;
2045 print_debug(vty, DEBUG_RTE_EVENTS, 0);
2046
2047 return CMD_SUCCESS;
2048 }
2049
2050 DEFUN (debug_isis_events,
2051 debug_isis_events_cmd,
2052 "debug " PROTO_NAME " events",
2053 DEBUG_STR
2054 PROTO_HELP
2055 "IS-IS Events\n")
2056 {
2057 debug_events |= DEBUG_EVENTS;
2058 print_debug(vty, DEBUG_EVENTS, 1);
2059
2060 return CMD_SUCCESS;
2061 }
2062
2063 DEFUN (no_debug_isis_events,
2064 no_debug_isis_events_cmd,
2065 "no debug " PROTO_NAME " events",
2066 NO_STR
2067 UNDEBUG_STR
2068 PROTO_HELP
2069 "IS-IS Events\n")
2070 {
2071 debug_events &= ~DEBUG_EVENTS;
2072 print_debug(vty, DEBUG_EVENTS, 0);
2073
2074 return CMD_SUCCESS;
2075 }
2076
2077 DEFUN (debug_isis_packet_dump,
2078 debug_isis_packet_dump_cmd,
2079 "debug " PROTO_NAME " packet-dump",
2080 DEBUG_STR
2081 PROTO_HELP
2082 "IS-IS packet dump\n")
2083 {
2084 debug_pkt_dump |= DEBUG_PACKET_DUMP;
2085 print_debug(vty, DEBUG_PACKET_DUMP, 1);
2086
2087 return CMD_SUCCESS;
2088 }
2089
2090 DEFUN (no_debug_isis_packet_dump,
2091 no_debug_isis_packet_dump_cmd,
2092 "no debug " PROTO_NAME " packet-dump",
2093 NO_STR
2094 UNDEBUG_STR
2095 PROTO_HELP
2096 "IS-IS packet dump\n")
2097 {
2098 debug_pkt_dump &= ~DEBUG_PACKET_DUMP;
2099 print_debug(vty, DEBUG_PACKET_DUMP, 0);
2100
2101 return CMD_SUCCESS;
2102 }
2103
2104 DEFUN (debug_isis_lsp_gen,
2105 debug_isis_lsp_gen_cmd,
2106 "debug " PROTO_NAME " lsp-gen",
2107 DEBUG_STR
2108 PROTO_HELP
2109 "IS-IS generation of own LSPs\n")
2110 {
2111 debug_lsp_gen |= DEBUG_LSP_GEN;
2112 print_debug(vty, DEBUG_LSP_GEN, 1);
2113
2114 return CMD_SUCCESS;
2115 }
2116
2117 DEFUN (no_debug_isis_lsp_gen,
2118 no_debug_isis_lsp_gen_cmd,
2119 "no debug " PROTO_NAME " lsp-gen",
2120 NO_STR
2121 UNDEBUG_STR
2122 PROTO_HELP
2123 "IS-IS generation of own LSPs\n")
2124 {
2125 debug_lsp_gen &= ~DEBUG_LSP_GEN;
2126 print_debug(vty, DEBUG_LSP_GEN, 0);
2127
2128 return CMD_SUCCESS;
2129 }
2130
2131 DEFUN (debug_isis_lsp_sched,
2132 debug_isis_lsp_sched_cmd,
2133 "debug " PROTO_NAME " lsp-sched",
2134 DEBUG_STR
2135 PROTO_HELP
2136 "IS-IS scheduling of LSP generation\n")
2137 {
2138 debug_lsp_sched |= DEBUG_LSP_SCHED;
2139 print_debug(vty, DEBUG_LSP_SCHED, 1);
2140
2141 return CMD_SUCCESS;
2142 }
2143
2144 DEFUN (no_debug_isis_lsp_sched,
2145 no_debug_isis_lsp_sched_cmd,
2146 "no debug " PROTO_NAME " lsp-sched",
2147 NO_STR
2148 UNDEBUG_STR
2149 PROTO_HELP
2150 "IS-IS scheduling of LSP generation\n")
2151 {
2152 debug_lsp_sched &= ~DEBUG_LSP_SCHED;
2153 print_debug(vty, DEBUG_LSP_SCHED, 0);
2154
2155 return CMD_SUCCESS;
2156 }
2157
2158 DEFUN (debug_isis_bfd,
2159 debug_isis_bfd_cmd,
2160 "debug " PROTO_NAME " bfd",
2161 DEBUG_STR
2162 PROTO_HELP
2163 PROTO_NAME " interaction with BFD\n")
2164 {
2165 debug_bfd |= DEBUG_BFD;
2166 bfd_protocol_integration_set_debug(true);
2167 print_debug(vty, DEBUG_BFD, 1);
2168
2169 return CMD_SUCCESS;
2170 }
2171
2172 DEFUN (no_debug_isis_bfd,
2173 no_debug_isis_bfd_cmd,
2174 "no debug " PROTO_NAME " bfd",
2175 NO_STR
2176 UNDEBUG_STR
2177 PROTO_HELP
2178 PROTO_NAME " interaction with BFD\n")
2179 {
2180 debug_bfd &= ~DEBUG_BFD;
2181 bfd_protocol_integration_set_debug(false);
2182 print_debug(vty, DEBUG_BFD, 0);
2183
2184 return CMD_SUCCESS;
2185 }
2186
2187 DEFUN(debug_isis_ldp_sync, debug_isis_ldp_sync_cmd,
2188 "debug " PROTO_NAME " ldp-sync",
2189 DEBUG_STR PROTO_HELP PROTO_NAME " interaction with LDP-Sync\n")
2190 {
2191 debug_ldp_sync |= DEBUG_LDP_SYNC;
2192 print_debug(vty, DEBUG_LDP_SYNC, 1);
2193
2194 return CMD_SUCCESS;
2195 }
2196
2197 DEFUN(no_debug_isis_ldp_sync, no_debug_isis_ldp_sync_cmd,
2198 "no debug " PROTO_NAME " ldp-sync",
2199 NO_STR UNDEBUG_STR PROTO_HELP PROTO_NAME " interaction with LDP-Sync\n")
2200 {
2201 debug_ldp_sync &= ~DEBUG_LDP_SYNC;
2202 print_debug(vty, DEBUG_LDP_SYNC, 0);
2203
2204 return CMD_SUCCESS;
2205 }
2206
2207 DEFUN (show_hostname,
2208 show_hostname_cmd,
2209 "show " PROTO_NAME " [vrf <NAME|all>] hostname",
2210 SHOW_STR PROTO_HELP VRF_CMD_HELP_STR
2211 "All VRFs\n"
2212 "IS-IS Dynamic hostname mapping\n")
2213 {
2214 struct listnode *node;
2215 const char *vrf_name = VRF_DEFAULT_NAME;
2216 bool all_vrf = false;
2217 int idx_vrf = 0;
2218 struct isis *isis;
2219
2220 ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
2221 if (vrf_name) {
2222 if (all_vrf) {
2223 for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
2224 dynhn_print_all(vty, isis);
2225
2226 return CMD_SUCCESS;
2227 }
2228 isis = isis_lookup_by_vrfname(vrf_name);
2229 if (isis != NULL)
2230 dynhn_print_all(vty, isis);
2231 }
2232
2233 return CMD_SUCCESS;
2234 }
2235
2236 static void isis_spf_ietf_common(struct vty *vty, struct isis *isis)
2237 {
2238 struct listnode *node;
2239 struct isis_area *area;
2240 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
2241
2242 vty_out(vty, "vrf : %s\n", isis->name);
2243 vty_out(vty, "Area %s:\n",
2244 area->area_tag ? area->area_tag : "null");
2245
2246 for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) {
2247 if ((area->is_type & level) == 0)
2248 continue;
2249
2250 vty_out(vty, " Level-%d:\n", level);
2251 vty_out(vty, " SPF delay status: ");
2252 if (area->spf_timer[level - 1]) {
2253 struct timeval remain = event_timer_remain(
2254 area->spf_timer[level - 1]);
2255 vty_out(vty, "Pending, due in %lld msec\n",
2256 (long long)remain.tv_sec * 1000
2257 + remain.tv_usec / 1000);
2258 } else {
2259 vty_out(vty, "Not scheduled\n");
2260 }
2261
2262 if (area->spf_delay_ietf[level - 1]) {
2263 vty_out(vty,
2264 " Using draft-ietf-rtgwg-backoff-algo-04\n");
2265 spf_backoff_show(
2266 area->spf_delay_ietf[level - 1], vty,
2267 " ");
2268 } else {
2269 vty_out(vty, " Using legacy backoff algo\n");
2270 }
2271 }
2272 }
2273 }
2274
2275 DEFUN(show_isis_spf_ietf, show_isis_spf_ietf_cmd,
2276 "show " PROTO_NAME " [vrf <NAME|all>] spf-delay-ietf",
2277 SHOW_STR PROTO_HELP VRF_CMD_HELP_STR
2278 "All VRFs\n"
2279 "SPF delay IETF information\n")
2280 {
2281 struct listnode *node;
2282 struct isis *isis;
2283 int idx_vrf = 0;
2284 const char *vrf_name = VRF_DEFAULT_NAME;
2285 bool all_vrf = false;
2286
2287 ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf)
2288
2289 if (!im) {
2290 vty_out(vty, "ISIS is not running\n");
2291 return CMD_SUCCESS;
2292 }
2293
2294 if (vrf_name) {
2295 if (all_vrf) {
2296 for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
2297 isis_spf_ietf_common(vty, isis);
2298
2299 return CMD_SUCCESS;
2300 }
2301 isis = isis_lookup_by_vrfname(vrf_name);
2302 if (isis != NULL)
2303 isis_spf_ietf_common(vty, isis);
2304 }
2305
2306 return CMD_SUCCESS;
2307 }
2308
2309
2310 static const char *pdu_counter_index_to_name_json(enum pdu_counter_index index)
2311 {
2312 switch (index) {
2313 case L1_LAN_HELLO_INDEX:
2314 return "l1-iih";
2315 case L2_LAN_HELLO_INDEX:
2316 return "l2-iih";
2317 case P2P_HELLO_INDEX:
2318 return "p2p-iih";
2319 case L1_LINK_STATE_INDEX:
2320 return "l1-lsp";
2321 case L2_LINK_STATE_INDEX:
2322 return "l2-lsp";
2323 case FS_LINK_STATE_INDEX:
2324 return "fs-lsp";
2325 case L1_COMPLETE_SEQ_NUM_INDEX:
2326 return "l1-csnp";
2327 case L2_COMPLETE_SEQ_NUM_INDEX:
2328 return "l2-csnp";
2329 case L1_PARTIAL_SEQ_NUM_INDEX:
2330 return "l1-psnp";
2331 case L2_PARTIAL_SEQ_NUM_INDEX:
2332 return "l2-psnp";
2333 case PDU_COUNTER_SIZE:
2334 return "???????";
2335 }
2336
2337 assert(!"Reached end of function where we are not expecting to");
2338 }
2339
2340 static void common_isis_summary_json(struct json_object *json,
2341 struct isis *isis)
2342 {
2343 int level;
2344 json_object *areas_json, *area_json, *tx_pdu_json, *rx_pdu_json,
2345 *levels_json, *level_json;
2346 struct listnode *node, *node2;
2347 struct isis_area *area;
2348 time_t cur;
2349 char uptime[MONOTIME_STRLEN];
2350 char stier[5];
2351
2352 json_object_string_add(json, "vrf", isis->name);
2353 json_object_int_add(json, "process-id", isis->process_id);
2354 if (isis->sysid_set)
2355 json_object_string_addf(json, "system-id", "%pSY", isis->sysid);
2356
2357 cur = time(NULL);
2358 cur -= isis->uptime;
2359 frrtime_to_interval(cur, uptime, sizeof(uptime));
2360 json_object_string_add(json, "up-time", uptime);
2361 if (isis->area_list)
2362 json_object_int_add(json, "number-areas",
2363 isis->area_list->count);
2364 areas_json = json_object_new_array();
2365 json_object_object_add(json, "areas", areas_json);
2366 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
2367 area_json = json_object_new_object();
2368 json_object_string_add(area_json, "area",
2369 area->area_tag ? area->area_tag
2370 : "null");
2371
2372
2373 if (fabricd) {
2374 uint8_t tier = fabricd_tier(area);
2375 snprintfrr(stier, sizeof(stier), "%s", &tier);
2376 json_object_string_add(area_json, "tier",
2377 tier == ISIS_TIER_UNDEFINED
2378 ? "undefined"
2379 : stier);
2380 }
2381
2382 if (listcount(area->area_addrs) > 0) {
2383 struct iso_address *area_addr;
2384 for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node2,
2385 area_addr))
2386 json_object_string_addf(area_json, "net",
2387 "%pISl", area_addr);
2388 }
2389
2390 tx_pdu_json = json_object_new_object();
2391 json_object_object_add(area_json, "tx-pdu-type", tx_pdu_json);
2392 for (int i = 0; i < PDU_COUNTER_SIZE; i++) {
2393 if (!area->pdu_tx_counters[i])
2394 continue;
2395 json_object_int_add(tx_pdu_json,
2396 pdu_counter_index_to_name_json(i),
2397 area->pdu_tx_counters[i]);
2398 }
2399 json_object_int_add(tx_pdu_json, "lsp-rxmt",
2400 area->lsp_rxmt_count);
2401
2402 rx_pdu_json = json_object_new_object();
2403 json_object_object_add(area_json, "rx-pdu-type", rx_pdu_json);
2404 for (int i = 0; i < PDU_COUNTER_SIZE; i++) {
2405 if (!area->pdu_rx_counters[i])
2406 continue;
2407 json_object_int_add(rx_pdu_json,
2408 pdu_counter_index_to_name_json(i),
2409 area->pdu_rx_counters[i]);
2410 }
2411
2412 levels_json = json_object_new_array();
2413 json_object_object_add(area_json, "levels", levels_json);
2414 for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) {
2415 if ((area->is_type & level) == 0)
2416 continue;
2417 level_json = json_object_new_object();
2418 json_object_int_add(level_json, "id", level);
2419 json_object_int_add(level_json, "lsp0-regenerated",
2420 area->lsp_gen_count[level - 1]);
2421 json_object_int_add(level_json, "lsp-purged",
2422 area->lsp_purge_count[level - 1]);
2423 if (area->spf_timer[level - 1])
2424 json_object_string_add(level_json, "spf",
2425 "pending");
2426 else
2427 json_object_string_add(level_json, "spf",
2428 "no pending");
2429 json_object_int_add(level_json, "minimum-interval",
2430 area->min_spf_interval[level - 1]);
2431 if (area->spf_delay_ietf[level - 1])
2432 json_object_string_add(
2433 level_json, "ietf-spf-delay-activated",
2434 "not used");
2435 if (area->ip_circuits) {
2436 isis_spf_print_json(
2437 area->spftree[SPFTREE_IPV4][level - 1],
2438 level_json);
2439 }
2440 if (area->ipv6_circuits) {
2441 isis_spf_print_json(
2442 area->spftree[SPFTREE_IPV6][level - 1],
2443 level_json);
2444 }
2445 json_object_array_add(levels_json, level_json);
2446 }
2447 json_object_array_add(areas_json, area_json);
2448 }
2449 }
2450
2451 static void common_isis_summary_vty(struct vty *vty, struct isis *isis)
2452 {
2453 struct listnode *node, *node2;
2454 struct isis_area *area;
2455 int level;
2456
2457 vty_out(vty, "vrf : %s\n", isis->name);
2458 vty_out(vty, "Process Id : %ld\n", isis->process_id);
2459 if (isis->sysid_set)
2460 vty_out(vty, "System Id : %pSY\n", isis->sysid);
2461
2462 vty_out(vty, "Up time : ");
2463 vty_out_timestr(vty, isis->uptime);
2464 vty_out(vty, "\n");
2465
2466 if (isis->area_list)
2467 vty_out(vty, "Number of areas : %d\n", isis->area_list->count);
2468
2469 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
2470 vty_out(vty, "Area %s:\n",
2471 area->area_tag ? area->area_tag : "null");
2472
2473 if (fabricd) {
2474 uint8_t tier = fabricd_tier(area);
2475 if (tier == ISIS_TIER_UNDEFINED)
2476 vty_out(vty, " Tier: undefined\n");
2477 else
2478 vty_out(vty, " Tier: %hhu\n", tier);
2479 }
2480
2481 if (listcount(area->area_addrs) > 0) {
2482 struct iso_address *area_addr;
2483 for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node2,
2484 area_addr))
2485 vty_out(vty, " Net: %pISl\n", area_addr);
2486 }
2487
2488 vty_out(vty, " TX counters per PDU type:\n");
2489 pdu_counter_print(vty, " ", area->pdu_tx_counters);
2490 vty_out(vty, " LSP RXMT: %" PRIu64 "\n",
2491 area->lsp_rxmt_count);
2492 vty_out(vty, " RX counters per PDU type:\n");
2493 pdu_counter_print(vty, " ", area->pdu_rx_counters);
2494
2495 vty_out(vty, " Drop counters per PDU type:\n");
2496 pdu_counter_print(vty, " ", area->pdu_drop_counters);
2497
2498 vty_out(vty, " Advertise high metrics: %s\n",
2499 area->advertise_high_metrics ? "Enabled" : "Disabled");
2500
2501 for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) {
2502 if ((area->is_type & level) == 0)
2503 continue;
2504
2505 vty_out(vty, " Level-%d:\n", level);
2506
2507 vty_out(vty, " LSP0 regenerated: %" PRIu64 "\n",
2508 area->lsp_gen_count[level - 1]);
2509
2510 vty_out(vty, " LSPs purged: %" PRIu64 "\n",
2511 area->lsp_purge_count[level - 1]);
2512
2513 if (area->spf_timer[level - 1])
2514 vty_out(vty, " SPF: (pending)\n");
2515 else
2516 vty_out(vty, " SPF:\n");
2517
2518 vty_out(vty, " minimum interval : %d",
2519 area->min_spf_interval[level - 1]);
2520 if (area->spf_delay_ietf[level - 1])
2521 vty_out(vty,
2522 " (not used, IETF SPF delay activated)");
2523 vty_out(vty, "\n");
2524
2525 if (area->ip_circuits) {
2526 vty_out(vty, " IPv4 route computation:\n");
2527 isis_spf_print(
2528 area->spftree[SPFTREE_IPV4][level - 1],
2529 vty);
2530 }
2531
2532 if (area->ipv6_circuits) {
2533 vty_out(vty, " IPv6 route computation:\n");
2534 isis_spf_print(
2535 area->spftree[SPFTREE_IPV6][level - 1],
2536 vty);
2537 }
2538
2539 if (area->ipv6_circuits
2540 && isis_area_ipv6_dstsrc_enabled(area)) {
2541 vty_out(vty,
2542 " IPv6 dst-src route computation:\n");
2543 isis_spf_print(area->spftree[SPFTREE_DSTSRC]
2544 [level - 1],
2545 vty);
2546 }
2547 }
2548 }
2549 }
2550
2551 static void common_isis_summary(struct vty *vty, struct json_object *json,
2552 struct isis *isis)
2553 {
2554 if (json) {
2555 common_isis_summary_json(json, isis);
2556 } else {
2557 common_isis_summary_vty(vty, isis);
2558 }
2559 }
2560
2561 DEFUN(show_isis_summary, show_isis_summary_cmd,
2562 "show " PROTO_NAME " [vrf <NAME|all>] summary [json]",
2563 SHOW_STR PROTO_HELP VRF_CMD_HELP_STR
2564 "All VRFs\n"
2565 "json output\n"
2566 "summary\n")
2567 {
2568 struct listnode *node;
2569 int idx_vrf = 0;
2570 struct isis *isis;
2571 const char *vrf_name = VRF_DEFAULT_NAME;
2572 bool all_vrf = false;
2573 bool uj = use_json(argc, argv);
2574 json_object *json = NULL;
2575
2576 ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf)
2577 if (!im) {
2578 vty_out(vty, PROTO_NAME " is not running\n");
2579 return CMD_SUCCESS;
2580 }
2581 if (uj)
2582 json = json_object_new_object();
2583 if (vrf_name) {
2584 if (all_vrf) {
2585 for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
2586 common_isis_summary(vty, json, isis);
2587
2588 return CMD_SUCCESS;
2589 }
2590 isis = isis_lookup_by_vrfname(vrf_name);
2591 if (isis != NULL)
2592 common_isis_summary(vty, json, isis);
2593 }
2594
2595 if (uj)
2596 vty_json(vty, json);
2597
2598 return CMD_SUCCESS;
2599 }
2600
2601 struct isis_lsp *lsp_for_sysid(struct lspdb_head *head, const char *sysid_str,
2602 struct isis *isis)
2603 {
2604 char sysid[255] = {0};
2605 uint8_t number[3] = {0};
2606 const char *pos;
2607 uint8_t lspid[ISIS_SYS_ID_LEN + 2] = {0};
2608 struct isis_dynhn *dynhn;
2609 struct isis_lsp *lsp = NULL;
2610
2611 if (!sysid_str)
2612 return NULL;
2613
2614 /*
2615 * extract fragment and pseudo id from the string sysid_str
2616 * in the forms:
2617 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
2618 * (b) <systemid/hostname>.<pseudo-id> or
2619 * (c) <systemid/hostname> or
2620 * Where systemid is in the form:
2621 * xxxx.xxxx.xxxx
2622 */
2623 strlcpy(sysid, sysid_str, sizeof(sysid));
2624
2625 if (strlen(sysid_str) > 3) {
2626 pos = sysid_str + strlen(sysid_str) - 3;
2627 if (strncmp(pos, "-", 1) == 0) {
2628 memcpy(number, ++pos, 2);
2629 lspid[ISIS_SYS_ID_LEN + 1] =
2630 (uint8_t)strtol((char *)number, NULL, 16);
2631 pos -= 4;
2632 if (strncmp(pos, ".", 1) != 0)
2633 return NULL;
2634 }
2635 if (strncmp(pos, ".", 1) == 0) {
2636 memcpy(number, ++pos, 2);
2637 lspid[ISIS_SYS_ID_LEN] =
2638 (uint8_t)strtol((char *)number, NULL, 16);
2639 sysid[pos - sysid_str - 1] = '\0';
2640 }
2641 }
2642
2643 /*
2644 * Try to find the lsp-id if the sysid_str
2645 * is in the form
2646 * hostname.<pseudo-id>-<fragment>
2647 */
2648 if (sysid2buff(lspid, sysid)) {
2649 lsp = lsp_search(head, lspid);
2650 } else if ((dynhn = dynhn_find_by_name(isis, sysid))) {
2651 memcpy(lspid, dynhn->id, ISIS_SYS_ID_LEN);
2652 lsp = lsp_search(head, lspid);
2653 } else if (strncmp(cmd_hostname_get(), sysid, 15) == 0) {
2654 memcpy(lspid, isis->sysid, ISIS_SYS_ID_LEN);
2655 lsp = lsp_search(head, lspid);
2656 }
2657
2658 return lsp;
2659 }
2660
2661 void show_isis_database_lspdb_json(struct json_object *json,
2662 struct isis_area *area, int level,
2663 struct lspdb_head *lspdb,
2664 const char *sysid_str, int ui_level)
2665 {
2666 struct isis_lsp *lsp;
2667 int lsp_count;
2668
2669 if (lspdb_count(lspdb) > 0) {
2670 lsp = lsp_for_sysid(lspdb, sysid_str, area->isis);
2671
2672 if (lsp != NULL || sysid_str == NULL) {
2673 json_object_int_add(json, "id", level + 1);
2674 }
2675
2676 if (lsp) {
2677 if (ui_level == ISIS_UI_LEVEL_DETAIL)
2678 lsp_print_detail(lsp, NULL, json,
2679 area->dynhostname, area->isis);
2680 else
2681 lsp_print_json(lsp, json, area->dynhostname,
2682 area->isis);
2683 } else if (sysid_str == NULL) {
2684 lsp_count =
2685 lsp_print_all(NULL, json, lspdb, ui_level,
2686 area->dynhostname, area->isis);
2687
2688 json_object_int_add(json, "count", lsp_count);
2689 }
2690 }
2691 }
2692 void show_isis_database_lspdb_vty(struct vty *vty, struct isis_area *area,
2693 int level, struct lspdb_head *lspdb,
2694 const char *sysid_str, int ui_level)
2695 {
2696 struct isis_lsp *lsp;
2697 int lsp_count;
2698
2699 if (lspdb_count(lspdb) > 0) {
2700 lsp = lsp_for_sysid(lspdb, sysid_str, area->isis);
2701
2702 if (lsp != NULL || sysid_str == NULL) {
2703 vty_out(vty, "IS-IS Level-%d link-state database:\n",
2704 level + 1);
2705
2706 /* print the title in all cases */
2707 vty_out(vty,
2708 "LSP ID PduLen SeqNumber Chksum Holdtime ATT/P/OL\n");
2709 }
2710
2711 if (lsp) {
2712 if (ui_level == ISIS_UI_LEVEL_DETAIL)
2713 lsp_print_detail(lsp, vty, NULL,
2714 area->dynhostname, area->isis);
2715 else
2716 lsp_print_vty(lsp, vty, area->dynhostname,
2717 area->isis);
2718 } else if (sysid_str == NULL) {
2719 lsp_count =
2720 lsp_print_all(vty, NULL, lspdb, ui_level,
2721 area->dynhostname, area->isis);
2722
2723 vty_out(vty, " %u LSPs\n\n", lsp_count);
2724 }
2725 }
2726 }
2727
2728 static void show_isis_database_json(struct json_object *json, const char *sysid_str,
2729 int ui_level, struct isis *isis)
2730 {
2731 struct listnode *node;
2732 struct isis_area *area;
2733 int level;
2734 struct json_object *tag_area_json,*area_json, *lsp_json, *area_arr_json, *arr_json;
2735
2736 if (isis->area_list->count == 0)
2737 return;
2738
2739 area_arr_json = json_object_new_array();
2740 json_object_object_add(json, "areas", area_arr_json);
2741 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
2742 area_json = json_object_new_object();
2743 tag_area_json = json_object_new_object();
2744 json_object_string_add(tag_area_json, "name",
2745 area->area_tag ? area->area_tag
2746 : "null");
2747
2748 arr_json = json_object_new_array();
2749 json_object_object_add(area_json,"area",tag_area_json);
2750 json_object_object_add(area_json,"levels",arr_json);
2751 for (level = 0; level < ISIS_LEVELS; level++) {
2752 lsp_json = json_object_new_object();
2753 show_isis_database_lspdb_json(lsp_json, area, level,
2754 &area->lspdb[level],
2755 sysid_str, ui_level);
2756 json_object_array_add(arr_json, lsp_json);
2757 }
2758 json_object_array_add(area_arr_json, area_json);
2759 }
2760 }
2761
2762 static void show_isis_database_vty(struct vty *vty, const char *sysid_str,
2763 int ui_level, struct isis *isis)
2764 {
2765 struct listnode *node;
2766 struct isis_area *area;
2767 int level;
2768
2769 if (isis->area_list->count == 0)
2770 return;
2771
2772 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
2773 vty_out(vty, "Area %s:\n",
2774 area->area_tag ? area->area_tag : "null");
2775
2776 for (level = 0; level < ISIS_LEVELS; level++)
2777 show_isis_database_lspdb_vty(vty, area, level,
2778 &area->lspdb[level], sysid_str,
2779 ui_level);
2780 }
2781 }
2782
2783 static void show_isis_database_common(struct vty *vty, struct json_object *json, const char *sysid_str,
2784 int ui_level, struct isis *isis)
2785 {
2786 if (json) {
2787 show_isis_database_json(json, sysid_str, ui_level, isis);
2788 } else {
2789 show_isis_database_vty(vty, sysid_str, ui_level, isis);
2790 }
2791 }
2792
2793 /*
2794 * This function supports following display options:
2795 * [ show isis database [detail] ]
2796 * [ show isis database <sysid> [detail] ]
2797 * [ show isis database <hostname> [detail] ]
2798 * [ show isis database <sysid>.<pseudo-id> [detail] ]
2799 * [ show isis database <hostname>.<pseudo-id> [detail] ]
2800 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
2801 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
2802 * [ show isis database detail <sysid> ]
2803 * [ show isis database detail <hostname> ]
2804 * [ show isis database detail <sysid>.<pseudo-id> ]
2805 * [ show isis database detail <hostname>.<pseudo-id> ]
2806 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
2807 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
2808 */
2809 static int show_isis_database(struct vty *vty, struct json_object *json, const char *sysid_str,
2810 int ui_level, const char *vrf_name, bool all_vrf)
2811 {
2812 struct listnode *node;
2813 struct isis *isis;
2814
2815 if (vrf_name) {
2816 if (all_vrf) {
2817 for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
2818 show_isis_database_common(vty, json, sysid_str,
2819 ui_level, isis);
2820
2821 return CMD_SUCCESS;
2822 }
2823 isis = isis_lookup_by_vrfname(vrf_name);
2824 if (isis)
2825 show_isis_database_common(vty, json, sysid_str,
2826 ui_level, isis);
2827 }
2828
2829 return CMD_SUCCESS;
2830 }
2831
2832 DEFUN(show_database, show_database_cmd,
2833 "show " PROTO_NAME " [vrf <NAME|all>] database [detail] [WORD] [json]",
2834 SHOW_STR PROTO_HELP VRF_CMD_HELP_STR
2835 "All VRFs\n"
2836 "Link state database\n"
2837 "Detailed information\n"
2838 "LSP ID\n"
2839 "json output\n")
2840 {
2841 int res = CMD_SUCCESS;
2842 int idx = 0;
2843 int idx_vrf = 0;
2844 const char *vrf_name = VRF_DEFAULT_NAME;
2845 bool all_vrf = false;
2846 int uilevel = argv_find(argv, argc, "detail", &idx)
2847 ? ISIS_UI_LEVEL_DETAIL
2848 : ISIS_UI_LEVEL_BRIEF;
2849 char *id = argv_find(argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL;
2850 bool uj = use_json(argc, argv);
2851 json_object *json = NULL;
2852
2853 ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
2854 if (uj)
2855 json = json_object_new_object();
2856
2857 res = show_isis_database(vty, json, id, uilevel, vrf_name, all_vrf);
2858 if (uj)
2859 vty_json(vty, json);
2860 return res;
2861 }
2862
2863 #ifdef FABRICD
2864 /*
2865 * 'router openfabric' command
2866 */
2867 DEFUN_NOSH (router_openfabric,
2868 router_openfabric_cmd,
2869 "router openfabric WORD",
2870 ROUTER_STR
2871 PROTO_HELP
2872 "ISO Routing area tag\n")
2873 {
2874 int idx_word = 2;
2875 return isis_area_get(vty, argv[idx_word]->arg);
2876 }
2877
2878 /*
2879 *'no router openfabric' command
2880 */
2881 DEFUN (no_router_openfabric,
2882 no_router_openfabric_cmd,
2883 "no router openfabric WORD",
2884 NO_STR
2885 ROUTER_STR
2886 PROTO_HELP
2887 "ISO Routing area tag\n")
2888 {
2889 struct isis_area *area;
2890 const char *area_tag;
2891 int idx_word = 3;
2892
2893 area_tag = argv[idx_word]->arg;
2894 area = isis_area_lookup(area_tag, VRF_DEFAULT);
2895 if (area == NULL) {
2896 zlog_warn("%s: could not find area with area-tag %s",
2897 __func__, area_tag);
2898 return CMD_ERR_NO_MATCH;
2899 }
2900
2901 isis_area_destroy(area);
2902 return CMD_SUCCESS;
2903 }
2904 #endif /* ifdef FABRICD */
2905 #ifdef FABRICD
2906 /*
2907 * 'net' command
2908 */
2909 DEFUN (net,
2910 net_cmd,
2911 "net WORD",
2912 "A Network Entity Title for this process (OSI only)\n"
2913 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
2914 {
2915 int idx_word = 1;
2916 return area_net_title(vty, argv[idx_word]->arg);
2917 }
2918
2919 /*
2920 * 'no net' command
2921 */
2922 DEFUN (no_net,
2923 no_net_cmd,
2924 "no net WORD",
2925 NO_STR
2926 "A Network Entity Title for this process (OSI only)\n"
2927 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
2928 {
2929 int idx_word = 2;
2930 return area_clear_net_title(vty, argv[idx_word]->arg);
2931 }
2932 #endif /* ifdef FABRICD */
2933 #ifdef FABRICD
2934 DEFUN (isis_topology,
2935 isis_topology_cmd,
2936 "topology " ISIS_MT_NAMES " [overload]",
2937 "Configure IS-IS topologies\n"
2938 ISIS_MT_DESCRIPTIONS
2939 "Set overload bit for topology\n")
2940 {
2941 VTY_DECLVAR_CONTEXT(isis_area, area);
2942
2943 const char *arg = argv[1]->arg;
2944 uint16_t mtid = isis_str2mtid(arg);
2945
2946 if (area->oldmetric) {
2947 vty_out(vty,
2948 "Multi topology IS-IS can only be used with wide metrics\n");
2949 return CMD_WARNING_CONFIG_FAILED;
2950 }
2951
2952 if (mtid == (uint16_t)-1) {
2953 vty_out(vty, "Don't know topology '%s'\n", arg);
2954 return CMD_WARNING_CONFIG_FAILED;
2955 }
2956 if (mtid == ISIS_MT_IPV4_UNICAST) {
2957 vty_out(vty, "Cannot configure IPv4 unicast topology\n");
2958 return CMD_WARNING_CONFIG_FAILED;
2959 }
2960
2961 area_set_mt_enabled(area, mtid, true);
2962 area_set_mt_overload(area, mtid, (argc == 3));
2963 return CMD_SUCCESS;
2964 }
2965
2966 DEFUN (no_isis_topology,
2967 no_isis_topology_cmd,
2968 "no topology " ISIS_MT_NAMES " [overload]",
2969 NO_STR
2970 "Configure IS-IS topologies\n"
2971 ISIS_MT_DESCRIPTIONS
2972 "Set overload bit for topology\n")
2973 {
2974 VTY_DECLVAR_CONTEXT(isis_area, area);
2975
2976 const char *arg = argv[2]->arg;
2977 uint16_t mtid = isis_str2mtid(arg);
2978
2979 if (area->oldmetric) {
2980 vty_out(vty,
2981 "Multi topology IS-IS can only be used with wide metrics\n");
2982 return CMD_WARNING_CONFIG_FAILED;
2983 }
2984
2985 if (mtid == (uint16_t)-1) {
2986 vty_out(vty, "Don't know topology '%s'\n", arg);
2987 return CMD_WARNING_CONFIG_FAILED;
2988 }
2989 if (mtid == ISIS_MT_IPV4_UNICAST) {
2990 vty_out(vty, "Cannot configure IPv4 unicast topology\n");
2991 return CMD_WARNING_CONFIG_FAILED;
2992 }
2993
2994 area_set_mt_enabled(area, mtid, false);
2995 area_set_mt_overload(area, mtid, false);
2996 return CMD_SUCCESS;
2997 }
2998 #endif /* ifdef FABRICD */
2999
3000 void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu)
3001 {
3002 area->lsp_mtu = lsp_mtu;
3003 lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1);
3004 }
3005
3006 static int isis_area_passwd_set(struct isis_area *area, int level,
3007 uint8_t passwd_type, const char *passwd,
3008 uint8_t snp_auth)
3009 {
3010 struct isis_passwd *dest;
3011 struct isis_passwd modified;
3012 int len;
3013
3014 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
3015 dest = (level == IS_LEVEL_1) ? &area->area_passwd
3016 : &area->domain_passwd;
3017 memset(&modified, 0, sizeof(modified));
3018
3019 if (passwd_type != ISIS_PASSWD_TYPE_UNUSED) {
3020 if (!passwd)
3021 return -1;
3022
3023 len = strlen(passwd);
3024 if (len > 254)
3025 return -1;
3026
3027 modified.len = len;
3028 strlcpy((char *)modified.passwd, passwd,
3029 sizeof(modified.passwd));
3030 modified.type = passwd_type;
3031 modified.snp_auth = snp_auth;
3032 }
3033
3034 if (memcmp(&modified, dest, sizeof(modified))) {
3035 memcpy(dest, &modified, sizeof(modified));
3036 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
3037 }
3038
3039 return 0;
3040 }
3041
3042 int isis_area_passwd_unset(struct isis_area *area, int level)
3043 {
3044 return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_UNUSED, NULL,
3045 0);
3046 }
3047
3048 int isis_area_passwd_cleartext_set(struct isis_area *area, int level,
3049 const char *passwd, uint8_t snp_auth)
3050 {
3051 return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_CLEARTXT,
3052 passwd, snp_auth);
3053 }
3054
3055 int isis_area_passwd_hmac_md5_set(struct isis_area *area, int level,
3056 const char *passwd, uint8_t snp_auth)
3057 {
3058 return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_HMAC_MD5,
3059 passwd, snp_auth);
3060 }
3061
3062 void isis_area_invalidate_routes(struct isis_area *area, int levels)
3063 {
3064 for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) {
3065 if (!(level & levels))
3066 continue;
3067 for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) {
3068 isis_spf_invalidate_routes(
3069 area->spftree[tree][level - 1]);
3070 }
3071 }
3072 }
3073
3074 void isis_area_verify_routes(struct isis_area *area)
3075 {
3076 for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++)
3077 isis_spf_verify_routes(area, area->spftree[tree]);
3078 }
3079
3080 void isis_area_switchover_routes(struct isis_area *area, int family,
3081 union g_addr *nexthop_ip, ifindex_t ifindex,
3082 int level)
3083 {
3084 int tree;
3085
3086 /* TODO SPFTREE_DSTSRC */
3087 if (family == AF_INET)
3088 tree = SPFTREE_IPV4;
3089 else if (family == AF_INET6)
3090 tree = SPFTREE_IPV6;
3091 else
3092 return;
3093
3094 isis_spf_switchover_routes(area, area->spftree[tree], family,
3095 nexthop_ip, ifindex, level);
3096 }
3097
3098
3099 static void area_resign_level(struct isis_area *area, int level)
3100 {
3101 isis_area_invalidate_routes(area, level);
3102 isis_area_verify_routes(area);
3103
3104 lsp_db_fini(&area->lspdb[level - 1]);
3105
3106 for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) {
3107 if (area->spftree[tree][level - 1]) {
3108 isis_spftree_del(area->spftree[tree][level - 1]);
3109 area->spftree[tree][level - 1] = NULL;
3110 }
3111 }
3112
3113 if (area->spf_timer[level - 1])
3114 isis_spf_timer_free(EVENT_ARG(area->spf_timer[level - 1]));
3115
3116 EVENT_OFF(area->spf_timer[level - 1]);
3117
3118 sched_debug(
3119 "ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.",
3120 area->area_tag, level);
3121 EVENT_OFF(area->t_lsp_refresh[level - 1]);
3122 area->lsp_regenerate_pending[level - 1] = 0;
3123 }
3124
3125 void isis_area_is_type_set(struct isis_area *area, int is_type)
3126 {
3127 struct listnode *node;
3128 struct isis_circuit *circuit;
3129
3130 if (IS_DEBUG_EVENTS)
3131 zlog_debug("ISIS-Evt (%s) system type change %s -> %s",
3132 area->area_tag, circuit_t2string(area->is_type),
3133 circuit_t2string(is_type));
3134
3135 if (area->is_type == is_type)
3136 return; /* No change */
3137
3138 switch (area->is_type) {
3139 case IS_LEVEL_1:
3140 if (is_type == IS_LEVEL_2)
3141 area_resign_level(area, IS_LEVEL_1);
3142
3143 lsp_db_init(&area->lspdb[1]);
3144 break;
3145
3146 case IS_LEVEL_1_AND_2:
3147 if (is_type == IS_LEVEL_1)
3148 area_resign_level(area, IS_LEVEL_2);
3149 else
3150 area_resign_level(area, IS_LEVEL_1);
3151 break;
3152
3153 case IS_LEVEL_2:
3154 if (is_type == IS_LEVEL_1)
3155 area_resign_level(area, IS_LEVEL_2);
3156
3157 lsp_db_init(&area->lspdb[0]);
3158 break;
3159
3160 default:
3161 break;
3162 }
3163
3164 area->is_type = is_type;
3165
3166 /*
3167 * If area's IS type is strict Level-1 or Level-2, override circuit's
3168 * IS type. Otherwise use circuit's configured IS type.
3169 */
3170 if (area->is_type != IS_LEVEL_1_AND_2) {
3171 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit))
3172 isis_circuit_is_type_set(circuit, is_type);
3173 } else {
3174 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit))
3175 isis_circuit_is_type_set(circuit, circuit->is_type_config);
3176 }
3177
3178 spftree_area_init(area);
3179
3180 if (listcount(area->area_addrs) > 0) {
3181 if (is_type & IS_LEVEL_1)
3182 lsp_generate(area, IS_LEVEL_1);
3183 if (is_type & IS_LEVEL_2)
3184 lsp_generate(area, IS_LEVEL_2);
3185 }
3186 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
3187
3188 return;
3189 }
3190
3191 void isis_area_metricstyle_set(struct isis_area *area, bool old_metric,
3192 bool new_metric)
3193 {
3194 area->oldmetric = old_metric;
3195 area->newmetric = new_metric;
3196 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
3197 }
3198
3199 void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit)
3200 {
3201 char new_overload_bit = overload_bit ? LSPBIT_OL : 0;
3202
3203 if (new_overload_bit != area->overload_bit) {
3204 area->overload_bit = new_overload_bit;
3205 if (new_overload_bit) {
3206 area->overload_counter++;
3207 } else {
3208 /* Cancel overload on startup timer if it's running */
3209 if (area->t_overload_on_startup_timer) {
3210 EVENT_OFF(area->t_overload_on_startup_timer);
3211 area->t_overload_on_startup_timer = NULL;
3212 }
3213 }
3214
3215 #ifndef FABRICD
3216 hook_call(isis_hook_db_overload, area);
3217 #endif /* ifndef FABRICD */
3218
3219 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
3220 }
3221 #ifndef FABRICD
3222 isis_notif_db_overload(area, overload_bit);
3223 #endif /* ifndef FABRICD */
3224 }
3225
3226 void isis_area_overload_on_startup_set(struct isis_area *area,
3227 uint32_t startup_time)
3228 {
3229 if (area->overload_on_startup_time != startup_time) {
3230 area->overload_on_startup_time = startup_time;
3231 isis_restart_write_overload_time(area, startup_time);
3232 }
3233 }
3234
3235 void config_end_lsp_generate(struct isis_area *area)
3236 {
3237 if (listcount(area->area_addrs) > 0) {
3238 if (CHECK_FLAG(area->is_type, IS_LEVEL_1))
3239 lsp_generate(area, IS_LEVEL_1);
3240 if (CHECK_FLAG(area->is_type, IS_LEVEL_2))
3241 lsp_generate(area, IS_LEVEL_2);
3242 }
3243 }
3244
3245 void isis_area_advertise_high_metrics_set(struct isis_area *area,
3246 bool advertise_high_metrics)
3247 {
3248 struct listnode *node;
3249 struct isis_circuit *circuit;
3250 int max_metric;
3251 char xpath[XPATH_MAXLEN];
3252 struct lyd_node *dnode;
3253 int configured_metric_l1;
3254 int configured_metric_l2;
3255
3256 if (area->advertise_high_metrics == advertise_high_metrics)
3257 return;
3258
3259 if (advertise_high_metrics) {
3260 if (area->oldmetric && area->newmetric)
3261 max_metric = ISIS_NARROW_METRIC_INFINITY;
3262 else if (area->newmetric)
3263 max_metric = MAX_WIDE_LINK_METRIC;
3264 else
3265 max_metric = MAX_NARROW_LINK_METRIC;
3266
3267 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) {
3268 isis_circuit_metric_set(circuit, IS_LEVEL_1,
3269 max_metric);
3270 isis_circuit_metric_set(circuit, IS_LEVEL_2,
3271 max_metric);
3272 }
3273
3274 area->advertise_high_metrics = true;
3275 } else {
3276 area->advertise_high_metrics = false;
3277 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) {
3278 /* Get configured metric */
3279 snprintf(xpath, XPATH_MAXLEN,
3280 "/frr-interface:lib/interface[name='%s']",
3281 circuit->interface->name);
3282 dnode = yang_dnode_get(running_config->dnode, xpath);
3283
3284 configured_metric_l1 = yang_dnode_get_uint32(
3285 dnode, "./frr-isisd:isis/metric/level-1");
3286 configured_metric_l2 = yang_dnode_get_uint32(
3287 dnode, "./frr-isisd:isis/metric/level-2");
3288
3289 isis_circuit_metric_set(circuit, IS_LEVEL_1,
3290 configured_metric_l1);
3291 isis_circuit_metric_set(circuit, IS_LEVEL_2,
3292 configured_metric_l2);
3293 }
3294 }
3295 }
3296
3297 /*
3298 * Returns the path of the file (non-volatile memory) that contains restart
3299 * information.
3300 */
3301 char *isis_restart_filepath(void)
3302 {
3303 static char filepath[MAXPATHLEN];
3304 snprintf(filepath, sizeof(filepath), ISISD_RESTART, "");
3305 return filepath;
3306 }
3307
3308 /*
3309 * Record in non-volatile memory the overload on startup time.
3310 */
3311 void isis_restart_write_overload_time(struct isis_area *isis_area,
3312 uint32_t overload_time)
3313 {
3314 char *filepath;
3315 const char *area_name;
3316 json_object *json;
3317 json_object *json_areas;
3318 json_object *json_area;
3319
3320 filepath = isis_restart_filepath();
3321 area_name = isis_area->area_tag;
3322
3323 json = json_object_from_file(filepath);
3324 if (json == NULL)
3325 json = json_object_new_object();
3326
3327 json_object_object_get_ex(json, "areas", &json_areas);
3328 if (!json_areas) {
3329 json_areas = json_object_new_object();
3330 json_object_object_add(json, "areas", json_areas);
3331 }
3332
3333 json_object_object_get_ex(json_areas, area_name, &json_area);
3334 if (!json_area) {
3335 json_area = json_object_new_object();
3336 json_object_object_add(json_areas, area_name, json_area);
3337 }
3338
3339 json_object_int_add(json_area, "overload_time",
3340 isis_area->overload_on_startup_time);
3341 json_object_to_file_ext(filepath, json, JSON_C_TO_STRING_PRETTY);
3342 json_object_free(json);
3343 }
3344
3345 /*
3346 * Fetch from non-volatile memory the overload on startup time.
3347 */
3348 uint32_t isis_restart_read_overload_time(struct isis_area *isis_area)
3349 {
3350 char *filepath;
3351 const char *area_name;
3352 json_object *json;
3353 json_object *json_areas;
3354 json_object *json_area;
3355 json_object *json_overload_time;
3356 uint32_t overload_time = 0;
3357
3358 filepath = isis_restart_filepath();
3359 area_name = isis_area->area_tag;
3360
3361 json = json_object_from_file(filepath);
3362 if (json == NULL)
3363 json = json_object_new_object();
3364
3365 json_object_object_get_ex(json, "areas", &json_areas);
3366 if (!json_areas) {
3367 json_areas = json_object_new_object();
3368 json_object_object_add(json, "areas", json_areas);
3369 }
3370
3371 json_object_object_get_ex(json_areas, area_name, &json_area);
3372 if (!json_area) {
3373 json_area = json_object_new_object();
3374 json_object_object_add(json_areas, area_name, json_area);
3375 }
3376
3377 json_object_object_get_ex(json_area, "overload_time",
3378 &json_overload_time);
3379 if (json_overload_time) {
3380 overload_time = json_object_get_int(json_overload_time);
3381 }
3382
3383 json_object_object_del(json_areas, area_name);
3384
3385 json_object_to_file_ext(filepath, json, JSON_C_TO_STRING_PRETTY);
3386 json_object_free(json);
3387
3388 return overload_time;
3389 }
3390
3391 void isis_area_attached_bit_send_set(struct isis_area *area, bool attached_bit)
3392 {
3393
3394 if (attached_bit != area->attached_bit_send) {
3395 area->attached_bit_send = attached_bit;
3396 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
3397 }
3398 }
3399
3400 void isis_area_attached_bit_receive_set(struct isis_area *area,
3401 bool attached_bit)
3402 {
3403
3404 if (attached_bit != area->attached_bit_rcv_ignore) {
3405 area->attached_bit_rcv_ignore = attached_bit;
3406 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
3407 }
3408 }
3409
3410 void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname)
3411 {
3412 if (area->dynhostname != dynhostname) {
3413 area->dynhostname = dynhostname;
3414 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
3415 }
3416 }
3417
3418 void isis_area_max_lsp_lifetime_set(struct isis_area *area, int level,
3419 uint16_t max_lsp_lifetime)
3420 {
3421 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
3422
3423 if (area->max_lsp_lifetime[level - 1] == max_lsp_lifetime)
3424 return;
3425
3426 area->max_lsp_lifetime[level - 1] = max_lsp_lifetime;
3427 lsp_regenerate_schedule(area, level, 1);
3428 }
3429
3430 void isis_area_lsp_refresh_set(struct isis_area *area, int level,
3431 uint16_t lsp_refresh)
3432 {
3433 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
3434
3435 if (area->lsp_refresh[level - 1] == lsp_refresh)
3436 return;
3437
3438 area->lsp_refresh[level - 1] = lsp_refresh;
3439 lsp_regenerate_schedule(area, level, 1);
3440 }
3441
3442 #ifdef FABRICD
3443 DEFUN (log_adj_changes,
3444 log_adj_changes_cmd,
3445 "log-adjacency-changes",
3446 "Log changes in adjacency state\n")
3447 {
3448 VTY_DECLVAR_CONTEXT(isis_area, area);
3449
3450 area->log_adj_changes = 1;
3451
3452 return CMD_SUCCESS;
3453 }
3454
3455 DEFUN (no_log_adj_changes,
3456 no_log_adj_changes_cmd,
3457 "no log-adjacency-changes",
3458 NO_STR
3459 "Stop logging changes in adjacency state\n")
3460 {
3461 VTY_DECLVAR_CONTEXT(isis_area, area);
3462
3463 area->log_adj_changes = 0;
3464
3465 return CMD_SUCCESS;
3466 }
3467 #endif /* ifdef FABRICD */
3468 #ifdef FABRICD
3469 /* IS-IS configuration write function */
3470 static int isis_config_write(struct vty *vty)
3471 {
3472 int write = 0;
3473 struct isis_area *area;
3474 struct listnode *node, *node2, *inode;
3475 struct isis *isis;
3476
3477 if (!im) {
3478 vty_out(vty, "IS-IS Routing Process not enabled\n");
3479 return CMD_SUCCESS;
3480 }
3481
3482 for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) {
3483 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
3484 /* ISIS - Area name */
3485 vty_out(vty, "router " PROTO_NAME " %s\n", area->area_tag);
3486 write++;
3487 /* ISIS - Net */
3488 if (listcount(area->area_addrs) > 0) {
3489 struct iso_address *area_addr;
3490 for (ALL_LIST_ELEMENTS_RO(area->area_addrs,
3491 node2, area_addr)) {
3492 vty_out(vty, " net %pISl\n", area_addr);
3493 write++;
3494 }
3495 }
3496 /* ISIS - Dynamic hostname - Defaults to true so only
3497 * display if
3498 * false. */
3499 if (!area->dynhostname) {
3500 vty_out(vty, " no hostname dynamic\n");
3501 write++;
3502 }
3503 /* ISIS - Metric-Style - when true displays wide */
3504 if (!fabricd) {
3505 if (area->newmetric) {
3506 if (!area->oldmetric)
3507 vty_out(vty, " metric-style wide\n");
3508 else
3509 vty_out(vty,
3510 " metric-style transition\n");
3511 write++;
3512 } else {
3513 vty_out(vty, " metric-style narrow\n");
3514 write++;
3515 }
3516 }
3517 /* ISIS - overload-bit */
3518 if (area->overload_bit) {
3519 vty_out(vty, " set-overload-bit\n");
3520 write++;
3521 }
3522 /* ISIS - Area is-type (level-1-2 is default) */
3523 if (!fabricd) {
3524 if (area->is_type == IS_LEVEL_1) {
3525 vty_out(vty, " is-type level-1\n");
3526 write++;
3527 } else if (area->is_type == IS_LEVEL_2) {
3528 vty_out(vty, " is-type level-2-only\n");
3529 write++;
3530 }
3531 }
3532 write += isis_redist_config_write(vty, area, AF_INET);
3533 write += isis_redist_config_write(vty, area, AF_INET6);
3534 /* ISIS - Lsp generation interval */
3535 if (area->lsp_gen_interval[0]
3536 == area->lsp_gen_interval[1]) {
3537 if (area->lsp_gen_interval[0]
3538 != DEFAULT_MIN_LSP_GEN_INTERVAL) {
3539 vty_out(vty, " lsp-gen-interval %d\n",
3540 area->lsp_gen_interval[0]);
3541 write++;
3542 }
3543 } else {
3544 if (area->lsp_gen_interval[0]
3545 != DEFAULT_MIN_LSP_GEN_INTERVAL) {
3546 vty_out(vty,
3547 " lsp-gen-interval level-1 %d\n",
3548 area->lsp_gen_interval[0]);
3549 write++;
3550 }
3551 if (area->lsp_gen_interval[1]
3552 != DEFAULT_MIN_LSP_GEN_INTERVAL) {
3553 vty_out(vty,
3554 " lsp-gen-interval level-2 %d\n",
3555 area->lsp_gen_interval[1]);
3556 write++;
3557 }
3558 }
3559 /* ISIS - LSP lifetime */
3560 if (area->max_lsp_lifetime[0]
3561 == area->max_lsp_lifetime[1]) {
3562 if (area->max_lsp_lifetime[0]
3563 != DEFAULT_LSP_LIFETIME) {
3564 vty_out(vty, " max-lsp-lifetime %u\n",
3565 area->max_lsp_lifetime[0]);
3566 write++;
3567 }
3568 } else {
3569 if (area->max_lsp_lifetime[0]
3570 != DEFAULT_LSP_LIFETIME) {
3571 vty_out(vty,
3572 " max-lsp-lifetime level-1 %u\n",
3573 area->max_lsp_lifetime[0]);
3574 write++;
3575 }
3576 if (area->max_lsp_lifetime[1]
3577 != DEFAULT_LSP_LIFETIME) {
3578 vty_out(vty,
3579 " max-lsp-lifetime level-2 %u\n",
3580 area->max_lsp_lifetime[1]);
3581 write++;
3582 }
3583 }
3584 /* ISIS - LSP refresh interval */
3585 if (area->lsp_refresh[0] == area->lsp_refresh[1]) {
3586 if (area->lsp_refresh[0]
3587 != DEFAULT_MAX_LSP_GEN_INTERVAL) {
3588 vty_out(vty,
3589 " lsp-refresh-interval %u\n",
3590 area->lsp_refresh[0]);
3591 write++;
3592 }
3593 } else {
3594 if (area->lsp_refresh[0]
3595 != DEFAULT_MAX_LSP_GEN_INTERVAL) {
3596 vty_out(vty,
3597 " lsp-refresh-interval level-1 %u\n",
3598 area->lsp_refresh[0]);
3599 write++;
3600 }
3601 if (area->lsp_refresh[1]
3602 != DEFAULT_MAX_LSP_GEN_INTERVAL) {
3603 vty_out(vty,
3604 " lsp-refresh-interval level-2 %u\n",
3605 area->lsp_refresh[1]);
3606 write++;
3607 }
3608 }
3609 if (area->lsp_mtu != DEFAULT_LSP_MTU) {
3610 vty_out(vty, " lsp-mtu %u\n", area->lsp_mtu);
3611 write++;
3612 }
3613 if (area->purge_originator) {
3614 vty_out(vty, " purge-originator\n");
3615 write++;
3616 }
3617
3618 /* Minimum SPF interval. */
3619 if (area->min_spf_interval[0]
3620 == area->min_spf_interval[1]) {
3621 if (area->min_spf_interval[0]
3622 != MINIMUM_SPF_INTERVAL) {
3623 vty_out(vty, " spf-interval %d\n",
3624 area->min_spf_interval[0]);
3625 write++;
3626 }
3627 } else {
3628 if (area->min_spf_interval[0]
3629 != MINIMUM_SPF_INTERVAL) {
3630 vty_out(vty,
3631 " spf-interval level-1 %d\n",
3632 area->min_spf_interval[0]);
3633 write++;
3634 }
3635 if (area->min_spf_interval[1]
3636 != MINIMUM_SPF_INTERVAL) {
3637 vty_out(vty,
3638 " spf-interval level-2 %d\n",
3639 area->min_spf_interval[1]);
3640 write++;
3641 }
3642 }
3643
3644 /* IETF SPF interval */
3645 if (area->spf_delay_ietf[0]) {
3646 vty_out(vty,
3647 " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld\n",
3648 spf_backoff_init_delay(
3649 area->spf_delay_ietf[0]),
3650 spf_backoff_short_delay(
3651 area->spf_delay_ietf[0]),
3652 spf_backoff_long_delay(
3653 area->spf_delay_ietf[0]),
3654 spf_backoff_holddown(
3655 area->spf_delay_ietf[0]),
3656 spf_backoff_timetolearn(
3657 area->spf_delay_ietf[0]));
3658 write++;
3659 }
3660
3661 /* Authentication passwords. */
3662 if (area->area_passwd.type
3663 == ISIS_PASSWD_TYPE_HMAC_MD5) {
3664 vty_out(vty, " area-password md5 %s",
3665 area->area_passwd.passwd);
3666 if (CHECK_FLAG(area->area_passwd.snp_auth,
3667 SNP_AUTH_SEND)) {
3668 vty_out(vty, " authenticate snp ");
3669 if (CHECK_FLAG(
3670 area->area_passwd.snp_auth,
3671 SNP_AUTH_RECV))
3672 vty_out(vty, "validate");
3673 else
3674 vty_out(vty, "send-only");
3675 }
3676 vty_out(vty, "\n");
3677 write++;
3678 } else if (area->area_passwd.type
3679 == ISIS_PASSWD_TYPE_CLEARTXT) {
3680 vty_out(vty, " area-password clear %s",
3681 area->area_passwd.passwd);
3682 if (CHECK_FLAG(area->area_passwd.snp_auth,
3683 SNP_AUTH_SEND)) {
3684 vty_out(vty, " authenticate snp ");
3685 if (CHECK_FLAG(
3686 area->area_passwd.snp_auth,
3687 SNP_AUTH_RECV))
3688 vty_out(vty, "validate");
3689 else
3690 vty_out(vty, "send-only");
3691 }
3692 vty_out(vty, "\n");
3693 write++;
3694 }
3695 if (area->domain_passwd.type
3696 == ISIS_PASSWD_TYPE_HMAC_MD5) {
3697 vty_out(vty, " domain-password md5 %s",
3698 area->domain_passwd.passwd);
3699 if (CHECK_FLAG(area->domain_passwd.snp_auth,
3700 SNP_AUTH_SEND)) {
3701 vty_out(vty, " authenticate snp ");
3702 if (CHECK_FLAG(area->domain_passwd
3703 .snp_auth,
3704 SNP_AUTH_RECV))
3705 vty_out(vty, "validate");
3706 else
3707 vty_out(vty, "send-only");
3708 }
3709 vty_out(vty, "\n");
3710 write++;
3711 } else if (area->domain_passwd.type
3712 == ISIS_PASSWD_TYPE_CLEARTXT) {
3713 vty_out(vty, " domain-password clear %s",
3714 area->domain_passwd.passwd);
3715 if (CHECK_FLAG(area->domain_passwd.snp_auth,
3716 SNP_AUTH_SEND)) {
3717 vty_out(vty, " authenticate snp ");
3718 if (CHECK_FLAG(area->domain_passwd
3719 .snp_auth,
3720 SNP_AUTH_RECV))
3721 vty_out(vty, "validate");
3722 else
3723 vty_out(vty, "send-only");
3724 }
3725 vty_out(vty, "\n");
3726 write++;
3727 }
3728
3729 if (area->log_adj_changes) {
3730 vty_out(vty, " log-adjacency-changes\n");
3731 write++;
3732 }
3733
3734 write += area_write_mt_settings(area, vty);
3735 write += fabricd_write_settings(area, vty);
3736
3737 vty_out(vty, "exit\n");
3738 }
3739 }
3740
3741 return write;
3742 }
3743
3744 struct cmd_node router_node = {
3745 .name = "openfabric",
3746 .node = OPENFABRIC_NODE,
3747 .parent_node = CONFIG_NODE,
3748 .prompt = "%s(config-router)# ",
3749 .config_write = isis_config_write,
3750 };
3751 #else
3752 /* IS-IS configuration write function */
3753 static int isis_config_write(struct vty *vty)
3754 {
3755 int write = 0;
3756 struct lyd_node *dnode;
3757
3758 dnode = yang_dnode_get(running_config->dnode, "/frr-isisd:isis");
3759 if (dnode) {
3760 nb_cli_show_dnode_cmds(vty, dnode, false);
3761 write++;
3762 }
3763
3764 return write;
3765 }
3766
3767 struct cmd_node router_node = {
3768 .name = "isis",
3769 .node = ISIS_NODE,
3770 .parent_node = CONFIG_NODE,
3771 .prompt = "%s(config-router)# ",
3772 .config_write = isis_config_write,
3773 };
3774 #endif /* ifdef FABRICD */
3775
3776 void isis_init(void)
3777 {
3778 /* Install IS-IS top node */
3779 install_node(&router_node);
3780
3781 install_element(VIEW_NODE, &show_isis_summary_cmd);
3782
3783 install_element(VIEW_NODE, &show_isis_spf_ietf_cmd);
3784
3785 install_element(VIEW_NODE, &show_isis_interface_cmd);
3786 install_element(VIEW_NODE, &show_isis_interface_detail_cmd);
3787 install_element(VIEW_NODE, &show_isis_interface_arg_cmd);
3788
3789 install_element(VIEW_NODE, &show_isis_neighbor_cmd);
3790 install_element(VIEW_NODE, &show_isis_neighbor_detail_cmd);
3791 install_element(VIEW_NODE, &show_isis_neighbor_arg_cmd);
3792 install_element(ENABLE_NODE, &clear_isis_neighbor_cmd);
3793 install_element(ENABLE_NODE, &clear_isis_neighbor_arg_cmd);
3794
3795 install_element(VIEW_NODE, &show_hostname_cmd);
3796 install_element(VIEW_NODE, &show_database_cmd);
3797
3798 install_element(ENABLE_NODE, &show_debugging_isis_cmd);
3799
3800 install_node(&debug_node);
3801
3802 install_element(ENABLE_NODE, &debug_isis_adj_cmd);
3803 install_element(ENABLE_NODE, &no_debug_isis_adj_cmd);
3804 install_element(ENABLE_NODE, &debug_isis_tx_queue_cmd);
3805 install_element(ENABLE_NODE, &no_debug_isis_tx_queue_cmd);
3806 install_element(ENABLE_NODE, &debug_isis_flooding_cmd);
3807 install_element(ENABLE_NODE, &no_debug_isis_flooding_cmd);
3808 install_element(ENABLE_NODE, &debug_isis_snp_cmd);
3809 install_element(ENABLE_NODE, &no_debug_isis_snp_cmd);
3810 install_element(ENABLE_NODE, &debug_isis_upd_cmd);
3811 install_element(ENABLE_NODE, &no_debug_isis_upd_cmd);
3812 install_element(ENABLE_NODE, &debug_isis_spfevents_cmd);
3813 install_element(ENABLE_NODE, &no_debug_isis_spfevents_cmd);
3814 install_element(ENABLE_NODE, &debug_isis_srevents_cmd);
3815 install_element(ENABLE_NODE, &no_debug_isis_srevents_cmd);
3816 install_element(ENABLE_NODE, &debug_isis_teevents_cmd);
3817 install_element(ENABLE_NODE, &no_debug_isis_teevents_cmd);
3818 install_element(ENABLE_NODE, &debug_isis_lfa_cmd);
3819 install_element(ENABLE_NODE, &no_debug_isis_lfa_cmd);
3820 install_element(ENABLE_NODE, &debug_isis_rtevents_cmd);
3821 install_element(ENABLE_NODE, &no_debug_isis_rtevents_cmd);
3822 install_element(ENABLE_NODE, &debug_isis_events_cmd);
3823 install_element(ENABLE_NODE, &no_debug_isis_events_cmd);
3824 install_element(ENABLE_NODE, &debug_isis_packet_dump_cmd);
3825 install_element(ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
3826 install_element(ENABLE_NODE, &debug_isis_lsp_gen_cmd);
3827 install_element(ENABLE_NODE, &no_debug_isis_lsp_gen_cmd);
3828 install_element(ENABLE_NODE, &debug_isis_lsp_sched_cmd);
3829 install_element(ENABLE_NODE, &no_debug_isis_lsp_sched_cmd);
3830 install_element(ENABLE_NODE, &debug_isis_bfd_cmd);
3831 install_element(ENABLE_NODE, &no_debug_isis_bfd_cmd);
3832 install_element(ENABLE_NODE, &debug_isis_ldp_sync_cmd);
3833 install_element(ENABLE_NODE, &no_debug_isis_ldp_sync_cmd);
3834
3835 install_element(CONFIG_NODE, &debug_isis_adj_cmd);
3836 install_element(CONFIG_NODE, &no_debug_isis_adj_cmd);
3837 install_element(CONFIG_NODE, &debug_isis_tx_queue_cmd);
3838 install_element(CONFIG_NODE, &no_debug_isis_tx_queue_cmd);
3839 install_element(CONFIG_NODE, &debug_isis_flooding_cmd);
3840 install_element(CONFIG_NODE, &no_debug_isis_flooding_cmd);
3841 install_element(CONFIG_NODE, &debug_isis_snp_cmd);
3842 install_element(CONFIG_NODE, &no_debug_isis_snp_cmd);
3843 install_element(CONFIG_NODE, &debug_isis_upd_cmd);
3844 install_element(CONFIG_NODE, &no_debug_isis_upd_cmd);
3845 install_element(CONFIG_NODE, &debug_isis_spfevents_cmd);
3846 install_element(CONFIG_NODE, &no_debug_isis_spfevents_cmd);
3847 install_element(CONFIG_NODE, &debug_isis_srevents_cmd);
3848 install_element(CONFIG_NODE, &no_debug_isis_srevents_cmd);
3849 install_element(CONFIG_NODE, &debug_isis_teevents_cmd);
3850 install_element(CONFIG_NODE, &no_debug_isis_teevents_cmd);
3851 install_element(CONFIG_NODE, &debug_isis_lfa_cmd);
3852 install_element(CONFIG_NODE, &no_debug_isis_lfa_cmd);
3853 install_element(CONFIG_NODE, &debug_isis_rtevents_cmd);
3854 install_element(CONFIG_NODE, &no_debug_isis_rtevents_cmd);
3855 install_element(CONFIG_NODE, &debug_isis_events_cmd);
3856 install_element(CONFIG_NODE, &no_debug_isis_events_cmd);
3857 install_element(CONFIG_NODE, &debug_isis_packet_dump_cmd);
3858 install_element(CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
3859 install_element(CONFIG_NODE, &debug_isis_lsp_gen_cmd);
3860 install_element(CONFIG_NODE, &no_debug_isis_lsp_gen_cmd);
3861 install_element(CONFIG_NODE, &debug_isis_lsp_sched_cmd);
3862 install_element(CONFIG_NODE, &no_debug_isis_lsp_sched_cmd);
3863 install_element(CONFIG_NODE, &debug_isis_bfd_cmd);
3864 install_element(CONFIG_NODE, &no_debug_isis_bfd_cmd);
3865 install_element(CONFIG_NODE, &debug_isis_ldp_sync_cmd);
3866 install_element(CONFIG_NODE, &no_debug_isis_ldp_sync_cmd);
3867
3868 install_default(ROUTER_NODE);
3869
3870 #ifdef FABRICD
3871 install_element(CONFIG_NODE, &router_openfabric_cmd);
3872 install_element(CONFIG_NODE, &no_router_openfabric_cmd);
3873
3874 install_element(ROUTER_NODE, &net_cmd);
3875 install_element(ROUTER_NODE, &no_net_cmd);
3876
3877 install_element(ROUTER_NODE, &isis_topology_cmd);
3878 install_element(ROUTER_NODE, &no_isis_topology_cmd);
3879
3880 install_element(ROUTER_NODE, &log_adj_changes_cmd);
3881 install_element(ROUTER_NODE, &no_log_adj_changes_cmd);
3882 #endif /* ifdef FABRICD */
3883
3884 spf_backoff_cmd_init();
3885 }