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