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