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; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 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_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"
57 #include "isisd/isis_te.h"
58 #include "isisd/isis_mt.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_add_timer(master
, lsp_tick
, area
, 1, &area
->t_tick
);
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
;
156 area
->area_tag
= strdup(area_tag
);
157 listnode_add(isis
->area_list
, area
);
160 QOBJ_REG(area
, isis_area
);
165 struct isis_area
*isis_area_lookup(const char *area_tag
)
167 struct isis_area
*area
;
168 struct listnode
*node
;
170 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
))
171 if ((area
->area_tag
== NULL
&& area_tag
== NULL
)
172 || (area
->area_tag
&& area_tag
173 && strcmp(area
->area_tag
, area_tag
) == 0))
179 int isis_area_get(struct vty
*vty
, const char *area_tag
)
181 struct isis_area
*area
;
183 area
= isis_area_lookup(area_tag
);
186 VTY_PUSH_CONTEXT(ISIS_NODE
, area
);
190 area
= isis_area_create(area_tag
);
192 if (isis
->debugs
& DEBUG_EVENTS
)
193 zlog_debug("New IS-IS area instance %s", area
->area_tag
);
195 VTY_PUSH_CONTEXT(ISIS_NODE
, area
);
200 int isis_area_destroy(struct vty
*vty
, const char *area_tag
)
202 struct isis_area
*area
;
203 struct listnode
*node
, *nnode
;
204 struct isis_circuit
*circuit
;
205 struct area_addr
*addr
;
207 area
= isis_area_lookup(area_tag
);
210 vty_out(vty
, "Can't find ISIS instance \n");
211 return CMD_ERR_NO_MATCH
;
216 if (area
->circuit_list
) {
217 for (ALL_LIST_ELEMENTS(area
->circuit_list
, node
, nnode
,
219 circuit
->ip_router
= 0;
220 circuit
->ipv6_router
= 0;
221 isis_csm_state_change(ISIS_DISABLE
, circuit
, area
);
223 list_delete(area
->circuit_list
);
224 area
->circuit_list
= NULL
;
227 if (area
->lspdb
[0] != NULL
) {
228 lsp_db_destroy(area
->lspdb
[0]);
229 area
->lspdb
[0] = NULL
;
231 if (area
->lspdb
[1] != NULL
) {
232 lsp_db_destroy(area
->lspdb
[1]);
233 area
->lspdb
[1] = NULL
;
236 spftree_area_del(area
);
238 THREAD_TIMER_OFF(area
->spf_timer
[0]);
239 THREAD_TIMER_OFF(area
->spf_timer
[1]);
241 spf_backoff_free(area
->spf_delay_ietf
[0]);
242 spf_backoff_free(area
->spf_delay_ietf
[1]);
244 /* invalidate and validate would delete all routes from zebra */
245 isis_route_invalidate(area
);
246 isis_route_validate(area
);
248 if (area
->route_table
[0]) {
249 route_table_finish(area
->route_table
[0]);
250 area
->route_table
[0] = NULL
;
252 if (area
->route_table
[1]) {
253 route_table_finish(area
->route_table
[1]);
254 area
->route_table
[1] = NULL
;
256 if (area
->route_table6
[0]) {
257 route_table_finish(area
->route_table6
[0]);
258 area
->route_table6
[0] = NULL
;
260 if (area
->route_table6
[1]) {
261 route_table_finish(area
->route_table6
[1]);
262 area
->route_table6
[1] = NULL
;
265 isis_redist_area_finish(area
);
267 for (ALL_LIST_ELEMENTS(area
->area_addrs
, node
, nnode
, addr
)) {
268 list_delete_node(area
->area_addrs
, node
);
269 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
271 area
->area_addrs
= NULL
;
273 THREAD_TIMER_OFF(area
->t_tick
);
274 THREAD_TIMER_OFF(area
->t_lsp_refresh
[0]);
275 THREAD_TIMER_OFF(area
->t_lsp_refresh
[1]);
277 thread_cancel_event(master
, area
);
279 listnode_delete(isis
->area_list
, area
);
281 free(area
->area_tag
);
283 area_mt_finish(area
);
285 XFREE(MTYPE_ISIS_AREA
, area
);
287 if (listcount(isis
->area_list
) == 0) {
288 memset(isis
->sysid
, 0, ISIS_SYS_ID_LEN
);
295 static void area_set_mt_enabled(struct isis_area
*area
, uint16_t mtid
,
298 struct isis_area_mt_setting
*setting
;
300 setting
= area_get_mt_setting(area
, mtid
);
301 if (setting
->enabled
!= enabled
) {
302 setting
->enabled
= enabled
;
303 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 0);
307 static void area_set_mt_overload(struct isis_area
*area
, uint16_t mtid
,
310 struct isis_area_mt_setting
*setting
;
312 setting
= area_get_mt_setting(area
, mtid
);
313 if (setting
->overload
!= overload
) {
314 setting
->overload
= overload
;
315 if (setting
->enabled
)
316 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
,
321 int area_net_title(struct vty
*vty
, const char *net_title
)
323 VTY_DECLVAR_CONTEXT(isis_area
, area
);
324 struct area_addr
*addr
;
325 struct area_addr
*addrp
;
326 struct listnode
*node
;
330 /* We check that we are not over the maximal number of addresses */
331 if (listcount(area
->area_addrs
) >= isis
->max_area_addrs
) {
333 "Maximum of area addresses (%d) already reached \n",
334 isis
->max_area_addrs
);
335 return CMD_ERR_NOTHING_TODO
;
338 addr
= XMALLOC(MTYPE_ISIS_AREA_ADDR
, sizeof(struct area_addr
));
339 addr
->addr_len
= dotformat2buff(buff
, net_title
);
340 memcpy(addr
->area_addr
, buff
, addr
->addr_len
);
342 zlog_debug("added area address %s for area %s (address length %d)",
343 net_title
, area
->area_tag
, addr
->addr_len
);
344 #endif /* EXTREME_DEBUG */
345 if (addr
->addr_len
< 8 || addr
->addr_len
> 20) {
347 "area address must be at least 8..20 octets long (%d)\n",
349 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
350 return CMD_WARNING_CONFIG_FAILED
;
353 if (addr
->area_addr
[addr
->addr_len
- 1] != 0) {
355 "nsel byte (last byte) in area address must be 0\n");
356 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
357 return CMD_WARNING_CONFIG_FAILED
;
360 if (isis
->sysid_set
== 0) {
362 * First area address - get the SystemID for this router
364 memcpy(isis
->sysid
, GETSYSID(addr
), ISIS_SYS_ID_LEN
);
366 if (isis
->debugs
& DEBUG_EVENTS
)
367 zlog_debug("Router has SystemID %s",
368 sysid_print(isis
->sysid
));
371 * Check that the SystemID portions match
373 if (memcmp(isis
->sysid
, GETSYSID(addr
), ISIS_SYS_ID_LEN
)) {
375 "System ID must not change when defining additional area addresses\n");
376 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
377 return CMD_WARNING_CONFIG_FAILED
;
380 /* now we see that we don't already have this address */
381 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
, node
, addrp
)) {
382 if ((addrp
->addr_len
+ ISIS_SYS_ID_LEN
+ ISIS_NSEL_LEN
)
385 if (!memcmp(addrp
->area_addr
, addr
->area_addr
,
387 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
388 return CMD_SUCCESS
; /* silent fail */
394 * Forget the systemID part of the address
396 addr
->addr_len
-= (ISIS_SYS_ID_LEN
+ ISIS_NSEL_LEN
);
397 listnode_add(area
->area_addrs
, addr
);
399 /* only now we can safely generate our LSPs for this area */
400 if (listcount(area
->area_addrs
) > 0) {
401 if (area
->is_type
& IS_LEVEL_1
)
402 lsp_generate(area
, IS_LEVEL_1
);
403 if (area
->is_type
& IS_LEVEL_2
)
404 lsp_generate(area
, IS_LEVEL_2
);
410 int area_clear_net_title(struct vty
*vty
, const char *net_title
)
412 VTY_DECLVAR_CONTEXT(isis_area
, area
);
413 struct area_addr addr
, *addrp
= NULL
;
414 struct listnode
*node
;
417 addr
.addr_len
= dotformat2buff(buff
, net_title
);
418 if (addr
.addr_len
< 8 || addr
.addr_len
> 20) {
420 "Unsupported area address length %d, should be 8...20 \n",
422 return CMD_WARNING_CONFIG_FAILED
;
425 memcpy(addr
.area_addr
, buff
, (int)addr
.addr_len
);
427 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
, node
, addrp
))
428 if ((addrp
->addr_len
+ ISIS_SYS_ID_LEN
+ 1) == addr
.addr_len
429 && !memcmp(addrp
->area_addr
, addr
.area_addr
, addr
.addr_len
))
433 vty_out(vty
, "No area address %s for area %s \n", net_title
,
435 return CMD_ERR_NO_MATCH
;
438 listnode_delete(area
->area_addrs
, addrp
);
439 XFREE(MTYPE_ISIS_AREA_ADDR
, addrp
);
442 * Last area address - reset the SystemID for this router
444 if (listcount(area
->area_addrs
) == 0) {
445 memset(isis
->sysid
, 0, ISIS_SYS_ID_LEN
);
447 if (isis
->debugs
& DEBUG_EVENTS
)
448 zlog_debug("Router has no SystemID");
455 * 'show isis interface' command
458 int show_isis_interface_common(struct vty
*vty
, const char *ifname
, char detail
)
460 struct listnode
*anode
, *cnode
;
461 struct isis_area
*area
;
462 struct isis_circuit
*circuit
;
465 vty_out(vty
, "IS-IS Routing Process not enabled\n");
469 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, anode
, area
)) {
470 vty_out(vty
, "Area %s:\n", area
->area_tag
);
472 if (detail
== ISIS_UI_LEVEL_BRIEF
)
474 " Interface CircId State Type Level\n");
476 for (ALL_LIST_ELEMENTS_RO(area
->circuit_list
, cnode
, circuit
))
478 isis_circuit_print_vty(circuit
, vty
, detail
);
479 else if (strcmp(circuit
->interface
->name
, ifname
) == 0)
480 isis_circuit_print_vty(circuit
, vty
, detail
);
486 DEFUN (show_isis_interface
,
487 show_isis_interface_cmd
,
488 "show isis interface",
490 "ISIS network information\n"
493 return show_isis_interface_common(vty
, NULL
, ISIS_UI_LEVEL_BRIEF
);
496 DEFUN (show_isis_interface_detail
,
497 show_isis_interface_detail_cmd
,
498 "show isis interface detail",
500 "ISIS network information\n"
502 "show detailed information\n")
504 return show_isis_interface_common(vty
, NULL
, ISIS_UI_LEVEL_DETAIL
);
507 DEFUN (show_isis_interface_arg
,
508 show_isis_interface_arg_cmd
,
509 "show isis interface WORD",
511 "ISIS network information\n"
513 "ISIS interface name\n")
516 return show_isis_interface_common(vty
, argv
[idx_word
]->arg
,
517 ISIS_UI_LEVEL_DETAIL
);
521 * 'show isis neighbor' command
524 int show_isis_neighbor_common(struct vty
*vty
, const char *id
, char detail
)
526 struct listnode
*anode
, *cnode
, *node
;
527 struct isis_area
*area
;
528 struct isis_circuit
*circuit
;
530 struct isis_adjacency
*adj
;
531 struct isis_dynhn
*dynhn
;
532 u_char sysid
[ISIS_SYS_ID_LEN
];
536 vty_out(vty
, "IS-IS Routing Process not enabled\n");
540 memset(sysid
, 0, ISIS_SYS_ID_LEN
);
542 if (sysid2buff(sysid
, id
) == 0) {
543 dynhn
= dynhn_find_by_name(id
);
545 vty_out(vty
, "Invalid system id %s\n", id
);
548 memcpy(sysid
, dynhn
->id
, ISIS_SYS_ID_LEN
);
552 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, anode
, area
)) {
553 vty_out(vty
, "Area %s:\n", area
->area_tag
);
555 if (detail
== ISIS_UI_LEVEL_BRIEF
)
557 " System Id Interface L State Holdtime SNPA\n");
559 for (ALL_LIST_ELEMENTS_RO(area
->circuit_list
, cnode
, circuit
)) {
560 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
561 for (i
= 0; i
< 2; i
++) {
562 adjdb
= circuit
->u
.bc
.adjdb
[i
];
563 if (adjdb
&& adjdb
->count
) {
564 for (ALL_LIST_ELEMENTS_RO(
567 || !memcmp(adj
->sysid
,
576 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
577 && circuit
->u
.p2p
.neighbor
) {
578 adj
= circuit
->u
.p2p
.neighbor
;
580 || !memcmp(adj
->sysid
, sysid
,
582 isis_adj_print_vty(adj
, vty
, detail
);
591 * 'clear isis neighbor' command
593 int clear_isis_neighbor_common(struct vty
*vty
, const char *id
)
595 struct listnode
*anode
, *cnode
, *cnextnode
, *node
, *nnode
;
596 struct isis_area
*area
;
597 struct isis_circuit
*circuit
;
599 struct isis_adjacency
*adj
;
600 struct isis_dynhn
*dynhn
;
601 u_char sysid
[ISIS_SYS_ID_LEN
];
605 vty_out(vty
, "IS-IS Routing Process not enabled\n");
609 memset(sysid
, 0, ISIS_SYS_ID_LEN
);
611 if (sysid2buff(sysid
, id
) == 0) {
612 dynhn
= dynhn_find_by_name(id
);
614 vty_out(vty
, "Invalid system id %s\n", id
);
617 memcpy(sysid
, dynhn
->id
, ISIS_SYS_ID_LEN
);
621 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, anode
, area
)) {
622 for (ALL_LIST_ELEMENTS(area
->circuit_list
, cnode
, cnextnode
,
624 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
625 for (i
= 0; i
< 2; i
++) {
626 adjdb
= circuit
->u
.bc
.adjdb
[i
];
627 if (adjdb
&& adjdb
->count
) {
628 for (ALL_LIST_ELEMENTS(
632 || !memcmp(adj
->sysid
,
635 isis_adj_state_change(
638 "clear user request");
641 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
642 && circuit
->u
.p2p
.neighbor
) {
643 adj
= circuit
->u
.p2p
.neighbor
;
645 || !memcmp(adj
->sysid
, sysid
,
647 isis_adj_state_change(
649 "clear user request");
657 DEFUN (show_isis_neighbor
,
658 show_isis_neighbor_cmd
,
659 "show isis neighbor",
661 "ISIS network information\n"
662 "ISIS neighbor adjacencies\n")
664 return show_isis_neighbor_common(vty
, NULL
, ISIS_UI_LEVEL_BRIEF
);
667 DEFUN (show_isis_neighbor_detail
,
668 show_isis_neighbor_detail_cmd
,
669 "show isis neighbor detail",
671 "ISIS network information\n"
672 "ISIS neighbor adjacencies\n"
673 "show detailed information\n")
675 return show_isis_neighbor_common(vty
, NULL
, ISIS_UI_LEVEL_DETAIL
);
678 DEFUN (show_isis_neighbor_arg
,
679 show_isis_neighbor_arg_cmd
,
680 "show isis neighbor WORD",
682 "ISIS network information\n"
683 "ISIS neighbor adjacencies\n"
687 return show_isis_neighbor_common(vty
, argv
[idx_word
]->arg
,
688 ISIS_UI_LEVEL_DETAIL
);
691 DEFUN (clear_isis_neighbor
,
692 clear_isis_neighbor_cmd
,
693 "clear isis neighbor",
695 "Reset ISIS network information\n"
696 "Reset ISIS neighbor adjacencies\n")
698 return clear_isis_neighbor_common(vty
, NULL
);
701 DEFUN (clear_isis_neighbor_arg
,
702 clear_isis_neighbor_arg_cmd
,
703 "clear isis neighbor WORD",
705 "ISIS network information\n"
706 "ISIS neighbor adjacencies\n"
710 return clear_isis_neighbor_common(vty
, argv
[idx_word
]->arg
);
714 * 'isis debug', 'show debugging'
716 void print_debug(struct vty
*vty
, int flags
, int onoff
)
720 strcpy(onoffs
, "on");
722 strcpy(onoffs
, "off");
724 if (flags
& DEBUG_ADJ_PACKETS
)
726 "IS-IS Adjacency related packets debugging is %s\n",
728 if (flags
& DEBUG_CHECKSUM_ERRORS
)
729 vty_out(vty
, "IS-IS checksum errors debugging is %s\n", onoffs
);
730 if (flags
& DEBUG_LOCAL_UPDATES
)
731 vty_out(vty
, "IS-IS local updates debugging is %s\n", onoffs
);
732 if (flags
& DEBUG_PROTOCOL_ERRORS
)
733 vty_out(vty
, "IS-IS protocol errors debugging is %s\n", onoffs
);
734 if (flags
& DEBUG_SNP_PACKETS
)
735 vty_out(vty
, "IS-IS CSNP/PSNP packets debugging is %s\n",
737 if (flags
& DEBUG_SPF_EVENTS
)
738 vty_out(vty
, "IS-IS SPF events debugging is %s\n", onoffs
);
739 if (flags
& DEBUG_SPF_STATS
)
741 "IS-IS SPF Timing and Statistics Data debugging is %s\n",
743 if (flags
& DEBUG_SPF_TRIGGERS
)
744 vty_out(vty
, "IS-IS SPF triggering events debugging is %s\n",
746 if (flags
& DEBUG_UPDATE_PACKETS
)
747 vty_out(vty
, "IS-IS Update related packet debugging is %s\n",
749 if (flags
& DEBUG_RTE_EVENTS
)
750 vty_out(vty
, "IS-IS Route related debuggin is %s\n", onoffs
);
751 if (flags
& DEBUG_EVENTS
)
752 vty_out(vty
, "IS-IS Event debugging is %s\n", onoffs
);
753 if (flags
& DEBUG_PACKET_DUMP
)
754 vty_out(vty
, "IS-IS Packet dump debugging is %s\n", onoffs
);
755 if (flags
& DEBUG_LSP_GEN
)
756 vty_out(vty
, "IS-IS LSP generation debugging is %s\n", onoffs
);
757 if (flags
& DEBUG_LSP_SCHED
)
758 vty_out(vty
, "IS-IS LSP scheduling debugging is %s\n", onoffs
);
761 DEFUN_NOSH (show_debugging
,
762 show_debugging_isis_cmd
,
763 "show debugging [isis]",
765 "State of each debugging option\n"
768 vty_out (vty
, "IS-IS debugging status:\n");
771 print_debug(vty
, isis
->debugs
, 1);
777 static struct cmd_node debug_node
= {DEBUG_NODE
, "", 1};
779 static int config_write_debug(struct vty
*vty
)
782 int flags
= isis
->debugs
;
784 if (flags
& DEBUG_ADJ_PACKETS
) {
785 vty_out(vty
, "debug isis adj-packets\n");
788 if (flags
& DEBUG_CHECKSUM_ERRORS
) {
789 vty_out(vty
, "debug isis checksum-errors\n");
792 if (flags
& DEBUG_LOCAL_UPDATES
) {
793 vty_out(vty
, "debug isis local-updates\n");
796 if (flags
& DEBUG_PROTOCOL_ERRORS
) {
797 vty_out(vty
, "debug isis protocol-errors\n");
800 if (flags
& DEBUG_SNP_PACKETS
) {
801 vty_out(vty
, "debug isis snp-packets\n");
804 if (flags
& DEBUG_SPF_EVENTS
) {
805 vty_out(vty
, "debug isis spf-events\n");
808 if (flags
& DEBUG_SPF_STATS
) {
809 vty_out(vty
, "debug isis spf-statistics\n");
812 if (flags
& DEBUG_SPF_TRIGGERS
) {
813 vty_out(vty
, "debug isis spf-triggers\n");
816 if (flags
& DEBUG_UPDATE_PACKETS
) {
817 vty_out(vty
, "debug isis update-packets\n");
820 if (flags
& DEBUG_RTE_EVENTS
) {
821 vty_out(vty
, "debug isis route-events\n");
824 if (flags
& DEBUG_EVENTS
) {
825 vty_out(vty
, "debug isis events\n");
828 if (flags
& DEBUG_PACKET_DUMP
) {
829 vty_out(vty
, "debug isis packet-dump\n");
832 if (flags
& DEBUG_LSP_GEN
) {
833 vty_out(vty
, "debug isis lsp-gen\n");
836 if (flags
& DEBUG_LSP_SCHED
) {
837 vty_out(vty
, "debug isis lsp-sched\n");
840 write
+= spf_backoff_write_config(vty
);
845 DEFUN (debug_isis_adj
,
847 "debug isis adj-packets",
849 "IS-IS information\n"
850 "IS-IS Adjacency related packets\n")
852 isis
->debugs
|= DEBUG_ADJ_PACKETS
;
853 print_debug(vty
, DEBUG_ADJ_PACKETS
, 1);
858 DEFUN (no_debug_isis_adj
,
859 no_debug_isis_adj_cmd
,
860 "no debug isis adj-packets",
863 "IS-IS information\n"
864 "IS-IS Adjacency related packets\n")
866 isis
->debugs
&= ~DEBUG_ADJ_PACKETS
;
867 print_debug(vty
, DEBUG_ADJ_PACKETS
, 0);
872 DEFUN (debug_isis_csum
,
874 "debug isis checksum-errors",
876 "IS-IS information\n"
877 "IS-IS LSP checksum errors\n")
879 isis
->debugs
|= DEBUG_CHECKSUM_ERRORS
;
880 print_debug(vty
, DEBUG_CHECKSUM_ERRORS
, 1);
885 DEFUN (no_debug_isis_csum
,
886 no_debug_isis_csum_cmd
,
887 "no debug isis checksum-errors",
890 "IS-IS information\n"
891 "IS-IS LSP checksum errors\n")
893 isis
->debugs
&= ~DEBUG_CHECKSUM_ERRORS
;
894 print_debug(vty
, DEBUG_CHECKSUM_ERRORS
, 0);
899 DEFUN (debug_isis_lupd
,
901 "debug isis local-updates",
903 "IS-IS information\n"
904 "IS-IS local update packets\n")
906 isis
->debugs
|= DEBUG_LOCAL_UPDATES
;
907 print_debug(vty
, DEBUG_LOCAL_UPDATES
, 1);
912 DEFUN (no_debug_isis_lupd
,
913 no_debug_isis_lupd_cmd
,
914 "no debug isis local-updates",
917 "IS-IS information\n"
918 "IS-IS local update packets\n")
920 isis
->debugs
&= ~DEBUG_LOCAL_UPDATES
;
921 print_debug(vty
, DEBUG_LOCAL_UPDATES
, 0);
926 DEFUN (debug_isis_err
,
928 "debug isis protocol-errors",
930 "IS-IS information\n"
931 "IS-IS LSP protocol errors\n")
933 isis
->debugs
|= DEBUG_PROTOCOL_ERRORS
;
934 print_debug(vty
, DEBUG_PROTOCOL_ERRORS
, 1);
939 DEFUN (no_debug_isis_err
,
940 no_debug_isis_err_cmd
,
941 "no debug isis protocol-errors",
944 "IS-IS information\n"
945 "IS-IS LSP protocol errors\n")
947 isis
->debugs
&= ~DEBUG_PROTOCOL_ERRORS
;
948 print_debug(vty
, DEBUG_PROTOCOL_ERRORS
, 0);
953 DEFUN (debug_isis_snp
,
955 "debug isis snp-packets",
957 "IS-IS information\n"
958 "IS-IS CSNP/PSNP packets\n")
960 isis
->debugs
|= DEBUG_SNP_PACKETS
;
961 print_debug(vty
, DEBUG_SNP_PACKETS
, 1);
966 DEFUN (no_debug_isis_snp
,
967 no_debug_isis_snp_cmd
,
968 "no debug isis snp-packets",
971 "IS-IS information\n"
972 "IS-IS CSNP/PSNP packets\n")
974 isis
->debugs
&= ~DEBUG_SNP_PACKETS
;
975 print_debug(vty
, DEBUG_SNP_PACKETS
, 0);
980 DEFUN (debug_isis_upd
,
982 "debug isis update-packets",
984 "IS-IS information\n"
985 "IS-IS Update related packets\n")
987 isis
->debugs
|= DEBUG_UPDATE_PACKETS
;
988 print_debug(vty
, DEBUG_UPDATE_PACKETS
, 1);
993 DEFUN (no_debug_isis_upd
,
994 no_debug_isis_upd_cmd
,
995 "no debug isis update-packets",
998 "IS-IS information\n"
999 "IS-IS Update related packets\n")
1001 isis
->debugs
&= ~DEBUG_UPDATE_PACKETS
;
1002 print_debug(vty
, DEBUG_UPDATE_PACKETS
, 0);
1007 DEFUN (debug_isis_spfevents
,
1008 debug_isis_spfevents_cmd
,
1009 "debug isis spf-events",
1011 "IS-IS information\n"
1012 "IS-IS Shortest Path First Events\n")
1014 isis
->debugs
|= DEBUG_SPF_EVENTS
;
1015 print_debug(vty
, DEBUG_SPF_EVENTS
, 1);
1020 DEFUN (no_debug_isis_spfevents
,
1021 no_debug_isis_spfevents_cmd
,
1022 "no debug isis spf-events",
1025 "IS-IS information\n"
1026 "IS-IS Shortest Path First Events\n")
1028 isis
->debugs
&= ~DEBUG_SPF_EVENTS
;
1029 print_debug(vty
, DEBUG_SPF_EVENTS
, 0);
1034 DEFUN (debug_isis_spfstats
,
1035 debug_isis_spfstats_cmd
,
1036 "debug isis spf-statistics ",
1038 "IS-IS information\n"
1039 "IS-IS SPF Timing and Statistic Data\n")
1041 isis
->debugs
|= DEBUG_SPF_STATS
;
1042 print_debug(vty
, DEBUG_SPF_STATS
, 1);
1047 DEFUN (no_debug_isis_spfstats
,
1048 no_debug_isis_spfstats_cmd
,
1049 "no debug isis spf-statistics",
1052 "IS-IS information\n"
1053 "IS-IS SPF Timing and Statistic Data\n")
1055 isis
->debugs
&= ~DEBUG_SPF_STATS
;
1056 print_debug(vty
, DEBUG_SPF_STATS
, 0);
1061 DEFUN (debug_isis_spftrigg
,
1062 debug_isis_spftrigg_cmd
,
1063 "debug isis spf-triggers",
1065 "IS-IS information\n"
1066 "IS-IS SPF triggering events\n")
1068 isis
->debugs
|= DEBUG_SPF_TRIGGERS
;
1069 print_debug(vty
, DEBUG_SPF_TRIGGERS
, 1);
1074 DEFUN (no_debug_isis_spftrigg
,
1075 no_debug_isis_spftrigg_cmd
,
1076 "no debug isis spf-triggers",
1079 "IS-IS information\n"
1080 "IS-IS SPF triggering events\n")
1082 isis
->debugs
&= ~DEBUG_SPF_TRIGGERS
;
1083 print_debug(vty
, DEBUG_SPF_TRIGGERS
, 0);
1088 DEFUN (debug_isis_rtevents
,
1089 debug_isis_rtevents_cmd
,
1090 "debug isis route-events",
1092 "IS-IS information\n"
1093 "IS-IS Route related events\n")
1095 isis
->debugs
|= DEBUG_RTE_EVENTS
;
1096 print_debug(vty
, DEBUG_RTE_EVENTS
, 1);
1101 DEFUN (no_debug_isis_rtevents
,
1102 no_debug_isis_rtevents_cmd
,
1103 "no debug isis route-events",
1106 "IS-IS information\n"
1107 "IS-IS Route related events\n")
1109 isis
->debugs
&= ~DEBUG_RTE_EVENTS
;
1110 print_debug(vty
, DEBUG_RTE_EVENTS
, 0);
1115 DEFUN (debug_isis_events
,
1116 debug_isis_events_cmd
,
1117 "debug isis events",
1119 "IS-IS information\n"
1122 isis
->debugs
|= DEBUG_EVENTS
;
1123 print_debug(vty
, DEBUG_EVENTS
, 1);
1128 DEFUN (no_debug_isis_events
,
1129 no_debug_isis_events_cmd
,
1130 "no debug isis events",
1133 "IS-IS information\n"
1136 isis
->debugs
&= ~DEBUG_EVENTS
;
1137 print_debug(vty
, DEBUG_EVENTS
, 0);
1142 DEFUN (debug_isis_packet_dump
,
1143 debug_isis_packet_dump_cmd
,
1144 "debug isis packet-dump",
1146 "IS-IS information\n"
1147 "IS-IS packet dump\n")
1149 isis
->debugs
|= DEBUG_PACKET_DUMP
;
1150 print_debug(vty
, DEBUG_PACKET_DUMP
, 1);
1155 DEFUN (no_debug_isis_packet_dump
,
1156 no_debug_isis_packet_dump_cmd
,
1157 "no debug isis packet-dump",
1160 "IS-IS information\n"
1161 "IS-IS packet dump\n")
1163 isis
->debugs
&= ~DEBUG_PACKET_DUMP
;
1164 print_debug(vty
, DEBUG_PACKET_DUMP
, 0);
1169 DEFUN (debug_isis_lsp_gen
,
1170 debug_isis_lsp_gen_cmd
,
1171 "debug isis lsp-gen",
1173 "IS-IS information\n"
1174 "IS-IS generation of own LSPs\n")
1176 isis
->debugs
|= DEBUG_LSP_GEN
;
1177 print_debug(vty
, DEBUG_LSP_GEN
, 1);
1182 DEFUN (no_debug_isis_lsp_gen
,
1183 no_debug_isis_lsp_gen_cmd
,
1184 "no debug isis lsp-gen",
1187 "IS-IS information\n"
1188 "IS-IS generation of own LSPs\n")
1190 isis
->debugs
&= ~DEBUG_LSP_GEN
;
1191 print_debug(vty
, DEBUG_LSP_GEN
, 0);
1196 DEFUN (debug_isis_lsp_sched
,
1197 debug_isis_lsp_sched_cmd
,
1198 "debug isis lsp-sched",
1200 "IS-IS information\n"
1201 "IS-IS scheduling of LSP generation\n")
1203 isis
->debugs
|= DEBUG_LSP_SCHED
;
1204 print_debug(vty
, DEBUG_LSP_SCHED
, 1);
1209 DEFUN (no_debug_isis_lsp_sched
,
1210 no_debug_isis_lsp_sched_cmd
,
1211 "no debug isis lsp-sched",
1214 "IS-IS information\n"
1215 "IS-IS scheduling of LSP generation\n")
1217 isis
->debugs
&= ~DEBUG_LSP_SCHED
;
1218 print_debug(vty
, DEBUG_LSP_SCHED
, 0);
1223 DEFUN (show_hostname
,
1225 "show isis hostname",
1227 "IS-IS information\n"
1228 "IS-IS Dynamic hostname mapping\n")
1230 dynhn_print_all(vty
);
1235 DEFUN (show_isis_spf_ietf
,
1236 show_isis_spf_ietf_cmd
,
1237 "show isis spf-delay-ietf",
1239 "IS-IS information\n"
1240 "IS-IS SPF delay IETF information\n")
1243 vty_out(vty
, "ISIS is not running\n");
1247 struct listnode
*node
;
1248 struct isis_area
*area
;
1250 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1251 vty_out(vty
, "Area %s:\n",
1252 area
->area_tag
? area
->area_tag
: "null");
1254 for (int level
= ISIS_LEVEL1
; level
<= ISIS_LEVELS
; level
++) {
1255 if ((area
->is_type
& level
) == 0)
1258 vty_out(vty
, " Level-%d:\n", level
);
1259 vty_out(vty
, " SPF delay status: ");
1260 if (area
->spf_timer
[level
- 1]) {
1261 struct timeval remain
= thread_timer_remain(
1262 area
->spf_timer
[level
- 1]);
1263 vty_out(vty
, "Pending, due in %lld msec\n",
1264 (long long)remain
.tv_sec
* 1000
1265 + remain
.tv_usec
/ 1000);
1267 vty_out(vty
, "Not scheduled\n");
1270 if (area
->spf_delay_ietf
[level
- 1]) {
1272 " Using draft-ietf-rtgwg-backoff-algo-04\n");
1274 area
->spf_delay_ietf
[level
- 1], vty
,
1277 vty_out(vty
, " Using legacy backoff algo\n");
1284 DEFUN (show_isis_summary
,
1285 show_isis_summary_cmd
,
1286 "show isis summary",
1287 SHOW_STR
"IS-IS information\n" "IS-IS summary\n")
1289 struct listnode
*node
, *node2
;
1290 struct isis_area
*area
;
1294 vty_out(vty
, "ISIS is not running\n");
1298 vty_out(vty
, "Process Id : %ld\n", isis
->process_id
);
1299 if (isis
->sysid_set
)
1300 vty_out(vty
, "System Id : %s\n",
1301 sysid_print(isis
->sysid
));
1303 vty_out(vty
, "Up time : ");
1304 vty_out_timestr(vty
, isis
->uptime
);
1307 if (isis
->area_list
)
1308 vty_out(vty
, "Number of areas : %d\n", isis
->area_list
->count
);
1310 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1311 vty_out(vty
, "Area %s:\n",
1312 area
->area_tag
? area
->area_tag
: "null");
1314 if (listcount(area
->area_addrs
) > 0) {
1315 struct area_addr
*area_addr
;
1316 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
, node2
,
1318 vty_out(vty
, " Net: %s\n",
1319 isonet_print(area_addr
->area_addr
,
1326 for (level
= ISIS_LEVEL1
; level
<= ISIS_LEVELS
; level
++) {
1327 if ((area
->is_type
& level
) == 0)
1330 vty_out(vty
, " Level-%d:\n", level
);
1331 if (area
->spf_timer
[level
- 1])
1332 vty_out(vty
, " SPF: (pending)\n");
1334 vty_out(vty
, " SPF:\n");
1336 vty_out(vty
, " minimum interval : %d",
1337 area
->min_spf_interval
[level
- 1]);
1338 if (area
->spf_delay_ietf
[level
- 1])
1340 " (not used, IETF SPF delay activated)");
1343 vty_out(vty
, " IPv4 route computation:\n");
1344 isis_spf_print(area
->spftree
[level
- 1], vty
);
1346 vty_out(vty
, " IPv6 route computation:\n");
1347 isis_spf_print(area
->spftree6
[level
- 1], vty
);
1356 * This function supports following display options:
1357 * [ show isis database [detail] ]
1358 * [ show isis database <sysid> [detail] ]
1359 * [ show isis database <hostname> [detail] ]
1360 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1361 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1362 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1363 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1364 * [ show isis database detail <sysid> ]
1365 * [ show isis database detail <hostname> ]
1366 * [ show isis database detail <sysid>.<pseudo-id> ]
1367 * [ show isis database detail <hostname>.<pseudo-id> ]
1368 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1369 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1371 static int show_isis_database(struct vty
*vty
, const char *argv
, int ui_level
)
1373 struct listnode
*node
;
1374 struct isis_area
*area
;
1375 struct isis_lsp
*lsp
;
1376 struct isis_dynhn
*dynhn
;
1377 const char *pos
= argv
;
1378 u_char lspid
[ISIS_SYS_ID_LEN
+ 2];
1381 int level
, lsp_count
;
1383 if (isis
->area_list
->count
== 0)
1386 memset(&lspid
, 0, ISIS_SYS_ID_LEN
);
1387 memset(&sysid
, 0, 255);
1390 * extract fragment and pseudo id from the string argv
1392 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1393 * (b) <systemid/hostname>.<pseudo-id> or
1394 * (c) <systemid/hostname> or
1395 * Where systemid is in the form:
1399 strncpy(sysid
, argv
, 254);
1400 if (argv
&& strlen(argv
) > 3) {
1401 pos
= argv
+ strlen(argv
) - 3;
1402 if (strncmp(pos
, "-", 1) == 0) {
1403 memcpy(number
, ++pos
, 2);
1404 lspid
[ISIS_SYS_ID_LEN
+ 1] =
1405 (u_char
)strtol((char *)number
, NULL
, 16);
1407 if (strncmp(pos
, ".", 1) != 0)
1410 if (strncmp(pos
, ".", 1) == 0) {
1411 memcpy(number
, ++pos
, 2);
1412 lspid
[ISIS_SYS_ID_LEN
] =
1413 (u_char
)strtol((char *)number
, NULL
, 16);
1414 sysid
[pos
- argv
- 1] = '\0';
1418 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1419 vty_out(vty
, "Area %s:\n",
1420 area
->area_tag
? area
->area_tag
: "null");
1422 for (level
= 0; level
< ISIS_LEVELS
; level
++) {
1423 if (area
->lspdb
[level
]
1424 && dict_count(area
->lspdb
[level
]) > 0) {
1428 * Try to find the lsp-id if the argv
1431 * hostname.<pseudo-id>-<fragment>
1433 if (sysid2buff(lspid
, sysid
)) {
1436 area
->lspdb
[level
]);
1437 } else if ((dynhn
= dynhn_find_by_name(
1439 memcpy(lspid
, dynhn
->id
,
1443 area
->lspdb
[level
]);
1444 } else if (strncmp(unix_hostname(),
1447 memcpy(lspid
, isis
->sysid
,
1451 area
->lspdb
[level
]);
1455 if (lsp
!= NULL
|| argv
== NULL
) {
1457 "IS-IS Level-%d link-state database:\n",
1460 /* print the title in all cases */
1462 "LSP ID PduLen SeqNumber Chksum Holdtime ATT/P/OL\n");
1466 if (ui_level
== ISIS_UI_LEVEL_DETAIL
)
1473 } else if (argv
== NULL
) {
1474 lsp_count
= lsp_print_all(
1475 vty
, area
->lspdb
[level
],
1476 ui_level
, area
->dynhostname
);
1478 vty_out(vty
, " %u LSPs\n\n",
1488 DEFUN (show_database
,
1490 "show isis database [detail] [WORD]",
1492 "IS-IS information\n"
1493 "IS-IS link state database\n"
1494 "Detailed information\n"
1498 int uilevel
= argv_find(argv
, argc
, "detail", &idx
)
1499 ? ISIS_UI_LEVEL_DETAIL
1500 : ISIS_UI_LEVEL_BRIEF
;
1501 char *id
= argv_find(argv
, argc
, "WORD", &idx
) ? argv
[idx
]->arg
: NULL
;
1502 return show_isis_database(vty
, id
, uilevel
);
1506 * 'router isis' command
1508 DEFUN_NOSH (router_isis
,
1513 "ISO Routing area tag")
1516 return isis_area_get(vty
, argv
[idx_word
]->arg
);
1520 *'no router isis' command
1522 DEFUN (no_router_isis
,
1524 "no router isis WORD",
1525 "no\n" ROUTER_STR
"ISO IS-IS\n" "ISO Routing area tag")
1528 return isis_area_destroy(vty
, argv
[idx_word
]->arg
);
1537 "A Network Entity Title for this process (OSI only)\n"
1538 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1541 return area_net_title(vty
, argv
[idx_word
]->arg
);
1551 "A Network Entity Title for this process (OSI only)\n"
1552 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1555 return area_clear_net_title(vty
, argv
[idx_word
]->arg
);
1558 DEFUN (isis_topology
,
1560 "topology " ISIS_MT_NAMES
" [overload]",
1561 "Configure IS-IS topologies\n"
1562 ISIS_MT_DESCRIPTIONS
1563 "Set overload bit for topology\n")
1565 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1567 const char *arg
= argv
[1]->arg
;
1568 uint16_t mtid
= isis_str2mtid(arg
);
1570 if (area
->oldmetric
) {
1572 "Multi topology IS-IS can only be used with wide metrics\n");
1573 return CMD_WARNING_CONFIG_FAILED
;
1576 if (mtid
== (uint16_t)-1) {
1577 vty_out(vty
, "Don't know topology '%s'\n", arg
);
1578 return CMD_WARNING_CONFIG_FAILED
;
1580 if (mtid
== ISIS_MT_IPV4_UNICAST
) {
1581 vty_out(vty
, "Cannot configure IPv4 unicast topology\n");
1582 return CMD_WARNING_CONFIG_FAILED
;
1585 area_set_mt_enabled(area
, mtid
, true);
1586 area_set_mt_overload(area
, mtid
, (argc
== 3));
1590 DEFUN (no_isis_topology
,
1591 no_isis_topology_cmd
,
1592 "no topology " ISIS_MT_NAMES
" [overload]",
1594 "Configure IS-IS topologies\n"
1595 ISIS_MT_DESCRIPTIONS
1596 "Set overload bit for topology\n")
1598 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1600 const char *arg
= argv
[2]->arg
;
1601 uint16_t mtid
= isis_str2mtid(arg
);
1603 if (area
->oldmetric
) {
1605 "Multi topology IS-IS can only be used with wide metrics\n");
1606 return CMD_WARNING_CONFIG_FAILED
;
1609 if (mtid
== (uint16_t)-1) {
1610 vty_out(vty
, "Don't know topology '%s'\n", arg
);
1611 return CMD_WARNING_CONFIG_FAILED
;
1613 if (mtid
== ISIS_MT_IPV4_UNICAST
) {
1614 vty_out(vty
, "Cannot configure IPv4 unicast topology\n");
1615 return CMD_WARNING_CONFIG_FAILED
;
1618 area_set_mt_enabled(area
, mtid
, false);
1619 area_set_mt_overload(area
, mtid
, false);
1623 void isis_area_lsp_mtu_set(struct isis_area
*area
, unsigned int lsp_mtu
)
1625 area
->lsp_mtu
= lsp_mtu
;
1626 lsp_regenerate_schedule(area
, IS_LEVEL_1_AND_2
, 1);
1629 static int isis_area_passwd_set(struct isis_area
*area
, int level
,
1630 u_char passwd_type
, const char *passwd
,
1633 struct isis_passwd
*dest
;
1634 struct isis_passwd modified
;
1637 assert((level
== IS_LEVEL_1
) || (level
== IS_LEVEL_2
));
1638 dest
= (level
== IS_LEVEL_1
) ? &area
->area_passwd
1639 : &area
->domain_passwd
;
1640 memset(&modified
, 0, sizeof(modified
));
1642 if (passwd_type
!= ISIS_PASSWD_TYPE_UNUSED
) {
1646 len
= strlen(passwd
);
1651 strncpy((char *)modified
.passwd
, passwd
, 255);
1652 modified
.type
= passwd_type
;
1653 modified
.snp_auth
= snp_auth
;
1656 if (memcmp(&modified
, dest
, sizeof(modified
))) {
1657 memcpy(dest
, &modified
, sizeof(modified
));
1658 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1664 int isis_area_passwd_unset(struct isis_area
*area
, int level
)
1666 return isis_area_passwd_set(area
, level
, ISIS_PASSWD_TYPE_UNUSED
, NULL
,
1670 int isis_area_passwd_cleartext_set(struct isis_area
*area
, int level
,
1671 const char *passwd
, u_char snp_auth
)
1673 return isis_area_passwd_set(area
, level
, ISIS_PASSWD_TYPE_CLEARTXT
,
1677 int isis_area_passwd_hmac_md5_set(struct isis_area
*area
, int level
,
1678 const char *passwd
, u_char snp_auth
)
1680 return isis_area_passwd_set(area
, level
, ISIS_PASSWD_TYPE_HMAC_MD5
,
1684 static void area_resign_level(struct isis_area
*area
, int level
)
1686 if (area
->lspdb
[level
- 1]) {
1687 lsp_db_destroy(area
->lspdb
[level
- 1]);
1688 area
->lspdb
[level
- 1] = NULL
;
1690 if (area
->spftree
[level
- 1]) {
1691 isis_spftree_del(area
->spftree
[level
- 1]);
1692 area
->spftree
[level
- 1] = NULL
;
1694 if (area
->spftree6
[level
- 1]) {
1695 isis_spftree_del(area
->spftree6
[level
- 1]);
1696 area
->spftree6
[level
- 1] = NULL
;
1698 THREAD_TIMER_OFF(area
->spf_timer
[level
- 1]);
1699 if (area
->route_table
[level
- 1]) {
1700 route_table_finish(area
->route_table
[level
- 1]);
1701 area
->route_table
[level
- 1] = NULL
;
1703 if (area
->route_table6
[level
- 1]) {
1704 route_table_finish(area
->route_table6
[level
- 1]);
1705 area
->route_table6
[level
- 1] = NULL
;
1709 "ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.",
1710 area
->area_tag
, level
);
1711 THREAD_TIMER_OFF(area
->t_lsp_refresh
[level
- 1]);
1712 area
->lsp_regenerate_pending
[level
- 1] = 0;
1715 void isis_area_is_type_set(struct isis_area
*area
, int is_type
)
1717 struct listnode
*node
;
1718 struct isis_circuit
*circuit
;
1720 if (isis
->debugs
& DEBUG_EVENTS
)
1721 zlog_debug("ISIS-Evt (%s) system type change %s -> %s",
1722 area
->area_tag
, circuit_t2string(area
->is_type
),
1723 circuit_t2string(is_type
));
1725 if (area
->is_type
== is_type
)
1726 return; /* No change */
1728 switch (area
->is_type
) {
1730 if (is_type
== IS_LEVEL_2
)
1731 area_resign_level(area
, IS_LEVEL_1
);
1733 if (area
->lspdb
[1] == NULL
)
1734 area
->lspdb
[1] = lsp_db_init();
1735 if (area
->route_table
[1] == NULL
)
1736 area
->route_table
[1] = route_table_init();
1737 if (area
->route_table6
[1] == NULL
)
1738 area
->route_table6
[1] = route_table_init();
1741 case IS_LEVEL_1_AND_2
:
1742 if (is_type
== IS_LEVEL_1
)
1743 area_resign_level(area
, IS_LEVEL_2
);
1745 area_resign_level(area
, IS_LEVEL_1
);
1749 if (is_type
== IS_LEVEL_1
)
1750 area_resign_level(area
, IS_LEVEL_2
);
1752 if (area
->lspdb
[0] == NULL
)
1753 area
->lspdb
[0] = lsp_db_init();
1754 if (area
->route_table
[0] == NULL
)
1755 area
->route_table
[0] = route_table_init();
1756 if (area
->route_table6
[0] == NULL
)
1757 area
->route_table6
[0] = route_table_init();
1764 area
->is_type
= is_type
;
1766 /* override circuit's is_type */
1767 if (area
->is_type
!= IS_LEVEL_1_AND_2
) {
1768 for (ALL_LIST_ELEMENTS_RO(area
->circuit_list
, node
, circuit
))
1769 isis_circuit_is_type_set(circuit
, is_type
);
1772 spftree_area_init(area
);
1774 if (listcount(area
->area_addrs
) > 0) {
1775 if (is_type
& IS_LEVEL_1
)
1776 lsp_generate(area
, IS_LEVEL_1
);
1777 if (is_type
& IS_LEVEL_2
)
1778 lsp_generate(area
, IS_LEVEL_2
);
1780 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1785 void isis_area_metricstyle_set(struct isis_area
*area
, bool old_metric
,
1788 if (area
->oldmetric
!= old_metric
|| area
->newmetric
!= new_metric
) {
1789 area
->oldmetric
= old_metric
;
1790 area
->newmetric
= new_metric
;
1791 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1795 void isis_area_overload_bit_set(struct isis_area
*area
, bool overload_bit
)
1797 char new_overload_bit
= overload_bit
? LSPBIT_OL
: 0;
1799 if (new_overload_bit
!= area
->overload_bit
) {
1800 area
->overload_bit
= new_overload_bit
;
1801 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1805 void isis_area_attached_bit_set(struct isis_area
*area
, bool attached_bit
)
1807 char new_attached_bit
= attached_bit
? LSPBIT_ATT
: 0;
1809 if (new_attached_bit
!= area
->attached_bit
) {
1810 area
->attached_bit
= new_attached_bit
;
1811 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1815 void isis_area_dynhostname_set(struct isis_area
*area
, bool dynhostname
)
1817 if (area
->dynhostname
!= dynhostname
) {
1818 area
->dynhostname
= dynhostname
;
1819 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 0);
1823 void isis_area_max_lsp_lifetime_set(struct isis_area
*area
, int level
,
1824 uint16_t max_lsp_lifetime
)
1826 assert((level
== IS_LEVEL_1
) || (level
== IS_LEVEL_2
));
1828 if (area
->max_lsp_lifetime
[level
- 1] == max_lsp_lifetime
)
1831 area
->max_lsp_lifetime
[level
- 1] = max_lsp_lifetime
;
1832 lsp_regenerate_schedule(area
, level
, 1);
1835 void isis_area_lsp_refresh_set(struct isis_area
*area
, int level
,
1836 uint16_t lsp_refresh
)
1838 assert((level
== IS_LEVEL_1
) || (level
== IS_LEVEL_2
));
1840 if (area
->lsp_refresh
[level
- 1] == lsp_refresh
)
1843 area
->lsp_refresh
[level
- 1] = lsp_refresh
;
1844 lsp_regenerate_schedule(area
, level
, 1);
1847 DEFUN (log_adj_changes
,
1848 log_adj_changes_cmd
,
1849 "log-adjacency-changes",
1850 "Log changes in adjacency state\n")
1852 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1854 area
->log_adj_changes
= 1;
1859 DEFUN (no_log_adj_changes
,
1860 no_log_adj_changes_cmd
,
1861 "no log-adjacency-changes",
1863 "Stop logging changes in adjacency state\n")
1865 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1867 area
->log_adj_changes
= 0;
1872 /* IS-IS configuration write function */
1873 int isis_config_write(struct vty
*vty
)
1878 struct isis_area
*area
;
1879 struct listnode
*node
, *node2
;
1881 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1882 /* ISIS - Area name */
1883 vty_out(vty
, "router isis %s\n", area
->area_tag
);
1886 if (listcount(area
->area_addrs
) > 0) {
1887 struct area_addr
*area_addr
;
1888 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
,
1889 node2
, area_addr
)) {
1890 vty_out(vty
, " net %s\n",
1892 area_addr
->area_addr
,
1899 /* ISIS - Dynamic hostname - Defaults to true so only
1902 if (!area
->dynhostname
) {
1903 vty_out(vty
, " no hostname dynamic\n");
1906 /* ISIS - Metric-Style - when true displays wide */
1907 if (area
->newmetric
) {
1908 if (!area
->oldmetric
)
1909 vty_out(vty
, " metric-style wide\n");
1912 " metric-style transition\n");
1915 vty_out(vty
, " metric-style narrow\n");
1918 /* ISIS - overload-bit */
1919 if (area
->overload_bit
) {
1920 vty_out(vty
, " set-overload-bit\n");
1923 /* ISIS - Area is-type (level-1-2 is default) */
1924 if (area
->is_type
== IS_LEVEL_1
) {
1925 vty_out(vty
, " is-type level-1\n");
1927 } else if (area
->is_type
== IS_LEVEL_2
) {
1928 vty_out(vty
, " is-type level-2-only\n");
1931 write
+= isis_redist_config_write(vty
, area
, AF_INET
);
1932 write
+= isis_redist_config_write(vty
, area
, AF_INET6
);
1933 /* ISIS - Lsp generation interval */
1934 if (area
->lsp_gen_interval
[0]
1935 == area
->lsp_gen_interval
[1]) {
1936 if (area
->lsp_gen_interval
[0]
1937 != DEFAULT_MIN_LSP_GEN_INTERVAL
) {
1938 vty_out(vty
, " lsp-gen-interval %d\n",
1939 area
->lsp_gen_interval
[0]);
1943 if (area
->lsp_gen_interval
[0]
1944 != DEFAULT_MIN_LSP_GEN_INTERVAL
) {
1946 " lsp-gen-interval level-1 %d\n",
1947 area
->lsp_gen_interval
[0]);
1950 if (area
->lsp_gen_interval
[1]
1951 != DEFAULT_MIN_LSP_GEN_INTERVAL
) {
1953 " lsp-gen-interval level-2 %d\n",
1954 area
->lsp_gen_interval
[1]);
1958 /* ISIS - LSP lifetime */
1959 if (area
->max_lsp_lifetime
[0]
1960 == area
->max_lsp_lifetime
[1]) {
1961 if (area
->max_lsp_lifetime
[0]
1962 != DEFAULT_LSP_LIFETIME
) {
1963 vty_out(vty
, " max-lsp-lifetime %u\n",
1964 area
->max_lsp_lifetime
[0]);
1968 if (area
->max_lsp_lifetime
[0]
1969 != DEFAULT_LSP_LIFETIME
) {
1971 " max-lsp-lifetime level-1 %u\n",
1972 area
->max_lsp_lifetime
[0]);
1975 if (area
->max_lsp_lifetime
[1]
1976 != DEFAULT_LSP_LIFETIME
) {
1978 " max-lsp-lifetime level-2 %u\n",
1979 area
->max_lsp_lifetime
[1]);
1983 /* ISIS - LSP refresh interval */
1984 if (area
->lsp_refresh
[0] == area
->lsp_refresh
[1]) {
1985 if (area
->lsp_refresh
[0]
1986 != DEFAULT_MAX_LSP_GEN_INTERVAL
) {
1988 " lsp-refresh-interval %u\n",
1989 area
->lsp_refresh
[0]);
1993 if (area
->lsp_refresh
[0]
1994 != DEFAULT_MAX_LSP_GEN_INTERVAL
) {
1996 " lsp-refresh-interval level-1 %u\n",
1997 area
->lsp_refresh
[0]);
2000 if (area
->lsp_refresh
[1]
2001 != DEFAULT_MAX_LSP_GEN_INTERVAL
) {
2003 " lsp-refresh-interval level-2 %u\n",
2004 area
->lsp_refresh
[1]);
2008 if (area
->lsp_mtu
!= DEFAULT_LSP_MTU
) {
2009 vty_out(vty
, " lsp-mtu %u\n", area
->lsp_mtu
);
2013 /* Minimum SPF interval. */
2014 if (area
->min_spf_interval
[0]
2015 == area
->min_spf_interval
[1]) {
2016 if (area
->min_spf_interval
[0]
2017 != MINIMUM_SPF_INTERVAL
) {
2018 vty_out(vty
, " spf-interval %d\n",
2019 area
->min_spf_interval
[0]);
2023 if (area
->min_spf_interval
[0]
2024 != MINIMUM_SPF_INTERVAL
) {
2026 " spf-interval level-1 %d\n",
2027 area
->min_spf_interval
[0]);
2030 if (area
->min_spf_interval
[1]
2031 != MINIMUM_SPF_INTERVAL
) {
2033 " spf-interval level-2 %d\n",
2034 area
->min_spf_interval
[1]);
2039 /* IETF SPF interval */
2040 if (area
->spf_delay_ietf
[0]) {
2042 " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld\n",
2043 spf_backoff_init_delay(
2044 area
->spf_delay_ietf
[0]),
2045 spf_backoff_short_delay(
2046 area
->spf_delay_ietf
[0]),
2047 spf_backoff_long_delay(
2048 area
->spf_delay_ietf
[0]),
2049 spf_backoff_holddown(
2050 area
->spf_delay_ietf
[0]),
2051 spf_backoff_timetolearn(
2052 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");
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");
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");
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");
2124 if (area
->log_adj_changes
) {
2125 vty_out(vty
, " log-adjacency-changes\n");
2129 write
+= area_write_mt_settings(area
, vty
);
2131 isis_mpls_te_config_write_router(vty
);
2137 struct cmd_node isis_node
= {ISIS_NODE
, "%s(config-router)# ", 1};
2141 /* Install IS-IS top node */
2142 install_node(&isis_node
, isis_config_write
);
2144 install_element(VIEW_NODE
, &show_isis_summary_cmd
);
2146 install_element(VIEW_NODE
, &show_isis_spf_ietf_cmd
);
2148 install_element(VIEW_NODE
, &show_isis_interface_cmd
);
2149 install_element(VIEW_NODE
, &show_isis_interface_detail_cmd
);
2150 install_element(VIEW_NODE
, &show_isis_interface_arg_cmd
);
2152 install_element(VIEW_NODE
, &show_isis_neighbor_cmd
);
2153 install_element(VIEW_NODE
, &show_isis_neighbor_detail_cmd
);
2154 install_element(VIEW_NODE
, &show_isis_neighbor_arg_cmd
);
2155 install_element(VIEW_NODE
, &clear_isis_neighbor_cmd
);
2156 install_element(VIEW_NODE
, &clear_isis_neighbor_arg_cmd
);
2158 install_element(VIEW_NODE
, &show_hostname_cmd
);
2159 install_element(VIEW_NODE
, &show_database_cmd
);
2161 install_element(ENABLE_NODE
, &show_debugging_isis_cmd
);
2163 install_node(&debug_node
, config_write_debug
);
2165 install_element(ENABLE_NODE
, &debug_isis_adj_cmd
);
2166 install_element(ENABLE_NODE
, &no_debug_isis_adj_cmd
);
2167 install_element(ENABLE_NODE
, &debug_isis_csum_cmd
);
2168 install_element(ENABLE_NODE
, &no_debug_isis_csum_cmd
);
2169 install_element(ENABLE_NODE
, &debug_isis_lupd_cmd
);
2170 install_element(ENABLE_NODE
, &no_debug_isis_lupd_cmd
);
2171 install_element(ENABLE_NODE
, &debug_isis_err_cmd
);
2172 install_element(ENABLE_NODE
, &no_debug_isis_err_cmd
);
2173 install_element(ENABLE_NODE
, &debug_isis_snp_cmd
);
2174 install_element(ENABLE_NODE
, &no_debug_isis_snp_cmd
);
2175 install_element(ENABLE_NODE
, &debug_isis_upd_cmd
);
2176 install_element(ENABLE_NODE
, &no_debug_isis_upd_cmd
);
2177 install_element(ENABLE_NODE
, &debug_isis_spfevents_cmd
);
2178 install_element(ENABLE_NODE
, &no_debug_isis_spfevents_cmd
);
2179 install_element(ENABLE_NODE
, &debug_isis_spfstats_cmd
);
2180 install_element(ENABLE_NODE
, &no_debug_isis_spfstats_cmd
);
2181 install_element(ENABLE_NODE
, &debug_isis_spftrigg_cmd
);
2182 install_element(ENABLE_NODE
, &no_debug_isis_spftrigg_cmd
);
2183 install_element(ENABLE_NODE
, &debug_isis_rtevents_cmd
);
2184 install_element(ENABLE_NODE
, &no_debug_isis_rtevents_cmd
);
2185 install_element(ENABLE_NODE
, &debug_isis_events_cmd
);
2186 install_element(ENABLE_NODE
, &no_debug_isis_events_cmd
);
2187 install_element(ENABLE_NODE
, &debug_isis_packet_dump_cmd
);
2188 install_element(ENABLE_NODE
, &no_debug_isis_packet_dump_cmd
);
2189 install_element(ENABLE_NODE
, &debug_isis_lsp_gen_cmd
);
2190 install_element(ENABLE_NODE
, &no_debug_isis_lsp_gen_cmd
);
2191 install_element(ENABLE_NODE
, &debug_isis_lsp_sched_cmd
);
2192 install_element(ENABLE_NODE
, &no_debug_isis_lsp_sched_cmd
);
2194 install_element(CONFIG_NODE
, &debug_isis_adj_cmd
);
2195 install_element(CONFIG_NODE
, &no_debug_isis_adj_cmd
);
2196 install_element(CONFIG_NODE
, &debug_isis_csum_cmd
);
2197 install_element(CONFIG_NODE
, &no_debug_isis_csum_cmd
);
2198 install_element(CONFIG_NODE
, &debug_isis_lupd_cmd
);
2199 install_element(CONFIG_NODE
, &no_debug_isis_lupd_cmd
);
2200 install_element(CONFIG_NODE
, &debug_isis_err_cmd
);
2201 install_element(CONFIG_NODE
, &no_debug_isis_err_cmd
);
2202 install_element(CONFIG_NODE
, &debug_isis_snp_cmd
);
2203 install_element(CONFIG_NODE
, &no_debug_isis_snp_cmd
);
2204 install_element(CONFIG_NODE
, &debug_isis_upd_cmd
);
2205 install_element(CONFIG_NODE
, &no_debug_isis_upd_cmd
);
2206 install_element(CONFIG_NODE
, &debug_isis_spfevents_cmd
);
2207 install_element(CONFIG_NODE
, &no_debug_isis_spfevents_cmd
);
2208 install_element(CONFIG_NODE
, &debug_isis_spfstats_cmd
);
2209 install_element(CONFIG_NODE
, &no_debug_isis_spfstats_cmd
);
2210 install_element(CONFIG_NODE
, &debug_isis_spftrigg_cmd
);
2211 install_element(CONFIG_NODE
, &no_debug_isis_spftrigg_cmd
);
2212 install_element(CONFIG_NODE
, &debug_isis_rtevents_cmd
);
2213 install_element(CONFIG_NODE
, &no_debug_isis_rtevents_cmd
);
2214 install_element(CONFIG_NODE
, &debug_isis_events_cmd
);
2215 install_element(CONFIG_NODE
, &no_debug_isis_events_cmd
);
2216 install_element(CONFIG_NODE
, &debug_isis_packet_dump_cmd
);
2217 install_element(CONFIG_NODE
, &no_debug_isis_packet_dump_cmd
);
2218 install_element(CONFIG_NODE
, &debug_isis_lsp_gen_cmd
);
2219 install_element(CONFIG_NODE
, &no_debug_isis_lsp_gen_cmd
);
2220 install_element(CONFIG_NODE
, &debug_isis_lsp_sched_cmd
);
2221 install_element(CONFIG_NODE
, &no_debug_isis_lsp_sched_cmd
);
2223 install_element(CONFIG_NODE
, &router_isis_cmd
);
2224 install_element(CONFIG_NODE
, &no_router_isis_cmd
);
2226 install_default(ISIS_NODE
);
2228 install_element(ISIS_NODE
, &net_cmd
);
2229 install_element(ISIS_NODE
, &no_net_cmd
);
2231 install_element(ISIS_NODE
, &isis_topology_cmd
);
2232 install_element(ISIS_NODE
, &no_isis_topology_cmd
);
2234 install_element(ISIS_NODE
, &log_adj_changes_cmd
);
2235 install_element(ISIS_NODE
, &no_log_adj_changes_cmd
);
2237 spf_backoff_cmd_init();