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