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