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 * Fabricd runs only as level-2.
109 * For IS-IS, the first instance is level-1-2 rest are level-1,
110 * unless otherwise configured
113 area
->is_type
= IS_LEVEL_2
;
114 } else if (listcount(isis
->area_list
) > 0)
115 area
->is_type
= IS_LEVEL_1
;
117 area
->is_type
= IS_LEVEL_1_AND_2
;
120 * intialize the databases
122 if (area
->is_type
& IS_LEVEL_1
) {
123 area
->lspdb
[0] = lsp_db_init();
125 if (area
->is_type
& IS_LEVEL_2
) {
126 area
->lspdb
[1] = lsp_db_init();
129 spftree_area_init(area
);
131 area
->circuit_list
= list_new();
132 area
->area_addrs
= list_new();
133 thread_add_timer(master
, lsp_tick
, area
, 1, &area
->t_tick
);
134 flags_initialize(&area
->flags
);
139 area
->max_lsp_lifetime
[0] = DEFAULT_LSP_LIFETIME
; /* 1200 */
140 area
->max_lsp_lifetime
[1] = DEFAULT_LSP_LIFETIME
; /* 1200 */
141 area
->lsp_refresh
[0] = DEFAULT_MAX_LSP_GEN_INTERVAL
; /* 900 */
142 area
->lsp_refresh
[1] = DEFAULT_MAX_LSP_GEN_INTERVAL
; /* 900 */
143 area
->lsp_gen_interval
[0] = DEFAULT_MIN_LSP_GEN_INTERVAL
;
144 area
->lsp_gen_interval
[1] = DEFAULT_MIN_LSP_GEN_INTERVAL
;
145 area
->min_spf_interval
[0] = MINIMUM_SPF_INTERVAL
;
146 area
->min_spf_interval
[1] = MINIMUM_SPF_INTERVAL
;
147 area
->dynhostname
= 1;
150 area
->lsp_frag_threshold
= 90;
151 area
->lsp_mtu
= DEFAULT_LSP_MTU
;
155 area
->area_tag
= strdup(area_tag
);
156 listnode_add(isis
->area_list
, area
);
159 QOBJ_REG(area
, isis_area
);
164 struct isis_area
*isis_area_lookup(const char *area_tag
)
166 struct isis_area
*area
;
167 struct listnode
*node
;
169 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
))
170 if ((area
->area_tag
== NULL
&& area_tag
== NULL
)
171 || (area
->area_tag
&& area_tag
172 && strcmp(area
->area_tag
, area_tag
) == 0))
178 int isis_area_get(struct vty
*vty
, const char *area_tag
)
180 struct isis_area
*area
;
182 area
= isis_area_lookup(area_tag
);
185 VTY_PUSH_CONTEXT(ROUTER_NODE
, area
);
189 area
= isis_area_create(area_tag
);
191 if (isis
->debugs
& DEBUG_EVENTS
)
192 zlog_debug("New IS-IS area instance %s", area
->area_tag
);
194 VTY_PUSH_CONTEXT(ROUTER_NODE
, area
);
199 int isis_area_destroy(struct vty
*vty
, const char *area_tag
)
201 struct isis_area
*area
;
202 struct listnode
*node
, *nnode
;
203 struct isis_circuit
*circuit
;
204 struct area_addr
*addr
;
206 area
= isis_area_lookup(area_tag
);
209 vty_out(vty
, "Can't find ISIS instance \n");
210 return CMD_ERR_NO_MATCH
;
215 if (area
->circuit_list
) {
216 for (ALL_LIST_ELEMENTS(area
->circuit_list
, node
, nnode
,
218 circuit
->ip_router
= 0;
219 circuit
->ipv6_router
= 0;
220 isis_csm_state_change(ISIS_DISABLE
, circuit
, area
);
222 list_delete_and_null(&area
->circuit_list
);
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 /* invalidate and verify to delete all routes from zebra */
235 isis_area_invalidate_routes(area
, ISIS_LEVEL1
& ISIS_LEVEL2
);
236 isis_area_verify_routes(area
);
238 spftree_area_del(area
);
240 THREAD_TIMER_OFF(area
->spf_timer
[0]);
241 THREAD_TIMER_OFF(area
->spf_timer
[1]);
243 spf_backoff_free(area
->spf_delay_ietf
[0]);
244 spf_backoff_free(area
->spf_delay_ietf
[1]);
246 isis_redist_area_finish(area
);
248 for (ALL_LIST_ELEMENTS(area
->area_addrs
, node
, nnode
, addr
)) {
249 list_delete_node(area
->area_addrs
, node
);
250 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
252 area
->area_addrs
= NULL
;
254 THREAD_TIMER_OFF(area
->t_tick
);
255 THREAD_TIMER_OFF(area
->t_lsp_refresh
[0]);
256 THREAD_TIMER_OFF(area
->t_lsp_refresh
[1]);
258 thread_cancel_event(master
, area
);
260 listnode_delete(isis
->area_list
, area
);
262 free(area
->area_tag
);
264 area_mt_finish(area
);
266 XFREE(MTYPE_ISIS_AREA
, area
);
268 if (listcount(isis
->area_list
) == 0) {
269 memset(isis
->sysid
, 0, ISIS_SYS_ID_LEN
);
276 static void area_set_mt_enabled(struct isis_area
*area
, uint16_t mtid
,
279 struct isis_area_mt_setting
*setting
;
281 setting
= area_get_mt_setting(area
, mtid
);
282 if (setting
->enabled
!= enabled
) {
283 setting
->enabled
= enabled
;
284 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 0);
288 static void area_set_mt_overload(struct isis_area
*area
, uint16_t mtid
,
291 struct isis_area_mt_setting
*setting
;
293 setting
= area_get_mt_setting(area
, mtid
);
294 if (setting
->overload
!= overload
) {
295 setting
->overload
= overload
;
296 if (setting
->enabled
)
297 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
,
302 int area_net_title(struct vty
*vty
, const char *net_title
)
304 VTY_DECLVAR_CONTEXT(isis_area
, area
);
305 struct area_addr
*addr
;
306 struct area_addr
*addrp
;
307 struct listnode
*node
;
311 /* We check that we are not over the maximal number of addresses */
312 if (listcount(area
->area_addrs
) >= isis
->max_area_addrs
) {
314 "Maximum of area addresses (%d) already reached \n",
315 isis
->max_area_addrs
);
316 return CMD_ERR_NOTHING_TODO
;
319 addr
= XMALLOC(MTYPE_ISIS_AREA_ADDR
, sizeof(struct area_addr
));
320 addr
->addr_len
= dotformat2buff(buff
, net_title
);
321 memcpy(addr
->area_addr
, buff
, addr
->addr_len
);
323 zlog_debug("added area address %s for area %s (address length %d)",
324 net_title
, area
->area_tag
, addr
->addr_len
);
325 #endif /* EXTREME_DEBUG */
326 if (addr
->addr_len
< 8 || addr
->addr_len
> 20) {
328 "area address must be at least 8..20 octets long (%d)\n",
330 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
331 return CMD_WARNING_CONFIG_FAILED
;
334 if (addr
->area_addr
[addr
->addr_len
- 1] != 0) {
336 "nsel byte (last byte) in area address must be 0\n");
337 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
338 return CMD_WARNING_CONFIG_FAILED
;
341 if (isis
->sysid_set
== 0) {
343 * First area address - get the SystemID for this router
345 memcpy(isis
->sysid
, GETSYSID(addr
), ISIS_SYS_ID_LEN
);
347 if (isis
->debugs
& DEBUG_EVENTS
)
348 zlog_debug("Router has SystemID %s",
349 sysid_print(isis
->sysid
));
352 * Check that the SystemID portions match
354 if (memcmp(isis
->sysid
, GETSYSID(addr
), ISIS_SYS_ID_LEN
)) {
356 "System ID must not change when defining additional area addresses\n");
357 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
358 return CMD_WARNING_CONFIG_FAILED
;
361 /* now we see that we don't already have this address */
362 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
, node
, addrp
)) {
363 if ((addrp
->addr_len
+ ISIS_SYS_ID_LEN
+ ISIS_NSEL_LEN
)
366 if (!memcmp(addrp
->area_addr
, addr
->area_addr
,
368 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
369 return CMD_SUCCESS
; /* silent fail */
375 * Forget the systemID part of the address
377 addr
->addr_len
-= (ISIS_SYS_ID_LEN
+ ISIS_NSEL_LEN
);
378 listnode_add(area
->area_addrs
, addr
);
380 /* only now we can safely generate our LSPs for this area */
381 if (listcount(area
->area_addrs
) > 0) {
382 if (area
->is_type
& IS_LEVEL_1
)
383 lsp_generate(area
, IS_LEVEL_1
);
384 if (area
->is_type
& IS_LEVEL_2
)
385 lsp_generate(area
, IS_LEVEL_2
);
391 int area_clear_net_title(struct vty
*vty
, const char *net_title
)
393 VTY_DECLVAR_CONTEXT(isis_area
, area
);
394 struct area_addr addr
, *addrp
= NULL
;
395 struct listnode
*node
;
398 addr
.addr_len
= dotformat2buff(buff
, net_title
);
399 if (addr
.addr_len
< 8 || addr
.addr_len
> 20) {
401 "Unsupported area address length %d, should be 8...20 \n",
403 return CMD_WARNING_CONFIG_FAILED
;
406 memcpy(addr
.area_addr
, buff
, (int)addr
.addr_len
);
408 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
, node
, addrp
))
409 if ((addrp
->addr_len
+ ISIS_SYS_ID_LEN
+ 1) == addr
.addr_len
410 && !memcmp(addrp
->area_addr
, addr
.area_addr
, addr
.addr_len
))
414 vty_out(vty
, "No area address %s for area %s \n", net_title
,
416 return CMD_ERR_NO_MATCH
;
419 listnode_delete(area
->area_addrs
, addrp
);
420 XFREE(MTYPE_ISIS_AREA_ADDR
, addrp
);
423 * Last area address - reset the SystemID for this router
425 if (listcount(area
->area_addrs
) == 0) {
426 memset(isis
->sysid
, 0, ISIS_SYS_ID_LEN
);
428 if (isis
->debugs
& DEBUG_EVENTS
)
429 zlog_debug("Router has no SystemID");
436 * 'show isis interface' command
439 int show_isis_interface_common(struct vty
*vty
, const char *ifname
, char detail
)
441 struct listnode
*anode
, *cnode
;
442 struct isis_area
*area
;
443 struct isis_circuit
*circuit
;
446 vty_out(vty
, "IS-IS Routing Process not enabled\n");
450 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, anode
, area
)) {
451 vty_out(vty
, "Area %s:\n", area
->area_tag
);
453 if (detail
== ISIS_UI_LEVEL_BRIEF
)
455 " Interface CircId State Type Level\n");
457 for (ALL_LIST_ELEMENTS_RO(area
->circuit_list
, cnode
, circuit
))
459 isis_circuit_print_vty(circuit
, vty
, detail
);
460 else if (strcmp(circuit
->interface
->name
, ifname
) == 0)
461 isis_circuit_print_vty(circuit
, vty
, detail
);
467 DEFUN (show_isis_interface
,
468 show_isis_interface_cmd
,
469 "show " PROTO_NAME
" interface",
474 return show_isis_interface_common(vty
, NULL
, ISIS_UI_LEVEL_BRIEF
);
477 DEFUN (show_isis_interface_detail
,
478 show_isis_interface_detail_cmd
,
479 "show " PROTO_NAME
" interface detail",
483 "show detailed information\n")
485 return show_isis_interface_common(vty
, NULL
, ISIS_UI_LEVEL_DETAIL
);
488 DEFUN (show_isis_interface_arg
,
489 show_isis_interface_arg_cmd
,
490 "show " PROTO_NAME
" interface WORD",
494 "ISIS interface name\n")
497 return show_isis_interface_common(vty
, argv
[idx_word
]->arg
,
498 ISIS_UI_LEVEL_DETAIL
);
502 * 'show isis neighbor' command
505 int show_isis_neighbor_common(struct vty
*vty
, const char *id
, char detail
)
507 struct listnode
*anode
, *cnode
, *node
;
508 struct isis_area
*area
;
509 struct isis_circuit
*circuit
;
511 struct isis_adjacency
*adj
;
512 struct isis_dynhn
*dynhn
;
513 uint8_t sysid
[ISIS_SYS_ID_LEN
];
517 vty_out(vty
, "IS-IS Routing Process not enabled\n");
521 memset(sysid
, 0, ISIS_SYS_ID_LEN
);
523 if (sysid2buff(sysid
, id
) == 0) {
524 dynhn
= dynhn_find_by_name(id
);
526 vty_out(vty
, "Invalid system id %s\n", id
);
529 memcpy(sysid
, dynhn
->id
, ISIS_SYS_ID_LEN
);
533 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, anode
, area
)) {
534 vty_out(vty
, "Area %s:\n", area
->area_tag
);
536 if (detail
== ISIS_UI_LEVEL_BRIEF
)
538 " System Id Interface L State Holdtime SNPA\n");
540 for (ALL_LIST_ELEMENTS_RO(area
->circuit_list
, cnode
, circuit
)) {
541 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
542 for (i
= 0; i
< 2; i
++) {
543 adjdb
= circuit
->u
.bc
.adjdb
[i
];
544 if (adjdb
&& adjdb
->count
) {
545 for (ALL_LIST_ELEMENTS_RO(
548 || !memcmp(adj
->sysid
,
557 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
558 && circuit
->u
.p2p
.neighbor
) {
559 adj
= circuit
->u
.p2p
.neighbor
;
561 || !memcmp(adj
->sysid
, sysid
,
563 isis_adj_print_vty(adj
, vty
, detail
);
572 * 'clear isis neighbor' command
574 int clear_isis_neighbor_common(struct vty
*vty
, const char *id
)
576 struct listnode
*anode
, *cnode
, *cnextnode
, *node
, *nnode
;
577 struct isis_area
*area
;
578 struct isis_circuit
*circuit
;
580 struct isis_adjacency
*adj
;
581 struct isis_dynhn
*dynhn
;
582 uint8_t sysid
[ISIS_SYS_ID_LEN
];
586 vty_out(vty
, "IS-IS Routing Process not enabled\n");
590 memset(sysid
, 0, ISIS_SYS_ID_LEN
);
592 if (sysid2buff(sysid
, id
) == 0) {
593 dynhn
= dynhn_find_by_name(id
);
595 vty_out(vty
, "Invalid system id %s\n", 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 " PROTO_NAME
" neighbor",
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 " PROTO_NAME
" neighbor detail",
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 " PROTO_NAME
" neighbor WORD",
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 " PROTO_NAME
" neighbor",
677 "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 " PROTO_NAME
" neighbor WORD",
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\n",
709 if (flags
& DEBUG_CHECKSUM_ERRORS
)
710 vty_out(vty
, "IS-IS checksum errors debugging is %s\n", onoffs
);
711 if (flags
& DEBUG_LOCAL_UPDATES
)
712 vty_out(vty
, "IS-IS local updates debugging is %s\n", onoffs
);
713 if (flags
& DEBUG_PROTOCOL_ERRORS
)
714 vty_out(vty
, "IS-IS protocol errors debugging is %s\n", onoffs
);
715 if (flags
& DEBUG_SNP_PACKETS
)
716 vty_out(vty
, "IS-IS CSNP/PSNP packets debugging is %s\n",
718 if (flags
& DEBUG_SPF_EVENTS
)
719 vty_out(vty
, "IS-IS SPF events debugging is %s\n", onoffs
);
720 if (flags
& DEBUG_SPF_STATS
)
722 "IS-IS SPF Timing and Statistics Data debugging is %s\n",
724 if (flags
& DEBUG_SPF_TRIGGERS
)
725 vty_out(vty
, "IS-IS SPF triggering events debugging is %s\n",
727 if (flags
& DEBUG_UPDATE_PACKETS
)
728 vty_out(vty
, "IS-IS Update related packet debugging is %s\n",
730 if (flags
& DEBUG_RTE_EVENTS
)
731 vty_out(vty
, "IS-IS Route related debuggin is %s\n", onoffs
);
732 if (flags
& DEBUG_EVENTS
)
733 vty_out(vty
, "IS-IS Event debugging is %s\n", onoffs
);
734 if (flags
& DEBUG_PACKET_DUMP
)
735 vty_out(vty
, "IS-IS Packet dump debugging is %s\n", onoffs
);
736 if (flags
& DEBUG_LSP_GEN
)
737 vty_out(vty
, "IS-IS LSP generation debugging is %s\n", onoffs
);
738 if (flags
& DEBUG_LSP_SCHED
)
739 vty_out(vty
, "IS-IS LSP scheduling debugging is %s\n", onoffs
);
742 DEFUN_NOSH (show_debugging
,
743 show_debugging_isis_cmd
,
744 "show debugging [" PROTO_NAME
"]",
746 "State of each debugging option\n"
749 vty_out(vty
, PROTO_NAME
" debugging status:\n");
752 print_debug(vty
, isis
->debugs
, 1);
758 static struct cmd_node debug_node
= {DEBUG_NODE
, "", 1};
760 static int config_write_debug(struct vty
*vty
)
763 int flags
= isis
->debugs
;
765 if (flags
& DEBUG_ADJ_PACKETS
) {
766 vty_out(vty
, "debug " PROTO_NAME
" adj-packets\n");
769 if (flags
& DEBUG_CHECKSUM_ERRORS
) {
770 vty_out(vty
, "debug " PROTO_NAME
" checksum-errors\n");
773 if (flags
& DEBUG_LOCAL_UPDATES
) {
774 vty_out(vty
, "debug " PROTO_NAME
" local-updates\n");
777 if (flags
& DEBUG_PROTOCOL_ERRORS
) {
778 vty_out(vty
, "debug " PROTO_NAME
" protocol-errors\n");
781 if (flags
& DEBUG_SNP_PACKETS
) {
782 vty_out(vty
, "debug " PROTO_NAME
" snp-packets\n");
785 if (flags
& DEBUG_SPF_EVENTS
) {
786 vty_out(vty
, "debug " PROTO_NAME
" spf-events\n");
789 if (flags
& DEBUG_SPF_STATS
) {
790 vty_out(vty
, "debug " PROTO_NAME
" spf-statistics\n");
793 if (flags
& DEBUG_SPF_TRIGGERS
) {
794 vty_out(vty
, "debug " PROTO_NAME
" spf-triggers\n");
797 if (flags
& DEBUG_UPDATE_PACKETS
) {
798 vty_out(vty
, "debug " PROTO_NAME
" update-packets\n");
801 if (flags
& DEBUG_RTE_EVENTS
) {
802 vty_out(vty
, "debug " PROTO_NAME
" route-events\n");
805 if (flags
& DEBUG_EVENTS
) {
806 vty_out(vty
, "debug " PROTO_NAME
" events\n");
809 if (flags
& DEBUG_PACKET_DUMP
) {
810 vty_out(vty
, "debug " PROTO_NAME
" packet-dump\n");
813 if (flags
& DEBUG_LSP_GEN
) {
814 vty_out(vty
, "debug " PROTO_NAME
" lsp-gen\n");
817 if (flags
& DEBUG_LSP_SCHED
) {
818 vty_out(vty
, "debug " PROTO_NAME
" lsp-sched\n");
821 write
+= spf_backoff_write_config(vty
);
826 DEFUN (debug_isis_adj
,
828 "debug " PROTO_NAME
" adj-packets",
831 "IS-IS Adjacency related packets\n")
833 isis
->debugs
|= DEBUG_ADJ_PACKETS
;
834 print_debug(vty
, DEBUG_ADJ_PACKETS
, 1);
839 DEFUN (no_debug_isis_adj
,
840 no_debug_isis_adj_cmd
,
841 "no debug " PROTO_NAME
" adj-packets",
845 "IS-IS Adjacency related packets\n")
847 isis
->debugs
&= ~DEBUG_ADJ_PACKETS
;
848 print_debug(vty
, DEBUG_ADJ_PACKETS
, 0);
853 DEFUN (debug_isis_csum
,
855 "debug " PROTO_NAME
" checksum-errors",
858 "IS-IS LSP checksum errors\n")
860 isis
->debugs
|= DEBUG_CHECKSUM_ERRORS
;
861 print_debug(vty
, DEBUG_CHECKSUM_ERRORS
, 1);
866 DEFUN (no_debug_isis_csum
,
867 no_debug_isis_csum_cmd
,
868 "no debug " PROTO_NAME
" checksum-errors",
872 "IS-IS LSP checksum errors\n")
874 isis
->debugs
&= ~DEBUG_CHECKSUM_ERRORS
;
875 print_debug(vty
, DEBUG_CHECKSUM_ERRORS
, 0);
880 DEFUN (debug_isis_lupd
,
882 "debug " PROTO_NAME
" local-updates",
885 "IS-IS local update packets\n")
887 isis
->debugs
|= DEBUG_LOCAL_UPDATES
;
888 print_debug(vty
, DEBUG_LOCAL_UPDATES
, 1);
893 DEFUN (no_debug_isis_lupd
,
894 no_debug_isis_lupd_cmd
,
895 "no debug " PROTO_NAME
" local-updates",
899 "IS-IS local update packets\n")
901 isis
->debugs
&= ~DEBUG_LOCAL_UPDATES
;
902 print_debug(vty
, DEBUG_LOCAL_UPDATES
, 0);
907 DEFUN (debug_isis_err
,
909 "debug " PROTO_NAME
" protocol-errors",
912 "IS-IS LSP protocol errors\n")
914 isis
->debugs
|= DEBUG_PROTOCOL_ERRORS
;
915 print_debug(vty
, DEBUG_PROTOCOL_ERRORS
, 1);
920 DEFUN (no_debug_isis_err
,
921 no_debug_isis_err_cmd
,
922 "no debug " PROTO_NAME
" protocol-errors",
926 "IS-IS LSP protocol errors\n")
928 isis
->debugs
&= ~DEBUG_PROTOCOL_ERRORS
;
929 print_debug(vty
, DEBUG_PROTOCOL_ERRORS
, 0);
934 DEFUN (debug_isis_snp
,
936 "debug " PROTO_NAME
" snp-packets",
939 "IS-IS CSNP/PSNP packets\n")
941 isis
->debugs
|= DEBUG_SNP_PACKETS
;
942 print_debug(vty
, DEBUG_SNP_PACKETS
, 1);
947 DEFUN (no_debug_isis_snp
,
948 no_debug_isis_snp_cmd
,
949 "no debug " PROTO_NAME
" snp-packets",
953 "IS-IS CSNP/PSNP packets\n")
955 isis
->debugs
&= ~DEBUG_SNP_PACKETS
;
956 print_debug(vty
, DEBUG_SNP_PACKETS
, 0);
961 DEFUN (debug_isis_upd
,
963 "debug " PROTO_NAME
" update-packets",
966 "IS-IS Update related packets\n")
968 isis
->debugs
|= DEBUG_UPDATE_PACKETS
;
969 print_debug(vty
, DEBUG_UPDATE_PACKETS
, 1);
974 DEFUN (no_debug_isis_upd
,
975 no_debug_isis_upd_cmd
,
976 "no debug " PROTO_NAME
" update-packets",
980 "IS-IS Update related packets\n")
982 isis
->debugs
&= ~DEBUG_UPDATE_PACKETS
;
983 print_debug(vty
, DEBUG_UPDATE_PACKETS
, 0);
988 DEFUN (debug_isis_spfevents
,
989 debug_isis_spfevents_cmd
,
990 "debug " PROTO_NAME
" spf-events",
993 "IS-IS Shortest Path First Events\n")
995 isis
->debugs
|= DEBUG_SPF_EVENTS
;
996 print_debug(vty
, DEBUG_SPF_EVENTS
, 1);
1001 DEFUN (no_debug_isis_spfevents
,
1002 no_debug_isis_spfevents_cmd
,
1003 "no debug " PROTO_NAME
" spf-events",
1007 "IS-IS Shortest Path First Events\n")
1009 isis
->debugs
&= ~DEBUG_SPF_EVENTS
;
1010 print_debug(vty
, DEBUG_SPF_EVENTS
, 0);
1015 DEFUN (debug_isis_spfstats
,
1016 debug_isis_spfstats_cmd
,
1017 "debug " PROTO_NAME
" spf-statistics ",
1020 "IS-IS SPF Timing and Statistic Data\n")
1022 isis
->debugs
|= DEBUG_SPF_STATS
;
1023 print_debug(vty
, DEBUG_SPF_STATS
, 1);
1028 DEFUN (no_debug_isis_spfstats
,
1029 no_debug_isis_spfstats_cmd
,
1030 "no debug " PROTO_NAME
" spf-statistics",
1034 "IS-IS SPF Timing and Statistic Data\n")
1036 isis
->debugs
&= ~DEBUG_SPF_STATS
;
1037 print_debug(vty
, DEBUG_SPF_STATS
, 0);
1042 DEFUN (debug_isis_spftrigg
,
1043 debug_isis_spftrigg_cmd
,
1044 "debug " PROTO_NAME
" spf-triggers",
1047 "IS-IS SPF triggering events\n")
1049 isis
->debugs
|= DEBUG_SPF_TRIGGERS
;
1050 print_debug(vty
, DEBUG_SPF_TRIGGERS
, 1);
1055 DEFUN (no_debug_isis_spftrigg
,
1056 no_debug_isis_spftrigg_cmd
,
1057 "no debug " PROTO_NAME
" spf-triggers",
1061 "IS-IS SPF triggering events\n")
1063 isis
->debugs
&= ~DEBUG_SPF_TRIGGERS
;
1064 print_debug(vty
, DEBUG_SPF_TRIGGERS
, 0);
1069 DEFUN (debug_isis_rtevents
,
1070 debug_isis_rtevents_cmd
,
1071 "debug " PROTO_NAME
" route-events",
1074 "IS-IS Route related events\n")
1076 isis
->debugs
|= DEBUG_RTE_EVENTS
;
1077 print_debug(vty
, DEBUG_RTE_EVENTS
, 1);
1082 DEFUN (no_debug_isis_rtevents
,
1083 no_debug_isis_rtevents_cmd
,
1084 "no debug " PROTO_NAME
" route-events",
1088 "IS-IS Route related events\n")
1090 isis
->debugs
&= ~DEBUG_RTE_EVENTS
;
1091 print_debug(vty
, DEBUG_RTE_EVENTS
, 0);
1096 DEFUN (debug_isis_events
,
1097 debug_isis_events_cmd
,
1098 "debug " PROTO_NAME
" events",
1103 isis
->debugs
|= DEBUG_EVENTS
;
1104 print_debug(vty
, DEBUG_EVENTS
, 1);
1109 DEFUN (no_debug_isis_events
,
1110 no_debug_isis_events_cmd
,
1111 "no debug " PROTO_NAME
" events",
1117 isis
->debugs
&= ~DEBUG_EVENTS
;
1118 print_debug(vty
, DEBUG_EVENTS
, 0);
1123 DEFUN (debug_isis_packet_dump
,
1124 debug_isis_packet_dump_cmd
,
1125 "debug " PROTO_NAME
" packet-dump",
1128 "IS-IS packet dump\n")
1130 isis
->debugs
|= DEBUG_PACKET_DUMP
;
1131 print_debug(vty
, DEBUG_PACKET_DUMP
, 1);
1136 DEFUN (no_debug_isis_packet_dump
,
1137 no_debug_isis_packet_dump_cmd
,
1138 "no debug " PROTO_NAME
" packet-dump",
1142 "IS-IS packet dump\n")
1144 isis
->debugs
&= ~DEBUG_PACKET_DUMP
;
1145 print_debug(vty
, DEBUG_PACKET_DUMP
, 0);
1150 DEFUN (debug_isis_lsp_gen
,
1151 debug_isis_lsp_gen_cmd
,
1152 "debug " PROTO_NAME
" lsp-gen",
1155 "IS-IS generation of own LSPs\n")
1157 isis
->debugs
|= DEBUG_LSP_GEN
;
1158 print_debug(vty
, DEBUG_LSP_GEN
, 1);
1163 DEFUN (no_debug_isis_lsp_gen
,
1164 no_debug_isis_lsp_gen_cmd
,
1165 "no debug " PROTO_NAME
" lsp-gen",
1169 "IS-IS generation of own LSPs\n")
1171 isis
->debugs
&= ~DEBUG_LSP_GEN
;
1172 print_debug(vty
, DEBUG_LSP_GEN
, 0);
1177 DEFUN (debug_isis_lsp_sched
,
1178 debug_isis_lsp_sched_cmd
,
1179 "debug " PROTO_NAME
" lsp-sched",
1182 "IS-IS scheduling of LSP generation\n")
1184 isis
->debugs
|= DEBUG_LSP_SCHED
;
1185 print_debug(vty
, DEBUG_LSP_SCHED
, 1);
1190 DEFUN (no_debug_isis_lsp_sched
,
1191 no_debug_isis_lsp_sched_cmd
,
1192 "no debug " PROTO_NAME
" lsp-sched",
1196 "IS-IS scheduling of LSP generation\n")
1198 isis
->debugs
&= ~DEBUG_LSP_SCHED
;
1199 print_debug(vty
, DEBUG_LSP_SCHED
, 0);
1204 DEFUN (show_hostname
,
1206 "show " PROTO_NAME
" hostname",
1209 "IS-IS Dynamic hostname mapping\n")
1211 dynhn_print_all(vty
);
1216 DEFUN (show_isis_spf_ietf
,
1217 show_isis_spf_ietf_cmd
,
1218 "show " PROTO_NAME
" spf-delay-ietf",
1221 "SPF delay IETF information\n")
1224 vty_out(vty
, "ISIS is not running\n");
1228 struct listnode
*node
;
1229 struct isis_area
*area
;
1231 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1232 vty_out(vty
, "Area %s:\n",
1233 area
->area_tag
? area
->area_tag
: "null");
1235 for (int level
= ISIS_LEVEL1
; level
<= ISIS_LEVELS
; level
++) {
1236 if ((area
->is_type
& level
) == 0)
1239 vty_out(vty
, " Level-%d:\n", level
);
1240 vty_out(vty
, " SPF delay status: ");
1241 if (area
->spf_timer
[level
- 1]) {
1242 struct timeval remain
= thread_timer_remain(
1243 area
->spf_timer
[level
- 1]);
1244 vty_out(vty
, "Pending, due in %lld msec\n",
1245 (long long)remain
.tv_sec
* 1000
1246 + remain
.tv_usec
/ 1000);
1248 vty_out(vty
, "Not scheduled\n");
1251 if (area
->spf_delay_ietf
[level
- 1]) {
1253 " Using draft-ietf-rtgwg-backoff-algo-04\n");
1255 area
->spf_delay_ietf
[level
- 1], vty
,
1258 vty_out(vty
, " Using legacy backoff algo\n");
1265 DEFUN (show_isis_summary
,
1266 show_isis_summary_cmd
,
1267 "show " PROTO_NAME
" summary",
1268 SHOW_STR PROTO_HELP
"summary\n")
1270 struct listnode
*node
, *node2
;
1271 struct isis_area
*area
;
1275 vty_out(vty
, PROTO_NAME
" is not running\n");
1279 vty_out(vty
, "Process Id : %ld\n", isis
->process_id
);
1280 if (isis
->sysid_set
)
1281 vty_out(vty
, "System Id : %s\n",
1282 sysid_print(isis
->sysid
));
1284 vty_out(vty
, "Up time : ");
1285 vty_out_timestr(vty
, isis
->uptime
);
1288 if (isis
->area_list
)
1289 vty_out(vty
, "Number of areas : %d\n", isis
->area_list
->count
);
1291 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1292 vty_out(vty
, "Area %s:\n",
1293 area
->area_tag
? area
->area_tag
: "null");
1295 if (listcount(area
->area_addrs
) > 0) {
1296 struct area_addr
*area_addr
;
1297 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
, node2
,
1299 vty_out(vty
, " Net: %s\n",
1300 isonet_print(area_addr
->area_addr
,
1307 for (level
= ISIS_LEVEL1
; level
<= ISIS_LEVELS
; level
++) {
1308 if ((area
->is_type
& level
) == 0)
1311 vty_out(vty
, " Level-%d:\n", level
);
1312 if (area
->spf_timer
[level
- 1])
1313 vty_out(vty
, " SPF: (pending)\n");
1315 vty_out(vty
, " SPF:\n");
1317 vty_out(vty
, " minimum interval : %d",
1318 area
->min_spf_interval
[level
- 1]);
1319 if (area
->spf_delay_ietf
[level
- 1])
1321 " (not used, IETF SPF delay activated)");
1324 vty_out(vty
, " IPv4 route computation:\n");
1325 isis_spf_print(area
->spftree
[SPFTREE_IPV4
][level
- 1],
1328 vty_out(vty
, " IPv6 route computation:\n");
1329 isis_spf_print(area
->spftree
[SPFTREE_IPV6
][level
- 1],
1332 vty_out(vty
, " IPv6 dst-src route computation:\n");
1333 isis_spf_print(area
->spftree
[SPFTREE_DSTSRC
][level
-1],
1343 * This function supports following display options:
1344 * [ show isis database [detail] ]
1345 * [ show isis database <sysid> [detail] ]
1346 * [ show isis database <hostname> [detail] ]
1347 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1348 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1349 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1350 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1351 * [ show isis database detail <sysid> ]
1352 * [ show isis database detail <hostname> ]
1353 * [ show isis database detail <sysid>.<pseudo-id> ]
1354 * [ show isis database detail <hostname>.<pseudo-id> ]
1355 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1356 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1358 static int show_isis_database(struct vty
*vty
, const char *argv
, int ui_level
)
1360 struct listnode
*node
;
1361 struct isis_area
*area
;
1362 struct isis_lsp
*lsp
;
1363 struct isis_dynhn
*dynhn
;
1365 uint8_t lspid
[ISIS_SYS_ID_LEN
+ 2];
1368 int level
, lsp_count
;
1370 if (isis
->area_list
->count
== 0)
1373 memset(&lspid
, 0, ISIS_SYS_ID_LEN
);
1374 memset(&sysid
, 0, 255);
1377 * extract fragment and pseudo id from the string argv
1379 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1380 * (b) <systemid/hostname>.<pseudo-id> or
1381 * (c) <systemid/hostname> or
1382 * Where systemid is in the form:
1386 strncpy(sysid
, argv
, 254);
1387 if (argv
&& strlen(argv
) > 3) {
1388 pos
= argv
+ strlen(argv
) - 3;
1389 if (strncmp(pos
, "-", 1) == 0) {
1390 memcpy(number
, ++pos
, 2);
1391 lspid
[ISIS_SYS_ID_LEN
+ 1] =
1392 (uint8_t)strtol((char *)number
, NULL
, 16);
1394 if (strncmp(pos
, ".", 1) != 0)
1397 if (strncmp(pos
, ".", 1) == 0) {
1398 memcpy(number
, ++pos
, 2);
1399 lspid
[ISIS_SYS_ID_LEN
] =
1400 (uint8_t)strtol((char *)number
, NULL
, 16);
1401 sysid
[pos
- argv
- 1] = '\0';
1405 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1406 vty_out(vty
, "Area %s:\n",
1407 area
->area_tag
? area
->area_tag
: "null");
1409 for (level
= 0; level
< ISIS_LEVELS
; level
++) {
1410 if (area
->lspdb
[level
]
1411 && dict_count(area
->lspdb
[level
]) > 0) {
1415 * Try to find the lsp-id if the argv
1418 * hostname.<pseudo-id>-<fragment>
1420 if (sysid2buff(lspid
, sysid
)) {
1423 area
->lspdb
[level
]);
1424 } else if ((dynhn
= dynhn_find_by_name(
1426 memcpy(lspid
, dynhn
->id
,
1430 area
->lspdb
[level
]);
1431 } else if (strncmp(cmd_hostname_get(),
1434 memcpy(lspid
, isis
->sysid
,
1438 area
->lspdb
[level
]);
1442 if (lsp
!= NULL
|| argv
== NULL
) {
1444 "IS-IS Level-%d link-state database:\n",
1447 /* print the title in all cases */
1449 "LSP ID PduLen SeqNumber Chksum Holdtime ATT/P/OL\n");
1453 if (ui_level
== ISIS_UI_LEVEL_DETAIL
)
1460 } else if (argv
== NULL
) {
1461 lsp_count
= lsp_print_all(
1462 vty
, area
->lspdb
[level
],
1463 ui_level
, area
->dynhostname
);
1465 vty_out(vty
, " %u LSPs\n\n",
1475 DEFUN (show_database
,
1477 "show " PROTO_NAME
" database [detail] [WORD]",
1480 "Link state database\n"
1481 "Detailed information\n"
1485 int uilevel
= argv_find(argv
, argc
, "detail", &idx
)
1486 ? ISIS_UI_LEVEL_DETAIL
1487 : ISIS_UI_LEVEL_BRIEF
;
1488 char *id
= argv_find(argv
, argc
, "WORD", &idx
) ? argv
[idx
]->arg
: NULL
;
1489 return show_isis_database(vty
, id
, uilevel
);
1493 * 'router isis' command
1495 DEFUN_NOSH (router_isis
,
1497 "router " PROTO_NAME
" WORD",
1500 "ISO Routing area tag\n")
1503 return isis_area_get(vty
, argv
[idx_word
]->arg
);
1507 *'no router isis' command
1509 DEFUN (no_router_isis
,
1511 "no router " PROTO_NAME
" WORD",
1515 "ISO Routing area tag\n")
1518 return isis_area_destroy(vty
, argv
[idx_word
]->arg
);
1527 "A Network Entity Title for this process (OSI only)\n"
1528 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1531 return area_net_title(vty
, argv
[idx_word
]->arg
);
1541 "A Network Entity Title for this process (OSI only)\n"
1542 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1545 return area_clear_net_title(vty
, argv
[idx_word
]->arg
);
1548 DEFUN (isis_topology
,
1550 "topology " ISIS_MT_NAMES
" [overload]",
1551 "Configure IS-IS topologies\n"
1552 ISIS_MT_DESCRIPTIONS
1553 "Set overload bit for topology\n")
1555 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1557 const char *arg
= argv
[1]->arg
;
1558 uint16_t mtid
= isis_str2mtid(arg
);
1560 if (area
->oldmetric
) {
1562 "Multi topology IS-IS can only be used with wide metrics\n");
1563 return CMD_WARNING_CONFIG_FAILED
;
1566 if (mtid
== (uint16_t)-1) {
1567 vty_out(vty
, "Don't know topology '%s'\n", arg
);
1568 return CMD_WARNING_CONFIG_FAILED
;
1570 if (mtid
== ISIS_MT_IPV4_UNICAST
) {
1571 vty_out(vty
, "Cannot configure IPv4 unicast topology\n");
1572 return CMD_WARNING_CONFIG_FAILED
;
1575 area_set_mt_enabled(area
, mtid
, true);
1576 area_set_mt_overload(area
, mtid
, (argc
== 3));
1580 DEFUN (no_isis_topology
,
1581 no_isis_topology_cmd
,
1582 "no topology " ISIS_MT_NAMES
" [overload]",
1584 "Configure IS-IS topologies\n"
1585 ISIS_MT_DESCRIPTIONS
1586 "Set overload bit for topology\n")
1588 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1590 const char *arg
= argv
[2]->arg
;
1591 uint16_t mtid
= isis_str2mtid(arg
);
1593 if (area
->oldmetric
) {
1595 "Multi topology IS-IS can only be used with wide metrics\n");
1596 return CMD_WARNING_CONFIG_FAILED
;
1599 if (mtid
== (uint16_t)-1) {
1600 vty_out(vty
, "Don't know topology '%s'\n", arg
);
1601 return CMD_WARNING_CONFIG_FAILED
;
1603 if (mtid
== ISIS_MT_IPV4_UNICAST
) {
1604 vty_out(vty
, "Cannot configure IPv4 unicast topology\n");
1605 return CMD_WARNING_CONFIG_FAILED
;
1608 area_set_mt_enabled(area
, mtid
, false);
1609 area_set_mt_overload(area
, mtid
, false);
1613 void isis_area_lsp_mtu_set(struct isis_area
*area
, unsigned int lsp_mtu
)
1615 area
->lsp_mtu
= lsp_mtu
;
1616 lsp_regenerate_schedule(area
, IS_LEVEL_1_AND_2
, 1);
1619 static int isis_area_passwd_set(struct isis_area
*area
, int level
,
1620 uint8_t passwd_type
, const char *passwd
,
1623 struct isis_passwd
*dest
;
1624 struct isis_passwd modified
;
1627 assert((level
== IS_LEVEL_1
) || (level
== IS_LEVEL_2
));
1628 dest
= (level
== IS_LEVEL_1
) ? &area
->area_passwd
1629 : &area
->domain_passwd
;
1630 memset(&modified
, 0, sizeof(modified
));
1632 if (passwd_type
!= ISIS_PASSWD_TYPE_UNUSED
) {
1636 len
= strlen(passwd
);
1641 strncpy((char *)modified
.passwd
, passwd
, 255);
1642 modified
.type
= passwd_type
;
1643 modified
.snp_auth
= snp_auth
;
1646 if (memcmp(&modified
, dest
, sizeof(modified
))) {
1647 memcpy(dest
, &modified
, sizeof(modified
));
1648 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1654 int isis_area_passwd_unset(struct isis_area
*area
, int level
)
1656 return isis_area_passwd_set(area
, level
, ISIS_PASSWD_TYPE_UNUSED
, NULL
,
1660 int isis_area_passwd_cleartext_set(struct isis_area
*area
, int level
,
1661 const char *passwd
, uint8_t snp_auth
)
1663 return isis_area_passwd_set(area
, level
, ISIS_PASSWD_TYPE_CLEARTXT
,
1667 int isis_area_passwd_hmac_md5_set(struct isis_area
*area
, int level
,
1668 const char *passwd
, uint8_t snp_auth
)
1670 return isis_area_passwd_set(area
, level
, ISIS_PASSWD_TYPE_HMAC_MD5
,
1674 void isis_area_invalidate_routes(struct isis_area
*area
, int levels
)
1676 for (int level
= ISIS_LEVEL1
; level
<= ISIS_LEVEL2
; level
++) {
1677 if (!(level
& levels
))
1679 for (int tree
= SPFTREE_IPV4
; tree
< SPFTREE_COUNT
; tree
++) {
1680 isis_spf_invalidate_routes(
1681 area
->spftree
[tree
][level
- 1]);
1686 void isis_area_verify_routes(struct isis_area
*area
)
1688 for (int tree
= SPFTREE_IPV4
; tree
< SPFTREE_COUNT
; tree
++)
1689 isis_spf_verify_routes(area
, area
->spftree
[tree
]);
1692 static void area_resign_level(struct isis_area
*area
, int level
)
1694 isis_area_invalidate_routes(area
, level
);
1695 isis_area_verify_routes(area
);
1697 if (area
->lspdb
[level
- 1]) {
1698 lsp_db_destroy(area
->lspdb
[level
- 1]);
1699 area
->lspdb
[level
- 1] = NULL
;
1702 for (int tree
= SPFTREE_IPV4
; tree
< SPFTREE_COUNT
; tree
++) {
1703 if (area
->spftree
[tree
][level
- 1]) {
1704 isis_spftree_del(area
->spftree
[tree
][level
- 1]);
1705 area
->spftree
[tree
][level
- 1] = NULL
;
1709 THREAD_TIMER_OFF(area
->spf_timer
[level
- 1]);
1712 "ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.",
1713 area
->area_tag
, level
);
1714 THREAD_TIMER_OFF(area
->t_lsp_refresh
[level
- 1]);
1715 area
->lsp_regenerate_pending
[level
- 1] = 0;
1718 void isis_area_is_type_set(struct isis_area
*area
, int is_type
)
1720 struct listnode
*node
;
1721 struct isis_circuit
*circuit
;
1723 if (isis
->debugs
& DEBUG_EVENTS
)
1724 zlog_debug("ISIS-Evt (%s) system type change %s -> %s",
1725 area
->area_tag
, circuit_t2string(area
->is_type
),
1726 circuit_t2string(is_type
));
1728 if (area
->is_type
== is_type
)
1729 return; /* No change */
1731 switch (area
->is_type
) {
1733 if (is_type
== IS_LEVEL_2
)
1734 area_resign_level(area
, IS_LEVEL_1
);
1736 if (area
->lspdb
[1] == NULL
)
1737 area
->lspdb
[1] = lsp_db_init();
1740 case IS_LEVEL_1_AND_2
:
1741 if (is_type
== IS_LEVEL_1
)
1742 area_resign_level(area
, IS_LEVEL_2
);
1744 area_resign_level(area
, IS_LEVEL_1
);
1748 if (is_type
== IS_LEVEL_1
)
1749 area_resign_level(area
, IS_LEVEL_2
);
1751 if (area
->lspdb
[0] == NULL
)
1752 area
->lspdb
[0] = lsp_db_init();
1759 area
->is_type
= is_type
;
1761 /* override circuit's is_type */
1762 if (area
->is_type
!= IS_LEVEL_1_AND_2
) {
1763 for (ALL_LIST_ELEMENTS_RO(area
->circuit_list
, node
, circuit
))
1764 isis_circuit_is_type_set(circuit
, is_type
);
1767 spftree_area_init(area
);
1769 if (listcount(area
->area_addrs
) > 0) {
1770 if (is_type
& IS_LEVEL_1
)
1771 lsp_generate(area
, IS_LEVEL_1
);
1772 if (is_type
& IS_LEVEL_2
)
1773 lsp_generate(area
, IS_LEVEL_2
);
1775 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1780 void isis_area_metricstyle_set(struct isis_area
*area
, bool old_metric
,
1783 if (area
->oldmetric
!= old_metric
|| area
->newmetric
!= new_metric
) {
1784 area
->oldmetric
= old_metric
;
1785 area
->newmetric
= new_metric
;
1786 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1790 void isis_area_overload_bit_set(struct isis_area
*area
, bool overload_bit
)
1792 char new_overload_bit
= overload_bit
? LSPBIT_OL
: 0;
1794 if (new_overload_bit
!= area
->overload_bit
) {
1795 area
->overload_bit
= new_overload_bit
;
1796 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1800 void isis_area_attached_bit_set(struct isis_area
*area
, bool attached_bit
)
1802 char new_attached_bit
= attached_bit
? LSPBIT_ATT
: 0;
1804 if (new_attached_bit
!= area
->attached_bit
) {
1805 area
->attached_bit
= new_attached_bit
;
1806 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1810 void isis_area_dynhostname_set(struct isis_area
*area
, bool dynhostname
)
1812 if (area
->dynhostname
!= dynhostname
) {
1813 area
->dynhostname
= dynhostname
;
1814 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 0);
1818 void isis_area_max_lsp_lifetime_set(struct isis_area
*area
, int level
,
1819 uint16_t max_lsp_lifetime
)
1821 assert((level
== IS_LEVEL_1
) || (level
== IS_LEVEL_2
));
1823 if (area
->max_lsp_lifetime
[level
- 1] == max_lsp_lifetime
)
1826 area
->max_lsp_lifetime
[level
- 1] = max_lsp_lifetime
;
1827 lsp_regenerate_schedule(area
, level
, 1);
1830 void isis_area_lsp_refresh_set(struct isis_area
*area
, int level
,
1831 uint16_t lsp_refresh
)
1833 assert((level
== IS_LEVEL_1
) || (level
== IS_LEVEL_2
));
1835 if (area
->lsp_refresh
[level
- 1] == lsp_refresh
)
1838 area
->lsp_refresh
[level
- 1] = lsp_refresh
;
1839 lsp_regenerate_schedule(area
, level
, 1);
1842 DEFUN (log_adj_changes
,
1843 log_adj_changes_cmd
,
1844 "log-adjacency-changes",
1845 "Log changes in adjacency state\n")
1847 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1849 area
->log_adj_changes
= 1;
1854 DEFUN (no_log_adj_changes
,
1855 no_log_adj_changes_cmd
,
1856 "no log-adjacency-changes",
1858 "Stop logging changes in adjacency state\n")
1860 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1862 area
->log_adj_changes
= 0;
1867 /* IS-IS configuration write function */
1868 int isis_config_write(struct vty
*vty
)
1873 struct isis_area
*area
;
1874 struct listnode
*node
, *node2
;
1876 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1877 /* ISIS - Area name */
1878 vty_out(vty
, "router " PROTO_NAME
" %s\n", area
->area_tag
);
1881 if (listcount(area
->area_addrs
) > 0) {
1882 struct area_addr
*area_addr
;
1883 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
,
1884 node2
, area_addr
)) {
1885 vty_out(vty
, " net %s\n",
1887 area_addr
->area_addr
,
1894 /* ISIS - Dynamic hostname - Defaults to true so only
1897 if (!area
->dynhostname
) {
1898 vty_out(vty
, " no hostname dynamic\n");
1901 /* ISIS - Metric-Style - when true displays wide */
1903 if (area
->newmetric
) {
1904 if (!area
->oldmetric
)
1905 vty_out(vty
, " metric-style wide\n");
1908 " metric-style transition\n");
1911 vty_out(vty
, " metric-style narrow\n");
1915 /* ISIS - overload-bit */
1916 if (area
->overload_bit
) {
1917 vty_out(vty
, " set-overload-bit\n");
1920 /* ISIS - Area is-type (level-1-2 is default) */
1922 if (area
->is_type
== IS_LEVEL_1
) {
1923 vty_out(vty
, " is-type level-1\n");
1925 } else if (area
->is_type
== IS_LEVEL_2
) {
1926 vty_out(vty
, " is-type level-2-only\n");
1930 write
+= isis_redist_config_write(vty
, area
, AF_INET
);
1931 write
+= isis_redist_config_write(vty
, area
, AF_INET6
);
1932 /* ISIS - Lsp generation interval */
1933 if (area
->lsp_gen_interval
[0]
1934 == area
->lsp_gen_interval
[1]) {
1935 if (area
->lsp_gen_interval
[0]
1936 != DEFAULT_MIN_LSP_GEN_INTERVAL
) {
1937 vty_out(vty
, " lsp-gen-interval %d\n",
1938 area
->lsp_gen_interval
[0]);
1942 if (area
->lsp_gen_interval
[0]
1943 != DEFAULT_MIN_LSP_GEN_INTERVAL
) {
1945 " lsp-gen-interval level-1 %d\n",
1946 area
->lsp_gen_interval
[0]);
1949 if (area
->lsp_gen_interval
[1]
1950 != DEFAULT_MIN_LSP_GEN_INTERVAL
) {
1952 " lsp-gen-interval level-2 %d\n",
1953 area
->lsp_gen_interval
[1]);
1957 /* ISIS - LSP lifetime */
1958 if (area
->max_lsp_lifetime
[0]
1959 == area
->max_lsp_lifetime
[1]) {
1960 if (area
->max_lsp_lifetime
[0]
1961 != DEFAULT_LSP_LIFETIME
) {
1962 vty_out(vty
, " max-lsp-lifetime %u\n",
1963 area
->max_lsp_lifetime
[0]);
1967 if (area
->max_lsp_lifetime
[0]
1968 != DEFAULT_LSP_LIFETIME
) {
1970 " max-lsp-lifetime level-1 %u\n",
1971 area
->max_lsp_lifetime
[0]);
1974 if (area
->max_lsp_lifetime
[1]
1975 != DEFAULT_LSP_LIFETIME
) {
1977 " max-lsp-lifetime level-2 %u\n",
1978 area
->max_lsp_lifetime
[1]);
1982 /* ISIS - LSP refresh interval */
1983 if (area
->lsp_refresh
[0] == area
->lsp_refresh
[1]) {
1984 if (area
->lsp_refresh
[0]
1985 != DEFAULT_MAX_LSP_GEN_INTERVAL
) {
1987 " lsp-refresh-interval %u\n",
1988 area
->lsp_refresh
[0]);
1992 if (area
->lsp_refresh
[0]
1993 != DEFAULT_MAX_LSP_GEN_INTERVAL
) {
1995 " lsp-refresh-interval level-1 %u\n",
1996 area
->lsp_refresh
[0]);
1999 if (area
->lsp_refresh
[1]
2000 != DEFAULT_MAX_LSP_GEN_INTERVAL
) {
2002 " lsp-refresh-interval level-2 %u\n",
2003 area
->lsp_refresh
[1]);
2007 if (area
->lsp_mtu
!= DEFAULT_LSP_MTU
) {
2008 vty_out(vty
, " lsp-mtu %u\n", area
->lsp_mtu
);
2012 /* Minimum SPF interval. */
2013 if (area
->min_spf_interval
[0]
2014 == area
->min_spf_interval
[1]) {
2015 if (area
->min_spf_interval
[0]
2016 != MINIMUM_SPF_INTERVAL
) {
2017 vty_out(vty
, " spf-interval %d\n",
2018 area
->min_spf_interval
[0]);
2022 if (area
->min_spf_interval
[0]
2023 != MINIMUM_SPF_INTERVAL
) {
2025 " spf-interval level-1 %d\n",
2026 area
->min_spf_interval
[0]);
2029 if (area
->min_spf_interval
[1]
2030 != MINIMUM_SPF_INTERVAL
) {
2032 " spf-interval level-2 %d\n",
2033 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\n",
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]));
2055 /* Authentication passwords. */
2056 if (area
->area_passwd
.type
2057 == ISIS_PASSWD_TYPE_HMAC_MD5
) {
2058 vty_out(vty
, " area-password md5 %s",
2059 area
->area_passwd
.passwd
);
2060 if (CHECK_FLAG(area
->area_passwd
.snp_auth
,
2062 vty_out(vty
, " authenticate snp ");
2064 area
->area_passwd
.snp_auth
,
2066 vty_out(vty
, "validate");
2068 vty_out(vty
, "send-only");
2072 } else if (area
->area_passwd
.type
2073 == ISIS_PASSWD_TYPE_CLEARTXT
) {
2074 vty_out(vty
, " area-password clear %s",
2075 area
->area_passwd
.passwd
);
2076 if (CHECK_FLAG(area
->area_passwd
.snp_auth
,
2078 vty_out(vty
, " authenticate snp ");
2080 area
->area_passwd
.snp_auth
,
2082 vty_out(vty
, "validate");
2084 vty_out(vty
, "send-only");
2089 if (area
->domain_passwd
.type
2090 == ISIS_PASSWD_TYPE_HMAC_MD5
) {
2091 vty_out(vty
, " domain-password md5 %s",
2092 area
->domain_passwd
.passwd
);
2093 if (CHECK_FLAG(area
->domain_passwd
.snp_auth
,
2095 vty_out(vty
, " authenticate snp ");
2096 if (CHECK_FLAG(area
->domain_passwd
2099 vty_out(vty
, "validate");
2101 vty_out(vty
, "send-only");
2105 } else if (area
->domain_passwd
.type
2106 == ISIS_PASSWD_TYPE_CLEARTXT
) {
2107 vty_out(vty
, " domain-password clear %s",
2108 area
->domain_passwd
.passwd
);
2109 if (CHECK_FLAG(area
->domain_passwd
.snp_auth
,
2111 vty_out(vty
, " authenticate snp ");
2112 if (CHECK_FLAG(area
->domain_passwd
2115 vty_out(vty
, "validate");
2117 vty_out(vty
, "send-only");
2123 if (area
->log_adj_changes
) {
2124 vty_out(vty
, " log-adjacency-changes\n");
2128 write
+= area_write_mt_settings(area
, vty
);
2130 isis_mpls_te_config_write_router(vty
);
2136 struct cmd_node router_node
= {ROUTER_NODE
, "%s(config-router)# ", 1};
2140 /* Install IS-IS top node */
2141 install_node(&router_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(ROUTER_NODE
);
2227 install_element(ROUTER_NODE
, &net_cmd
);
2228 install_element(ROUTER_NODE
, &no_net_cmd
);
2230 install_element(ROUTER_NODE
, &isis_topology_cmd
);
2231 install_element(ROUTER_NODE
, &no_isis_topology_cmd
);
2233 install_element(ROUTER_NODE
, &log_adj_changes_cmd
);
2234 install_element(ROUTER_NODE
, &no_log_adj_changes_cmd
);
2236 spf_backoff_cmd_init();