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