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