]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isisd.c
lib: remove pqueue_*
[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)
e28544ed 1366 strlcpy(sysid, argv, sizeof(sysid));
d62a17ae 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;
e28544ed
QY
1642 strlcpy((char *)modified.passwd, passwd,
1643 sizeof(modified.passwd));
d62a17ae 1644 modified.type = passwd_type;
1645 modified.snp_auth = snp_auth;
1646 }
1647
1648 if (memcmp(&modified, dest, sizeof(modified))) {
1649 memcpy(dest, &modified, sizeof(modified));
1650 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1651 }
1652
1653 return 0;
1654}
1655
1656int isis_area_passwd_unset(struct isis_area *area, int level)
1657{
1658 return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_UNUSED, NULL,
1659 0);
1660}
1661
1662int isis_area_passwd_cleartext_set(struct isis_area *area, int level,
d7c0a89a 1663 const char *passwd, uint8_t snp_auth)
d62a17ae 1664{
1665 return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_CLEARTXT,
1666 passwd, snp_auth);
1667}
1668
1669int isis_area_passwd_hmac_md5_set(struct isis_area *area, int level,
d7c0a89a 1670 const char *passwd, uint8_t snp_auth)
d62a17ae 1671{
1672 return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_HMAC_MD5,
1673 passwd, snp_auth);
b20ccb3a
CF
1674}
1675
3dace42d
CF
1676void isis_area_invalidate_routes(struct isis_area *area, int levels)
1677{
1678 for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) {
1679 if (!(level & levels))
1680 continue;
be985ba0
CF
1681 for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) {
1682 isis_spf_invalidate_routes(
1683 area->spftree[tree][level - 1]);
1684 }
3dace42d
CF
1685 }
1686}
1687
1688void isis_area_verify_routes(struct isis_area *area)
1689{
be985ba0
CF
1690 for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++)
1691 isis_spf_verify_routes(area, area->spftree[tree]);
3dace42d
CF
1692}
1693
d62a17ae 1694static void area_resign_level(struct isis_area *area, int level)
3f045a08 1695{
3dace42d
CF
1696 isis_area_invalidate_routes(area, level);
1697 isis_area_verify_routes(area);
1698
d62a17ae 1699 if (area->lspdb[level - 1]) {
1700 lsp_db_destroy(area->lspdb[level - 1]);
1701 area->lspdb[level - 1] = NULL;
1702 }
be985ba0
CF
1703
1704 for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) {
1705 if (area->spftree[tree][level - 1]) {
1706 isis_spftree_del(area->spftree[tree][level - 1]);
1707 area->spftree[tree][level - 1] = NULL;
1708 }
d62a17ae 1709 }
be985ba0 1710
d62a17ae 1711 THREAD_TIMER_OFF(area->spf_timer[level - 1]);
3f045a08 1712
d62a17ae 1713 sched_debug(
1714 "ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.",
1715 area->area_tag, level);
1716 THREAD_TIMER_OFF(area->t_lsp_refresh[level - 1]);
1717 area->lsp_regenerate_pending[level - 1] = 0;
1718}
3f045a08 1719
d62a17ae 1720void isis_area_is_type_set(struct isis_area *area, int is_type)
1721{
1722 struct listnode *node;
1723 struct isis_circuit *circuit;
3f045a08 1724
d62a17ae 1725 if (isis->debugs & DEBUG_EVENTS)
1726 zlog_debug("ISIS-Evt (%s) system type change %s -> %s",
1727 area->area_tag, circuit_t2string(area->is_type),
1728 circuit_t2string(is_type));
f390d2c7 1729
d62a17ae 1730 if (area->is_type == is_type)
1731 return; /* No change */
1732
1733 switch (area->is_type) {
1734 case IS_LEVEL_1:
1735 if (is_type == IS_LEVEL_2)
1736 area_resign_level(area, IS_LEVEL_1);
1737
1738 if (area->lspdb[1] == NULL)
1739 area->lspdb[1] = lsp_db_init();
d62a17ae 1740 break;
1741
1742 case IS_LEVEL_1_AND_2:
1743 if (is_type == IS_LEVEL_1)
1744 area_resign_level(area, IS_LEVEL_2);
1745 else
1746 area_resign_level(area, IS_LEVEL_1);
1747 break;
1748
1749 case IS_LEVEL_2:
1750 if (is_type == IS_LEVEL_1)
1751 area_resign_level(area, IS_LEVEL_2);
1752
1753 if (area->lspdb[0] == NULL)
1754 area->lspdb[0] = lsp_db_init();
d62a17ae 1755 break;
1756
1757 default:
1758 break;
1759 }
1760
1761 area->is_type = is_type;
1762
1763 /* override circuit's is_type */
1764 if (area->is_type != IS_LEVEL_1_AND_2) {
1765 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit))
1766 isis_circuit_is_type_set(circuit, is_type);
1767 }
1768
1769 spftree_area_init(area);
1770
1771 if (listcount(area->area_addrs) > 0) {
1772 if (is_type & IS_LEVEL_1)
1773 lsp_generate(area, IS_LEVEL_1);
1774 if (is_type & IS_LEVEL_2)
1775 lsp_generate(area, IS_LEVEL_2);
1776 }
1777 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1778
1779 return;
eb5d44eb 1780}
1781
a38a72db
CF
1782void isis_area_metricstyle_set(struct isis_area *area, bool old_metric,
1783 bool new_metric)
e38e0df0 1784{
e0df3206
EDP
1785 area->oldmetric = old_metric;
1786 area->newmetric = new_metric;
1787 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
e38e0df0
SV
1788}
1789
a38a72db 1790void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit)
eb5d44eb 1791{
d62a17ae 1792 char new_overload_bit = overload_bit ? LSPBIT_OL : 0;
eb5d44eb 1793
d62a17ae 1794 if (new_overload_bit != area->overload_bit) {
1795 area->overload_bit = new_overload_bit;
1796 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1797 }
9414b6f6
EDP
1798#ifndef FABRICD
1799 isis_notif_db_overload(area, overload_bit);
1800#endif /* ifndef FABRICD */
3f045a08
JB
1801}
1802
a38a72db 1803void isis_area_attached_bit_set(struct isis_area *area, bool attached_bit)
3f045a08 1804{
d62a17ae 1805 char new_attached_bit = attached_bit ? LSPBIT_ATT : 0;
3f045a08 1806
d62a17ae 1807 if (new_attached_bit != area->attached_bit) {
1808 area->attached_bit = new_attached_bit;
1809 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1810 }
eb5d44eb 1811}
1812
a38a72db 1813void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname)
eb5d44eb 1814{
d62a17ae 1815 if (area->dynhostname != dynhostname) {
1816 area->dynhostname = dynhostname;
1817 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
1818 }
eb5d44eb 1819}
1820
d62a17ae 1821void isis_area_max_lsp_lifetime_set(struct isis_area *area, int level,
1822 uint16_t max_lsp_lifetime)
eb5d44eb 1823{
d62a17ae 1824 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
eb5d44eb 1825
d62a17ae 1826 if (area->max_lsp_lifetime[level - 1] == max_lsp_lifetime)
1827 return;
3f045a08 1828
d62a17ae 1829 area->max_lsp_lifetime[level - 1] = max_lsp_lifetime;
1830 lsp_regenerate_schedule(area, level, 1);
3f045a08
JB
1831}
1832
d62a17ae 1833void isis_area_lsp_refresh_set(struct isis_area *area, int level,
1834 uint16_t lsp_refresh)
3f045a08 1835{
d62a17ae 1836 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
eb5d44eb 1837
d62a17ae 1838 if (area->lsp_refresh[level - 1] == lsp_refresh)
1839 return;
eb5d44eb 1840
d62a17ae 1841 area->lsp_refresh[level - 1] = lsp_refresh;
1842 lsp_regenerate_schedule(area, level, 1);
3f045a08
JB
1843}
1844
2adf66ff 1845#ifdef FABRICD
3f045a08
JB
1846DEFUN (log_adj_changes,
1847 log_adj_changes_cmd,
1848 "log-adjacency-changes",
1849 "Log changes in adjacency state\n")
1850{
d62a17ae 1851 VTY_DECLVAR_CONTEXT(isis_area, area);
eb5d44eb 1852
d62a17ae 1853 area->log_adj_changes = 1;
eb5d44eb 1854
d62a17ae 1855 return CMD_SUCCESS;
eb5d44eb 1856}
1857
3f045a08
JB
1858DEFUN (no_log_adj_changes,
1859 no_log_adj_changes_cmd,
1860 "no log-adjacency-changes",
d7fa34c1 1861 NO_STR
3f045a08 1862 "Stop logging changes in adjacency state\n")
eb5d44eb 1863{
d62a17ae 1864 VTY_DECLVAR_CONTEXT(isis_area, area);
f390d2c7 1865
d62a17ae 1866 area->log_adj_changes = 0;
eb5d44eb 1867
d62a17ae 1868 return CMD_SUCCESS;
eb5d44eb 1869}
2adf66ff 1870#endif /* ifdef FABRICD */
20600086 1871#ifdef FABRICD
eb5d44eb 1872/* IS-IS configuration write function */
d62a17ae 1873int isis_config_write(struct vty *vty)
1874{
1875 int write = 0;
1876
1877 if (isis != NULL) {
1878 struct isis_area *area;
1879 struct listnode *node, *node2;
1880
1881 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
1882 /* ISIS - Area name */
7c0cbd0e 1883 vty_out(vty, "router " PROTO_NAME " %s\n", area->area_tag);
d62a17ae 1884 write++;
1885 /* ISIS - Net */
1886 if (listcount(area->area_addrs) > 0) {
1887 struct area_addr *area_addr;
1888 for (ALL_LIST_ELEMENTS_RO(area->area_addrs,
1889 node2, area_addr)) {
1890 vty_out(vty, " net %s\n",
1891 isonet_print(
1892 area_addr->area_addr,
1893 area_addr->addr_len
1894 + ISIS_SYS_ID_LEN
1895 + 1));
1896 write++;
1897 }
1898 }
1899 /* ISIS - Dynamic hostname - Defaults to true so only
1900 * display if
1901 * false. */
1902 if (!area->dynhostname) {
1903 vty_out(vty, " no hostname dynamic\n");
1904 write++;
1905 }
1906 /* ISIS - Metric-Style - when true displays wide */
65f18157
CF
1907 if (!fabricd) {
1908 if (area->newmetric) {
1909 if (!area->oldmetric)
1910 vty_out(vty, " metric-style wide\n");
1911 else
1912 vty_out(vty,
1913 " metric-style transition\n");
1914 write++;
1915 } else {
1916 vty_out(vty, " metric-style narrow\n");
1917 write++;
1918 }
d62a17ae 1919 }
1920 /* ISIS - overload-bit */
1921 if (area->overload_bit) {
1922 vty_out(vty, " set-overload-bit\n");
1923 write++;
1924 }
1925 /* ISIS - Area is-type (level-1-2 is default) */
65f18157
CF
1926 if (!fabricd) {
1927 if (area->is_type == IS_LEVEL_1) {
1928 vty_out(vty, " is-type level-1\n");
1929 write++;
1930 } else if (area->is_type == IS_LEVEL_2) {
1931 vty_out(vty, " is-type level-2-only\n");
1932 write++;
1933 }
d62a17ae 1934 }
1935 write += isis_redist_config_write(vty, area, AF_INET);
1936 write += isis_redist_config_write(vty, area, AF_INET6);
1937 /* ISIS - Lsp generation interval */
1938 if (area->lsp_gen_interval[0]
1939 == area->lsp_gen_interval[1]) {
1940 if (area->lsp_gen_interval[0]
1941 != DEFAULT_MIN_LSP_GEN_INTERVAL) {
1942 vty_out(vty, " lsp-gen-interval %d\n",
1943 area->lsp_gen_interval[0]);
1944 write++;
1945 }
1946 } else {
1947 if (area->lsp_gen_interval[0]
1948 != DEFAULT_MIN_LSP_GEN_INTERVAL) {
1949 vty_out(vty,
1950 " lsp-gen-interval level-1 %d\n",
1951 area->lsp_gen_interval[0]);
1952 write++;
1953 }
1954 if (area->lsp_gen_interval[1]
1955 != DEFAULT_MIN_LSP_GEN_INTERVAL) {
1956 vty_out(vty,
1957 " lsp-gen-interval level-2 %d\n",
1958 area->lsp_gen_interval[1]);
1959 write++;
1960 }
1961 }
1962 /* ISIS - LSP lifetime */
1963 if (area->max_lsp_lifetime[0]
1964 == area->max_lsp_lifetime[1]) {
1965 if (area->max_lsp_lifetime[0]
1966 != DEFAULT_LSP_LIFETIME) {
1967 vty_out(vty, " max-lsp-lifetime %u\n",
1968 area->max_lsp_lifetime[0]);
1969 write++;
1970 }
1971 } else {
1972 if (area->max_lsp_lifetime[0]
1973 != DEFAULT_LSP_LIFETIME) {
1974 vty_out(vty,
1975 " max-lsp-lifetime level-1 %u\n",
1976 area->max_lsp_lifetime[0]);
1977 write++;
1978 }
1979 if (area->max_lsp_lifetime[1]
1980 != DEFAULT_LSP_LIFETIME) {
1981 vty_out(vty,
1982 " max-lsp-lifetime level-2 %u\n",
1983 area->max_lsp_lifetime[1]);
1984 write++;
1985 }
1986 }
1987 /* ISIS - LSP refresh interval */
1988 if (area->lsp_refresh[0] == area->lsp_refresh[1]) {
1989 if (area->lsp_refresh[0]
1990 != DEFAULT_MAX_LSP_GEN_INTERVAL) {
1991 vty_out(vty,
1992 " lsp-refresh-interval %u\n",
1993 area->lsp_refresh[0]);
1994 write++;
1995 }
1996 } else {
1997 if (area->lsp_refresh[0]
1998 != DEFAULT_MAX_LSP_GEN_INTERVAL) {
1999 vty_out(vty,
2000 " lsp-refresh-interval level-1 %u\n",
2001 area->lsp_refresh[0]);
2002 write++;
2003 }
2004 if (area->lsp_refresh[1]
2005 != DEFAULT_MAX_LSP_GEN_INTERVAL) {
2006 vty_out(vty,
2007 " lsp-refresh-interval level-2 %u\n",
2008 area->lsp_refresh[1]);
2009 write++;
2010 }
2011 }
2012 if (area->lsp_mtu != DEFAULT_LSP_MTU) {
2013 vty_out(vty, " lsp-mtu %u\n", area->lsp_mtu);
2014 write++;
2015 }
2c92bee4
CF
2016 if (area->purge_originator) {
2017 vty_out(vty, " purge-originator\n");
2018 write++;
2019 }
d62a17ae 2020
2021 /* Minimum SPF interval. */
2022 if (area->min_spf_interval[0]
2023 == area->min_spf_interval[1]) {
2024 if (area->min_spf_interval[0]
2025 != MINIMUM_SPF_INTERVAL) {
2026 vty_out(vty, " spf-interval %d\n",
2027 area->min_spf_interval[0]);
2028 write++;
2029 }
2030 } else {
2031 if (area->min_spf_interval[0]
2032 != MINIMUM_SPF_INTERVAL) {
2033 vty_out(vty,
2034 " spf-interval level-1 %d\n",
2035 area->min_spf_interval[0]);
2036 write++;
2037 }
2038 if (area->min_spf_interval[1]
2039 != MINIMUM_SPF_INTERVAL) {
2040 vty_out(vty,
2041 " spf-interval level-2 %d\n",
2042 area->min_spf_interval[1]);
2043 write++;
2044 }
2045 }
2046
2047 /* IETF SPF interval */
2048 if (area->spf_delay_ietf[0]) {
2049 vty_out(vty,
2050 " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld\n",
2051 spf_backoff_init_delay(
2052 area->spf_delay_ietf[0]),
2053 spf_backoff_short_delay(
2054 area->spf_delay_ietf[0]),
2055 spf_backoff_long_delay(
2056 area->spf_delay_ietf[0]),
2057 spf_backoff_holddown(
2058 area->spf_delay_ietf[0]),
2059 spf_backoff_timetolearn(
2060 area->spf_delay_ietf[0]));
2061 write++;
2062 }
2063
2064 /* Authentication passwords. */
2065 if (area->area_passwd.type
2066 == ISIS_PASSWD_TYPE_HMAC_MD5) {
2067 vty_out(vty, " area-password md5 %s",
2068 area->area_passwd.passwd);
2069 if (CHECK_FLAG(area->area_passwd.snp_auth,
2070 SNP_AUTH_SEND)) {
2071 vty_out(vty, " authenticate snp ");
2072 if (CHECK_FLAG(
2073 area->area_passwd.snp_auth,
2074 SNP_AUTH_RECV))
2075 vty_out(vty, "validate");
2076 else
2077 vty_out(vty, "send-only");
2078 }
2079 vty_out(vty, "\n");
2080 write++;
2081 } else if (area->area_passwd.type
2082 == ISIS_PASSWD_TYPE_CLEARTXT) {
2083 vty_out(vty, " area-password clear %s",
2084 area->area_passwd.passwd);
2085 if (CHECK_FLAG(area->area_passwd.snp_auth,
2086 SNP_AUTH_SEND)) {
2087 vty_out(vty, " authenticate snp ");
2088 if (CHECK_FLAG(
2089 area->area_passwd.snp_auth,
2090 SNP_AUTH_RECV))
2091 vty_out(vty, "validate");
2092 else
2093 vty_out(vty, "send-only");
2094 }
2095 vty_out(vty, "\n");
2096 write++;
2097 }
2098 if (area->domain_passwd.type
2099 == ISIS_PASSWD_TYPE_HMAC_MD5) {
2100 vty_out(vty, " domain-password md5 %s",
2101 area->domain_passwd.passwd);
2102 if (CHECK_FLAG(area->domain_passwd.snp_auth,
2103 SNP_AUTH_SEND)) {
2104 vty_out(vty, " authenticate snp ");
2105 if (CHECK_FLAG(area->domain_passwd
2106 .snp_auth,
2107 SNP_AUTH_RECV))
2108 vty_out(vty, "validate");
2109 else
2110 vty_out(vty, "send-only");
2111 }
2112 vty_out(vty, "\n");
2113 write++;
2114 } else if (area->domain_passwd.type
2115 == ISIS_PASSWD_TYPE_CLEARTXT) {
2116 vty_out(vty, " domain-password clear %s",
2117 area->domain_passwd.passwd);
2118 if (CHECK_FLAG(area->domain_passwd.snp_auth,
2119 SNP_AUTH_SEND)) {
2120 vty_out(vty, " authenticate snp ");
2121 if (CHECK_FLAG(area->domain_passwd
2122 .snp_auth,
2123 SNP_AUTH_RECV))
2124 vty_out(vty, "validate");
2125 else
2126 vty_out(vty, "send-only");
2127 }
2128 vty_out(vty, "\n");
2129 write++;
2130 }
2131
2132 if (area->log_adj_changes) {
2133 vty_out(vty, " log-adjacency-changes\n");
2134 write++;
2135 }
2136
2137 write += area_write_mt_settings(area, vty);
92ed0cde 2138 write += fabricd_write_settings(area, vty);
d62a17ae 2139 }
2140 isis_mpls_te_config_write_router(vty);
2141 }
2142
2143 return write;
2144}
2145
20600086
EDP
2146#else
2147/* IS-IS configuration write function */
2148int isis_config_write(struct vty *vty)
2149{
2150 int write = 0;
2151 struct lyd_node *dnode;
2152
2153 dnode = yang_dnode_get(running_config->dnode, "/frr-isisd:isis");
cc50ddb2 2154 if (dnode) {
20600086 2155 nb_cli_show_dnode_cmds(vty, dnode, false);
cc50ddb2
EDP
2156 write++;
2157 }
20600086
EDP
2158
2159 return write;
2160}
2161#endif /* ifdef FABRICD */
2162
7c0cbd0e 2163struct cmd_node router_node = {ROUTER_NODE, "%s(config-router)# ", 1};
d62a17ae 2164
4d762f26 2165void isis_init(void)
d62a17ae 2166{
2167 /* Install IS-IS top node */
7c0cbd0e 2168 install_node(&router_node, isis_config_write);
d62a17ae 2169
2170 install_element(VIEW_NODE, &show_isis_summary_cmd);
2171
2172 install_element(VIEW_NODE, &show_isis_spf_ietf_cmd);
2173
2174 install_element(VIEW_NODE, &show_isis_interface_cmd);
2175 install_element(VIEW_NODE, &show_isis_interface_detail_cmd);
2176 install_element(VIEW_NODE, &show_isis_interface_arg_cmd);
2177
2178 install_element(VIEW_NODE, &show_isis_neighbor_cmd);
2179 install_element(VIEW_NODE, &show_isis_neighbor_detail_cmd);
2180 install_element(VIEW_NODE, &show_isis_neighbor_arg_cmd);
2181 install_element(VIEW_NODE, &clear_isis_neighbor_cmd);
2182 install_element(VIEW_NODE, &clear_isis_neighbor_arg_cmd);
2183
2184 install_element(VIEW_NODE, &show_hostname_cmd);
2185 install_element(VIEW_NODE, &show_database_cmd);
2186
2187 install_element(ENABLE_NODE, &show_debugging_isis_cmd);
2188
2189 install_node(&debug_node, config_write_debug);
2190
2191 install_element(ENABLE_NODE, &debug_isis_adj_cmd);
2192 install_element(ENABLE_NODE, &no_debug_isis_adj_cmd);
161fa356
CF
2193 install_element(ENABLE_NODE, &debug_isis_tx_queue_cmd);
2194 install_element(ENABLE_NODE, &no_debug_isis_tx_queue_cmd);
ddb33326
CF
2195 install_element(ENABLE_NODE, &debug_isis_flooding_cmd);
2196 install_element(ENABLE_NODE, &no_debug_isis_flooding_cmd);
d62a17ae 2197 install_element(ENABLE_NODE, &debug_isis_snp_cmd);
2198 install_element(ENABLE_NODE, &no_debug_isis_snp_cmd);
2199 install_element(ENABLE_NODE, &debug_isis_upd_cmd);
2200 install_element(ENABLE_NODE, &no_debug_isis_upd_cmd);
2201 install_element(ENABLE_NODE, &debug_isis_spfevents_cmd);
2202 install_element(ENABLE_NODE, &no_debug_isis_spfevents_cmd);
d62a17ae 2203 install_element(ENABLE_NODE, &debug_isis_rtevents_cmd);
2204 install_element(ENABLE_NODE, &no_debug_isis_rtevents_cmd);
2205 install_element(ENABLE_NODE, &debug_isis_events_cmd);
2206 install_element(ENABLE_NODE, &no_debug_isis_events_cmd);
2207 install_element(ENABLE_NODE, &debug_isis_packet_dump_cmd);
2208 install_element(ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
2209 install_element(ENABLE_NODE, &debug_isis_lsp_gen_cmd);
2210 install_element(ENABLE_NODE, &no_debug_isis_lsp_gen_cmd);
2211 install_element(ENABLE_NODE, &debug_isis_lsp_sched_cmd);
2212 install_element(ENABLE_NODE, &no_debug_isis_lsp_sched_cmd);
2815f817
CF
2213 install_element(ENABLE_NODE, &debug_isis_bfd_cmd);
2214 install_element(ENABLE_NODE, &no_debug_isis_bfd_cmd);
d62a17ae 2215
2216 install_element(CONFIG_NODE, &debug_isis_adj_cmd);
2217 install_element(CONFIG_NODE, &no_debug_isis_adj_cmd);
161fa356
CF
2218 install_element(CONFIG_NODE, &debug_isis_tx_queue_cmd);
2219 install_element(CONFIG_NODE, &no_debug_isis_tx_queue_cmd);
ddb33326
CF
2220 install_element(CONFIG_NODE, &debug_isis_flooding_cmd);
2221 install_element(CONFIG_NODE, &no_debug_isis_flooding_cmd);
d62a17ae 2222 install_element(CONFIG_NODE, &debug_isis_snp_cmd);
2223 install_element(CONFIG_NODE, &no_debug_isis_snp_cmd);
2224 install_element(CONFIG_NODE, &debug_isis_upd_cmd);
2225 install_element(CONFIG_NODE, &no_debug_isis_upd_cmd);
2226 install_element(CONFIG_NODE, &debug_isis_spfevents_cmd);
2227 install_element(CONFIG_NODE, &no_debug_isis_spfevents_cmd);
d62a17ae 2228 install_element(CONFIG_NODE, &debug_isis_rtevents_cmd);
2229 install_element(CONFIG_NODE, &no_debug_isis_rtevents_cmd);
2230 install_element(CONFIG_NODE, &debug_isis_events_cmd);
2231 install_element(CONFIG_NODE, &no_debug_isis_events_cmd);
2232 install_element(CONFIG_NODE, &debug_isis_packet_dump_cmd);
2233 install_element(CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
2234 install_element(CONFIG_NODE, &debug_isis_lsp_gen_cmd);
2235 install_element(CONFIG_NODE, &no_debug_isis_lsp_gen_cmd);
2236 install_element(CONFIG_NODE, &debug_isis_lsp_sched_cmd);
2237 install_element(CONFIG_NODE, &no_debug_isis_lsp_sched_cmd);
2815f817
CF
2238 install_element(CONFIG_NODE, &debug_isis_bfd_cmd);
2239 install_element(CONFIG_NODE, &no_debug_isis_bfd_cmd);
d62a17ae 2240
7c0cbd0e 2241 install_default(ROUTER_NODE);
d62a17ae 2242
aaf2fd21
EDP
2243#ifdef FABRICD
2244 install_element(CONFIG_NODE, &router_openfabric_cmd);
2245 install_element(CONFIG_NODE, &no_router_openfabric_cmd);
2adf66ff 2246
7c0cbd0e
CF
2247 install_element(ROUTER_NODE, &net_cmd);
2248 install_element(ROUTER_NODE, &no_net_cmd);
2adf66ff 2249
7c0cbd0e
CF
2250 install_element(ROUTER_NODE, &isis_topology_cmd);
2251 install_element(ROUTER_NODE, &no_isis_topology_cmd);
2adf66ff 2252
7c0cbd0e
CF
2253 install_element(ROUTER_NODE, &log_adj_changes_cmd);
2254 install_element(ROUTER_NODE, &no_log_adj_changes_cmd);
2adf66ff 2255#endif /* ifdef FABRICD */
d62a17ae 2256
2257 spf_backoff_cmd_init();
eb5d44eb 2258}