]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isisd.c
lib: enforce vrf_name_to_id by returning default_vrf when name is null
[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"
34#include "stream.h"
35#include "prefix.h"
36#include "table.h"
676a4ea3 37#include "qobj.h"
03f7e182 38#include "spf_backoff.h"
aaf2fd21 39#include "lib/northbound_cli.h"
eb5d44eb 40
41#include "isisd/dict.h"
eb5d44eb 42#include "isisd/isis_constants.h"
43#include "isisd/isis_common.h"
eb5d44eb 44#include "isisd/isis_flags.h"
3f045a08
JB
45#include "isisd/isis_circuit.h"
46#include "isisd/isis_csm.h"
eb5d44eb 47#include "isisd/isisd.h"
48#include "isisd/isis_dynhn.h"
49#include "isisd/isis_adjacency.h"
50#include "isisd/isis_pdu.h"
51#include "isisd/isis_misc.h"
52#include "isisd/isis_constants.h"
eb5d44eb 53#include "isisd/isis_lsp.h"
54#include "isisd/isis_spf.h"
55#include "isisd/isis_route.h"
56#include "isisd/isis_zebra.h"
57#include "isisd/isis_events.h"
f8c06e2c 58#include "isisd/isis_te.h"
064f4896 59#include "isisd/isis_mt.h"
8e6fb83b 60#include "isisd/fabricd.h"
eb5d44eb 61
eb5d44eb 62struct isis *isis = NULL;
eb5d44eb 63
676a4ea3
DL
64DEFINE_QOBJ_TYPE(isis)
65DEFINE_QOBJ_TYPE(isis_area)
66
41b36e90
PJ
67/*
68 * Prototypes.
69 */
41b36e90 70int isis_area_get(struct vty *, const char *);
3f045a08
JB
71int area_net_title(struct vty *, const char *);
72int area_clear_net_title(struct vty *, const char *);
73int show_isis_interface_common(struct vty *, const char *ifname, char);
74int show_isis_neighbor_common(struct vty *, const char *id, char);
75int clear_isis_neighbor_common(struct vty *, const char *id);
41b36e90
PJ
76int isis_config_write(struct vty *);
77
78
d62a17ae 79void isis_new(unsigned long process_id)
80{
81 isis = XCALLOC(MTYPE_ISIS, sizeof(struct isis));
82 /*
83 * Default values
84 */
85 isis->max_area_addrs = 3;
86 isis->process_id = process_id;
87 isis->router_id = 0;
88 isis->area_list = list_new();
89 isis->init_circ_list = list_new();
90 isis->uptime = time(NULL);
91 isis->nexthops = list_new();
92 isis->nexthops6 = list_new();
93 dyn_cache_init();
94 /*
95 * uncomment the next line for full debugs
96 */
97 /* isis->debugs = 0xFFFF; */
98 isisMplsTE.status = disable; /* Only support TE metric */
8e6fb83b 99
d62a17ae 100 QOBJ_REG(isis, isis);
101}
102
103struct isis_area *isis_area_create(const char *area_tag)
104{
105 struct isis_area *area;
106
107 area = XCALLOC(MTYPE_ISIS_AREA, sizeof(struct isis_area));
108
109 /*
65f18157
CF
110 * Fabricd runs only as level-2.
111 * For IS-IS, the first instance is level-1-2 rest are level-1,
112 * unless otherwise configured
d62a17ae 113 */
65f18157
CF
114 if (fabricd) {
115 area->is_type = IS_LEVEL_2;
cc50ddb2 116 } else if (listcount(isis->area_list) == 0)
d62a17ae 117 area->is_type = IS_LEVEL_1_AND_2;
cc50ddb2
EDP
118 else
119 area->is_type = yang_get_default_enum(
120 "/frr-isisd:isis/instance/is-type");
d62a17ae 121
122 /*
123 * intialize the databases
124 */
125 if (area->is_type & IS_LEVEL_1) {
126 area->lspdb[0] = lsp_db_init();
d62a17ae 127 }
128 if (area->is_type & IS_LEVEL_2) {
129 area->lspdb[1] = lsp_db_init();
d62a17ae 130 }
131
132 spftree_area_init(area);
133
134 area->circuit_list = list_new();
135 area->area_addrs = list_new();
136 thread_add_timer(master, lsp_tick, area, 1, &area->t_tick);
137 flags_initialize(&area->flags);
138
139 /*
140 * Default values
141 */
cc50ddb2
EDP
142#ifndef FABRICD
143 enum isis_metric_style default_style;
144
145 area->max_lsp_lifetime[0] = yang_get_default_uint16(
146 "/frr-isisd:isis/instance/lsp/maximum-lifetime/level-1");
147 area->max_lsp_lifetime[1] = yang_get_default_uint16(
148 "/frr-isisd:isis/instance/lsp/maximum-lifetime/level-2");
149 area->lsp_refresh[0] = yang_get_default_uint16(
150 "/frr-isisd:isis/instance/lsp/refresh-interval/level-1");
151 area->lsp_refresh[1] = yang_get_default_uint16(
152 "/frr-isisd:isis/instance/lsp/refresh-interval/level-2");
153 area->lsp_gen_interval[0] = yang_get_default_uint16(
154 "/frr-isisd:isis/instance/lsp/generation-interval/level-1");
155 area->lsp_gen_interval[1] = yang_get_default_uint16(
156 "/frr-isisd:isis/instance/lsp/generation-interval/level-2");
157 area->min_spf_interval[0] = yang_get_default_uint16(
158 "/frr-isisd:isis/instance/spf/minimum-interval/level-1");
159 area->min_spf_interval[1] = yang_get_default_uint16(
160 "/frr-isisd:isis/instance/spf/minimum-interval/level-1");
161 area->dynhostname = yang_get_default_bool(
162 "/frr-isisd:isis/instance/dynamic-hostname");
163 default_style =
164 yang_get_default_enum("/frr-isisd:isis/instance/metric-style");
165 area->oldmetric = default_style == ISIS_WIDE_METRIC ? 0 : 1;
166 area->newmetric = default_style == ISIS_NARROW_METRIC ? 0 : 1;
167 area->lsp_frag_threshold = 90; /* not currently configurable */
168 area->lsp_mtu =
169 yang_get_default_uint16("/frr-isisd:isis/instance/lsp/mtu");
170#else
d62a17ae 171 area->max_lsp_lifetime[0] = DEFAULT_LSP_LIFETIME; /* 1200 */
172 area->max_lsp_lifetime[1] = DEFAULT_LSP_LIFETIME; /* 1200 */
173 area->lsp_refresh[0] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
174 area->lsp_refresh[1] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
175 area->lsp_gen_interval[0] = DEFAULT_MIN_LSP_GEN_INTERVAL;
176 area->lsp_gen_interval[1] = DEFAULT_MIN_LSP_GEN_INTERVAL;
177 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
178 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
179 area->dynhostname = 1;
180 area->oldmetric = 0;
181 area->newmetric = 1;
182 area->lsp_frag_threshold = 90;
183 area->lsp_mtu = DEFAULT_LSP_MTU;
cc50ddb2 184#endif /* ifndef FABRICD */
d62a17ae 185
186 area_mt_init(area);
41b36e90 187
d62a17ae 188 area->area_tag = strdup(area_tag);
189 listnode_add(isis->area_list, area);
190 area->isis = isis;
f390d2c7 191
8e6fb83b 192 if (fabricd)
b30e837b 193 area->fabricd = fabricd_new(area);
9196731f
CF
194
195 area->lsp_refresh_arg[0].area = area;
196 area->lsp_refresh_arg[0].level = IS_LEVEL_1;
197 area->lsp_refresh_arg[1].area = area;
198 area->lsp_refresh_arg[1].level = IS_LEVEL_2;
199
200
d62a17ae 201 QOBJ_REG(area, isis_area);
eb5d44eb 202
d62a17ae 203 return area;
204}
3f045a08 205
d62a17ae 206struct isis_area *isis_area_lookup(const char *area_tag)
207{
208 struct isis_area *area;
209 struct listnode *node;
3f045a08 210
d62a17ae 211 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area))
212 if ((area->area_tag == NULL && area_tag == NULL)
213 || (area->area_tag && area_tag
214 && strcmp(area->area_tag, area_tag) == 0))
215 return area;
3f045a08 216
d62a17ae 217 return NULL;
218}
3f045a08 219
d62a17ae 220int isis_area_get(struct vty *vty, const char *area_tag)
221{
222 struct isis_area *area;
5475ecf7 223
d62a17ae 224 area = isis_area_lookup(area_tag);
03f7e182 225
d62a17ae 226 if (area) {
7c0cbd0e 227 VTY_PUSH_CONTEXT(ROUTER_NODE, area);
d62a17ae 228 return CMD_SUCCESS;
229 }
230
231 area = isis_area_create(area_tag);
3f045a08 232
d62a17ae 233 if (isis->debugs & DEBUG_EVENTS)
234 zlog_debug("New IS-IS area instance %s", area->area_tag);
3f045a08 235
7c0cbd0e 236 VTY_PUSH_CONTEXT(ROUTER_NODE, area);
f3ccedaa 237
d62a17ae 238 return CMD_SUCCESS;
239}
3f045a08 240
aaf2fd21 241int isis_area_destroy(const char *area_tag)
eb5d44eb 242{
d62a17ae 243 struct isis_area *area;
244 struct listnode *node, *nnode;
245 struct isis_circuit *circuit;
246 struct area_addr *addr;
eb5d44eb 247
d62a17ae 248 area = isis_area_lookup(area_tag);
249
250 if (area == NULL) {
aaf2fd21
EDP
251 zlog_warn("%s: could not find area with area-tag %s",
252 __func__, area_tag);
d62a17ae 253 return CMD_ERR_NO_MATCH;
254 }
255
256 QOBJ_UNREG(area);
257
b30e837b
CF
258 if (fabricd)
259 fabricd_finish(area->fabricd);
260
d62a17ae 261 if (area->circuit_list) {
262 for (ALL_LIST_ELEMENTS(area->circuit_list, node, nnode,
263 circuit)) {
264 circuit->ip_router = 0;
265 circuit->ipv6_router = 0;
266 isis_csm_state_change(ISIS_DISABLE, circuit, area);
267 }
6a154c88 268 list_delete(&area->circuit_list);
d62a17ae 269 }
270
271 if (area->lspdb[0] != NULL) {
272 lsp_db_destroy(area->lspdb[0]);
273 area->lspdb[0] = NULL;
274 }
275 if (area->lspdb[1] != NULL) {
276 lsp_db_destroy(area->lspdb[1]);
277 area->lspdb[1] = NULL;
278 }
279
3dace42d
CF
280 /* invalidate and verify to delete all routes from zebra */
281 isis_area_invalidate_routes(area, ISIS_LEVEL1 & ISIS_LEVEL2);
282 isis_area_verify_routes(area);
283
d62a17ae 284 spftree_area_del(area);
285
286 THREAD_TIMER_OFF(area->spf_timer[0]);
287 THREAD_TIMER_OFF(area->spf_timer[1]);
288
289 spf_backoff_free(area->spf_delay_ietf[0]);
290 spf_backoff_free(area->spf_delay_ietf[1]);
291
d62a17ae 292 isis_redist_area_finish(area);
293
294 for (ALL_LIST_ELEMENTS(area->area_addrs, node, nnode, addr)) {
295 list_delete_node(area->area_addrs, node);
296 XFREE(MTYPE_ISIS_AREA_ADDR, addr);
297 }
298 area->area_addrs = NULL;
299
300 THREAD_TIMER_OFF(area->t_tick);
301 THREAD_TIMER_OFF(area->t_lsp_refresh[0]);
302 THREAD_TIMER_OFF(area->t_lsp_refresh[1]);
303
304 thread_cancel_event(master, area);
305
306 listnode_delete(isis->area_list, area);
307
308 free(area->area_tag);
309
310 area_mt_finish(area);
311
312 XFREE(MTYPE_ISIS_AREA, area);
313
314 if (listcount(isis->area_list) == 0) {
315 memset(isis->sysid, 0, ISIS_SYS_ID_LEN);
316 isis->sysid_set = 0;
317 }
318
319 return CMD_SUCCESS;
320}
321
22af6a80 322#ifdef FABRICD
d62a17ae 323static void area_set_mt_enabled(struct isis_area *area, uint16_t mtid,
324 bool enabled)
325{
326 struct isis_area_mt_setting *setting;
327
328 setting = area_get_mt_setting(area, mtid);
329 if (setting->enabled != enabled) {
330 setting->enabled = enabled;
331 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
332 }
333}
334
335static void area_set_mt_overload(struct isis_area *area, uint16_t mtid,
336 bool overload)
337{
338 struct isis_area_mt_setting *setting;
339
340 setting = area_get_mt_setting(area, mtid);
341 if (setting->overload != overload) {
342 setting->overload = overload;
343 if (setting->enabled)
344 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2,
345 0);
346 }
347}
22af6a80 348#endif /* ifdef FABRICD */
d62a17ae 349
350int area_net_title(struct vty *vty, const char *net_title)
351{
352 VTY_DECLVAR_CONTEXT(isis_area, area);
353 struct area_addr *addr;
354 struct area_addr *addrp;
355 struct listnode *node;
eb5d44eb 356
d7c0a89a 357 uint8_t buff[255];
d62a17ae 358
359 /* We check that we are not over the maximal number of addresses */
360 if (listcount(area->area_addrs) >= isis->max_area_addrs) {
361 vty_out(vty,
362 "Maximum of area addresses (%d) already reached \n",
363 isis->max_area_addrs);
364 return CMD_ERR_NOTHING_TODO;
365 }
366
367 addr = XMALLOC(MTYPE_ISIS_AREA_ADDR, sizeof(struct area_addr));
368 addr->addr_len = dotformat2buff(buff, net_title);
369 memcpy(addr->area_addr, buff, addr->addr_len);
eb5d44eb 370#ifdef EXTREME_DEBUG
d62a17ae 371 zlog_debug("added area address %s for area %s (address length %d)",
372 net_title, area->area_tag, addr->addr_len);
eb5d44eb 373#endif /* EXTREME_DEBUG */
d62a17ae 374 if (addr->addr_len < 8 || addr->addr_len > 20) {
375 vty_out(vty,
376 "area address must be at least 8..20 octets long (%d)\n",
377 addr->addr_len);
378 XFREE(MTYPE_ISIS_AREA_ADDR, addr);
a5fdb4c5 379 return CMD_WARNING_CONFIG_FAILED;
d62a17ae 380 }
381
382 if (addr->area_addr[addr->addr_len - 1] != 0) {
383 vty_out(vty,
384 "nsel byte (last byte) in area address must be 0\n");
385 XFREE(MTYPE_ISIS_AREA_ADDR, addr);
a5fdb4c5 386 return CMD_WARNING_CONFIG_FAILED;
d62a17ae 387 }
388
389 if (isis->sysid_set == 0) {
390 /*
391 * First area address - get the SystemID for this router
392 */
393 memcpy(isis->sysid, GETSYSID(addr), ISIS_SYS_ID_LEN);
394 isis->sysid_set = 1;
395 if (isis->debugs & DEBUG_EVENTS)
396 zlog_debug("Router has SystemID %s",
397 sysid_print(isis->sysid));
398 } else {
399 /*
400 * Check that the SystemID portions match
401 */
402 if (memcmp(isis->sysid, GETSYSID(addr), ISIS_SYS_ID_LEN)) {
403 vty_out(vty,
404 "System ID must not change when defining additional area addresses\n");
405 XFREE(MTYPE_ISIS_AREA_ADDR, addr);
a5fdb4c5 406 return CMD_WARNING_CONFIG_FAILED;
d62a17ae 407 }
408
409 /* now we see that we don't already have this address */
410 for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) {
411 if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN)
412 != (addr->addr_len))
413 continue;
414 if (!memcmp(addrp->area_addr, addr->area_addr,
415 addr->addr_len)) {
416 XFREE(MTYPE_ISIS_AREA_ADDR, addr);
417 return CMD_SUCCESS; /* silent fail */
418 }
419 }
420 }
421
422 /*
423 * Forget the systemID part of the address
424 */
425 addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN);
426 listnode_add(area->area_addrs, addr);
427
428 /* only now we can safely generate our LSPs for this area */
429 if (listcount(area->area_addrs) > 0) {
430 if (area->is_type & IS_LEVEL_1)
431 lsp_generate(area, IS_LEVEL_1);
432 if (area->is_type & IS_LEVEL_2)
433 lsp_generate(area, IS_LEVEL_2);
434 }
435
436 return CMD_SUCCESS;
437}
438
439int area_clear_net_title(struct vty *vty, const char *net_title)
440{
441 VTY_DECLVAR_CONTEXT(isis_area, area);
442 struct area_addr addr, *addrp = NULL;
443 struct listnode *node;
d7c0a89a 444 uint8_t buff[255];
d62a17ae 445
446 addr.addr_len = dotformat2buff(buff, net_title);
447 if (addr.addr_len < 8 || addr.addr_len > 20) {
448 vty_out(vty,
449 "Unsupported area address length %d, should be 8...20 \n",
450 addr.addr_len);
a5fdb4c5 451 return CMD_WARNING_CONFIG_FAILED;
d62a17ae 452 }
453
454 memcpy(addr.area_addr, buff, (int)addr.addr_len);
455
456 for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp))
457 if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len
458 && !memcmp(addrp->area_addr, addr.area_addr, addr.addr_len))
459 break;
460
461 if (!addrp) {
462 vty_out(vty, "No area address %s for area %s \n", net_title,
463 area->area_tag);
464 return CMD_ERR_NO_MATCH;
465 }
466
467 listnode_delete(area->area_addrs, addrp);
468 XFREE(MTYPE_ISIS_AREA_ADDR, addrp);
469
470 /*
471 * Last area address - reset the SystemID for this router
472 */
473 if (listcount(area->area_addrs) == 0) {
474 memset(isis->sysid, 0, ISIS_SYS_ID_LEN);
475 isis->sysid_set = 0;
476 if (isis->debugs & DEBUG_EVENTS)
477 zlog_debug("Router has no SystemID");
478 }
479
480 return CMD_SUCCESS;
eb5d44eb 481}
482
eb5d44eb 483/*
3f045a08 484 * 'show isis interface' command
eb5d44eb 485 */
486
d62a17ae 487int show_isis_interface_common(struct vty *vty, const char *ifname, char detail)
eb5d44eb 488{
d62a17ae 489 struct listnode *anode, *cnode;
490 struct isis_area *area;
491 struct isis_circuit *circuit;
eb5d44eb 492
d62a17ae 493 if (!isis) {
494 vty_out(vty, "IS-IS Routing Process not enabled\n");
495 return CMD_SUCCESS;
496 }
eb5d44eb 497
d62a17ae 498 for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
499 vty_out(vty, "Area %s:\n", area->area_tag);
f390d2c7 500
d62a17ae 501 if (detail == ISIS_UI_LEVEL_BRIEF)
502 vty_out(vty,
503 " Interface CircId State Type Level\n");
f390d2c7 504
d62a17ae 505 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit))
506 if (!ifname)
507 isis_circuit_print_vty(circuit, vty, detail);
508 else if (strcmp(circuit->interface->name, ifname) == 0)
509 isis_circuit_print_vty(circuit, vty, detail);
510 }
f390d2c7 511
d62a17ae 512 return CMD_SUCCESS;
eb5d44eb 513}
514
3f045a08
JB
515DEFUN (show_isis_interface,
516 show_isis_interface_cmd,
7c0cbd0e 517 "show " PROTO_NAME " interface",
eb5d44eb 518 SHOW_STR
7c0cbd0e 519 PROTO_HELP
3f045a08 520 "ISIS interface\n")
eb5d44eb 521{
d62a17ae 522 return show_isis_interface_common(vty, NULL, ISIS_UI_LEVEL_BRIEF);
eb5d44eb 523}
524
3f045a08
JB
525DEFUN (show_isis_interface_detail,
526 show_isis_interface_detail_cmd,
7c0cbd0e 527 "show " PROTO_NAME " interface detail",
eb5d44eb 528 SHOW_STR
7c0cbd0e 529 PROTO_HELP
3f045a08
JB
530 "ISIS interface\n"
531 "show detailed information\n")
532{
d62a17ae 533 return show_isis_interface_common(vty, NULL, ISIS_UI_LEVEL_DETAIL);
3f045a08 534}
eb5d44eb 535
3f045a08
JB
536DEFUN (show_isis_interface_arg,
537 show_isis_interface_arg_cmd,
7c0cbd0e 538 "show " PROTO_NAME " interface WORD",
eb5d44eb 539 SHOW_STR
7c0cbd0e 540 PROTO_HELP
3f045a08
JB
541 "ISIS interface\n"
542 "ISIS interface name\n")
543{
d62a17ae 544 int idx_word = 3;
545 return show_isis_interface_common(vty, argv[idx_word]->arg,
546 ISIS_UI_LEVEL_DETAIL);
3f045a08
JB
547}
548
549/*
550 * 'show isis neighbor' command
551 */
552
d62a17ae 553int show_isis_neighbor_common(struct vty *vty, const char *id, char detail)
554{
555 struct listnode *anode, *cnode, *node;
556 struct isis_area *area;
557 struct isis_circuit *circuit;
558 struct list *adjdb;
559 struct isis_adjacency *adj;
560 struct isis_dynhn *dynhn;
d7c0a89a 561 uint8_t sysid[ISIS_SYS_ID_LEN];
d62a17ae 562 int i;
563
564 if (!isis) {
565 vty_out(vty, "IS-IS Routing Process not enabled\n");
566 return CMD_SUCCESS;
567 }
568
569 memset(sysid, 0, ISIS_SYS_ID_LEN);
570 if (id) {
571 if (sysid2buff(sysid, id) == 0) {
572 dynhn = dynhn_find_by_name(id);
573 if (dynhn == NULL) {
574 vty_out(vty, "Invalid system id %s\n", id);
575 return CMD_SUCCESS;
576 }
577 memcpy(sysid, dynhn->id, ISIS_SYS_ID_LEN);
578 }
579 }
580
581 for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
582 vty_out(vty, "Area %s:\n", area->area_tag);
583
584 if (detail == ISIS_UI_LEVEL_BRIEF)
585 vty_out(vty,
586 " System Id Interface L State Holdtime SNPA\n");
587
588 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) {
589 if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
590 for (i = 0; i < 2; i++) {
591 adjdb = circuit->u.bc.adjdb[i];
592 if (adjdb && adjdb->count) {
593 for (ALL_LIST_ELEMENTS_RO(
594 adjdb, node, adj))
595 if (!id
596 || !memcmp(adj->sysid,
597 sysid,
598 ISIS_SYS_ID_LEN))
599 isis_adj_print_vty(
600 adj,
601 vty,
602 detail);
603 }
604 }
605 } else if (circuit->circ_type == CIRCUIT_T_P2P
606 && circuit->u.p2p.neighbor) {
607 adj = circuit->u.p2p.neighbor;
608 if (!id
609 || !memcmp(adj->sysid, sysid,
610 ISIS_SYS_ID_LEN))
611 isis_adj_print_vty(adj, vty, detail);
612 }
613 }
614 }
615
616 return CMD_SUCCESS;
3f045a08
JB
617}
618
619/*
620 * 'clear isis neighbor' command
621 */
d62a17ae 622int clear_isis_neighbor_common(struct vty *vty, const char *id)
623{
624 struct listnode *anode, *cnode, *cnextnode, *node, *nnode;
625 struct isis_area *area;
626 struct isis_circuit *circuit;
627 struct list *adjdb;
628 struct isis_adjacency *adj;
629 struct isis_dynhn *dynhn;
d7c0a89a 630 uint8_t sysid[ISIS_SYS_ID_LEN];
d62a17ae 631 int i;
632
633 if (!isis) {
634 vty_out(vty, "IS-IS Routing Process not enabled\n");
635 return CMD_SUCCESS;
636 }
637
638 memset(sysid, 0, ISIS_SYS_ID_LEN);
639 if (id) {
640 if (sysid2buff(sysid, id) == 0) {
641 dynhn = dynhn_find_by_name(id);
642 if (dynhn == NULL) {
643 vty_out(vty, "Invalid system id %s\n", id);
644 return CMD_SUCCESS;
645 }
646 memcpy(sysid, dynhn->id, ISIS_SYS_ID_LEN);
647 }
648 }
649
650 for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
651 for (ALL_LIST_ELEMENTS(area->circuit_list, cnode, cnextnode,
652 circuit)) {
653 if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
654 for (i = 0; i < 2; i++) {
655 adjdb = circuit->u.bc.adjdb[i];
656 if (adjdb && adjdb->count) {
657 for (ALL_LIST_ELEMENTS(
658 adjdb, node, nnode,
659 adj))
660 if (!id
661 || !memcmp(adj->sysid,
662 sysid,
663 ISIS_SYS_ID_LEN))
664 isis_adj_state_change(
665 adj,
666 ISIS_ADJ_DOWN,
667 "clear user request");
668 }
669 }
670 } else if (circuit->circ_type == CIRCUIT_T_P2P
671 && circuit->u.p2p.neighbor) {
672 adj = circuit->u.p2p.neighbor;
673 if (!id
674 || !memcmp(adj->sysid, sysid,
675 ISIS_SYS_ID_LEN))
676 isis_adj_state_change(
677 adj, ISIS_ADJ_DOWN,
678 "clear user request");
679 }
680 }
681 }
682
683 return CMD_SUCCESS;
3f045a08
JB
684}
685
686DEFUN (show_isis_neighbor,
687 show_isis_neighbor_cmd,
7c0cbd0e 688 "show " PROTO_NAME " neighbor",
3f045a08 689 SHOW_STR
7c0cbd0e 690 PROTO_HELP
3f045a08 691 "ISIS neighbor adjacencies\n")
eb5d44eb 692{
d62a17ae 693 return show_isis_neighbor_common(vty, NULL, ISIS_UI_LEVEL_BRIEF);
eb5d44eb 694}
695
3f045a08
JB
696DEFUN (show_isis_neighbor_detail,
697 show_isis_neighbor_detail_cmd,
7c0cbd0e 698 "show " PROTO_NAME " neighbor detail",
eb5d44eb 699 SHOW_STR
7c0cbd0e 700 PROTO_HELP
3f045a08 701 "ISIS neighbor adjacencies\n"
eb5d44eb 702 "show detailed information\n")
3f045a08 703{
d62a17ae 704 return show_isis_neighbor_common(vty, NULL, ISIS_UI_LEVEL_DETAIL);
3f045a08
JB
705}
706
707DEFUN (show_isis_neighbor_arg,
708 show_isis_neighbor_arg_cmd,
7c0cbd0e 709 "show " PROTO_NAME " neighbor WORD",
3f045a08 710 SHOW_STR
7c0cbd0e 711 PROTO_HELP
3f045a08
JB
712 "ISIS neighbor adjacencies\n"
713 "System id\n")
714{
d62a17ae 715 int idx_word = 3;
716 return show_isis_neighbor_common(vty, argv[idx_word]->arg,
717 ISIS_UI_LEVEL_DETAIL);
3f045a08
JB
718}
719
720DEFUN (clear_isis_neighbor,
721 clear_isis_neighbor_cmd,
7c0cbd0e 722 "clear " PROTO_NAME " neighbor",
3f045a08 723 CLEAR_STR
7c0cbd0e
CF
724 PROTO_HELP
725 "ISIS neighbor adjacencies\n")
3f045a08 726{
d62a17ae 727 return clear_isis_neighbor_common(vty, NULL);
3f045a08
JB
728}
729
730DEFUN (clear_isis_neighbor_arg,
731 clear_isis_neighbor_arg_cmd,
7c0cbd0e 732 "clear " PROTO_NAME " neighbor WORD",
3f045a08 733 CLEAR_STR
7c0cbd0e 734 PROTO_HELP
3f045a08
JB
735 "ISIS neighbor adjacencies\n"
736 "System id\n")
737{
d62a17ae 738 int idx_word = 3;
739 return clear_isis_neighbor_common(vty, argv[idx_word]->arg);
3f045a08
JB
740}
741
eb5d44eb 742/*
743 * 'isis debug', 'show debugging'
744 */
d62a17ae 745void print_debug(struct vty *vty, int flags, int onoff)
746{
747 char onoffs[4];
748 if (onoff)
749 strcpy(onoffs, "on");
750 else
751 strcpy(onoffs, "off");
752
753 if (flags & DEBUG_ADJ_PACKETS)
754 vty_out(vty,
755 "IS-IS Adjacency related packets debugging is %s\n",
756 onoffs);
161fa356
CF
757 if (flags & DEBUG_TX_QUEUE)
758 vty_out(vty, "IS-IS TX queue debugging is %s\n",
759 onoffs);
d62a17ae 760 if (flags & DEBUG_SNP_PACKETS)
761 vty_out(vty, "IS-IS CSNP/PSNP packets debugging is %s\n",
762 onoffs);
763 if (flags & DEBUG_SPF_EVENTS)
764 vty_out(vty, "IS-IS SPF events debugging is %s\n", onoffs);
d62a17ae 765 if (flags & DEBUG_UPDATE_PACKETS)
766 vty_out(vty, "IS-IS Update related packet debugging is %s\n",
767 onoffs);
768 if (flags & DEBUG_RTE_EVENTS)
769 vty_out(vty, "IS-IS Route related debuggin is %s\n", onoffs);
770 if (flags & DEBUG_EVENTS)
771 vty_out(vty, "IS-IS Event debugging is %s\n", onoffs);
772 if (flags & DEBUG_PACKET_DUMP)
773 vty_out(vty, "IS-IS Packet dump debugging is %s\n", onoffs);
774 if (flags & DEBUG_LSP_GEN)
775 vty_out(vty, "IS-IS LSP generation debugging is %s\n", onoffs);
776 if (flags & DEBUG_LSP_SCHED)
777 vty_out(vty, "IS-IS LSP scheduling debugging is %s\n", onoffs);
ddb33326
CF
778 if (flags & DEBUG_FLOODING)
779 vty_out(vty, "IS-IS Flooding debugging is %s\n", onoffs);
2815f817
CF
780 if (flags & DEBUG_BFD)
781 vty_out(vty, "IS-IS BFD debugging is %s\n", onoffs);
eb5d44eb 782}
783
87f6dc50
DS
784DEFUN_NOSH (show_debugging,
785 show_debugging_isis_cmd,
7c0cbd0e 786 "show debugging [" PROTO_NAME "]",
87f6dc50
DS
787 SHOW_STR
788 "State of each debugging option\n"
7c0cbd0e 789 PROTO_HELP)
eb5d44eb 790{
7c0cbd0e 791 vty_out(vty, PROTO_NAME " debugging status:\n");
87f6dc50
DS
792
793 if (isis->debugs)
d62a17ae 794 print_debug(vty, isis->debugs, 1);
87f6dc50 795
d62a17ae 796 return CMD_SUCCESS;
eb5d44eb 797}
798
9e867fe6 799/* Debug node. */
d62a17ae 800static struct cmd_node debug_node = {DEBUG_NODE, "", 1};
801
802static int config_write_debug(struct vty *vty)
803{
804 int write = 0;
805 int flags = isis->debugs;
806
807 if (flags & DEBUG_ADJ_PACKETS) {
7c0cbd0e 808 vty_out(vty, "debug " PROTO_NAME " adj-packets\n");
d62a17ae 809 write++;
810 }
161fa356
CF
811 if (flags & DEBUG_TX_QUEUE) {
812 vty_out(vty, "debug " PROTO_NAME " tx-queue\n");
813 write++;
814 }
d62a17ae 815 if (flags & DEBUG_SNP_PACKETS) {
7c0cbd0e 816 vty_out(vty, "debug " PROTO_NAME " snp-packets\n");
d62a17ae 817 write++;
818 }
819 if (flags & DEBUG_SPF_EVENTS) {
7c0cbd0e 820 vty_out(vty, "debug " PROTO_NAME " spf-events\n");
d62a17ae 821 write++;
822 }
d62a17ae 823 if (flags & DEBUG_UPDATE_PACKETS) {
7c0cbd0e 824 vty_out(vty, "debug " PROTO_NAME " update-packets\n");
d62a17ae 825 write++;
826 }
827 if (flags & DEBUG_RTE_EVENTS) {
7c0cbd0e 828 vty_out(vty, "debug " PROTO_NAME " route-events\n");
d62a17ae 829 write++;
830 }
831 if (flags & DEBUG_EVENTS) {
7c0cbd0e 832 vty_out(vty, "debug " PROTO_NAME " events\n");
d62a17ae 833 write++;
834 }
835 if (flags & DEBUG_PACKET_DUMP) {
7c0cbd0e 836 vty_out(vty, "debug " PROTO_NAME " packet-dump\n");
d62a17ae 837 write++;
838 }
839 if (flags & DEBUG_LSP_GEN) {
7c0cbd0e 840 vty_out(vty, "debug " PROTO_NAME " lsp-gen\n");
d62a17ae 841 write++;
842 }
843 if (flags & DEBUG_LSP_SCHED) {
7c0cbd0e 844 vty_out(vty, "debug " PROTO_NAME " lsp-sched\n");
d62a17ae 845 write++;
846 }
ddb33326 847 if (flags & DEBUG_FLOODING) {
d4cff91a
CF
848 vty_out(vty, "debug " PROTO_NAME " flooding\n");
849 write++;
850 }
2815f817
CF
851 if (flags & DEBUG_BFD) {
852 vty_out(vty, "debug " PROTO_NAME " bfd\n");
853 write++;
854 }
d62a17ae 855 write += spf_backoff_write_config(vty);
856
857 return write;
9e867fe6 858}
859
eb5d44eb 860DEFUN (debug_isis_adj,
861 debug_isis_adj_cmd,
7c0cbd0e 862 "debug " PROTO_NAME " adj-packets",
eb5d44eb 863 DEBUG_STR
7c0cbd0e 864 PROTO_HELP
f390d2c7 865 "IS-IS Adjacency related packets\n")
eb5d44eb 866{
d62a17ae 867 isis->debugs |= DEBUG_ADJ_PACKETS;
868 print_debug(vty, DEBUG_ADJ_PACKETS, 1);
eb5d44eb 869
d62a17ae 870 return CMD_SUCCESS;
eb5d44eb 871}
872
873DEFUN (no_debug_isis_adj,
874 no_debug_isis_adj_cmd,
7c0cbd0e 875 "no debug " PROTO_NAME " adj-packets",
16cedbb0 876 NO_STR
eb5d44eb 877 UNDEBUG_STR
7c0cbd0e 878 PROTO_HELP
f390d2c7 879 "IS-IS Adjacency related packets\n")
eb5d44eb 880{
d62a17ae 881 isis->debugs &= ~DEBUG_ADJ_PACKETS;
882 print_debug(vty, DEBUG_ADJ_PACKETS, 0);
eb5d44eb 883
d62a17ae 884 return CMD_SUCCESS;
eb5d44eb 885}
886
161fa356
CF
887DEFUN (debug_isis_tx_queue,
888 debug_isis_tx_queue_cmd,
889 "debug " PROTO_NAME " tx-queue",
890 DEBUG_STR
891 PROTO_HELP
892 "IS-IS TX queues\n")
893{
894 isis->debugs |= DEBUG_TX_QUEUE;
895 print_debug(vty, DEBUG_TX_QUEUE, 1);
896
897 return CMD_SUCCESS;
898}
899
900DEFUN (no_debug_isis_tx_queue,
901 no_debug_isis_tx_queue_cmd,
902 "no debug " PROTO_NAME " tx-queue",
903 NO_STR
904 UNDEBUG_STR
905 PROTO_HELP
906 "IS-IS TX queues\n")
907{
908 isis->debugs &= ~DEBUG_TX_QUEUE;
909 print_debug(vty, DEBUG_TX_QUEUE, 0);
910
911 return CMD_SUCCESS;
912}
913
ddb33326
CF
914DEFUN (debug_isis_flooding,
915 debug_isis_flooding_cmd,
916 "debug " PROTO_NAME " flooding",
917 DEBUG_STR
918 PROTO_HELP
919 "Flooding algorithm\n")
920{
921 isis->debugs |= DEBUG_FLOODING;
922 print_debug(vty, DEBUG_FLOODING, 1);
923
924 return CMD_SUCCESS;
925}
926
927DEFUN (no_debug_isis_flooding,
928 no_debug_isis_flooding_cmd,
929 "no debug " PROTO_NAME " flooding",
930 NO_STR
931 UNDEBUG_STR
932 PROTO_HELP
933 "Flooding algorithm\n")
934{
935 isis->debugs &= ~DEBUG_FLOODING;
936 print_debug(vty, DEBUG_FLOODING, 0);
937
938 return CMD_SUCCESS;
939}
940
eb5d44eb 941DEFUN (debug_isis_snp,
942 debug_isis_snp_cmd,
7c0cbd0e 943 "debug " PROTO_NAME " snp-packets",
eb5d44eb 944 DEBUG_STR
7c0cbd0e 945 PROTO_HELP
f390d2c7 946 "IS-IS CSNP/PSNP packets\n")
eb5d44eb 947{
d62a17ae 948 isis->debugs |= DEBUG_SNP_PACKETS;
949 print_debug(vty, DEBUG_SNP_PACKETS, 1);
eb5d44eb 950
d62a17ae 951 return CMD_SUCCESS;
eb5d44eb 952}
953
954DEFUN (no_debug_isis_snp,
955 no_debug_isis_snp_cmd,
7c0cbd0e 956 "no debug " PROTO_NAME " snp-packets",
16cedbb0 957 NO_STR
eb5d44eb 958 UNDEBUG_STR
7c0cbd0e 959 PROTO_HELP
f390d2c7 960 "IS-IS CSNP/PSNP packets\n")
eb5d44eb 961{
d62a17ae 962 isis->debugs &= ~DEBUG_SNP_PACKETS;
963 print_debug(vty, DEBUG_SNP_PACKETS, 0);
f390d2c7 964
d62a17ae 965 return CMD_SUCCESS;
eb5d44eb 966}
967
eb5d44eb 968DEFUN (debug_isis_upd,
969 debug_isis_upd_cmd,
7c0cbd0e 970 "debug " PROTO_NAME " update-packets",
eb5d44eb 971 DEBUG_STR
7c0cbd0e 972 PROTO_HELP
f390d2c7 973 "IS-IS Update related packets\n")
eb5d44eb 974{
d62a17ae 975 isis->debugs |= DEBUG_UPDATE_PACKETS;
976 print_debug(vty, DEBUG_UPDATE_PACKETS, 1);
eb5d44eb 977
d62a17ae 978 return CMD_SUCCESS;
eb5d44eb 979}
980
981DEFUN (no_debug_isis_upd,
982 no_debug_isis_upd_cmd,
7c0cbd0e 983 "no debug " PROTO_NAME " update-packets",
16cedbb0 984 NO_STR
eb5d44eb 985 UNDEBUG_STR
7c0cbd0e 986 PROTO_HELP
f390d2c7 987 "IS-IS Update related packets\n")
eb5d44eb 988{
d62a17ae 989 isis->debugs &= ~DEBUG_UPDATE_PACKETS;
990 print_debug(vty, DEBUG_UPDATE_PACKETS, 0);
f390d2c7 991
d62a17ae 992 return CMD_SUCCESS;
eb5d44eb 993}
994
eb5d44eb 995DEFUN (debug_isis_spfevents,
996 debug_isis_spfevents_cmd,
7c0cbd0e 997 "debug " PROTO_NAME " spf-events",
eb5d44eb 998 DEBUG_STR
7c0cbd0e 999 PROTO_HELP
f390d2c7 1000 "IS-IS Shortest Path First Events\n")
eb5d44eb 1001{
d62a17ae 1002 isis->debugs |= DEBUG_SPF_EVENTS;
1003 print_debug(vty, DEBUG_SPF_EVENTS, 1);
eb5d44eb 1004
d62a17ae 1005 return CMD_SUCCESS;
eb5d44eb 1006}
1007
1008DEFUN (no_debug_isis_spfevents,
1009 no_debug_isis_spfevents_cmd,
7c0cbd0e 1010 "no debug " PROTO_NAME " spf-events",
16cedbb0 1011 NO_STR
eb5d44eb 1012 UNDEBUG_STR
7c0cbd0e 1013 PROTO_HELP
f390d2c7 1014 "IS-IS Shortest Path First Events\n")
eb5d44eb 1015{
d62a17ae 1016 isis->debugs &= ~DEBUG_SPF_EVENTS;
1017 print_debug(vty, DEBUG_SPF_EVENTS, 0);
f390d2c7 1018
d62a17ae 1019 return CMD_SUCCESS;
eb5d44eb 1020}
1021
eb5d44eb 1022DEFUN (debug_isis_rtevents,
1023 debug_isis_rtevents_cmd,
7c0cbd0e 1024 "debug " PROTO_NAME " route-events",
eb5d44eb 1025 DEBUG_STR
7c0cbd0e 1026 PROTO_HELP
f390d2c7 1027 "IS-IS Route related events\n")
eb5d44eb 1028{
d62a17ae 1029 isis->debugs |= DEBUG_RTE_EVENTS;
1030 print_debug(vty, DEBUG_RTE_EVENTS, 1);
eb5d44eb 1031
d62a17ae 1032 return CMD_SUCCESS;
eb5d44eb 1033}
1034
1035DEFUN (no_debug_isis_rtevents,
1036 no_debug_isis_rtevents_cmd,
7c0cbd0e 1037 "no debug " PROTO_NAME " route-events",
16cedbb0 1038 NO_STR
eb5d44eb 1039 UNDEBUG_STR
7c0cbd0e 1040 PROTO_HELP
f390d2c7 1041 "IS-IS Route related events\n")
eb5d44eb 1042{
d62a17ae 1043 isis->debugs &= ~DEBUG_RTE_EVENTS;
1044 print_debug(vty, DEBUG_RTE_EVENTS, 0);
f390d2c7 1045
d62a17ae 1046 return CMD_SUCCESS;
eb5d44eb 1047}
1048
1049DEFUN (debug_isis_events,
1050 debug_isis_events_cmd,
7c0cbd0e 1051 "debug " PROTO_NAME " events",
eb5d44eb 1052 DEBUG_STR
7c0cbd0e 1053 PROTO_HELP
f1082d19 1054 "IS-IS Events\n")
eb5d44eb 1055{
d62a17ae 1056 isis->debugs |= DEBUG_EVENTS;
1057 print_debug(vty, DEBUG_EVENTS, 1);
eb5d44eb 1058
d62a17ae 1059 return CMD_SUCCESS;
eb5d44eb 1060}
1061
1062DEFUN (no_debug_isis_events,
1063 no_debug_isis_events_cmd,
7c0cbd0e 1064 "no debug " PROTO_NAME " events",
16cedbb0 1065 NO_STR
eb5d44eb 1066 UNDEBUG_STR
7c0cbd0e 1067 PROTO_HELP
f390d2c7 1068 "IS-IS Events\n")
eb5d44eb 1069{
d62a17ae 1070 isis->debugs &= ~DEBUG_EVENTS;
1071 print_debug(vty, DEBUG_EVENTS, 0);
f390d2c7 1072
d62a17ae 1073 return CMD_SUCCESS;
eb5d44eb 1074}
1075
3f045a08
JB
1076DEFUN (debug_isis_packet_dump,
1077 debug_isis_packet_dump_cmd,
7c0cbd0e 1078 "debug " PROTO_NAME " packet-dump",
3f045a08 1079 DEBUG_STR
7c0cbd0e 1080 PROTO_HELP
3f045a08
JB
1081 "IS-IS packet dump\n")
1082{
d62a17ae 1083 isis->debugs |= DEBUG_PACKET_DUMP;
1084 print_debug(vty, DEBUG_PACKET_DUMP, 1);
3f045a08 1085
d62a17ae 1086 return CMD_SUCCESS;
3f045a08
JB
1087}
1088
1089DEFUN (no_debug_isis_packet_dump,
1090 no_debug_isis_packet_dump_cmd,
7c0cbd0e 1091 "no debug " PROTO_NAME " packet-dump",
16cedbb0 1092 NO_STR
3f045a08 1093 UNDEBUG_STR
7c0cbd0e 1094 PROTO_HELP
3f045a08
JB
1095 "IS-IS packet dump\n")
1096{
d62a17ae 1097 isis->debugs &= ~DEBUG_PACKET_DUMP;
1098 print_debug(vty, DEBUG_PACKET_DUMP, 0);
3f045a08 1099
d62a17ae 1100 return CMD_SUCCESS;
3f045a08
JB
1101}
1102
14872644
CF
1103DEFUN (debug_isis_lsp_gen,
1104 debug_isis_lsp_gen_cmd,
7c0cbd0e 1105 "debug " PROTO_NAME " lsp-gen",
14872644 1106 DEBUG_STR
7c0cbd0e 1107 PROTO_HELP
14872644
CF
1108 "IS-IS generation of own LSPs\n")
1109{
d62a17ae 1110 isis->debugs |= DEBUG_LSP_GEN;
1111 print_debug(vty, DEBUG_LSP_GEN, 1);
14872644 1112
d62a17ae 1113 return CMD_SUCCESS;
14872644
CF
1114}
1115
1116DEFUN (no_debug_isis_lsp_gen,
1117 no_debug_isis_lsp_gen_cmd,
7c0cbd0e 1118 "no debug " PROTO_NAME " lsp-gen",
16cedbb0 1119 NO_STR
14872644 1120 UNDEBUG_STR
7c0cbd0e 1121 PROTO_HELP
14872644
CF
1122 "IS-IS generation of own LSPs\n")
1123{
d62a17ae 1124 isis->debugs &= ~DEBUG_LSP_GEN;
1125 print_debug(vty, DEBUG_LSP_GEN, 0);
14872644 1126
d62a17ae 1127 return CMD_SUCCESS;
14872644
CF
1128}
1129
414766a1
CF
1130DEFUN (debug_isis_lsp_sched,
1131 debug_isis_lsp_sched_cmd,
7c0cbd0e 1132 "debug " PROTO_NAME " lsp-sched",
414766a1 1133 DEBUG_STR
7c0cbd0e 1134 PROTO_HELP
414766a1
CF
1135 "IS-IS scheduling of LSP generation\n")
1136{
d62a17ae 1137 isis->debugs |= DEBUG_LSP_SCHED;
1138 print_debug(vty, DEBUG_LSP_SCHED, 1);
414766a1 1139
d62a17ae 1140 return CMD_SUCCESS;
414766a1
CF
1141}
1142
49d41a26
DS
1143DEFUN (no_debug_isis_lsp_sched,
1144 no_debug_isis_lsp_sched_cmd,
7c0cbd0e 1145 "no debug " PROTO_NAME " lsp-sched",
16cedbb0 1146 NO_STR
49d41a26 1147 UNDEBUG_STR
7c0cbd0e 1148 PROTO_HELP
49d41a26
DS
1149 "IS-IS scheduling of LSP generation\n")
1150{
d62a17ae 1151 isis->debugs &= ~DEBUG_LSP_SCHED;
1152 print_debug(vty, DEBUG_LSP_SCHED, 0);
49d41a26 1153
d62a17ae 1154 return CMD_SUCCESS;
49d41a26
DS
1155}
1156
2815f817
CF
1157DEFUN (debug_isis_bfd,
1158 debug_isis_bfd_cmd,
1159 "debug " PROTO_NAME " bfd",
1160 DEBUG_STR
1161 PROTO_HELP
1162 PROTO_NAME " interaction with BFD\n")
1163{
1164 isis->debugs |= DEBUG_BFD;
1165 print_debug(vty, DEBUG_BFD, 1);
1166
1167 return CMD_SUCCESS;
1168}
1169
1170DEFUN (no_debug_isis_bfd,
1171 no_debug_isis_bfd_cmd,
1172 "no debug " PROTO_NAME " bfd",
1173 NO_STR
1174 UNDEBUG_STR
1175 PROTO_HELP
1176 PROTO_NAME " interaction with BFD\n")
1177{
1178 isis->debugs &= ~DEBUG_BFD;
1179 print_debug(vty, DEBUG_BFD, 0);
1180
1181 return CMD_SUCCESS;
1182}
1183
eb5d44eb 1184DEFUN (show_hostname,
1185 show_hostname_cmd,
7c0cbd0e 1186 "show " PROTO_NAME " hostname",
eb5d44eb 1187 SHOW_STR
7c0cbd0e 1188 PROTO_HELP
eb5d44eb 1189 "IS-IS Dynamic hostname mapping\n")
1190{
d62a17ae 1191 dynhn_print_all(vty);
f390d2c7 1192
d62a17ae 1193 return CMD_SUCCESS;
eb5d44eb 1194}
1195
03f7e182
SL
1196DEFUN (show_isis_spf_ietf,
1197 show_isis_spf_ietf_cmd,
7c0cbd0e 1198 "show " PROTO_NAME " spf-delay-ietf",
03f7e182 1199 SHOW_STR
7c0cbd0e
CF
1200 PROTO_HELP
1201 "SPF delay IETF information\n")
03f7e182 1202{
d62a17ae 1203 if (!isis) {
1204 vty_out(vty, "ISIS is not running\n");
1205 return CMD_SUCCESS;
1206 }
1207
1208 struct listnode *node;
1209 struct isis_area *area;
1210
1211 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
1212 vty_out(vty, "Area %s:\n",
1213 area->area_tag ? area->area_tag : "null");
1214
1215 for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) {
1216 if ((area->is_type & level) == 0)
1217 continue;
1218
1219 vty_out(vty, " Level-%d:\n", level);
1220 vty_out(vty, " SPF delay status: ");
1221 if (area->spf_timer[level - 1]) {
1222 struct timeval remain = thread_timer_remain(
1223 area->spf_timer[level - 1]);
a97986ff
DL
1224 vty_out(vty, "Pending, due in %lld msec\n",
1225 (long long)remain.tv_sec * 1000
d62a17ae 1226 + remain.tv_usec / 1000);
1227 } else {
1228 vty_out(vty, "Not scheduled\n");
1229 }
1230
1231 if (area->spf_delay_ietf[level - 1]) {
1232 vty_out(vty,
1233 " Using draft-ietf-rtgwg-backoff-algo-04\n");
1234 spf_backoff_show(
1235 area->spf_delay_ietf[level - 1], vty,
1236 " ");
1237 } else {
1238 vty_out(vty, " Using legacy backoff algo\n");
1239 }
1240 }
1241 }
1242 return CMD_SUCCESS;
03f7e182
SL
1243}
1244
3f045a08
JB
1245DEFUN (show_isis_summary,
1246 show_isis_summary_cmd,
7c0cbd0e
CF
1247 "show " PROTO_NAME " summary",
1248 SHOW_STR PROTO_HELP "summary\n")
3f045a08 1249{
d62a17ae 1250 struct listnode *node, *node2;
1251 struct isis_area *area;
d62a17ae 1252 int level;
1253
1254 if (isis == NULL) {
7c0cbd0e 1255 vty_out(vty, PROTO_NAME " is not running\n");
d62a17ae 1256 return CMD_SUCCESS;
1257 }
1258
1259 vty_out(vty, "Process Id : %ld\n", isis->process_id);
1260 if (isis->sysid_set)
1261 vty_out(vty, "System Id : %s\n",
1262 sysid_print(isis->sysid));
1263
1264 vty_out(vty, "Up time : ");
1265 vty_out_timestr(vty, isis->uptime);
1266 vty_out(vty, "\n");
1267
1268 if (isis->area_list)
1269 vty_out(vty, "Number of areas : %d\n", isis->area_list->count);
1270
1271 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
1272 vty_out(vty, "Area %s:\n",
1273 area->area_tag ? area->area_tag : "null");
1274
92ed0cde
CF
1275 if (fabricd) {
1276 uint8_t tier = fabricd_tier(area);
1277 if (tier == ISIS_TIER_UNDEFINED)
1278 vty_out(vty, " Tier: undefined\n");
1279 else
1280 vty_out(vty, " Tier: %" PRIu8 "\n", tier);
1281 }
1282
d62a17ae 1283 if (listcount(area->area_addrs) > 0) {
1284 struct area_addr *area_addr;
1285 for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node2,
1286 area_addr)) {
1287 vty_out(vty, " Net: %s\n",
1288 isonet_print(area_addr->area_addr,
1289 area_addr->addr_len
1290 + ISIS_SYS_ID_LEN
1291 + 1));
1292 }
1293 }
1294
39bb53d6
CF
1295 vty_out(vty, " TX counters per PDU type:\n");
1296 pdu_counter_print(vty, " ", area->pdu_tx_counters);
86d6f80d
CF
1297 vty_out(vty, " LSP RXMT: %" PRIu64 "\n",
1298 area->lsp_rxmt_count);
39bb53d6
CF
1299 vty_out(vty, " RX counters per PDU type:\n");
1300 pdu_counter_print(vty, " ", area->pdu_rx_counters);
1301
d62a17ae 1302 for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) {
1303 if ((area->is_type & level) == 0)
1304 continue;
1305
1306 vty_out(vty, " Level-%d:\n", level);
062f4d36
CF
1307
1308 vty_out(vty, " LSP0 regenerated: %" PRIu64 "\n",
1309 area->lsp_gen_count[level - 1]);
1310
6f004b60
CF
1311 vty_out(vty, " LSPs purged: %" PRIu64 "\n",
1312 area->lsp_purge_count[level - 1]);
1313
d62a17ae 1314 if (area->spf_timer[level - 1])
1315 vty_out(vty, " SPF: (pending)\n");
1316 else
1317 vty_out(vty, " SPF:\n");
1318
1319 vty_out(vty, " minimum interval : %d",
1320 area->min_spf_interval[level - 1]);
1321 if (area->spf_delay_ietf[level - 1])
1322 vty_out(vty,
1323 " (not used, IETF SPF delay activated)");
1324 vty_out(vty, "\n");
1325
1326 vty_out(vty, " IPv4 route computation:\n");
be985ba0
CF
1327 isis_spf_print(area->spftree[SPFTREE_IPV4][level - 1],
1328 vty);
d62a17ae 1329
d62a17ae 1330 vty_out(vty, " IPv6 route computation:\n");
be985ba0
CF
1331 isis_spf_print(area->spftree[SPFTREE_IPV6][level - 1],
1332 vty);
321c1bbb
CF
1333
1334 vty_out(vty, " IPv6 dst-src route computation:\n");
1335 isis_spf_print(area->spftree[SPFTREE_DSTSRC][level-1],
1336 vty);
d62a17ae 1337 }
1338 }
1339 vty_out(vty, "\n");
1340
1341 return CMD_SUCCESS;
eb5d44eb 1342}
1343
eb2bcb28 1344struct isis_lsp *lsp_for_arg(const char *argv, dict_t *lspdb)
d62a17ae 1345{
eb2bcb28 1346 char sysid[255] = {0};
d7c0a89a 1347 uint8_t number[3];
eb2bcb28
CF
1348 const char *pos;
1349 uint8_t lspid[ISIS_SYS_ID_LEN + 2] = {0};
1350 struct isis_dynhn *dynhn;
1351 struct isis_lsp *lsp = NULL;
d62a17ae 1352
eb2bcb28
CF
1353 if (!argv)
1354 return NULL;
d62a17ae 1355
1356 /*
1357 * extract fragment and pseudo id from the string argv
1358 * in the forms:
1359 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1360 * (b) <systemid/hostname>.<pseudo-id> or
1361 * (c) <systemid/hostname> or
1362 * Where systemid is in the form:
1363 * xxxx.xxxx.xxxx
1364 */
1365 if (argv)
1366 strncpy(sysid, argv, 254);
1367 if (argv && strlen(argv) > 3) {
1368 pos = argv + strlen(argv) - 3;
1369 if (strncmp(pos, "-", 1) == 0) {
1370 memcpy(number, ++pos, 2);
1371 lspid[ISIS_SYS_ID_LEN + 1] =
d7c0a89a 1372 (uint8_t)strtol((char *)number, NULL, 16);
d62a17ae 1373 pos -= 4;
1374 if (strncmp(pos, ".", 1) != 0)
eb2bcb28 1375 return NULL;
d62a17ae 1376 }
1377 if (strncmp(pos, ".", 1) == 0) {
1378 memcpy(number, ++pos, 2);
1379 lspid[ISIS_SYS_ID_LEN] =
d7c0a89a 1380 (uint8_t)strtol((char *)number, NULL, 16);
d62a17ae 1381 sysid[pos - argv - 1] = '\0';
1382 }
1383 }
1384
eb2bcb28
CF
1385 /*
1386 * Try to find the lsp-id if the argv
1387 * string is in
1388 * the form
1389 * hostname.<pseudo-id>-<fragment>
1390 */
1391 if (sysid2buff(lspid, sysid)) {
1392 lsp = lsp_search(lspid, lspdb);
1393 } else if ((dynhn = dynhn_find_by_name(sysid))) {
1394 memcpy(lspid, dynhn->id, ISIS_SYS_ID_LEN);
1395 lsp = lsp_search(lspid, lspdb);
1396 } else if (strncmp(cmd_hostname_get(), sysid, 15) == 0) {
1397 memcpy(lspid, isis->sysid, ISIS_SYS_ID_LEN);
1398 lsp = lsp_search(lspid, lspdb);
1399 }
1400
1401 return lsp;
1402}
1403
1404/*
1405 * This function supports following display options:
1406 * [ show isis database [detail] ]
1407 * [ show isis database <sysid> [detail] ]
1408 * [ show isis database <hostname> [detail] ]
1409 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1410 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1411 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1412 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1413 * [ show isis database detail <sysid> ]
1414 * [ show isis database detail <hostname> ]
1415 * [ show isis database detail <sysid>.<pseudo-id> ]
1416 * [ show isis database detail <hostname>.<pseudo-id> ]
1417 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1418 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1419 */
1420static int show_isis_database(struct vty *vty, const char *argv, int ui_level)
1421{
1422 struct listnode *node;
1423 struct isis_area *area;
1424 struct isis_lsp *lsp;
1425 int level, lsp_count;
1426
1427 if (isis->area_list->count == 0)
1428 return CMD_SUCCESS;
1429
d62a17ae 1430 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
1431 vty_out(vty, "Area %s:\n",
1432 area->area_tag ? area->area_tag : "null");
1433
1434 for (level = 0; level < ISIS_LEVELS; level++) {
1435 if (area->lspdb[level]
1436 && dict_count(area->lspdb[level]) > 0) {
eb2bcb28 1437 lsp = lsp_for_arg(argv, area->lspdb[level]);
d62a17ae 1438
1439 if (lsp != NULL || argv == NULL) {
1440 vty_out(vty,
1441 "IS-IS Level-%d link-state database:\n",
1442 level + 1);
1443
1444 /* print the title in all cases */
1445 vty_out(vty,
1446 "LSP ID PduLen SeqNumber Chksum Holdtime ATT/P/OL\n");
1447 }
1448
1449 if (lsp) {
1450 if (ui_level == ISIS_UI_LEVEL_DETAIL)
1451 lsp_print_detail(
1452 lsp, vty,
1453 area->dynhostname);
1454 else
1455 lsp_print(lsp, vty,
1456 area->dynhostname);
1457 } else if (argv == NULL) {
1458 lsp_count = lsp_print_all(
1459 vty, area->lspdb[level],
1460 ui_level, area->dynhostname);
1461
1462 vty_out(vty, " %u LSPs\n\n",
1463 lsp_count);
1464 }
1465 }
1466 }
1467 }
1468
1469 return CMD_SUCCESS;
eb5d44eb 1470}
1471
3a2d747c 1472DEFUN (show_database,
3f045a08 1473 show_database_cmd,
7c0cbd0e 1474 "show " PROTO_NAME " database [detail] [WORD]",
3f045a08 1475 SHOW_STR
7c0cbd0e
CF
1476 PROTO_HELP
1477 "Link state database\n"
3f045a08
JB
1478 "Detailed information\n"
1479 "LSP ID\n")
1480{
d62a17ae 1481 int idx = 0;
1482 int uilevel = argv_find(argv, argc, "detail", &idx)
1483 ? ISIS_UI_LEVEL_DETAIL
1484 : ISIS_UI_LEVEL_BRIEF;
1485 char *id = argv_find(argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL;
1486 return show_isis_database(vty, id, uilevel);
3f045a08
JB
1487}
1488
aaf2fd21 1489#ifdef FABRICD
d62a17ae 1490/*
aaf2fd21 1491 * 'router openfabric' command
3f045a08 1492 */
aaf2fd21
EDP
1493DEFUN_NOSH (router_openfabric,
1494 router_openfabric_cmd,
1495 "router openfabric WORD",
3f045a08 1496 ROUTER_STR
7c0cbd0e 1497 PROTO_HELP
efd7904e 1498 "ISO Routing area tag\n")
3f045a08 1499{
d62a17ae 1500 int idx_word = 2;
1501 return isis_area_get(vty, argv[idx_word]->arg);
3f045a08
JB
1502}
1503
d62a17ae 1504/*
aaf2fd21 1505 *'no router openfabric' command
3f045a08 1506 */
aaf2fd21
EDP
1507DEFUN (no_router_openfabric,
1508 no_router_openfabric_cmd,
1509 "no router openfabric WORD",
7c0cbd0e
CF
1510 NO_STR
1511 ROUTER_STR
1512 PROTO_HELP
1513 "ISO Routing area tag\n")
eb5d44eb 1514{
d62a17ae 1515 int idx_word = 3;
aaf2fd21 1516 return isis_area_destroy(argv[idx_word]->arg);
eb5d44eb 1517}
aaf2fd21 1518#endif /* ifdef FABRICD */
f084ea55 1519#ifdef FABRICD
eb5d44eb 1520/*
1521 * 'net' command
1522 */
1523DEFUN (net,
1524 net_cmd,
1525 "net WORD",
1526 "A Network Entity Title for this process (OSI only)\n"
f390d2c7 1527 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
eb5d44eb 1528{
d62a17ae 1529 int idx_word = 1;
1530 return area_net_title(vty, argv[idx_word]->arg);
eb5d44eb 1531}
1532
eb5d44eb 1533/*
1534 * 'no net' command
1535 */
1536DEFUN (no_net,
1537 no_net_cmd,
1538 "no net WORD",
1539 NO_STR
1540 "A Network Entity Title for this process (OSI only)\n"
f390d2c7 1541 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
eb5d44eb 1542{
d62a17ae 1543 int idx_word = 2;
1544 return area_clear_net_title(vty, argv[idx_word]->arg);
eb5d44eb 1545}
f084ea55 1546#endif /* ifdef FABRICD */
22af6a80 1547#ifdef FABRICD
064f4896
CF
1548DEFUN (isis_topology,
1549 isis_topology_cmd,
1550 "topology " ISIS_MT_NAMES " [overload]",
1551 "Configure IS-IS topologies\n"
1552 ISIS_MT_DESCRIPTIONS
1553 "Set overload bit for topology\n")
1554{
d62a17ae 1555 VTY_DECLVAR_CONTEXT(isis_area, area);
064f4896 1556
d62a17ae 1557 const char *arg = argv[1]->arg;
1558 uint16_t mtid = isis_str2mtid(arg);
c3ea3906 1559
d62a17ae 1560 if (area->oldmetric) {
1561 vty_out(vty,
1562 "Multi topology IS-IS can only be used with wide metrics\n");
a5fdb4c5 1563 return CMD_WARNING_CONFIG_FAILED;
d62a17ae 1564 }
c3ea3906 1565
d62a17ae 1566 if (mtid == (uint16_t)-1) {
1567 vty_out(vty, "Don't know topology '%s'\n", arg);
a5fdb4c5 1568 return CMD_WARNING_CONFIG_FAILED;
d62a17ae 1569 }
1570 if (mtid == ISIS_MT_IPV4_UNICAST) {
1571 vty_out(vty, "Cannot configure IPv4 unicast topology\n");
a5fdb4c5 1572 return CMD_WARNING_CONFIG_FAILED;
d62a17ae 1573 }
064f4896 1574
d62a17ae 1575 area_set_mt_enabled(area, mtid, true);
1576 area_set_mt_overload(area, mtid, (argc == 3));
1577 return CMD_SUCCESS;
064f4896
CF
1578}
1579
1580DEFUN (no_isis_topology,
1581 no_isis_topology_cmd,
1582 "no topology " ISIS_MT_NAMES " [overload]",
1583 NO_STR
1584 "Configure IS-IS topologies\n"
1585 ISIS_MT_DESCRIPTIONS
1586 "Set overload bit for topology\n")
1587{
d62a17ae 1588 VTY_DECLVAR_CONTEXT(isis_area, area);
064f4896 1589
d62a17ae 1590 const char *arg = argv[2]->arg;
1591 uint16_t mtid = isis_str2mtid(arg);
c3ea3906 1592
d62a17ae 1593 if (area->oldmetric) {
1594 vty_out(vty,
1595 "Multi topology IS-IS can only be used with wide metrics\n");
a5fdb4c5 1596 return CMD_WARNING_CONFIG_FAILED;
d62a17ae 1597 }
c3ea3906 1598
d62a17ae 1599 if (mtid == (uint16_t)-1) {
1600 vty_out(vty, "Don't know topology '%s'\n", arg);
a5fdb4c5 1601 return CMD_WARNING_CONFIG_FAILED;
d62a17ae 1602 }
1603 if (mtid == ISIS_MT_IPV4_UNICAST) {
1604 vty_out(vty, "Cannot configure IPv4 unicast topology\n");
a5fdb4c5 1605 return CMD_WARNING_CONFIG_FAILED;
d62a17ae 1606 }
064f4896 1607
d62a17ae 1608 area_set_mt_enabled(area, mtid, false);
1609 area_set_mt_overload(area, mtid, false);
1610 return CMD_SUCCESS;
064f4896 1611}
22af6a80 1612#endif /* ifdef FABRICD */
064f4896 1613
6754fc66 1614void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu)
b20ccb3a 1615{
d62a17ae 1616 area->lsp_mtu = lsp_mtu;
1617 lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1);
1618}
1619
1620static int isis_area_passwd_set(struct isis_area *area, int level,
d7c0a89a
QY
1621 uint8_t passwd_type, const char *passwd,
1622 uint8_t snp_auth)
d62a17ae 1623{
1624 struct isis_passwd *dest;
1625 struct isis_passwd modified;
1626 int len;
1627
1628 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
1629 dest = (level == IS_LEVEL_1) ? &area->area_passwd
1630 : &area->domain_passwd;
1631 memset(&modified, 0, sizeof(modified));
1632
1633 if (passwd_type != ISIS_PASSWD_TYPE_UNUSED) {
1634 if (!passwd)
1635 return -1;
1636
1637 len = strlen(passwd);
1638 if (len > 254)
1639 return -1;
1640
1641 modified.len = len;
1642 strncpy((char *)modified.passwd, passwd, 255);
1643 modified.type = passwd_type;
1644 modified.snp_auth = snp_auth;
1645 }
1646
1647 if (memcmp(&modified, dest, sizeof(modified))) {
1648 memcpy(dest, &modified, sizeof(modified));
1649 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1650 }
1651
1652 return 0;
1653}
1654
1655int isis_area_passwd_unset(struct isis_area *area, int level)
1656{
1657 return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_UNUSED, NULL,
1658 0);
1659}
1660
1661int isis_area_passwd_cleartext_set(struct isis_area *area, int level,
d7c0a89a 1662 const char *passwd, uint8_t snp_auth)
d62a17ae 1663{
1664 return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_CLEARTXT,
1665 passwd, snp_auth);
1666}
1667
1668int isis_area_passwd_hmac_md5_set(struct isis_area *area, int level,
d7c0a89a 1669 const char *passwd, uint8_t snp_auth)
d62a17ae 1670{
1671 return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_HMAC_MD5,
1672 passwd, snp_auth);
b20ccb3a
CF
1673}
1674
3dace42d
CF
1675void isis_area_invalidate_routes(struct isis_area *area, int levels)
1676{
1677 for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) {
1678 if (!(level & levels))
1679 continue;
be985ba0
CF
1680 for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) {
1681 isis_spf_invalidate_routes(
1682 area->spftree[tree][level - 1]);
1683 }
3dace42d
CF
1684 }
1685}
1686
1687void isis_area_verify_routes(struct isis_area *area)
1688{
be985ba0
CF
1689 for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++)
1690 isis_spf_verify_routes(area, area->spftree[tree]);
3dace42d
CF
1691}
1692
d62a17ae 1693static void area_resign_level(struct isis_area *area, int level)
3f045a08 1694{
3dace42d
CF
1695 isis_area_invalidate_routes(area, level);
1696 isis_area_verify_routes(area);
1697
d62a17ae 1698 if (area->lspdb[level - 1]) {
1699 lsp_db_destroy(area->lspdb[level - 1]);
1700 area->lspdb[level - 1] = NULL;
1701 }
be985ba0
CF
1702
1703 for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) {
1704 if (area->spftree[tree][level - 1]) {
1705 isis_spftree_del(area->spftree[tree][level - 1]);
1706 area->spftree[tree][level - 1] = NULL;
1707 }
d62a17ae 1708 }
be985ba0 1709
d62a17ae 1710 THREAD_TIMER_OFF(area->spf_timer[level - 1]);
3f045a08 1711
d62a17ae 1712 sched_debug(
1713 "ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.",
1714 area->area_tag, level);
1715 THREAD_TIMER_OFF(area->t_lsp_refresh[level - 1]);
1716 area->lsp_regenerate_pending[level - 1] = 0;
1717}
3f045a08 1718
d62a17ae 1719void isis_area_is_type_set(struct isis_area *area, int is_type)
1720{
1721 struct listnode *node;
1722 struct isis_circuit *circuit;
3f045a08 1723
d62a17ae 1724 if (isis->debugs & DEBUG_EVENTS)
1725 zlog_debug("ISIS-Evt (%s) system type change %s -> %s",
1726 area->area_tag, circuit_t2string(area->is_type),
1727 circuit_t2string(is_type));
f390d2c7 1728
d62a17ae 1729 if (area->is_type == is_type)
1730 return; /* No change */
1731
1732 switch (area->is_type) {
1733 case IS_LEVEL_1:
1734 if (is_type == IS_LEVEL_2)
1735 area_resign_level(area, IS_LEVEL_1);
1736
1737 if (area->lspdb[1] == NULL)
1738 area->lspdb[1] = lsp_db_init();
d62a17ae 1739 break;
1740
1741 case IS_LEVEL_1_AND_2:
1742 if (is_type == IS_LEVEL_1)
1743 area_resign_level(area, IS_LEVEL_2);
1744 else
1745 area_resign_level(area, IS_LEVEL_1);
1746 break;
1747
1748 case IS_LEVEL_2:
1749 if (is_type == IS_LEVEL_1)
1750 area_resign_level(area, IS_LEVEL_2);
1751
1752 if (area->lspdb[0] == NULL)
1753 area->lspdb[0] = lsp_db_init();
d62a17ae 1754 break;
1755
1756 default:
1757 break;
1758 }
1759
1760 area->is_type = is_type;
1761
1762 /* override circuit's is_type */
1763 if (area->is_type != IS_LEVEL_1_AND_2) {
1764 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit))
1765 isis_circuit_is_type_set(circuit, is_type);
1766 }
1767
1768 spftree_area_init(area);
1769
1770 if (listcount(area->area_addrs) > 0) {
1771 if (is_type & IS_LEVEL_1)
1772 lsp_generate(area, IS_LEVEL_1);
1773 if (is_type & IS_LEVEL_2)
1774 lsp_generate(area, IS_LEVEL_2);
1775 }
1776 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1777
1778 return;
eb5d44eb 1779}
1780
a38a72db
CF
1781void isis_area_metricstyle_set(struct isis_area *area, bool old_metric,
1782 bool new_metric)
e38e0df0 1783{
e0df3206
EDP
1784 area->oldmetric = old_metric;
1785 area->newmetric = new_metric;
1786 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
e38e0df0
SV
1787}
1788
a38a72db 1789void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit)
eb5d44eb 1790{
d62a17ae 1791 char new_overload_bit = overload_bit ? LSPBIT_OL : 0;
eb5d44eb 1792
d62a17ae 1793 if (new_overload_bit != area->overload_bit) {
1794 area->overload_bit = new_overload_bit;
1795 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1796 }
9414b6f6
EDP
1797#ifndef FABRICD
1798 isis_notif_db_overload(area, overload_bit);
1799#endif /* ifndef FABRICD */
3f045a08
JB
1800}
1801
a38a72db 1802void isis_area_attached_bit_set(struct isis_area *area, bool attached_bit)
3f045a08 1803{
d62a17ae 1804 char new_attached_bit = attached_bit ? LSPBIT_ATT : 0;
3f045a08 1805
d62a17ae 1806 if (new_attached_bit != area->attached_bit) {
1807 area->attached_bit = new_attached_bit;
1808 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1809 }
eb5d44eb 1810}
1811
a38a72db 1812void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname)
eb5d44eb 1813{
d62a17ae 1814 if (area->dynhostname != dynhostname) {
1815 area->dynhostname = dynhostname;
1816 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
1817 }
eb5d44eb 1818}
1819
d62a17ae 1820void isis_area_max_lsp_lifetime_set(struct isis_area *area, int level,
1821 uint16_t max_lsp_lifetime)
eb5d44eb 1822{
d62a17ae 1823 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
eb5d44eb 1824
d62a17ae 1825 if (area->max_lsp_lifetime[level - 1] == max_lsp_lifetime)
1826 return;
3f045a08 1827
d62a17ae 1828 area->max_lsp_lifetime[level - 1] = max_lsp_lifetime;
1829 lsp_regenerate_schedule(area, level, 1);
3f045a08
JB
1830}
1831
d62a17ae 1832void isis_area_lsp_refresh_set(struct isis_area *area, int level,
1833 uint16_t lsp_refresh)
3f045a08 1834{
d62a17ae 1835 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
eb5d44eb 1836
d62a17ae 1837 if (area->lsp_refresh[level - 1] == lsp_refresh)
1838 return;
eb5d44eb 1839
d62a17ae 1840 area->lsp_refresh[level - 1] = lsp_refresh;
1841 lsp_regenerate_schedule(area, level, 1);
3f045a08
JB
1842}
1843
2adf66ff 1844#ifdef FABRICD
3f045a08
JB
1845DEFUN (log_adj_changes,
1846 log_adj_changes_cmd,
1847 "log-adjacency-changes",
1848 "Log changes in adjacency state\n")
1849{
d62a17ae 1850 VTY_DECLVAR_CONTEXT(isis_area, area);
eb5d44eb 1851
d62a17ae 1852 area->log_adj_changes = 1;
eb5d44eb 1853
d62a17ae 1854 return CMD_SUCCESS;
eb5d44eb 1855}
1856
3f045a08
JB
1857DEFUN (no_log_adj_changes,
1858 no_log_adj_changes_cmd,
1859 "no log-adjacency-changes",
d7fa34c1 1860 NO_STR
3f045a08 1861 "Stop logging changes in adjacency state\n")
eb5d44eb 1862{
d62a17ae 1863 VTY_DECLVAR_CONTEXT(isis_area, area);
f390d2c7 1864
d62a17ae 1865 area->log_adj_changes = 0;
eb5d44eb 1866
d62a17ae 1867 return CMD_SUCCESS;
eb5d44eb 1868}
2adf66ff 1869#endif /* ifdef FABRICD */
20600086 1870#ifdef FABRICD
eb5d44eb 1871/* IS-IS configuration write function */
d62a17ae 1872int isis_config_write(struct vty *vty)
1873{
1874 int write = 0;
1875
1876 if (isis != NULL) {
1877 struct isis_area *area;
1878 struct listnode *node, *node2;
1879
1880 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
1881 /* ISIS - Area name */
7c0cbd0e 1882 vty_out(vty, "router " PROTO_NAME " %s\n", area->area_tag);
d62a17ae 1883 write++;
1884 /* ISIS - Net */
1885 if (listcount(area->area_addrs) > 0) {
1886 struct area_addr *area_addr;
1887 for (ALL_LIST_ELEMENTS_RO(area->area_addrs,
1888 node2, area_addr)) {
1889 vty_out(vty, " net %s\n",
1890 isonet_print(
1891 area_addr->area_addr,
1892 area_addr->addr_len
1893 + ISIS_SYS_ID_LEN
1894 + 1));
1895 write++;
1896 }
1897 }
1898 /* ISIS - Dynamic hostname - Defaults to true so only
1899 * display if
1900 * false. */
1901 if (!area->dynhostname) {
1902 vty_out(vty, " no hostname dynamic\n");
1903 write++;
1904 }
1905 /* ISIS - Metric-Style - when true displays wide */
65f18157
CF
1906 if (!fabricd) {
1907 if (area->newmetric) {
1908 if (!area->oldmetric)
1909 vty_out(vty, " metric-style wide\n");
1910 else
1911 vty_out(vty,
1912 " metric-style transition\n");
1913 write++;
1914 } else {
1915 vty_out(vty, " metric-style narrow\n");
1916 write++;
1917 }
d62a17ae 1918 }
1919 /* ISIS - overload-bit */
1920 if (area->overload_bit) {
1921 vty_out(vty, " set-overload-bit\n");
1922 write++;
1923 }
1924 /* ISIS - Area is-type (level-1-2 is default) */
65f18157
CF
1925 if (!fabricd) {
1926 if (area->is_type == IS_LEVEL_1) {
1927 vty_out(vty, " is-type level-1\n");
1928 write++;
1929 } else if (area->is_type == IS_LEVEL_2) {
1930 vty_out(vty, " is-type level-2-only\n");
1931 write++;
1932 }
d62a17ae 1933 }
1934 write += isis_redist_config_write(vty, area, AF_INET);
1935 write += isis_redist_config_write(vty, area, AF_INET6);
1936 /* ISIS - Lsp generation interval */
1937 if (area->lsp_gen_interval[0]
1938 == area->lsp_gen_interval[1]) {
1939 if (area->lsp_gen_interval[0]
1940 != DEFAULT_MIN_LSP_GEN_INTERVAL) {
1941 vty_out(vty, " lsp-gen-interval %d\n",
1942 area->lsp_gen_interval[0]);
1943 write++;
1944 }
1945 } else {
1946 if (area->lsp_gen_interval[0]
1947 != DEFAULT_MIN_LSP_GEN_INTERVAL) {
1948 vty_out(vty,
1949 " lsp-gen-interval level-1 %d\n",
1950 area->lsp_gen_interval[0]);
1951 write++;
1952 }
1953 if (area->lsp_gen_interval[1]
1954 != DEFAULT_MIN_LSP_GEN_INTERVAL) {
1955 vty_out(vty,
1956 " lsp-gen-interval level-2 %d\n",
1957 area->lsp_gen_interval[1]);
1958 write++;
1959 }
1960 }
1961 /* ISIS - LSP lifetime */
1962 if (area->max_lsp_lifetime[0]
1963 == area->max_lsp_lifetime[1]) {
1964 if (area->max_lsp_lifetime[0]
1965 != DEFAULT_LSP_LIFETIME) {
1966 vty_out(vty, " max-lsp-lifetime %u\n",
1967 area->max_lsp_lifetime[0]);
1968 write++;
1969 }
1970 } else {
1971 if (area->max_lsp_lifetime[0]
1972 != DEFAULT_LSP_LIFETIME) {
1973 vty_out(vty,
1974 " max-lsp-lifetime level-1 %u\n",
1975 area->max_lsp_lifetime[0]);
1976 write++;
1977 }
1978 if (area->max_lsp_lifetime[1]
1979 != DEFAULT_LSP_LIFETIME) {
1980 vty_out(vty,
1981 " max-lsp-lifetime level-2 %u\n",
1982 area->max_lsp_lifetime[1]);
1983 write++;
1984 }
1985 }
1986 /* ISIS - LSP refresh interval */
1987 if (area->lsp_refresh[0] == area->lsp_refresh[1]) {
1988 if (area->lsp_refresh[0]
1989 != DEFAULT_MAX_LSP_GEN_INTERVAL) {
1990 vty_out(vty,
1991 " lsp-refresh-interval %u\n",
1992 area->lsp_refresh[0]);
1993 write++;
1994 }
1995 } else {
1996 if (area->lsp_refresh[0]
1997 != DEFAULT_MAX_LSP_GEN_INTERVAL) {
1998 vty_out(vty,
1999 " lsp-refresh-interval level-1 %u\n",
2000 area->lsp_refresh[0]);
2001 write++;
2002 }
2003 if (area->lsp_refresh[1]
2004 != DEFAULT_MAX_LSP_GEN_INTERVAL) {
2005 vty_out(vty,
2006 " lsp-refresh-interval level-2 %u\n",
2007 area->lsp_refresh[1]);
2008 write++;
2009 }
2010 }
2011 if (area->lsp_mtu != DEFAULT_LSP_MTU) {
2012 vty_out(vty, " lsp-mtu %u\n", area->lsp_mtu);
2013 write++;
2014 }
2c92bee4
CF
2015 if (area->purge_originator) {
2016 vty_out(vty, " purge-originator\n");
2017 write++;
2018 }
d62a17ae 2019
2020 /* Minimum SPF interval. */
2021 if (area->min_spf_interval[0]
2022 == area->min_spf_interval[1]) {
2023 if (area->min_spf_interval[0]
2024 != MINIMUM_SPF_INTERVAL) {
2025 vty_out(vty, " spf-interval %d\n",
2026 area->min_spf_interval[0]);
2027 write++;
2028 }
2029 } else {
2030 if (area->min_spf_interval[0]
2031 != MINIMUM_SPF_INTERVAL) {
2032 vty_out(vty,
2033 " spf-interval level-1 %d\n",
2034 area->min_spf_interval[0]);
2035 write++;
2036 }
2037 if (area->min_spf_interval[1]
2038 != MINIMUM_SPF_INTERVAL) {
2039 vty_out(vty,
2040 " spf-interval level-2 %d\n",
2041 area->min_spf_interval[1]);
2042 write++;
2043 }
2044 }
2045
2046 /* IETF SPF interval */
2047 if (area->spf_delay_ietf[0]) {
2048 vty_out(vty,
2049 " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld\n",
2050 spf_backoff_init_delay(
2051 area->spf_delay_ietf[0]),
2052 spf_backoff_short_delay(
2053 area->spf_delay_ietf[0]),
2054 spf_backoff_long_delay(
2055 area->spf_delay_ietf[0]),
2056 spf_backoff_holddown(
2057 area->spf_delay_ietf[0]),
2058 spf_backoff_timetolearn(
2059 area->spf_delay_ietf[0]));
2060 write++;
2061 }
2062
2063 /* Authentication passwords. */
2064 if (area->area_passwd.type
2065 == ISIS_PASSWD_TYPE_HMAC_MD5) {
2066 vty_out(vty, " area-password md5 %s",
2067 area->area_passwd.passwd);
2068 if (CHECK_FLAG(area->area_passwd.snp_auth,
2069 SNP_AUTH_SEND)) {
2070 vty_out(vty, " authenticate snp ");
2071 if (CHECK_FLAG(
2072 area->area_passwd.snp_auth,
2073 SNP_AUTH_RECV))
2074 vty_out(vty, "validate");
2075 else
2076 vty_out(vty, "send-only");
2077 }
2078 vty_out(vty, "\n");
2079 write++;
2080 } else if (area->area_passwd.type
2081 == ISIS_PASSWD_TYPE_CLEARTXT) {
2082 vty_out(vty, " area-password clear %s",
2083 area->area_passwd.passwd);
2084 if (CHECK_FLAG(area->area_passwd.snp_auth,
2085 SNP_AUTH_SEND)) {
2086 vty_out(vty, " authenticate snp ");
2087 if (CHECK_FLAG(
2088 area->area_passwd.snp_auth,
2089 SNP_AUTH_RECV))
2090 vty_out(vty, "validate");
2091 else
2092 vty_out(vty, "send-only");
2093 }
2094 vty_out(vty, "\n");
2095 write++;
2096 }
2097 if (area->domain_passwd.type
2098 == ISIS_PASSWD_TYPE_HMAC_MD5) {
2099 vty_out(vty, " domain-password md5 %s",
2100 area->domain_passwd.passwd);
2101 if (CHECK_FLAG(area->domain_passwd.snp_auth,
2102 SNP_AUTH_SEND)) {
2103 vty_out(vty, " authenticate snp ");
2104 if (CHECK_FLAG(area->domain_passwd
2105 .snp_auth,
2106 SNP_AUTH_RECV))
2107 vty_out(vty, "validate");
2108 else
2109 vty_out(vty, "send-only");
2110 }
2111 vty_out(vty, "\n");
2112 write++;
2113 } else if (area->domain_passwd.type
2114 == ISIS_PASSWD_TYPE_CLEARTXT) {
2115 vty_out(vty, " domain-password clear %s",
2116 area->domain_passwd.passwd);
2117 if (CHECK_FLAG(area->domain_passwd.snp_auth,
2118 SNP_AUTH_SEND)) {
2119 vty_out(vty, " authenticate snp ");
2120 if (CHECK_FLAG(area->domain_passwd
2121 .snp_auth,
2122 SNP_AUTH_RECV))
2123 vty_out(vty, "validate");
2124 else
2125 vty_out(vty, "send-only");
2126 }
2127 vty_out(vty, "\n");
2128 write++;
2129 }
2130
2131 if (area->log_adj_changes) {
2132 vty_out(vty, " log-adjacency-changes\n");
2133 write++;
2134 }
2135
2136 write += area_write_mt_settings(area, vty);
92ed0cde 2137 write += fabricd_write_settings(area, vty);
d62a17ae 2138 }
2139 isis_mpls_te_config_write_router(vty);
2140 }
2141
2142 return write;
2143}
2144
20600086
EDP
2145#else
2146/* IS-IS configuration write function */
2147int isis_config_write(struct vty *vty)
2148{
2149 int write = 0;
2150 struct lyd_node *dnode;
2151
2152 dnode = yang_dnode_get(running_config->dnode, "/frr-isisd:isis");
cc50ddb2 2153 if (dnode) {
20600086 2154 nb_cli_show_dnode_cmds(vty, dnode, false);
cc50ddb2
EDP
2155 write++;
2156 }
20600086
EDP
2157
2158 return write;
2159}
2160#endif /* ifdef FABRICD */
2161
7c0cbd0e 2162struct cmd_node router_node = {ROUTER_NODE, "%s(config-router)# ", 1};
d62a17ae 2163
2164void isis_init()
2165{
2166 /* Install IS-IS top node */
7c0cbd0e 2167 install_node(&router_node, isis_config_write);
d62a17ae 2168
2169 install_element(VIEW_NODE, &show_isis_summary_cmd);
2170
2171 install_element(VIEW_NODE, &show_isis_spf_ietf_cmd);
2172
2173 install_element(VIEW_NODE, &show_isis_interface_cmd);
2174 install_element(VIEW_NODE, &show_isis_interface_detail_cmd);
2175 install_element(VIEW_NODE, &show_isis_interface_arg_cmd);
2176
2177 install_element(VIEW_NODE, &show_isis_neighbor_cmd);
2178 install_element(VIEW_NODE, &show_isis_neighbor_detail_cmd);
2179 install_element(VIEW_NODE, &show_isis_neighbor_arg_cmd);
2180 install_element(VIEW_NODE, &clear_isis_neighbor_cmd);
2181 install_element(VIEW_NODE, &clear_isis_neighbor_arg_cmd);
2182
2183 install_element(VIEW_NODE, &show_hostname_cmd);
2184 install_element(VIEW_NODE, &show_database_cmd);
2185
2186 install_element(ENABLE_NODE, &show_debugging_isis_cmd);
2187
2188 install_node(&debug_node, config_write_debug);
2189
2190 install_element(ENABLE_NODE, &debug_isis_adj_cmd);
2191 install_element(ENABLE_NODE, &no_debug_isis_adj_cmd);
161fa356
CF
2192 install_element(ENABLE_NODE, &debug_isis_tx_queue_cmd);
2193 install_element(ENABLE_NODE, &no_debug_isis_tx_queue_cmd);
ddb33326
CF
2194 install_element(ENABLE_NODE, &debug_isis_flooding_cmd);
2195 install_element(ENABLE_NODE, &no_debug_isis_flooding_cmd);
d62a17ae 2196 install_element(ENABLE_NODE, &debug_isis_snp_cmd);
2197 install_element(ENABLE_NODE, &no_debug_isis_snp_cmd);
2198 install_element(ENABLE_NODE, &debug_isis_upd_cmd);
2199 install_element(ENABLE_NODE, &no_debug_isis_upd_cmd);
2200 install_element(ENABLE_NODE, &debug_isis_spfevents_cmd);
2201 install_element(ENABLE_NODE, &no_debug_isis_spfevents_cmd);
d62a17ae 2202 install_element(ENABLE_NODE, &debug_isis_rtevents_cmd);
2203 install_element(ENABLE_NODE, &no_debug_isis_rtevents_cmd);
2204 install_element(ENABLE_NODE, &debug_isis_events_cmd);
2205 install_element(ENABLE_NODE, &no_debug_isis_events_cmd);
2206 install_element(ENABLE_NODE, &debug_isis_packet_dump_cmd);
2207 install_element(ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
2208 install_element(ENABLE_NODE, &debug_isis_lsp_gen_cmd);
2209 install_element(ENABLE_NODE, &no_debug_isis_lsp_gen_cmd);
2210 install_element(ENABLE_NODE, &debug_isis_lsp_sched_cmd);
2211 install_element(ENABLE_NODE, &no_debug_isis_lsp_sched_cmd);
2815f817
CF
2212 install_element(ENABLE_NODE, &debug_isis_bfd_cmd);
2213 install_element(ENABLE_NODE, &no_debug_isis_bfd_cmd);
d62a17ae 2214
2215 install_element(CONFIG_NODE, &debug_isis_adj_cmd);
2216 install_element(CONFIG_NODE, &no_debug_isis_adj_cmd);
161fa356
CF
2217 install_element(CONFIG_NODE, &debug_isis_tx_queue_cmd);
2218 install_element(CONFIG_NODE, &no_debug_isis_tx_queue_cmd);
ddb33326
CF
2219 install_element(CONFIG_NODE, &debug_isis_flooding_cmd);
2220 install_element(CONFIG_NODE, &no_debug_isis_flooding_cmd);
d62a17ae 2221 install_element(CONFIG_NODE, &debug_isis_snp_cmd);
2222 install_element(CONFIG_NODE, &no_debug_isis_snp_cmd);
2223 install_element(CONFIG_NODE, &debug_isis_upd_cmd);
2224 install_element(CONFIG_NODE, &no_debug_isis_upd_cmd);
2225 install_element(CONFIG_NODE, &debug_isis_spfevents_cmd);
2226 install_element(CONFIG_NODE, &no_debug_isis_spfevents_cmd);
d62a17ae 2227 install_element(CONFIG_NODE, &debug_isis_rtevents_cmd);
2228 install_element(CONFIG_NODE, &no_debug_isis_rtevents_cmd);
2229 install_element(CONFIG_NODE, &debug_isis_events_cmd);
2230 install_element(CONFIG_NODE, &no_debug_isis_events_cmd);
2231 install_element(CONFIG_NODE, &debug_isis_packet_dump_cmd);
2232 install_element(CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
2233 install_element(CONFIG_NODE, &debug_isis_lsp_gen_cmd);
2234 install_element(CONFIG_NODE, &no_debug_isis_lsp_gen_cmd);
2235 install_element(CONFIG_NODE, &debug_isis_lsp_sched_cmd);
2236 install_element(CONFIG_NODE, &no_debug_isis_lsp_sched_cmd);
2815f817
CF
2237 install_element(CONFIG_NODE, &debug_isis_bfd_cmd);
2238 install_element(CONFIG_NODE, &no_debug_isis_bfd_cmd);
d62a17ae 2239
7c0cbd0e 2240 install_default(ROUTER_NODE);
d62a17ae 2241
aaf2fd21
EDP
2242#ifdef FABRICD
2243 install_element(CONFIG_NODE, &router_openfabric_cmd);
2244 install_element(CONFIG_NODE, &no_router_openfabric_cmd);
2adf66ff 2245
7c0cbd0e
CF
2246 install_element(ROUTER_NODE, &net_cmd);
2247 install_element(ROUTER_NODE, &no_net_cmd);
2adf66ff 2248
7c0cbd0e
CF
2249 install_element(ROUTER_NODE, &isis_topology_cmd);
2250 install_element(ROUTER_NODE, &no_isis_topology_cmd);
2adf66ff 2251
7c0cbd0e
CF
2252 install_element(ROUTER_NODE, &log_adj_changes_cmd);
2253 install_element(ROUTER_NODE, &no_log_adj_changes_cmd);
2adf66ff 2254#endif /* ifdef FABRICD */
d62a17ae 2255
2256 spf_backoff_cmd_init();
eb5d44eb 2257}