2 * IS-IS Rout(e)ing protocol - isisd.c
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
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)
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
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 #include "spf_backoff.h"
40 #include "isisd/dict.h"
41 #include "isisd/isis_constants.h"
42 #include "isisd/isis_common.h"
43 #include "isisd/isis_flags.h"
44 #include "isisd/isis_circuit.h"
45 #include "isisd/isis_csm.h"
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"
52 #include "isisd/isis_tlv.h"
53 #include "isisd/isis_lsp.h"
54 #include "isisd/isis_spf.h"
55 #include "isisd/isis_route.h"
56 #include "isisd/isis_zebra.h"
57 #include "isisd/isis_events.h"
58 #include "isisd/isis_te.h"
60 struct isis
*isis
= NULL
;
62 DEFINE_QOBJ_TYPE(isis
)
63 DEFINE_QOBJ_TYPE(isis_area
)
68 int isis_area_get(struct vty
*, const char *);
69 int isis_area_destroy(struct vty
*, const char *);
70 int area_net_title(struct vty
*, const char *);
71 int area_clear_net_title(struct vty
*, const char *);
72 int show_isis_interface_common(struct vty
*, const char *ifname
, char);
73 int show_isis_neighbor_common(struct vty
*, const char *id
, char);
74 int clear_isis_neighbor_common(struct vty
*, const char *id
);
75 int isis_config_write(struct vty
*);
78 void isis_new(unsigned long process_id
)
80 isis
= XCALLOC(MTYPE_ISIS
, sizeof(struct isis
));
84 isis
->max_area_addrs
= 3;
85 isis
->process_id
= process_id
;
87 isis
->area_list
= list_new();
88 isis
->init_circ_list
= list_new();
89 isis
->uptime
= time(NULL
);
90 isis
->nexthops
= list_new();
91 isis
->nexthops6
= list_new();
94 * uncomment the next line for full debugs
96 /* isis->debugs = 0xFFFF; */
97 isisMplsTE
.status
= disable
; /* Only support TE metric */
101 struct isis_area
*isis_area_create(const char *area_tag
)
103 struct isis_area
*area
;
105 area
= XCALLOC(MTYPE_ISIS_AREA
, sizeof(struct isis_area
));
108 * The first instance is level-1-2 rest are level-1, unless otherwise
111 if (listcount(isis
->area_list
) > 0)
112 area
->is_type
= IS_LEVEL_1
;
114 area
->is_type
= IS_LEVEL_1_AND_2
;
117 * intialize the databases
119 if (area
->is_type
& IS_LEVEL_1
) {
120 area
->lspdb
[0] = lsp_db_init();
121 area
->route_table
[0] = route_table_init();
122 area
->route_table6
[0] = route_table_init();
124 if (area
->is_type
& IS_LEVEL_2
) {
125 area
->lspdb
[1] = lsp_db_init();
126 area
->route_table
[1] = route_table_init();
127 area
->route_table6
[1] = route_table_init();
130 spftree_area_init(area
);
132 area
->circuit_list
= list_new();
133 area
->area_addrs
= list_new();
134 THREAD_TIMER_ON(master
, area
->t_tick
, lsp_tick
, area
, 1);
135 flags_initialize(&area
->flags
);
140 area
->max_lsp_lifetime
[0] = DEFAULT_LSP_LIFETIME
; /* 1200 */
141 area
->max_lsp_lifetime
[1] = DEFAULT_LSP_LIFETIME
; /* 1200 */
142 area
->lsp_refresh
[0] = DEFAULT_MAX_LSP_GEN_INTERVAL
; /* 900 */
143 area
->lsp_refresh
[1] = DEFAULT_MAX_LSP_GEN_INTERVAL
; /* 900 */
144 area
->lsp_gen_interval
[0] = DEFAULT_MIN_LSP_GEN_INTERVAL
;
145 area
->lsp_gen_interval
[1] = DEFAULT_MIN_LSP_GEN_INTERVAL
;
146 area
->min_spf_interval
[0] = MINIMUM_SPF_INTERVAL
;
147 area
->min_spf_interval
[1] = MINIMUM_SPF_INTERVAL
;
148 area
->dynhostname
= 1;
151 area
->lsp_frag_threshold
= 90;
152 area
->lsp_mtu
= DEFAULT_LSP_MTU
;
154 area
->area_tag
= strdup(area_tag
);
155 listnode_add(isis
->area_list
, area
);
158 QOBJ_REG(area
, isis_area
);
163 struct isis_area
*isis_area_lookup(const char *area_tag
)
165 struct isis_area
*area
;
166 struct listnode
*node
;
168 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
))
169 if ((area
->area_tag
== NULL
&& area_tag
== NULL
)
170 || (area
->area_tag
&& area_tag
171 && strcmp(area
->area_tag
, area_tag
) == 0))
177 int isis_area_get(struct vty
*vty
, const char *area_tag
)
179 struct isis_area
*area
;
181 area
= isis_area_lookup(area_tag
);
184 VTY_PUSH_CONTEXT(ISIS_NODE
, area
);
188 area
= isis_area_create(area_tag
);
190 if (isis
->debugs
& DEBUG_EVENTS
)
191 zlog_debug("New IS-IS area instance %s", area
->area_tag
);
193 VTY_PUSH_CONTEXT(ISIS_NODE
, area
);
198 int isis_area_destroy(struct vty
*vty
, const char *area_tag
)
200 struct isis_area
*area
;
201 struct listnode
*node
, *nnode
;
202 struct isis_circuit
*circuit
;
203 struct area_addr
*addr
;
205 area
= isis_area_lookup(area_tag
);
208 vty_out(vty
, "Can't find ISIS instance %s", VTY_NEWLINE
);
209 return CMD_ERR_NO_MATCH
;
214 if (area
->circuit_list
) {
215 for (ALL_LIST_ELEMENTS(area
->circuit_list
, node
, nnode
,
217 circuit
->ip_router
= 0;
218 circuit
->ipv6_router
= 0;
219 isis_csm_state_change(ISIS_DISABLE
, circuit
, area
);
221 list_delete(area
->circuit_list
);
222 area
->circuit_list
= NULL
;
225 if (area
->lspdb
[0] != NULL
) {
226 lsp_db_destroy(area
->lspdb
[0]);
227 area
->lspdb
[0] = NULL
;
229 if (area
->lspdb
[1] != NULL
) {
230 lsp_db_destroy(area
->lspdb
[1]);
231 area
->lspdb
[1] = NULL
;
234 spftree_area_del(area
);
236 THREAD_TIMER_OFF(area
->spf_timer
[0]);
237 THREAD_TIMER_OFF(area
->spf_timer
[1]);
239 spf_backoff_free(area
->spf_delay_ietf
[0]);
240 spf_backoff_free(area
->spf_delay_ietf
[1]);
242 /* invalidate and validate would delete all routes from zebra */
243 isis_route_invalidate(area
);
244 isis_route_validate(area
);
246 if (area
->route_table
[0]) {
247 route_table_finish(area
->route_table
[0]);
248 area
->route_table
[0] = NULL
;
250 if (area
->route_table
[1]) {
251 route_table_finish(area
->route_table
[1]);
252 area
->route_table
[1] = NULL
;
254 if (area
->route_table6
[0]) {
255 route_table_finish(area
->route_table6
[0]);
256 area
->route_table6
[0] = NULL
;
258 if (area
->route_table6
[1]) {
259 route_table_finish(area
->route_table6
[1]);
260 area
->route_table6
[1] = NULL
;
263 isis_redist_area_finish(area
);
265 for (ALL_LIST_ELEMENTS(area
->area_addrs
, node
, nnode
, addr
)) {
266 list_delete_node(area
->area_addrs
, node
);
267 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
269 area
->area_addrs
= NULL
;
271 THREAD_TIMER_OFF(area
->t_tick
);
272 THREAD_TIMER_OFF(area
->t_lsp_refresh
[0]);
273 THREAD_TIMER_OFF(area
->t_lsp_refresh
[1]);
275 thread_cancel_event(master
, area
);
277 listnode_delete(isis
->area_list
, area
);
279 free(area
->area_tag
);
281 XFREE(MTYPE_ISIS_AREA
, area
);
283 if (listcount(isis
->area_list
) == 0) {
284 memset(isis
->sysid
, 0, ISIS_SYS_ID_LEN
);
291 int area_net_title(struct vty
*vty
, const char *net_title
)
293 VTY_DECLVAR_CONTEXT(isis_area
, area
);
294 struct area_addr
*addr
;
295 struct area_addr
*addrp
;
296 struct listnode
*node
;
300 /* We check that we are not over the maximal number of addresses */
301 if (listcount(area
->area_addrs
) >= isis
->max_area_addrs
) {
303 "Maximum of area addresses (%d) already reached %s",
304 isis
->max_area_addrs
, VTY_NEWLINE
);
305 return CMD_ERR_NOTHING_TODO
;
308 addr
= XMALLOC(MTYPE_ISIS_AREA_ADDR
, sizeof(struct area_addr
));
309 addr
->addr_len
= dotformat2buff(buff
, net_title
);
310 memcpy(addr
->area_addr
, buff
, addr
->addr_len
);
312 zlog_debug("added area address %s for area %s (address length %d)",
313 net_title
, area
->area_tag
, addr
->addr_len
);
314 #endif /* EXTREME_DEBUG */
315 if (addr
->addr_len
< 8 || addr
->addr_len
> 20) {
317 "area address must be at least 8..20 octets long (%d)%s",
318 addr
->addr_len
, VTY_NEWLINE
);
319 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
320 return CMD_ERR_AMBIGUOUS
;
323 if (addr
->area_addr
[addr
->addr_len
- 1] != 0) {
325 "nsel byte (last byte) in area address must be 0%s",
327 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
328 return CMD_ERR_AMBIGUOUS
;
331 if (isis
->sysid_set
== 0) {
333 * First area address - get the SystemID for this router
335 memcpy(isis
->sysid
, GETSYSID(addr
), ISIS_SYS_ID_LEN
);
337 if (isis
->debugs
& DEBUG_EVENTS
)
338 zlog_debug("Router has SystemID %s",
339 sysid_print(isis
->sysid
));
342 * Check that the SystemID portions match
344 if (memcmp(isis
->sysid
, GETSYSID(addr
), ISIS_SYS_ID_LEN
)) {
346 "System ID must not change when defining additional area"
349 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
350 return CMD_ERR_AMBIGUOUS
;
353 /* now we see that we don't already have this address */
354 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
, node
, addrp
)) {
355 if ((addrp
->addr_len
+ ISIS_SYS_ID_LEN
+ ISIS_NSEL_LEN
)
358 if (!memcmp(addrp
->area_addr
, addr
->area_addr
,
360 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
361 return CMD_SUCCESS
; /* silent fail */
367 * Forget the systemID part of the address
369 addr
->addr_len
-= (ISIS_SYS_ID_LEN
+ ISIS_NSEL_LEN
);
370 listnode_add(area
->area_addrs
, addr
);
372 /* only now we can safely generate our LSPs for this area */
373 if (listcount(area
->area_addrs
) > 0) {
374 if (area
->is_type
& IS_LEVEL_1
)
375 lsp_generate(area
, IS_LEVEL_1
);
376 if (area
->is_type
& IS_LEVEL_2
)
377 lsp_generate(area
, IS_LEVEL_2
);
383 int area_clear_net_title(struct vty
*vty
, const char *net_title
)
385 VTY_DECLVAR_CONTEXT(isis_area
, area
);
386 struct area_addr addr
, *addrp
= NULL
;
387 struct listnode
*node
;
390 addr
.addr_len
= dotformat2buff(buff
, net_title
);
391 if (addr
.addr_len
< 8 || addr
.addr_len
> 20) {
393 "Unsupported area address length %d, should be 8...20 %s",
394 addr
.addr_len
, VTY_NEWLINE
);
395 return CMD_ERR_AMBIGUOUS
;
398 memcpy(addr
.area_addr
, buff
, (int)addr
.addr_len
);
400 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
, node
, addrp
))
401 if ((addrp
->addr_len
+ ISIS_SYS_ID_LEN
+ 1) == addr
.addr_len
402 && !memcmp(addrp
->area_addr
, addr
.area_addr
, addr
.addr_len
))
406 vty_out(vty
, "No area address %s for area %s %s", net_title
,
407 area
->area_tag
, VTY_NEWLINE
);
408 return CMD_ERR_NO_MATCH
;
411 listnode_delete(area
->area_addrs
, addrp
);
412 XFREE(MTYPE_ISIS_AREA_ADDR
, addrp
);
415 * Last area address - reset the SystemID for this router
417 if (listcount(area
->area_addrs
) == 0) {
418 memset(isis
->sysid
, 0, ISIS_SYS_ID_LEN
);
420 if (isis
->debugs
& DEBUG_EVENTS
)
421 zlog_debug("Router has no SystemID");
428 * 'show isis interface' command
431 int show_isis_interface_common(struct vty
*vty
, const char *ifname
, char detail
)
433 struct listnode
*anode
, *cnode
;
434 struct isis_area
*area
;
435 struct isis_circuit
*circuit
;
438 vty_out(vty
, "IS-IS Routing Process not enabled%s",
443 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, anode
, area
)) {
444 vty_out(vty
, "Area %s:%s", area
->area_tag
, VTY_NEWLINE
);
446 if (detail
== ISIS_UI_LEVEL_BRIEF
)
448 " Interface CircId State Type Level%s",
451 for (ALL_LIST_ELEMENTS_RO(area
->circuit_list
, cnode
, circuit
))
453 isis_circuit_print_vty(circuit
, vty
, detail
);
454 else if (strcmp(circuit
->interface
->name
, ifname
) == 0)
455 isis_circuit_print_vty(circuit
, vty
, detail
);
461 DEFUN (show_isis_interface
,
462 show_isis_interface_cmd
,
463 "show isis interface",
465 "ISIS network information\n"
468 return show_isis_interface_common(vty
, NULL
, ISIS_UI_LEVEL_BRIEF
);
471 DEFUN (show_isis_interface_detail
,
472 show_isis_interface_detail_cmd
,
473 "show isis interface detail",
475 "ISIS network information\n"
477 "show detailed information\n")
479 return show_isis_interface_common(vty
, NULL
, ISIS_UI_LEVEL_DETAIL
);
482 DEFUN (show_isis_interface_arg
,
483 show_isis_interface_arg_cmd
,
484 "show isis interface WORD",
486 "ISIS network information\n"
488 "ISIS interface name\n")
491 return show_isis_interface_common(vty
, argv
[idx_word
]->arg
,
492 ISIS_UI_LEVEL_DETAIL
);
496 * 'show isis neighbor' command
499 int show_isis_neighbor_common(struct vty
*vty
, const char *id
, char detail
)
501 struct listnode
*anode
, *cnode
, *node
;
502 struct isis_area
*area
;
503 struct isis_circuit
*circuit
;
505 struct isis_adjacency
*adj
;
506 struct isis_dynhn
*dynhn
;
507 u_char sysid
[ISIS_SYS_ID_LEN
];
511 vty_out(vty
, "IS-IS Routing Process not enabled%s",
516 memset(sysid
, 0, ISIS_SYS_ID_LEN
);
518 if (sysid2buff(sysid
, id
) == 0) {
519 dynhn
= dynhn_find_by_name(id
);
521 vty_out(vty
, "Invalid system id %s%s", id
,
525 memcpy(sysid
, dynhn
->id
, ISIS_SYS_ID_LEN
);
529 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, anode
, area
)) {
530 vty_out(vty
, "Area %s:%s", area
->area_tag
, VTY_NEWLINE
);
532 if (detail
== ISIS_UI_LEVEL_BRIEF
)
534 " System Id Interface L State"
538 for (ALL_LIST_ELEMENTS_RO(area
->circuit_list
, cnode
, circuit
)) {
539 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
540 for (i
= 0; i
< 2; i
++) {
541 adjdb
= circuit
->u
.bc
.adjdb
[i
];
542 if (adjdb
&& adjdb
->count
) {
543 for (ALL_LIST_ELEMENTS_RO(
546 || !memcmp(adj
->sysid
,
555 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
556 && circuit
->u
.p2p
.neighbor
) {
557 adj
= circuit
->u
.p2p
.neighbor
;
559 || !memcmp(adj
->sysid
, sysid
,
561 isis_adj_print_vty(adj
, vty
, detail
);
570 * 'clear isis neighbor' command
572 int clear_isis_neighbor_common(struct vty
*vty
, const char *id
)
574 struct listnode
*anode
, *cnode
, *cnextnode
, *node
, *nnode
;
575 struct isis_area
*area
;
576 struct isis_circuit
*circuit
;
578 struct isis_adjacency
*adj
;
579 struct isis_dynhn
*dynhn
;
580 u_char sysid
[ISIS_SYS_ID_LEN
];
584 vty_out(vty
, "IS-IS Routing Process not enabled%s",
589 memset(sysid
, 0, ISIS_SYS_ID_LEN
);
591 if (sysid2buff(sysid
, id
) == 0) {
592 dynhn
= dynhn_find_by_name(id
);
594 vty_out(vty
, "Invalid system id %s%s", id
,
598 memcpy(sysid
, dynhn
->id
, ISIS_SYS_ID_LEN
);
602 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, anode
, area
)) {
603 for (ALL_LIST_ELEMENTS(area
->circuit_list
, cnode
, cnextnode
,
605 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
606 for (i
= 0; i
< 2; i
++) {
607 adjdb
= circuit
->u
.bc
.adjdb
[i
];
608 if (adjdb
&& adjdb
->count
) {
609 for (ALL_LIST_ELEMENTS(
613 || !memcmp(adj
->sysid
,
616 isis_adj_state_change(
619 "clear user request");
622 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
623 && circuit
->u
.p2p
.neighbor
) {
624 adj
= circuit
->u
.p2p
.neighbor
;
626 || !memcmp(adj
->sysid
, sysid
,
628 isis_adj_state_change(
630 "clear user request");
638 DEFUN (show_isis_neighbor
,
639 show_isis_neighbor_cmd
,
640 "show isis neighbor",
642 "ISIS network information\n"
643 "ISIS neighbor adjacencies\n")
645 return show_isis_neighbor_common(vty
, NULL
, ISIS_UI_LEVEL_BRIEF
);
648 DEFUN (show_isis_neighbor_detail
,
649 show_isis_neighbor_detail_cmd
,
650 "show isis neighbor detail",
652 "ISIS network information\n"
653 "ISIS neighbor adjacencies\n"
654 "show detailed information\n")
656 return show_isis_neighbor_common(vty
, NULL
, ISIS_UI_LEVEL_DETAIL
);
659 DEFUN (show_isis_neighbor_arg
,
660 show_isis_neighbor_arg_cmd
,
661 "show isis neighbor WORD",
663 "ISIS network information\n"
664 "ISIS neighbor adjacencies\n"
668 return show_isis_neighbor_common(vty
, argv
[idx_word
]->arg
,
669 ISIS_UI_LEVEL_DETAIL
);
672 DEFUN (clear_isis_neighbor
,
673 clear_isis_neighbor_cmd
,
674 "clear isis neighbor",
676 "Reset ISIS network information\n"
677 "Reset ISIS neighbor adjacencies\n")
679 return clear_isis_neighbor_common(vty
, NULL
);
682 DEFUN (clear_isis_neighbor_arg
,
683 clear_isis_neighbor_arg_cmd
,
684 "clear isis neighbor WORD",
686 "ISIS network information\n"
687 "ISIS neighbor adjacencies\n"
691 return clear_isis_neighbor_common(vty
, argv
[idx_word
]->arg
);
695 * 'isis debug', 'show debugging'
697 void print_debug(struct vty
*vty
, int flags
, int onoff
)
701 strcpy(onoffs
, "on");
703 strcpy(onoffs
, "off");
705 if (flags
& DEBUG_ADJ_PACKETS
)
707 "IS-IS Adjacency related packets debugging is %s%s",
708 onoffs
, VTY_NEWLINE
);
709 if (flags
& DEBUG_CHECKSUM_ERRORS
)
710 vty_out(vty
, "IS-IS checksum errors debugging is %s%s", onoffs
,
712 if (flags
& DEBUG_LOCAL_UPDATES
)
713 vty_out(vty
, "IS-IS local updates debugging is %s%s", onoffs
,
715 if (flags
& DEBUG_PROTOCOL_ERRORS
)
716 vty_out(vty
, "IS-IS protocol errors debugging is %s%s", onoffs
,
718 if (flags
& DEBUG_SNP_PACKETS
)
719 vty_out(vty
, "IS-IS CSNP/PSNP packets debugging is %s%s",
720 onoffs
, VTY_NEWLINE
);
721 if (flags
& DEBUG_SPF_EVENTS
)
722 vty_out(vty
, "IS-IS SPF events debugging is %s%s", onoffs
,
724 if (flags
& DEBUG_SPF_STATS
)
726 "IS-IS SPF Timing and Statistics Data debugging is %s%s",
727 onoffs
, VTY_NEWLINE
);
728 if (flags
& DEBUG_SPF_TRIGGERS
)
729 vty_out(vty
, "IS-IS SPF triggering events debugging is %s%s",
730 onoffs
, VTY_NEWLINE
);
731 if (flags
& DEBUG_UPDATE_PACKETS
)
732 vty_out(vty
, "IS-IS Update related packet debugging is %s%s",
733 onoffs
, VTY_NEWLINE
);
734 if (flags
& DEBUG_RTE_EVENTS
)
735 vty_out(vty
, "IS-IS Route related debuggin is %s%s", onoffs
,
737 if (flags
& DEBUG_EVENTS
)
738 vty_out(vty
, "IS-IS Event debugging is %s%s", onoffs
,
740 if (flags
& DEBUG_PACKET_DUMP
)
741 vty_out(vty
, "IS-IS Packet dump debugging is %s%s", onoffs
,
743 if (flags
& DEBUG_LSP_GEN
)
744 vty_out(vty
, "IS-IS LSP generation debugging is %s%s", onoffs
,
746 if (flags
& DEBUG_LSP_SCHED
)
747 vty_out(vty
, "IS-IS LSP scheduling debugging is %s%s", onoffs
,
751 DEFUN (show_debugging
,
752 show_debugging_isis_cmd
,
753 "show debugging isis",
755 "State of each debugging option\n"
759 vty_out(vty
, "IS-IS:%s", VTY_NEWLINE
);
760 print_debug(vty
, isis
->debugs
, 1);
766 static struct cmd_node debug_node
= {DEBUG_NODE
, "", 1};
768 static int config_write_debug(struct vty
*vty
)
771 int flags
= isis
->debugs
;
773 if (flags
& DEBUG_ADJ_PACKETS
) {
774 vty_out(vty
, "debug isis adj-packets%s", VTY_NEWLINE
);
777 if (flags
& DEBUG_CHECKSUM_ERRORS
) {
778 vty_out(vty
, "debug isis checksum-errors%s", VTY_NEWLINE
);
781 if (flags
& DEBUG_LOCAL_UPDATES
) {
782 vty_out(vty
, "debug isis local-updates%s", VTY_NEWLINE
);
785 if (flags
& DEBUG_PROTOCOL_ERRORS
) {
786 vty_out(vty
, "debug isis protocol-errors%s", VTY_NEWLINE
);
789 if (flags
& DEBUG_SNP_PACKETS
) {
790 vty_out(vty
, "debug isis snp-packets%s", VTY_NEWLINE
);
793 if (flags
& DEBUG_SPF_EVENTS
) {
794 vty_out(vty
, "debug isis spf-events%s", VTY_NEWLINE
);
797 if (flags
& DEBUG_SPF_STATS
) {
798 vty_out(vty
, "debug isis spf-statistics%s", VTY_NEWLINE
);
801 if (flags
& DEBUG_SPF_TRIGGERS
) {
802 vty_out(vty
, "debug isis spf-triggers%s", VTY_NEWLINE
);
805 if (flags
& DEBUG_UPDATE_PACKETS
) {
806 vty_out(vty
, "debug isis update-packets%s", VTY_NEWLINE
);
809 if (flags
& DEBUG_RTE_EVENTS
) {
810 vty_out(vty
, "debug isis route-events%s", VTY_NEWLINE
);
813 if (flags
& DEBUG_EVENTS
) {
814 vty_out(vty
, "debug isis events%s", VTY_NEWLINE
);
817 if (flags
& DEBUG_PACKET_DUMP
) {
818 vty_out(vty
, "debug isis packet-dump%s", VTY_NEWLINE
);
821 if (flags
& DEBUG_LSP_GEN
) {
822 vty_out(vty
, "debug isis lsp-gen%s", VTY_NEWLINE
);
825 if (flags
& DEBUG_LSP_SCHED
) {
826 vty_out(vty
, "debug isis lsp-sched%s", VTY_NEWLINE
);
829 write
+= spf_backoff_write_config(vty
);
834 DEFUN (debug_isis_adj
,
836 "debug isis adj-packets",
838 "IS-IS information\n"
839 "IS-IS Adjacency related packets\n")
841 isis
->debugs
|= DEBUG_ADJ_PACKETS
;
842 print_debug(vty
, DEBUG_ADJ_PACKETS
, 1);
847 DEFUN (no_debug_isis_adj
,
848 no_debug_isis_adj_cmd
,
849 "no debug isis adj-packets",
852 "IS-IS information\n"
853 "IS-IS Adjacency related packets\n")
855 isis
->debugs
&= ~DEBUG_ADJ_PACKETS
;
856 print_debug(vty
, DEBUG_ADJ_PACKETS
, 0);
861 DEFUN (debug_isis_csum
,
863 "debug isis checksum-errors",
865 "IS-IS information\n"
866 "IS-IS LSP checksum errors\n")
868 isis
->debugs
|= DEBUG_CHECKSUM_ERRORS
;
869 print_debug(vty
, DEBUG_CHECKSUM_ERRORS
, 1);
874 DEFUN (no_debug_isis_csum
,
875 no_debug_isis_csum_cmd
,
876 "no debug isis checksum-errors",
879 "IS-IS information\n"
880 "IS-IS LSP checksum errors\n")
882 isis
->debugs
&= ~DEBUG_CHECKSUM_ERRORS
;
883 print_debug(vty
, DEBUG_CHECKSUM_ERRORS
, 0);
888 DEFUN (debug_isis_lupd
,
890 "debug isis local-updates",
892 "IS-IS information\n"
893 "IS-IS local update packets\n")
895 isis
->debugs
|= DEBUG_LOCAL_UPDATES
;
896 print_debug(vty
, DEBUG_LOCAL_UPDATES
, 1);
901 DEFUN (no_debug_isis_lupd
,
902 no_debug_isis_lupd_cmd
,
903 "no debug isis local-updates",
906 "IS-IS information\n"
907 "IS-IS local update packets\n")
909 isis
->debugs
&= ~DEBUG_LOCAL_UPDATES
;
910 print_debug(vty
, DEBUG_LOCAL_UPDATES
, 0);
915 DEFUN (debug_isis_err
,
917 "debug isis protocol-errors",
919 "IS-IS information\n"
920 "IS-IS LSP protocol errors\n")
922 isis
->debugs
|= DEBUG_PROTOCOL_ERRORS
;
923 print_debug(vty
, DEBUG_PROTOCOL_ERRORS
, 1);
928 DEFUN (no_debug_isis_err
,
929 no_debug_isis_err_cmd
,
930 "no debug isis protocol-errors",
933 "IS-IS information\n"
934 "IS-IS LSP protocol errors\n")
936 isis
->debugs
&= ~DEBUG_PROTOCOL_ERRORS
;
937 print_debug(vty
, DEBUG_PROTOCOL_ERRORS
, 0);
942 DEFUN (debug_isis_snp
,
944 "debug isis snp-packets",
946 "IS-IS information\n"
947 "IS-IS CSNP/PSNP packets\n")
949 isis
->debugs
|= DEBUG_SNP_PACKETS
;
950 print_debug(vty
, DEBUG_SNP_PACKETS
, 1);
955 DEFUN (no_debug_isis_snp
,
956 no_debug_isis_snp_cmd
,
957 "no debug isis snp-packets",
960 "IS-IS information\n"
961 "IS-IS CSNP/PSNP packets\n")
963 isis
->debugs
&= ~DEBUG_SNP_PACKETS
;
964 print_debug(vty
, DEBUG_SNP_PACKETS
, 0);
969 DEFUN (debug_isis_upd
,
971 "debug isis update-packets",
973 "IS-IS information\n"
974 "IS-IS Update related packets\n")
976 isis
->debugs
|= DEBUG_UPDATE_PACKETS
;
977 print_debug(vty
, DEBUG_UPDATE_PACKETS
, 1);
982 DEFUN (no_debug_isis_upd
,
983 no_debug_isis_upd_cmd
,
984 "no debug isis update-packets",
987 "IS-IS information\n"
988 "IS-IS Update related packets\n")
990 isis
->debugs
&= ~DEBUG_UPDATE_PACKETS
;
991 print_debug(vty
, DEBUG_UPDATE_PACKETS
, 0);
996 DEFUN (debug_isis_spfevents
,
997 debug_isis_spfevents_cmd
,
998 "debug isis spf-events",
1000 "IS-IS information\n"
1001 "IS-IS Shortest Path First Events\n")
1003 isis
->debugs
|= DEBUG_SPF_EVENTS
;
1004 print_debug(vty
, DEBUG_SPF_EVENTS
, 1);
1009 DEFUN (no_debug_isis_spfevents
,
1010 no_debug_isis_spfevents_cmd
,
1011 "no debug isis spf-events",
1014 "IS-IS information\n"
1015 "IS-IS Shortest Path First Events\n")
1017 isis
->debugs
&= ~DEBUG_SPF_EVENTS
;
1018 print_debug(vty
, DEBUG_SPF_EVENTS
, 0);
1023 DEFUN (debug_isis_spfstats
,
1024 debug_isis_spfstats_cmd
,
1025 "debug isis spf-statistics ",
1027 "IS-IS information\n"
1028 "IS-IS SPF Timing and Statistic Data\n")
1030 isis
->debugs
|= DEBUG_SPF_STATS
;
1031 print_debug(vty
, DEBUG_SPF_STATS
, 1);
1036 DEFUN (no_debug_isis_spfstats
,
1037 no_debug_isis_spfstats_cmd
,
1038 "no debug isis spf-statistics",
1041 "IS-IS information\n"
1042 "IS-IS SPF Timing and Statistic Data\n")
1044 isis
->debugs
&= ~DEBUG_SPF_STATS
;
1045 print_debug(vty
, DEBUG_SPF_STATS
, 0);
1050 DEFUN (debug_isis_spftrigg
,
1051 debug_isis_spftrigg_cmd
,
1052 "debug isis spf-triggers",
1054 "IS-IS information\n"
1055 "IS-IS SPF triggering events\n")
1057 isis
->debugs
|= DEBUG_SPF_TRIGGERS
;
1058 print_debug(vty
, DEBUG_SPF_TRIGGERS
, 1);
1063 DEFUN (no_debug_isis_spftrigg
,
1064 no_debug_isis_spftrigg_cmd
,
1065 "no debug isis spf-triggers",
1068 "IS-IS information\n"
1069 "IS-IS SPF triggering events\n")
1071 isis
->debugs
&= ~DEBUG_SPF_TRIGGERS
;
1072 print_debug(vty
, DEBUG_SPF_TRIGGERS
, 0);
1077 DEFUN (debug_isis_rtevents
,
1078 debug_isis_rtevents_cmd
,
1079 "debug isis route-events",
1081 "IS-IS information\n"
1082 "IS-IS Route related events\n")
1084 isis
->debugs
|= DEBUG_RTE_EVENTS
;
1085 print_debug(vty
, DEBUG_RTE_EVENTS
, 1);
1090 DEFUN (no_debug_isis_rtevents
,
1091 no_debug_isis_rtevents_cmd
,
1092 "no debug isis route-events",
1095 "IS-IS information\n"
1096 "IS-IS Route related events\n")
1098 isis
->debugs
&= ~DEBUG_RTE_EVENTS
;
1099 print_debug(vty
, DEBUG_RTE_EVENTS
, 0);
1104 DEFUN (debug_isis_events
,
1105 debug_isis_events_cmd
,
1106 "debug isis events",
1108 "IS-IS information\n"
1111 isis
->debugs
|= DEBUG_EVENTS
;
1112 print_debug(vty
, DEBUG_EVENTS
, 1);
1117 DEFUN (no_debug_isis_events
,
1118 no_debug_isis_events_cmd
,
1119 "no debug isis events",
1122 "IS-IS information\n"
1125 isis
->debugs
&= ~DEBUG_EVENTS
;
1126 print_debug(vty
, DEBUG_EVENTS
, 0);
1131 DEFUN (debug_isis_packet_dump
,
1132 debug_isis_packet_dump_cmd
,
1133 "debug isis packet-dump",
1135 "IS-IS information\n"
1136 "IS-IS packet dump\n")
1138 isis
->debugs
|= DEBUG_PACKET_DUMP
;
1139 print_debug(vty
, DEBUG_PACKET_DUMP
, 1);
1144 DEFUN (no_debug_isis_packet_dump
,
1145 no_debug_isis_packet_dump_cmd
,
1146 "no debug isis packet-dump",
1149 "IS-IS information\n"
1150 "IS-IS packet dump\n")
1152 isis
->debugs
&= ~DEBUG_PACKET_DUMP
;
1153 print_debug(vty
, DEBUG_PACKET_DUMP
, 0);
1158 DEFUN (debug_isis_lsp_gen
,
1159 debug_isis_lsp_gen_cmd
,
1160 "debug isis lsp-gen",
1162 "IS-IS information\n"
1163 "IS-IS generation of own LSPs\n")
1165 isis
->debugs
|= DEBUG_LSP_GEN
;
1166 print_debug(vty
, DEBUG_LSP_GEN
, 1);
1171 DEFUN (no_debug_isis_lsp_gen
,
1172 no_debug_isis_lsp_gen_cmd
,
1173 "no debug isis lsp-gen",
1176 "IS-IS information\n"
1177 "IS-IS generation of own LSPs\n")
1179 isis
->debugs
&= ~DEBUG_LSP_GEN
;
1180 print_debug(vty
, DEBUG_LSP_GEN
, 0);
1185 DEFUN (debug_isis_lsp_sched
,
1186 debug_isis_lsp_sched_cmd
,
1187 "debug isis lsp-sched",
1189 "IS-IS information\n"
1190 "IS-IS scheduling of LSP generation\n")
1192 isis
->debugs
|= DEBUG_LSP_SCHED
;
1193 print_debug(vty
, DEBUG_LSP_SCHED
, 1);
1198 DEFUN (no_debug_isis_lsp_sched
,
1199 no_debug_isis_lsp_sched_cmd
,
1200 "no debug isis lsp-sched",
1203 "IS-IS information\n"
1204 "IS-IS scheduling of LSP generation\n")
1206 isis
->debugs
&= ~DEBUG_LSP_SCHED
;
1207 print_debug(vty
, DEBUG_LSP_SCHED
, 0);
1212 DEFUN (show_hostname
,
1214 "show isis hostname",
1216 "IS-IS information\n"
1217 "IS-IS Dynamic hostname mapping\n")
1219 dynhn_print_all(vty
);
1224 static void vty_out_timestr(struct vty
*vty
, time_t uptime
)
1227 time_t difftime
= time(NULL
);
1229 tm
= gmtime(&difftime
);
1231 #define ONE_DAY_SECOND 60*60*24
1232 #define ONE_WEEK_SECOND 60*60*24*7
1233 if (difftime
< ONE_DAY_SECOND
)
1234 vty_out(vty
, "%02d:%02d:%02d", tm
->tm_hour
, tm
->tm_min
,
1236 else if (difftime
< ONE_WEEK_SECOND
)
1237 vty_out(vty
, "%dd%02dh%02dm", tm
->tm_yday
, tm
->tm_hour
,
1240 vty_out(vty
, "%02dw%dd%02dh", tm
->tm_yday
/ 7,
1241 tm
->tm_yday
- ((tm
->tm_yday
/ 7) * 7), tm
->tm_hour
);
1242 vty_out(vty
, " ago");
1245 DEFUN (show_isis_spf_ietf
,
1246 show_isis_spf_ietf_cmd
,
1247 "show isis spf-delay-ietf",
1249 "IS-IS information\n"
1250 "IS-IS SPF delay IETF information\n")
1253 vty_out(vty
, "ISIS is not running%s", VTY_NEWLINE
);
1257 struct listnode
*node
;
1258 struct isis_area
*area
;
1260 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1261 vty_out(vty
, "Area %s:%s",
1262 area
->area_tag
? area
->area_tag
: "null", VTY_NEWLINE
);
1264 for (int level
= ISIS_LEVEL1
; level
<= ISIS_LEVELS
; level
++) {
1265 if ((area
->is_type
& level
) == 0)
1268 vty_out(vty
, " Level-%d:%s", level
, VTY_NEWLINE
);
1269 vty_out(vty
, " SPF delay status: ");
1270 if (area
->spf_timer
[level
- 1]) {
1271 struct timeval remain
= thread_timer_remain(
1272 area
->spf_timer
[level
- 1]);
1273 vty_out(vty
, "Pending, due in %ld msec%s",
1274 remain
.tv_sec
* 1000
1275 + remain
.tv_usec
/ 1000,
1278 vty_out(vty
, "Not scheduled%s", VTY_NEWLINE
);
1281 if (area
->spf_delay_ietf
[level
- 1]) {
1283 " Using draft-ietf-rtgwg-backoff-algo-04%s",
1286 area
->spf_delay_ietf
[level
- 1], vty
,
1289 vty_out(vty
, " Using legacy backoff algo%s",
1297 DEFUN (show_isis_summary
,
1298 show_isis_summary_cmd
,
1299 "show isis summary",
1300 SHOW_STR
"IS-IS information\n" "IS-IS summary\n")
1302 struct listnode
*node
, *node2
;
1303 struct isis_area
*area
;
1304 struct isis_spftree
*spftree
;
1308 vty_out(vty
, "ISIS is not running%s", VTY_NEWLINE
);
1312 vty_out(vty
, "Process Id : %ld%s", isis
->process_id
, VTY_NEWLINE
);
1313 if (isis
->sysid_set
)
1314 vty_out(vty
, "System Id : %s%s", sysid_print(isis
->sysid
),
1317 vty_out(vty
, "Up time : ");
1318 vty_out_timestr(vty
, isis
->uptime
);
1319 vty_out(vty
, "%s", VTY_NEWLINE
);
1321 if (isis
->area_list
)
1322 vty_out(vty
, "Number of areas : %d%s", isis
->area_list
->count
,
1325 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1326 vty_out(vty
, "Area %s:%s",
1327 area
->area_tag
? area
->area_tag
: "null", VTY_NEWLINE
);
1329 if (listcount(area
->area_addrs
) > 0) {
1330 struct area_addr
*area_addr
;
1331 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
, node2
,
1333 vty_out(vty
, " Net: %s%s",
1334 isonet_print(area_addr
->area_addr
,
1342 for (level
= ISIS_LEVEL1
; level
<= ISIS_LEVELS
; level
++) {
1343 if ((area
->is_type
& level
) == 0)
1346 vty_out(vty
, " Level-%d:%s", level
, VTY_NEWLINE
);
1347 spftree
= area
->spftree
[level
- 1];
1348 if (area
->spf_timer
[level
- 1])
1349 vty_out(vty
, " SPF: (pending)%s",
1352 vty_out(vty
, " SPF:%s", VTY_NEWLINE
);
1354 vty_out(vty
, " minimum interval : %d",
1355 area
->min_spf_interval
[level
- 1]);
1356 if (area
->spf_delay_ietf
[level
- 1])
1358 " (not used, IETF SPF delay activated)");
1359 vty_out(vty
, VTY_NEWLINE
);
1361 vty_out(vty
, " IPv4 route computation:%s",
1363 vty_out(vty
, " last run elapsed : ");
1364 vty_out_timestr(vty
, spftree
->last_run_timestamp
);
1365 vty_out(vty
, "%s", VTY_NEWLINE
);
1367 vty_out(vty
, " last run duration : %u usec%s",
1368 (u_int32_t
)spftree
->last_run_duration
,
1371 vty_out(vty
, " run count : %d%s",
1372 spftree
->runcount
, VTY_NEWLINE
);
1374 spftree
= area
->spftree6
[level
- 1];
1375 vty_out(vty
, " IPv6 route computation:%s",
1378 vty_out(vty
, " last run elapsed : ");
1379 vty_out_timestr(vty
, spftree
->last_run_timestamp
);
1380 vty_out(vty
, "%s", VTY_NEWLINE
);
1382 vty_out(vty
, " last run duration : %llu msec%s",
1383 (unsigned long long)spftree
->last_run_duration
,
1386 vty_out(vty
, " run count : %d%s",
1387 spftree
->runcount
, VTY_NEWLINE
);
1390 vty_out(vty
, "%s", VTY_NEWLINE
);
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> ]
1411 static int show_isis_database(struct vty
*vty
, const char *argv
, int ui_level
)
1413 struct listnode
*node
;
1414 struct isis_area
*area
;
1415 struct isis_lsp
*lsp
;
1416 struct isis_dynhn
*dynhn
;
1417 const char *pos
= argv
;
1418 u_char lspid
[ISIS_SYS_ID_LEN
+ 2];
1421 int level
, lsp_count
;
1423 if (isis
->area_list
->count
== 0)
1426 memset(&lspid
, 0, ISIS_SYS_ID_LEN
);
1427 memset(&sysid
, 0, 255);
1430 * extract fragment and pseudo id from the string argv
1432 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1433 * (b) <systemid/hostname>.<pseudo-id> or
1434 * (c) <systemid/hostname> or
1435 * Where systemid is in the form:
1439 strncpy(sysid
, argv
, 254);
1440 if (argv
&& strlen(argv
) > 3) {
1441 pos
= argv
+ strlen(argv
) - 3;
1442 if (strncmp(pos
, "-", 1) == 0) {
1443 memcpy(number
, ++pos
, 2);
1444 lspid
[ISIS_SYS_ID_LEN
+ 1] =
1445 (u_char
)strtol((char *)number
, NULL
, 16);
1447 if (strncmp(pos
, ".", 1) != 0)
1448 return CMD_ERR_AMBIGUOUS
;
1450 if (strncmp(pos
, ".", 1) == 0) {
1451 memcpy(number
, ++pos
, 2);
1452 lspid
[ISIS_SYS_ID_LEN
] =
1453 (u_char
)strtol((char *)number
, NULL
, 16);
1454 sysid
[pos
- argv
- 1] = '\0';
1458 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1459 vty_out(vty
, "Area %s:%s",
1460 area
->area_tag
? area
->area_tag
: "null", VTY_NEWLINE
);
1462 for (level
= 0; level
< ISIS_LEVELS
; level
++) {
1463 if (area
->lspdb
[level
]
1464 && dict_count(area
->lspdb
[level
]) > 0) {
1468 * Try to find the lsp-id if the argv
1471 * hostname.<pseudo-id>-<fragment>
1473 if (sysid2buff(lspid
, sysid
)) {
1476 area
->lspdb
[level
]);
1477 } else if ((dynhn
= dynhn_find_by_name(
1479 memcpy(lspid
, dynhn
->id
,
1483 area
->lspdb
[level
]);
1484 } else if (strncmp(unix_hostname(),
1487 memcpy(lspid
, isis
->sysid
,
1491 area
->lspdb
[level
]);
1495 if (lsp
!= NULL
|| argv
== NULL
) {
1497 "IS-IS Level-%d link-state database:%s",
1498 level
+ 1, VTY_NEWLINE
);
1500 /* print the title in all cases */
1503 "SeqNumber Chksum Holdtime ATT/P/OL%s",
1508 if (ui_level
== ISIS_UI_LEVEL_DETAIL
)
1515 } else if (argv
== NULL
) {
1516 lsp_count
= lsp_print_all(
1517 vty
, area
->lspdb
[level
],
1518 ui_level
, area
->dynhostname
);
1520 vty_out(vty
, " %u LSPs%s%s",
1521 lsp_count
, VTY_NEWLINE
,
1531 DEFUN (show_database
,
1533 "show isis database [detail] [WORD]",
1535 "IS-IS information\n"
1536 "IS-IS link state database\n"
1537 "Detailed information\n"
1541 int uilevel
= argv_find(argv
, argc
, "detail", &idx
)
1542 ? ISIS_UI_LEVEL_DETAIL
1543 : ISIS_UI_LEVEL_BRIEF
;
1544 char *id
= argv_find(argv
, argc
, "WORD", &idx
) ? argv
[idx
]->arg
: NULL
;
1545 return show_isis_database(vty
, id
, uilevel
);
1549 * 'router isis' command
1551 DEFUN_NOSH (router_isis
,
1556 "ISO Routing area tag")
1559 return isis_area_get(vty
, argv
[idx_word
]->arg
);
1563 *'no router isis' command
1565 DEFUN (no_router_isis
,
1567 "no router isis WORD",
1568 "no\n" ROUTER_STR
"ISO IS-IS\n" "ISO Routing area tag")
1571 return isis_area_destroy(vty
, argv
[idx_word
]->arg
);
1580 "A Network Entity Title for this process (OSI only)\n"
1581 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1584 return area_net_title(vty
, argv
[idx_word
]->arg
);
1594 "A Network Entity Title for this process (OSI only)\n"
1595 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1598 return area_clear_net_title(vty
, argv
[idx_word
]->arg
);
1601 void isis_area_lsp_mtu_set(struct isis_area
*area
, unsigned int lsp_mtu
)
1603 area
->lsp_mtu
= lsp_mtu
;
1604 lsp_regenerate_schedule(area
, IS_LEVEL_1_AND_2
, 1);
1607 static int isis_area_passwd_set(struct isis_area
*area
, int level
,
1608 u_char passwd_type
, const char *passwd
,
1611 struct isis_passwd
*dest
;
1612 struct isis_passwd modified
;
1615 assert((level
== IS_LEVEL_1
) || (level
== IS_LEVEL_2
));
1616 dest
= (level
== IS_LEVEL_1
) ? &area
->area_passwd
1617 : &area
->domain_passwd
;
1618 memset(&modified
, 0, sizeof(modified
));
1620 if (passwd_type
!= ISIS_PASSWD_TYPE_UNUSED
) {
1624 len
= strlen(passwd
);
1629 strncpy((char *)modified
.passwd
, passwd
, 255);
1630 modified
.type
= passwd_type
;
1631 modified
.snp_auth
= snp_auth
;
1634 if (memcmp(&modified
, dest
, sizeof(modified
))) {
1635 memcpy(dest
, &modified
, sizeof(modified
));
1636 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1642 int isis_area_passwd_unset(struct isis_area
*area
, int level
)
1644 return isis_area_passwd_set(area
, level
, ISIS_PASSWD_TYPE_UNUSED
, NULL
,
1648 int isis_area_passwd_cleartext_set(struct isis_area
*area
, int level
,
1649 const char *passwd
, u_char snp_auth
)
1651 return isis_area_passwd_set(area
, level
, ISIS_PASSWD_TYPE_CLEARTXT
,
1655 int isis_area_passwd_hmac_md5_set(struct isis_area
*area
, int level
,
1656 const char *passwd
, u_char snp_auth
)
1658 return isis_area_passwd_set(area
, level
, ISIS_PASSWD_TYPE_HMAC_MD5
,
1662 static void area_resign_level(struct isis_area
*area
, int level
)
1664 if (area
->lspdb
[level
- 1]) {
1665 lsp_db_destroy(area
->lspdb
[level
- 1]);
1666 area
->lspdb
[level
- 1] = NULL
;
1668 if (area
->spftree
[level
- 1]) {
1669 isis_spftree_del(area
->spftree
[level
- 1]);
1670 area
->spftree
[level
- 1] = NULL
;
1672 if (area
->spftree6
[level
- 1]) {
1673 isis_spftree_del(area
->spftree6
[level
- 1]);
1674 area
->spftree6
[level
- 1] = NULL
;
1676 THREAD_TIMER_OFF(area
->spf_timer
[level
- 1]);
1677 if (area
->route_table
[level
- 1]) {
1678 route_table_finish(area
->route_table
[level
- 1]);
1679 area
->route_table
[level
- 1] = NULL
;
1681 if (area
->route_table6
[level
- 1]) {
1682 route_table_finish(area
->route_table6
[level
- 1]);
1683 area
->route_table6
[level
- 1] = NULL
;
1687 "ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.",
1688 area
->area_tag
, level
);
1689 THREAD_TIMER_OFF(area
->t_lsp_refresh
[level
- 1]);
1690 area
->lsp_regenerate_pending
[level
- 1] = 0;
1693 void isis_area_is_type_set(struct isis_area
*area
, int is_type
)
1695 struct listnode
*node
;
1696 struct isis_circuit
*circuit
;
1698 if (isis
->debugs
& DEBUG_EVENTS
)
1699 zlog_debug("ISIS-Evt (%s) system type change %s -> %s",
1700 area
->area_tag
, circuit_t2string(area
->is_type
),
1701 circuit_t2string(is_type
));
1703 if (area
->is_type
== is_type
)
1704 return; /* No change */
1706 switch (area
->is_type
) {
1708 if (is_type
== IS_LEVEL_2
)
1709 area_resign_level(area
, IS_LEVEL_1
);
1711 if (area
->lspdb
[1] == NULL
)
1712 area
->lspdb
[1] = lsp_db_init();
1713 if (area
->route_table
[1] == NULL
)
1714 area
->route_table
[1] = route_table_init();
1715 if (area
->route_table6
[1] == NULL
)
1716 area
->route_table6
[1] = route_table_init();
1719 case IS_LEVEL_1_AND_2
:
1720 if (is_type
== IS_LEVEL_1
)
1721 area_resign_level(area
, IS_LEVEL_2
);
1723 area_resign_level(area
, IS_LEVEL_1
);
1727 if (is_type
== IS_LEVEL_1
)
1728 area_resign_level(area
, IS_LEVEL_2
);
1730 if (area
->lspdb
[0] == NULL
)
1731 area
->lspdb
[0] = lsp_db_init();
1732 if (area
->route_table
[0] == NULL
)
1733 area
->route_table
[0] = route_table_init();
1734 if (area
->route_table6
[0] == NULL
)
1735 area
->route_table6
[0] = route_table_init();
1742 area
->is_type
= is_type
;
1744 /* override circuit's is_type */
1745 if (area
->is_type
!= IS_LEVEL_1_AND_2
) {
1746 for (ALL_LIST_ELEMENTS_RO(area
->circuit_list
, node
, circuit
))
1747 isis_circuit_is_type_set(circuit
, is_type
);
1750 spftree_area_init(area
);
1752 if (listcount(area
->area_addrs
) > 0) {
1753 if (is_type
& IS_LEVEL_1
)
1754 lsp_generate(area
, IS_LEVEL_1
);
1755 if (is_type
& IS_LEVEL_2
)
1756 lsp_generate(area
, IS_LEVEL_2
);
1758 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1763 void isis_area_metricstyle_set(struct isis_area
*area
, bool old_metric
,
1766 if (area
->oldmetric
!= old_metric
|| area
->newmetric
!= new_metric
) {
1767 area
->oldmetric
= old_metric
;
1768 area
->newmetric
= new_metric
;
1769 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1773 void isis_area_overload_bit_set(struct isis_area
*area
, bool overload_bit
)
1775 char new_overload_bit
= overload_bit
? LSPBIT_OL
: 0;
1777 if (new_overload_bit
!= area
->overload_bit
) {
1778 area
->overload_bit
= new_overload_bit
;
1779 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1783 void isis_area_attached_bit_set(struct isis_area
*area
, bool attached_bit
)
1785 char new_attached_bit
= attached_bit
? LSPBIT_ATT
: 0;
1787 if (new_attached_bit
!= area
->attached_bit
) {
1788 area
->attached_bit
= new_attached_bit
;
1789 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1793 void isis_area_dynhostname_set(struct isis_area
*area
, bool dynhostname
)
1795 if (area
->dynhostname
!= dynhostname
) {
1796 area
->dynhostname
= dynhostname
;
1797 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 0);
1801 void isis_area_max_lsp_lifetime_set(struct isis_area
*area
, int level
,
1802 uint16_t max_lsp_lifetime
)
1804 assert((level
== IS_LEVEL_1
) || (level
== IS_LEVEL_2
));
1806 if (area
->max_lsp_lifetime
[level
- 1] == max_lsp_lifetime
)
1809 area
->max_lsp_lifetime
[level
- 1] = max_lsp_lifetime
;
1810 lsp_regenerate_schedule(area
, level
, 1);
1813 void isis_area_lsp_refresh_set(struct isis_area
*area
, int level
,
1814 uint16_t lsp_refresh
)
1816 assert((level
== IS_LEVEL_1
) || (level
== IS_LEVEL_2
));
1818 if (area
->lsp_refresh
[level
- 1] == lsp_refresh
)
1821 area
->lsp_refresh
[level
- 1] = lsp_refresh
;
1822 lsp_regenerate_schedule(area
, level
, 1);
1825 DEFUN (log_adj_changes
,
1826 log_adj_changes_cmd
,
1827 "log-adjacency-changes",
1828 "Log changes in adjacency state\n")
1830 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1832 area
->log_adj_changes
= 1;
1837 DEFUN (no_log_adj_changes
,
1838 no_log_adj_changes_cmd
,
1839 "no log-adjacency-changes",
1841 "Stop logging changes in adjacency state\n")
1843 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1845 area
->log_adj_changes
= 0;
1850 /* IS-IS configuration write function */
1851 int isis_config_write(struct vty
*vty
)
1856 struct isis_area
*area
;
1857 struct listnode
*node
, *node2
;
1859 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1860 /* ISIS - Area name */
1861 vty_out(vty
, "router isis %s%s", area
->area_tag
,
1865 if (listcount(area
->area_addrs
) > 0) {
1866 struct area_addr
*area_addr
;
1867 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
,
1868 node2
, area_addr
)) {
1869 vty_out(vty
, " net %s%s",
1871 area_addr
->area_addr
,
1879 /* ISIS - Dynamic hostname - Defaults to true so only
1882 if (!area
->dynhostname
) {
1883 vty_out(vty
, " no hostname dynamic%s",
1887 /* ISIS - Metric-Style - when true displays wide */
1888 if (area
->newmetric
) {
1889 if (!area
->oldmetric
)
1890 vty_out(vty
, " metric-style wide%s",
1894 " metric-style transition%s",
1898 vty_out(vty
, " metric-style narrow%s",
1902 /* ISIS - overload-bit */
1903 if (area
->overload_bit
) {
1904 vty_out(vty
, " set-overload-bit%s",
1908 /* ISIS - Area is-type (level-1-2 is default) */
1909 if (area
->is_type
== IS_LEVEL_1
) {
1910 vty_out(vty
, " is-type level-1%s", VTY_NEWLINE
);
1912 } else if (area
->is_type
== IS_LEVEL_2
) {
1913 vty_out(vty
, " is-type level-2-only%s",
1917 write
+= isis_redist_config_write(vty
, area
, AF_INET
);
1918 write
+= isis_redist_config_write(vty
, area
, AF_INET6
);
1919 /* ISIS - Lsp generation interval */
1920 if (area
->lsp_gen_interval
[0]
1921 == area
->lsp_gen_interval
[1]) {
1922 if (area
->lsp_gen_interval
[0]
1923 != DEFAULT_MIN_LSP_GEN_INTERVAL
) {
1924 vty_out(vty
, " lsp-gen-interval %d%s",
1925 area
->lsp_gen_interval
[0],
1930 if (area
->lsp_gen_interval
[0]
1931 != DEFAULT_MIN_LSP_GEN_INTERVAL
) {
1933 " lsp-gen-interval level-1 %d%s",
1934 area
->lsp_gen_interval
[0],
1938 if (area
->lsp_gen_interval
[1]
1939 != DEFAULT_MIN_LSP_GEN_INTERVAL
) {
1941 " lsp-gen-interval level-2 %d%s",
1942 area
->lsp_gen_interval
[1],
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%s",
1953 area
->max_lsp_lifetime
[0],
1958 if (area
->max_lsp_lifetime
[0]
1959 != DEFAULT_LSP_LIFETIME
) {
1961 " max-lsp-lifetime level-1 %u%s",
1962 area
->max_lsp_lifetime
[0],
1966 if (area
->max_lsp_lifetime
[1]
1967 != DEFAULT_LSP_LIFETIME
) {
1969 " max-lsp-lifetime level-2 %u%s",
1970 area
->max_lsp_lifetime
[1],
1975 /* ISIS - LSP refresh interval */
1976 if (area
->lsp_refresh
[0] == area
->lsp_refresh
[1]) {
1977 if (area
->lsp_refresh
[0]
1978 != DEFAULT_MAX_LSP_GEN_INTERVAL
) {
1980 " lsp-refresh-interval %u%s",
1981 area
->lsp_refresh
[0],
1986 if (area
->lsp_refresh
[0]
1987 != DEFAULT_MAX_LSP_GEN_INTERVAL
) {
1989 " lsp-refresh-interval level-1 %u%s",
1990 area
->lsp_refresh
[0],
1994 if (area
->lsp_refresh
[1]
1995 != DEFAULT_MAX_LSP_GEN_INTERVAL
) {
1997 " lsp-refresh-interval level-2 %u%s",
1998 area
->lsp_refresh
[1],
2003 if (area
->lsp_mtu
!= DEFAULT_LSP_MTU
) {
2004 vty_out(vty
, " lsp-mtu %u%s", area
->lsp_mtu
,
2009 /* Minimum SPF interval. */
2010 if (area
->min_spf_interval
[0]
2011 == area
->min_spf_interval
[1]) {
2012 if (area
->min_spf_interval
[0]
2013 != MINIMUM_SPF_INTERVAL
) {
2014 vty_out(vty
, " spf-interval %d%s",
2015 area
->min_spf_interval
[0],
2020 if (area
->min_spf_interval
[0]
2021 != MINIMUM_SPF_INTERVAL
) {
2023 " spf-interval level-1 %d%s",
2024 area
->min_spf_interval
[0],
2028 if (area
->min_spf_interval
[1]
2029 != MINIMUM_SPF_INTERVAL
) {
2031 " spf-interval level-2 %d%s",
2032 area
->min_spf_interval
[1],
2038 /* IETF SPF interval */
2039 if (area
->spf_delay_ietf
[0]) {
2041 " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld%s",
2042 spf_backoff_init_delay(
2043 area
->spf_delay_ietf
[0]),
2044 spf_backoff_short_delay(
2045 area
->spf_delay_ietf
[0]),
2046 spf_backoff_long_delay(
2047 area
->spf_delay_ietf
[0]),
2048 spf_backoff_holddown(
2049 area
->spf_delay_ietf
[0]),
2050 spf_backoff_timetolearn(
2051 area
->spf_delay_ietf
[0]),
2056 /* Authentication passwords. */
2057 if (area
->area_passwd
.type
2058 == ISIS_PASSWD_TYPE_HMAC_MD5
) {
2059 vty_out(vty
, " area-password md5 %s",
2060 area
->area_passwd
.passwd
);
2061 if (CHECK_FLAG(area
->area_passwd
.snp_auth
,
2063 vty_out(vty
, " authenticate snp ");
2065 area
->area_passwd
.snp_auth
,
2067 vty_out(vty
, "validate");
2069 vty_out(vty
, "send-only");
2071 vty_out(vty
, "%s", VTY_NEWLINE
);
2073 } else if (area
->area_passwd
.type
2074 == ISIS_PASSWD_TYPE_CLEARTXT
) {
2075 vty_out(vty
, " area-password clear %s",
2076 area
->area_passwd
.passwd
);
2077 if (CHECK_FLAG(area
->area_passwd
.snp_auth
,
2079 vty_out(vty
, " authenticate snp ");
2081 area
->area_passwd
.snp_auth
,
2083 vty_out(vty
, "validate");
2085 vty_out(vty
, "send-only");
2087 vty_out(vty
, "%s", VTY_NEWLINE
);
2090 if (area
->domain_passwd
.type
2091 == ISIS_PASSWD_TYPE_HMAC_MD5
) {
2092 vty_out(vty
, " domain-password md5 %s",
2093 area
->domain_passwd
.passwd
);
2094 if (CHECK_FLAG(area
->domain_passwd
.snp_auth
,
2096 vty_out(vty
, " authenticate snp ");
2097 if (CHECK_FLAG(area
->domain_passwd
2100 vty_out(vty
, "validate");
2102 vty_out(vty
, "send-only");
2104 vty_out(vty
, "%s", VTY_NEWLINE
);
2106 } else if (area
->domain_passwd
.type
2107 == ISIS_PASSWD_TYPE_CLEARTXT
) {
2108 vty_out(vty
, " domain-password clear %s",
2109 area
->domain_passwd
.passwd
);
2110 if (CHECK_FLAG(area
->domain_passwd
.snp_auth
,
2112 vty_out(vty
, " authenticate snp ");
2113 if (CHECK_FLAG(area
->domain_passwd
2116 vty_out(vty
, "validate");
2118 vty_out(vty
, "send-only");
2120 vty_out(vty
, "%s", VTY_NEWLINE
);
2124 if (area
->log_adj_changes
) {
2125 vty_out(vty
, " log-adjacency-changes%s",
2130 isis_mpls_te_config_write_router(vty
);
2136 struct cmd_node isis_node
= {ISIS_NODE
, "%s(config-router)# ", 1};
2140 /* Install IS-IS top node */
2141 install_node(&isis_node
, isis_config_write
);
2143 install_element(VIEW_NODE
, &show_isis_summary_cmd
);
2145 install_element(VIEW_NODE
, &show_isis_spf_ietf_cmd
);
2147 install_element(VIEW_NODE
, &show_isis_interface_cmd
);
2148 install_element(VIEW_NODE
, &show_isis_interface_detail_cmd
);
2149 install_element(VIEW_NODE
, &show_isis_interface_arg_cmd
);
2151 install_element(VIEW_NODE
, &show_isis_neighbor_cmd
);
2152 install_element(VIEW_NODE
, &show_isis_neighbor_detail_cmd
);
2153 install_element(VIEW_NODE
, &show_isis_neighbor_arg_cmd
);
2154 install_element(VIEW_NODE
, &clear_isis_neighbor_cmd
);
2155 install_element(VIEW_NODE
, &clear_isis_neighbor_arg_cmd
);
2157 install_element(VIEW_NODE
, &show_hostname_cmd
);
2158 install_element(VIEW_NODE
, &show_database_cmd
);
2160 install_element(ENABLE_NODE
, &show_debugging_isis_cmd
);
2162 install_node(&debug_node
, config_write_debug
);
2164 install_element(ENABLE_NODE
, &debug_isis_adj_cmd
);
2165 install_element(ENABLE_NODE
, &no_debug_isis_adj_cmd
);
2166 install_element(ENABLE_NODE
, &debug_isis_csum_cmd
);
2167 install_element(ENABLE_NODE
, &no_debug_isis_csum_cmd
);
2168 install_element(ENABLE_NODE
, &debug_isis_lupd_cmd
);
2169 install_element(ENABLE_NODE
, &no_debug_isis_lupd_cmd
);
2170 install_element(ENABLE_NODE
, &debug_isis_err_cmd
);
2171 install_element(ENABLE_NODE
, &no_debug_isis_err_cmd
);
2172 install_element(ENABLE_NODE
, &debug_isis_snp_cmd
);
2173 install_element(ENABLE_NODE
, &no_debug_isis_snp_cmd
);
2174 install_element(ENABLE_NODE
, &debug_isis_upd_cmd
);
2175 install_element(ENABLE_NODE
, &no_debug_isis_upd_cmd
);
2176 install_element(ENABLE_NODE
, &debug_isis_spfevents_cmd
);
2177 install_element(ENABLE_NODE
, &no_debug_isis_spfevents_cmd
);
2178 install_element(ENABLE_NODE
, &debug_isis_spfstats_cmd
);
2179 install_element(ENABLE_NODE
, &no_debug_isis_spfstats_cmd
);
2180 install_element(ENABLE_NODE
, &debug_isis_spftrigg_cmd
);
2181 install_element(ENABLE_NODE
, &no_debug_isis_spftrigg_cmd
);
2182 install_element(ENABLE_NODE
, &debug_isis_rtevents_cmd
);
2183 install_element(ENABLE_NODE
, &no_debug_isis_rtevents_cmd
);
2184 install_element(ENABLE_NODE
, &debug_isis_events_cmd
);
2185 install_element(ENABLE_NODE
, &no_debug_isis_events_cmd
);
2186 install_element(ENABLE_NODE
, &debug_isis_packet_dump_cmd
);
2187 install_element(ENABLE_NODE
, &no_debug_isis_packet_dump_cmd
);
2188 install_element(ENABLE_NODE
, &debug_isis_lsp_gen_cmd
);
2189 install_element(ENABLE_NODE
, &no_debug_isis_lsp_gen_cmd
);
2190 install_element(ENABLE_NODE
, &debug_isis_lsp_sched_cmd
);
2191 install_element(ENABLE_NODE
, &no_debug_isis_lsp_sched_cmd
);
2193 install_element(CONFIG_NODE
, &debug_isis_adj_cmd
);
2194 install_element(CONFIG_NODE
, &no_debug_isis_adj_cmd
);
2195 install_element(CONFIG_NODE
, &debug_isis_csum_cmd
);
2196 install_element(CONFIG_NODE
, &no_debug_isis_csum_cmd
);
2197 install_element(CONFIG_NODE
, &debug_isis_lupd_cmd
);
2198 install_element(CONFIG_NODE
, &no_debug_isis_lupd_cmd
);
2199 install_element(CONFIG_NODE
, &debug_isis_err_cmd
);
2200 install_element(CONFIG_NODE
, &no_debug_isis_err_cmd
);
2201 install_element(CONFIG_NODE
, &debug_isis_snp_cmd
);
2202 install_element(CONFIG_NODE
, &no_debug_isis_snp_cmd
);
2203 install_element(CONFIG_NODE
, &debug_isis_upd_cmd
);
2204 install_element(CONFIG_NODE
, &no_debug_isis_upd_cmd
);
2205 install_element(CONFIG_NODE
, &debug_isis_spfevents_cmd
);
2206 install_element(CONFIG_NODE
, &no_debug_isis_spfevents_cmd
);
2207 install_element(CONFIG_NODE
, &debug_isis_spfstats_cmd
);
2208 install_element(CONFIG_NODE
, &no_debug_isis_spfstats_cmd
);
2209 install_element(CONFIG_NODE
, &debug_isis_spftrigg_cmd
);
2210 install_element(CONFIG_NODE
, &no_debug_isis_spftrigg_cmd
);
2211 install_element(CONFIG_NODE
, &debug_isis_rtevents_cmd
);
2212 install_element(CONFIG_NODE
, &no_debug_isis_rtevents_cmd
);
2213 install_element(CONFIG_NODE
, &debug_isis_events_cmd
);
2214 install_element(CONFIG_NODE
, &no_debug_isis_events_cmd
);
2215 install_element(CONFIG_NODE
, &debug_isis_packet_dump_cmd
);
2216 install_element(CONFIG_NODE
, &no_debug_isis_packet_dump_cmd
);
2217 install_element(CONFIG_NODE
, &debug_isis_lsp_gen_cmd
);
2218 install_element(CONFIG_NODE
, &no_debug_isis_lsp_gen_cmd
);
2219 install_element(CONFIG_NODE
, &debug_isis_lsp_sched_cmd
);
2220 install_element(CONFIG_NODE
, &no_debug_isis_lsp_sched_cmd
);
2222 install_element(CONFIG_NODE
, &router_isis_cmd
);
2223 install_element(CONFIG_NODE
, &no_router_isis_cmd
);
2225 install_default(ISIS_NODE
);
2227 install_element(ISIS_NODE
, &net_cmd
);
2228 install_element(ISIS_NODE
, &no_net_cmd
);
2230 install_element(ISIS_NODE
, &log_adj_changes_cmd
);
2231 install_element(ISIS_NODE
, &no_log_adj_changes_cmd
);
2233 spf_backoff_cmd_init();