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