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