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