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"
39 #include "lib/northbound_cli.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"
59 #include "isisd/fabricd.h"
61 struct isis
*isis
= NULL
;
63 DEFINE_QOBJ_TYPE(isis
)
64 DEFINE_QOBJ_TYPE(isis_area
)
69 int isis_area_get(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();
93 * uncomment the next line for full debugs
95 /* isis->debugs = 0xFFFF; */
100 struct isis_area
*isis_area_create(const char *area_tag
)
102 struct isis_area
*area
;
104 area
= XCALLOC(MTYPE_ISIS_AREA
, sizeof(struct isis_area
));
107 * Fabricd runs only as level-2.
108 * For IS-IS, the first instance is level-1-2 rest are level-1,
109 * unless otherwise configured
112 area
->is_type
= IS_LEVEL_2
;
113 } else if (listcount(isis
->area_list
) == 0)
114 area
->is_type
= IS_LEVEL_1_AND_2
;
116 area
->is_type
= yang_get_default_enum(
117 "/frr-isisd:isis/instance/is-type");
120 * intialize the databases
122 if (area
->is_type
& IS_LEVEL_1
)
123 lsp_db_init(&area
->lspdb
[0]);
124 if (area
->is_type
& IS_LEVEL_2
)
125 lsp_db_init(&area
->lspdb
[1]);
127 spftree_area_init(area
);
129 area
->circuit_list
= list_new();
130 area
->area_addrs
= list_new();
131 thread_add_timer(master
, lsp_tick
, area
, 1, &area
->t_tick
);
132 flags_initialize(&area
->flags
);
138 enum isis_metric_style default_style
;
140 area
->max_lsp_lifetime
[0] = yang_get_default_uint16(
141 "/frr-isisd:isis/instance/lsp/maximum-lifetime/level-1");
142 area
->max_lsp_lifetime
[1] = yang_get_default_uint16(
143 "/frr-isisd:isis/instance/lsp/maximum-lifetime/level-2");
144 area
->lsp_refresh
[0] = yang_get_default_uint16(
145 "/frr-isisd:isis/instance/lsp/refresh-interval/level-1");
146 area
->lsp_refresh
[1] = yang_get_default_uint16(
147 "/frr-isisd:isis/instance/lsp/refresh-interval/level-2");
148 area
->lsp_gen_interval
[0] = yang_get_default_uint16(
149 "/frr-isisd:isis/instance/lsp/generation-interval/level-1");
150 area
->lsp_gen_interval
[1] = yang_get_default_uint16(
151 "/frr-isisd:isis/instance/lsp/generation-interval/level-2");
152 area
->min_spf_interval
[0] = yang_get_default_uint16(
153 "/frr-isisd:isis/instance/spf/minimum-interval/level-1");
154 area
->min_spf_interval
[1] = yang_get_default_uint16(
155 "/frr-isisd:isis/instance/spf/minimum-interval/level-1");
156 area
->dynhostname
= yang_get_default_bool(
157 "/frr-isisd:isis/instance/dynamic-hostname");
159 yang_get_default_enum("/frr-isisd:isis/instance/metric-style");
160 area
->oldmetric
= default_style
== ISIS_WIDE_METRIC
? 0 : 1;
161 area
->newmetric
= default_style
== ISIS_NARROW_METRIC
? 0 : 1;
162 area
->lsp_frag_threshold
= 90; /* not currently configurable */
164 yang_get_default_uint16("/frr-isisd:isis/instance/lsp/mtu");
166 area
->max_lsp_lifetime
[0] = DEFAULT_LSP_LIFETIME
; /* 1200 */
167 area
->max_lsp_lifetime
[1] = DEFAULT_LSP_LIFETIME
; /* 1200 */
168 area
->lsp_refresh
[0] = DEFAULT_MAX_LSP_GEN_INTERVAL
; /* 900 */
169 area
->lsp_refresh
[1] = DEFAULT_MAX_LSP_GEN_INTERVAL
; /* 900 */
170 area
->lsp_gen_interval
[0] = DEFAULT_MIN_LSP_GEN_INTERVAL
;
171 area
->lsp_gen_interval
[1] = DEFAULT_MIN_LSP_GEN_INTERVAL
;
172 area
->min_spf_interval
[0] = MINIMUM_SPF_INTERVAL
;
173 area
->min_spf_interval
[1] = MINIMUM_SPF_INTERVAL
;
174 area
->dynhostname
= 1;
177 area
->lsp_frag_threshold
= 90;
178 area
->lsp_mtu
= DEFAULT_LSP_MTU
;
179 #endif /* ifndef FABRICD */
183 area
->area_tag
= strdup(area_tag
);
184 listnode_add(isis
->area_list
, area
);
188 area
->fabricd
= fabricd_new(area
);
190 area
->lsp_refresh_arg
[0].area
= area
;
191 area
->lsp_refresh_arg
[0].level
= IS_LEVEL_1
;
192 area
->lsp_refresh_arg
[1].area
= area
;
193 area
->lsp_refresh_arg
[1].level
= IS_LEVEL_2
;
196 QOBJ_REG(area
, isis_area
);
201 struct isis_area
*isis_area_lookup(const char *area_tag
)
203 struct isis_area
*area
;
204 struct listnode
*node
;
206 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
))
207 if ((area
->area_tag
== NULL
&& area_tag
== NULL
)
208 || (area
->area_tag
&& area_tag
209 && strcmp(area
->area_tag
, area_tag
) == 0))
215 int isis_area_get(struct vty
*vty
, const char *area_tag
)
217 struct isis_area
*area
;
219 area
= isis_area_lookup(area_tag
);
222 VTY_PUSH_CONTEXT(ROUTER_NODE
, area
);
226 area
= isis_area_create(area_tag
);
228 if (isis
->debugs
& DEBUG_EVENTS
)
229 zlog_debug("New IS-IS area instance %s", area
->area_tag
);
231 VTY_PUSH_CONTEXT(ROUTER_NODE
, area
);
236 int isis_area_destroy(const char *area_tag
)
238 struct isis_area
*area
;
239 struct listnode
*node
, *nnode
;
240 struct isis_circuit
*circuit
;
241 struct area_addr
*addr
;
243 area
= isis_area_lookup(area_tag
);
246 zlog_warn("%s: could not find area with area-tag %s",
248 return CMD_ERR_NO_MATCH
;
254 fabricd_finish(area
->fabricd
);
256 /* Disable MPLS if necessary before flooding LSP */
257 if (IS_MPLS_TE(area
->mta
))
258 area
->mta
->status
= disable
;
260 if (area
->circuit_list
) {
261 for (ALL_LIST_ELEMENTS(area
->circuit_list
, node
, nnode
,
263 circuit
->ip_router
= 0;
264 circuit
->ipv6_router
= 0;
265 isis_csm_state_change(ISIS_DISABLE
, circuit
, area
);
267 list_delete(&area
->circuit_list
);
270 lsp_db_fini(&area
->lspdb
[0]);
271 lsp_db_fini(&area
->lspdb
[1]);
273 /* invalidate and verify to delete all routes from zebra */
274 isis_area_invalidate_routes(area
, area
->is_type
);
275 isis_area_verify_routes(area
);
277 spftree_area_del(area
);
279 THREAD_TIMER_OFF(area
->spf_timer
[0]);
280 THREAD_TIMER_OFF(area
->spf_timer
[1]);
282 spf_backoff_free(area
->spf_delay_ietf
[0]);
283 spf_backoff_free(area
->spf_delay_ietf
[1]);
285 isis_redist_area_finish(area
);
287 for (ALL_LIST_ELEMENTS(area
->area_addrs
, node
, nnode
, addr
)) {
288 list_delete_node(area
->area_addrs
, node
);
289 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
291 area
->area_addrs
= NULL
;
293 THREAD_TIMER_OFF(area
->t_tick
);
294 THREAD_TIMER_OFF(area
->t_lsp_refresh
[0]);
295 THREAD_TIMER_OFF(area
->t_lsp_refresh
[1]);
297 thread_cancel_event(master
, area
);
299 listnode_delete(isis
->area_list
, area
);
301 free(area
->area_tag
);
303 area_mt_finish(area
);
305 XFREE(MTYPE_ISIS_AREA
, area
);
307 if (listcount(isis
->area_list
) == 0) {
308 memset(isis
->sysid
, 0, ISIS_SYS_ID_LEN
);
316 static void area_set_mt_enabled(struct isis_area
*area
, uint16_t mtid
,
319 struct isis_area_mt_setting
*setting
;
321 setting
= area_get_mt_setting(area
, mtid
);
322 if (setting
->enabled
!= enabled
) {
323 setting
->enabled
= enabled
;
324 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 0);
328 static void area_set_mt_overload(struct isis_area
*area
, uint16_t mtid
,
331 struct isis_area_mt_setting
*setting
;
333 setting
= area_get_mt_setting(area
, mtid
);
334 if (setting
->overload
!= overload
) {
335 setting
->overload
= overload
;
336 if (setting
->enabled
)
337 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
,
341 #endif /* ifdef FABRICD */
343 int area_net_title(struct vty
*vty
, const char *net_title
)
345 VTY_DECLVAR_CONTEXT(isis_area
, area
);
346 struct area_addr
*addr
;
347 struct area_addr
*addrp
;
348 struct listnode
*node
;
352 /* We check that we are not over the maximal number of addresses */
353 if (listcount(area
->area_addrs
) >= isis
->max_area_addrs
) {
355 "Maximum of area addresses (%d) already reached \n",
356 isis
->max_area_addrs
);
357 return CMD_ERR_NOTHING_TODO
;
360 addr
= XMALLOC(MTYPE_ISIS_AREA_ADDR
, sizeof(struct area_addr
));
361 addr
->addr_len
= dotformat2buff(buff
, net_title
);
362 memcpy(addr
->area_addr
, buff
, addr
->addr_len
);
364 zlog_debug("added area address %s for area %s (address length %d)",
365 net_title
, area
->area_tag
, addr
->addr_len
);
366 #endif /* EXTREME_DEBUG */
367 if (addr
->addr_len
< 8 || addr
->addr_len
> 20) {
369 "area address must be at least 8..20 octets long (%d)\n",
371 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
372 return CMD_WARNING_CONFIG_FAILED
;
375 if (addr
->area_addr
[addr
->addr_len
- 1] != 0) {
377 "nsel byte (last byte) in area address must be 0\n");
378 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
379 return CMD_WARNING_CONFIG_FAILED
;
382 if (isis
->sysid_set
== 0) {
384 * First area address - get the SystemID for this router
386 memcpy(isis
->sysid
, GETSYSID(addr
), ISIS_SYS_ID_LEN
);
388 if (isis
->debugs
& DEBUG_EVENTS
)
389 zlog_debug("Router has SystemID %s",
390 sysid_print(isis
->sysid
));
393 * Check that the SystemID portions match
395 if (memcmp(isis
->sysid
, GETSYSID(addr
), ISIS_SYS_ID_LEN
)) {
397 "System ID must not change when defining additional area addresses\n");
398 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
399 return CMD_WARNING_CONFIG_FAILED
;
402 /* now we see that we don't already have this address */
403 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
, node
, addrp
)) {
404 if ((addrp
->addr_len
+ ISIS_SYS_ID_LEN
+ ISIS_NSEL_LEN
)
407 if (!memcmp(addrp
->area_addr
, addr
->area_addr
,
409 XFREE(MTYPE_ISIS_AREA_ADDR
, addr
);
410 return CMD_SUCCESS
; /* silent fail */
416 * Forget the systemID part of the address
418 addr
->addr_len
-= (ISIS_SYS_ID_LEN
+ ISIS_NSEL_LEN
);
419 listnode_add(area
->area_addrs
, addr
);
421 /* only now we can safely generate our LSPs for this area */
422 if (listcount(area
->area_addrs
) > 0) {
423 if (area
->is_type
& IS_LEVEL_1
)
424 lsp_generate(area
, IS_LEVEL_1
);
425 if (area
->is_type
& IS_LEVEL_2
)
426 lsp_generate(area
, IS_LEVEL_2
);
432 int area_clear_net_title(struct vty
*vty
, const char *net_title
)
434 VTY_DECLVAR_CONTEXT(isis_area
, area
);
435 struct area_addr addr
, *addrp
= NULL
;
436 struct listnode
*node
;
439 addr
.addr_len
= dotformat2buff(buff
, net_title
);
440 if (addr
.addr_len
< 8 || addr
.addr_len
> 20) {
442 "Unsupported area address length %d, should be 8...20 \n",
444 return CMD_WARNING_CONFIG_FAILED
;
447 memcpy(addr
.area_addr
, buff
, (int)addr
.addr_len
);
449 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
, node
, addrp
))
450 if ((addrp
->addr_len
+ ISIS_SYS_ID_LEN
+ 1) == addr
.addr_len
451 && !memcmp(addrp
->area_addr
, addr
.area_addr
, addr
.addr_len
))
455 vty_out(vty
, "No area address %s for area %s \n", net_title
,
457 return CMD_ERR_NO_MATCH
;
460 listnode_delete(area
->area_addrs
, addrp
);
461 XFREE(MTYPE_ISIS_AREA_ADDR
, addrp
);
464 * Last area address - reset the SystemID for this router
466 if (listcount(area
->area_addrs
) == 0) {
467 memset(isis
->sysid
, 0, ISIS_SYS_ID_LEN
);
469 if (isis
->debugs
& DEBUG_EVENTS
)
470 zlog_debug("Router has no SystemID");
477 * 'show isis interface' command
480 int show_isis_interface_common(struct vty
*vty
, const char *ifname
, char detail
)
482 struct listnode
*anode
, *cnode
;
483 struct isis_area
*area
;
484 struct isis_circuit
*circuit
;
487 vty_out(vty
, "IS-IS Routing Process not enabled\n");
491 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, anode
, area
)) {
492 vty_out(vty
, "Area %s:\n", area
->area_tag
);
494 if (detail
== ISIS_UI_LEVEL_BRIEF
)
496 " Interface CircId State Type Level\n");
498 for (ALL_LIST_ELEMENTS_RO(area
->circuit_list
, cnode
, circuit
))
500 isis_circuit_print_vty(circuit
, vty
, detail
);
501 else if (strcmp(circuit
->interface
->name
, ifname
) == 0)
502 isis_circuit_print_vty(circuit
, vty
, detail
);
508 DEFUN (show_isis_interface
,
509 show_isis_interface_cmd
,
510 "show " PROTO_NAME
" interface",
515 return show_isis_interface_common(vty
, NULL
, ISIS_UI_LEVEL_BRIEF
);
518 DEFUN (show_isis_interface_detail
,
519 show_isis_interface_detail_cmd
,
520 "show " PROTO_NAME
" interface detail",
524 "show detailed information\n")
526 return show_isis_interface_common(vty
, NULL
, ISIS_UI_LEVEL_DETAIL
);
529 DEFUN (show_isis_interface_arg
,
530 show_isis_interface_arg_cmd
,
531 "show " PROTO_NAME
" interface WORD",
535 "ISIS interface name\n")
538 return show_isis_interface_common(vty
, argv
[idx_word
]->arg
,
539 ISIS_UI_LEVEL_DETAIL
);
543 * 'show isis neighbor' command
546 int show_isis_neighbor_common(struct vty
*vty
, const char *id
, char detail
)
548 struct listnode
*anode
, *cnode
, *node
;
549 struct isis_area
*area
;
550 struct isis_circuit
*circuit
;
552 struct isis_adjacency
*adj
;
553 struct isis_dynhn
*dynhn
;
554 uint8_t sysid
[ISIS_SYS_ID_LEN
];
558 vty_out(vty
, "IS-IS Routing Process not enabled\n");
562 memset(sysid
, 0, ISIS_SYS_ID_LEN
);
564 if (sysid2buff(sysid
, id
) == 0) {
565 dynhn
= dynhn_find_by_name(id
);
567 vty_out(vty
, "Invalid system id %s\n", id
);
570 memcpy(sysid
, dynhn
->id
, ISIS_SYS_ID_LEN
);
574 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, anode
, area
)) {
575 vty_out(vty
, "Area %s:\n", area
->area_tag
);
577 if (detail
== ISIS_UI_LEVEL_BRIEF
)
579 " System Id Interface L State Holdtime SNPA\n");
581 for (ALL_LIST_ELEMENTS_RO(area
->circuit_list
, cnode
, circuit
)) {
582 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
583 for (i
= 0; i
< 2; i
++) {
584 adjdb
= circuit
->u
.bc
.adjdb
[i
];
585 if (adjdb
&& adjdb
->count
) {
586 for (ALL_LIST_ELEMENTS_RO(
589 || !memcmp(adj
->sysid
,
598 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
599 && circuit
->u
.p2p
.neighbor
) {
600 adj
= circuit
->u
.p2p
.neighbor
;
602 || !memcmp(adj
->sysid
, sysid
,
604 isis_adj_print_vty(adj
, vty
, detail
);
613 * 'clear isis neighbor' command
615 int clear_isis_neighbor_common(struct vty
*vty
, const char *id
)
617 struct listnode
*anode
, *cnode
, *cnextnode
, *node
, *nnode
;
618 struct isis_area
*area
;
619 struct isis_circuit
*circuit
;
621 struct isis_adjacency
*adj
;
622 struct isis_dynhn
*dynhn
;
623 uint8_t sysid
[ISIS_SYS_ID_LEN
];
627 vty_out(vty
, "IS-IS Routing Process not enabled\n");
631 memset(sysid
, 0, ISIS_SYS_ID_LEN
);
633 if (sysid2buff(sysid
, id
) == 0) {
634 dynhn
= dynhn_find_by_name(id
);
636 vty_out(vty
, "Invalid system id %s\n", id
);
639 memcpy(sysid
, dynhn
->id
, ISIS_SYS_ID_LEN
);
643 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, anode
, area
)) {
644 for (ALL_LIST_ELEMENTS(area
->circuit_list
, cnode
, cnextnode
,
646 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
647 for (i
= 0; i
< 2; i
++) {
648 adjdb
= circuit
->u
.bc
.adjdb
[i
];
649 if (adjdb
&& adjdb
->count
) {
650 for (ALL_LIST_ELEMENTS(
654 || !memcmp(adj
->sysid
,
657 isis_adj_state_change(
660 "clear user request");
663 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
664 && circuit
->u
.p2p
.neighbor
) {
665 adj
= circuit
->u
.p2p
.neighbor
;
667 || !memcmp(adj
->sysid
, sysid
,
669 isis_adj_state_change(
671 "clear user request");
679 DEFUN (show_isis_neighbor
,
680 show_isis_neighbor_cmd
,
681 "show " PROTO_NAME
" neighbor",
684 "ISIS neighbor adjacencies\n")
686 return show_isis_neighbor_common(vty
, NULL
, ISIS_UI_LEVEL_BRIEF
);
689 DEFUN (show_isis_neighbor_detail
,
690 show_isis_neighbor_detail_cmd
,
691 "show " PROTO_NAME
" neighbor detail",
694 "ISIS neighbor adjacencies\n"
695 "show detailed information\n")
697 return show_isis_neighbor_common(vty
, NULL
, ISIS_UI_LEVEL_DETAIL
);
700 DEFUN (show_isis_neighbor_arg
,
701 show_isis_neighbor_arg_cmd
,
702 "show " PROTO_NAME
" neighbor WORD",
705 "ISIS neighbor adjacencies\n"
709 return show_isis_neighbor_common(vty
, argv
[idx_word
]->arg
,
710 ISIS_UI_LEVEL_DETAIL
);
713 DEFUN (clear_isis_neighbor
,
714 clear_isis_neighbor_cmd
,
715 "clear " PROTO_NAME
" neighbor",
718 "ISIS neighbor adjacencies\n")
720 return clear_isis_neighbor_common(vty
, NULL
);
723 DEFUN (clear_isis_neighbor_arg
,
724 clear_isis_neighbor_arg_cmd
,
725 "clear " PROTO_NAME
" neighbor WORD",
728 "ISIS neighbor adjacencies\n"
732 return clear_isis_neighbor_common(vty
, argv
[idx_word
]->arg
);
736 * 'isis debug', 'show debugging'
738 void print_debug(struct vty
*vty
, int flags
, int onoff
)
740 const char *onoffs
= onoff
? "on" : "off";
742 if (flags
& DEBUG_ADJ_PACKETS
)
744 "IS-IS Adjacency related packets debugging is %s\n",
746 if (flags
& DEBUG_TX_QUEUE
)
747 vty_out(vty
, "IS-IS TX queue debugging is %s\n",
749 if (flags
& DEBUG_SNP_PACKETS
)
750 vty_out(vty
, "IS-IS CSNP/PSNP packets debugging is %s\n",
752 if (flags
& DEBUG_SPF_EVENTS
)
753 vty_out(vty
, "IS-IS SPF events debugging is %s\n", onoffs
);
754 if (flags
& DEBUG_UPDATE_PACKETS
)
755 vty_out(vty
, "IS-IS Update related packet debugging is %s\n",
757 if (flags
& DEBUG_RTE_EVENTS
)
758 vty_out(vty
, "IS-IS Route related debuggin is %s\n", onoffs
);
759 if (flags
& DEBUG_EVENTS
)
760 vty_out(vty
, "IS-IS Event debugging is %s\n", onoffs
);
761 if (flags
& DEBUG_PACKET_DUMP
)
762 vty_out(vty
, "IS-IS Packet dump debugging is %s\n", onoffs
);
763 if (flags
& DEBUG_LSP_GEN
)
764 vty_out(vty
, "IS-IS LSP generation debugging is %s\n", onoffs
);
765 if (flags
& DEBUG_LSP_SCHED
)
766 vty_out(vty
, "IS-IS LSP scheduling debugging is %s\n", onoffs
);
767 if (flags
& DEBUG_FLOODING
)
768 vty_out(vty
, "IS-IS Flooding debugging is %s\n", onoffs
);
769 if (flags
& DEBUG_BFD
)
770 vty_out(vty
, "IS-IS BFD debugging is %s\n", onoffs
);
773 DEFUN_NOSH (show_debugging
,
774 show_debugging_isis_cmd
,
775 "show debugging [" PROTO_NAME
"]",
777 "State of each debugging option\n"
780 vty_out(vty
, PROTO_NAME
" debugging status:\n");
783 print_debug(vty
, isis
->debugs
, 1);
789 static struct cmd_node debug_node
= {DEBUG_NODE
, "", 1};
791 static int config_write_debug(struct vty
*vty
)
794 int flags
= isis
->debugs
;
796 if (flags
& DEBUG_ADJ_PACKETS
) {
797 vty_out(vty
, "debug " PROTO_NAME
" adj-packets\n");
800 if (flags
& DEBUG_TX_QUEUE
) {
801 vty_out(vty
, "debug " PROTO_NAME
" tx-queue\n");
804 if (flags
& DEBUG_SNP_PACKETS
) {
805 vty_out(vty
, "debug " PROTO_NAME
" snp-packets\n");
808 if (flags
& DEBUG_SPF_EVENTS
) {
809 vty_out(vty
, "debug " PROTO_NAME
" spf-events\n");
812 if (flags
& DEBUG_UPDATE_PACKETS
) {
813 vty_out(vty
, "debug " PROTO_NAME
" update-packets\n");
816 if (flags
& DEBUG_RTE_EVENTS
) {
817 vty_out(vty
, "debug " PROTO_NAME
" route-events\n");
820 if (flags
& DEBUG_EVENTS
) {
821 vty_out(vty
, "debug " PROTO_NAME
" events\n");
824 if (flags
& DEBUG_PACKET_DUMP
) {
825 vty_out(vty
, "debug " PROTO_NAME
" packet-dump\n");
828 if (flags
& DEBUG_LSP_GEN
) {
829 vty_out(vty
, "debug " PROTO_NAME
" lsp-gen\n");
832 if (flags
& DEBUG_LSP_SCHED
) {
833 vty_out(vty
, "debug " PROTO_NAME
" lsp-sched\n");
836 if (flags
& DEBUG_FLOODING
) {
837 vty_out(vty
, "debug " PROTO_NAME
" flooding\n");
840 if (flags
& DEBUG_BFD
) {
841 vty_out(vty
, "debug " PROTO_NAME
" bfd\n");
844 write
+= spf_backoff_write_config(vty
);
849 DEFUN (debug_isis_adj
,
851 "debug " PROTO_NAME
" adj-packets",
854 "IS-IS Adjacency related packets\n")
856 isis
->debugs
|= DEBUG_ADJ_PACKETS
;
857 print_debug(vty
, DEBUG_ADJ_PACKETS
, 1);
862 DEFUN (no_debug_isis_adj
,
863 no_debug_isis_adj_cmd
,
864 "no debug " PROTO_NAME
" adj-packets",
868 "IS-IS Adjacency related packets\n")
870 isis
->debugs
&= ~DEBUG_ADJ_PACKETS
;
871 print_debug(vty
, DEBUG_ADJ_PACKETS
, 0);
876 DEFUN (debug_isis_tx_queue
,
877 debug_isis_tx_queue_cmd
,
878 "debug " PROTO_NAME
" tx-queue",
883 isis
->debugs
|= DEBUG_TX_QUEUE
;
884 print_debug(vty
, DEBUG_TX_QUEUE
, 1);
889 DEFUN (no_debug_isis_tx_queue
,
890 no_debug_isis_tx_queue_cmd
,
891 "no debug " PROTO_NAME
" tx-queue",
897 isis
->debugs
&= ~DEBUG_TX_QUEUE
;
898 print_debug(vty
, DEBUG_TX_QUEUE
, 0);
903 DEFUN (debug_isis_flooding
,
904 debug_isis_flooding_cmd
,
905 "debug " PROTO_NAME
" flooding",
908 "Flooding algorithm\n")
910 isis
->debugs
|= DEBUG_FLOODING
;
911 print_debug(vty
, DEBUG_FLOODING
, 1);
916 DEFUN (no_debug_isis_flooding
,
917 no_debug_isis_flooding_cmd
,
918 "no debug " PROTO_NAME
" flooding",
922 "Flooding algorithm\n")
924 isis
->debugs
&= ~DEBUG_FLOODING
;
925 print_debug(vty
, DEBUG_FLOODING
, 0);
930 DEFUN (debug_isis_snp
,
932 "debug " PROTO_NAME
" snp-packets",
935 "IS-IS CSNP/PSNP packets\n")
937 isis
->debugs
|= DEBUG_SNP_PACKETS
;
938 print_debug(vty
, DEBUG_SNP_PACKETS
, 1);
943 DEFUN (no_debug_isis_snp
,
944 no_debug_isis_snp_cmd
,
945 "no debug " PROTO_NAME
" snp-packets",
949 "IS-IS CSNP/PSNP packets\n")
951 isis
->debugs
&= ~DEBUG_SNP_PACKETS
;
952 print_debug(vty
, DEBUG_SNP_PACKETS
, 0);
957 DEFUN (debug_isis_upd
,
959 "debug " PROTO_NAME
" update-packets",
962 "IS-IS Update related packets\n")
964 isis
->debugs
|= DEBUG_UPDATE_PACKETS
;
965 print_debug(vty
, DEBUG_UPDATE_PACKETS
, 1);
970 DEFUN (no_debug_isis_upd
,
971 no_debug_isis_upd_cmd
,
972 "no debug " PROTO_NAME
" update-packets",
976 "IS-IS Update related packets\n")
978 isis
->debugs
&= ~DEBUG_UPDATE_PACKETS
;
979 print_debug(vty
, DEBUG_UPDATE_PACKETS
, 0);
984 DEFUN (debug_isis_spfevents
,
985 debug_isis_spfevents_cmd
,
986 "debug " PROTO_NAME
" spf-events",
989 "IS-IS Shortest Path First Events\n")
991 isis
->debugs
|= DEBUG_SPF_EVENTS
;
992 print_debug(vty
, DEBUG_SPF_EVENTS
, 1);
997 DEFUN (no_debug_isis_spfevents
,
998 no_debug_isis_spfevents_cmd
,
999 "no debug " PROTO_NAME
" spf-events",
1003 "IS-IS Shortest Path First Events\n")
1005 isis
->debugs
&= ~DEBUG_SPF_EVENTS
;
1006 print_debug(vty
, DEBUG_SPF_EVENTS
, 0);
1011 DEFUN (debug_isis_rtevents
,
1012 debug_isis_rtevents_cmd
,
1013 "debug " PROTO_NAME
" route-events",
1016 "IS-IS Route related events\n")
1018 isis
->debugs
|= DEBUG_RTE_EVENTS
;
1019 print_debug(vty
, DEBUG_RTE_EVENTS
, 1);
1024 DEFUN (no_debug_isis_rtevents
,
1025 no_debug_isis_rtevents_cmd
,
1026 "no debug " PROTO_NAME
" route-events",
1030 "IS-IS Route related events\n")
1032 isis
->debugs
&= ~DEBUG_RTE_EVENTS
;
1033 print_debug(vty
, DEBUG_RTE_EVENTS
, 0);
1038 DEFUN (debug_isis_events
,
1039 debug_isis_events_cmd
,
1040 "debug " PROTO_NAME
" events",
1045 isis
->debugs
|= DEBUG_EVENTS
;
1046 print_debug(vty
, DEBUG_EVENTS
, 1);
1051 DEFUN (no_debug_isis_events
,
1052 no_debug_isis_events_cmd
,
1053 "no debug " PROTO_NAME
" events",
1059 isis
->debugs
&= ~DEBUG_EVENTS
;
1060 print_debug(vty
, DEBUG_EVENTS
, 0);
1065 DEFUN (debug_isis_packet_dump
,
1066 debug_isis_packet_dump_cmd
,
1067 "debug " PROTO_NAME
" packet-dump",
1070 "IS-IS packet dump\n")
1072 isis
->debugs
|= DEBUG_PACKET_DUMP
;
1073 print_debug(vty
, DEBUG_PACKET_DUMP
, 1);
1078 DEFUN (no_debug_isis_packet_dump
,
1079 no_debug_isis_packet_dump_cmd
,
1080 "no debug " PROTO_NAME
" packet-dump",
1084 "IS-IS packet dump\n")
1086 isis
->debugs
&= ~DEBUG_PACKET_DUMP
;
1087 print_debug(vty
, DEBUG_PACKET_DUMP
, 0);
1092 DEFUN (debug_isis_lsp_gen
,
1093 debug_isis_lsp_gen_cmd
,
1094 "debug " PROTO_NAME
" lsp-gen",
1097 "IS-IS generation of own LSPs\n")
1099 isis
->debugs
|= DEBUG_LSP_GEN
;
1100 print_debug(vty
, DEBUG_LSP_GEN
, 1);
1105 DEFUN (no_debug_isis_lsp_gen
,
1106 no_debug_isis_lsp_gen_cmd
,
1107 "no debug " PROTO_NAME
" lsp-gen",
1111 "IS-IS generation of own LSPs\n")
1113 isis
->debugs
&= ~DEBUG_LSP_GEN
;
1114 print_debug(vty
, DEBUG_LSP_GEN
, 0);
1119 DEFUN (debug_isis_lsp_sched
,
1120 debug_isis_lsp_sched_cmd
,
1121 "debug " PROTO_NAME
" lsp-sched",
1124 "IS-IS scheduling of LSP generation\n")
1126 isis
->debugs
|= DEBUG_LSP_SCHED
;
1127 print_debug(vty
, DEBUG_LSP_SCHED
, 1);
1132 DEFUN (no_debug_isis_lsp_sched
,
1133 no_debug_isis_lsp_sched_cmd
,
1134 "no debug " PROTO_NAME
" lsp-sched",
1138 "IS-IS scheduling of LSP generation\n")
1140 isis
->debugs
&= ~DEBUG_LSP_SCHED
;
1141 print_debug(vty
, DEBUG_LSP_SCHED
, 0);
1146 DEFUN (debug_isis_bfd
,
1148 "debug " PROTO_NAME
" bfd",
1151 PROTO_NAME
" interaction with BFD\n")
1153 isis
->debugs
|= DEBUG_BFD
;
1154 print_debug(vty
, DEBUG_BFD
, 1);
1159 DEFUN (no_debug_isis_bfd
,
1160 no_debug_isis_bfd_cmd
,
1161 "no debug " PROTO_NAME
" bfd",
1165 PROTO_NAME
" interaction with BFD\n")
1167 isis
->debugs
&= ~DEBUG_BFD
;
1168 print_debug(vty
, DEBUG_BFD
, 0);
1173 DEFUN (show_hostname
,
1175 "show " PROTO_NAME
" hostname",
1178 "IS-IS Dynamic hostname mapping\n")
1180 dynhn_print_all(vty
);
1185 DEFUN (show_isis_spf_ietf
,
1186 show_isis_spf_ietf_cmd
,
1187 "show " PROTO_NAME
" spf-delay-ietf",
1190 "SPF delay IETF information\n")
1193 vty_out(vty
, "ISIS is not running\n");
1197 struct listnode
*node
;
1198 struct isis_area
*area
;
1200 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1201 vty_out(vty
, "Area %s:\n",
1202 area
->area_tag
? area
->area_tag
: "null");
1204 for (int level
= ISIS_LEVEL1
; level
<= ISIS_LEVELS
; level
++) {
1205 if ((area
->is_type
& level
) == 0)
1208 vty_out(vty
, " Level-%d:\n", level
);
1209 vty_out(vty
, " SPF delay status: ");
1210 if (area
->spf_timer
[level
- 1]) {
1211 struct timeval remain
= thread_timer_remain(
1212 area
->spf_timer
[level
- 1]);
1213 vty_out(vty
, "Pending, due in %lld msec\n",
1214 (long long)remain
.tv_sec
* 1000
1215 + remain
.tv_usec
/ 1000);
1217 vty_out(vty
, "Not scheduled\n");
1220 if (area
->spf_delay_ietf
[level
- 1]) {
1222 " Using draft-ietf-rtgwg-backoff-algo-04\n");
1224 area
->spf_delay_ietf
[level
- 1], vty
,
1227 vty_out(vty
, " Using legacy backoff algo\n");
1234 DEFUN (show_isis_summary
,
1235 show_isis_summary_cmd
,
1236 "show " PROTO_NAME
" summary",
1237 SHOW_STR PROTO_HELP
"summary\n")
1239 struct listnode
*node
, *node2
;
1240 struct isis_area
*area
;
1244 vty_out(vty
, PROTO_NAME
" is not running\n");
1248 vty_out(vty
, "Process Id : %ld\n", isis
->process_id
);
1249 if (isis
->sysid_set
)
1250 vty_out(vty
, "System Id : %s\n",
1251 sysid_print(isis
->sysid
));
1253 vty_out(vty
, "Up time : ");
1254 vty_out_timestr(vty
, isis
->uptime
);
1257 if (isis
->area_list
)
1258 vty_out(vty
, "Number of areas : %d\n", isis
->area_list
->count
);
1260 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1261 vty_out(vty
, "Area %s:\n",
1262 area
->area_tag
? area
->area_tag
: "null");
1265 uint8_t tier
= fabricd_tier(area
);
1266 if (tier
== ISIS_TIER_UNDEFINED
)
1267 vty_out(vty
, " Tier: undefined\n");
1269 vty_out(vty
, " Tier: %" PRIu8
"\n", tier
);
1272 if (listcount(area
->area_addrs
) > 0) {
1273 struct area_addr
*area_addr
;
1274 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
, node2
,
1276 vty_out(vty
, " Net: %s\n",
1277 isonet_print(area_addr
->area_addr
,
1284 vty_out(vty
, " TX counters per PDU type:\n");
1285 pdu_counter_print(vty
, " ", area
->pdu_tx_counters
);
1286 vty_out(vty
, " LSP RXMT: %" PRIu64
"\n",
1287 area
->lsp_rxmt_count
);
1288 vty_out(vty
, " RX counters per PDU type:\n");
1289 pdu_counter_print(vty
, " ", area
->pdu_rx_counters
);
1291 for (level
= ISIS_LEVEL1
; level
<= ISIS_LEVELS
; level
++) {
1292 if ((area
->is_type
& level
) == 0)
1295 vty_out(vty
, " Level-%d:\n", level
);
1297 vty_out(vty
, " LSP0 regenerated: %" PRIu64
"\n",
1298 area
->lsp_gen_count
[level
- 1]);
1300 vty_out(vty
, " LSPs purged: %" PRIu64
"\n",
1301 area
->lsp_purge_count
[level
- 1]);
1303 if (area
->spf_timer
[level
- 1])
1304 vty_out(vty
, " SPF: (pending)\n");
1306 vty_out(vty
, " SPF:\n");
1308 vty_out(vty
, " minimum interval : %d",
1309 area
->min_spf_interval
[level
- 1]);
1310 if (area
->spf_delay_ietf
[level
- 1])
1312 " (not used, IETF SPF delay activated)");
1315 vty_out(vty
, " IPv4 route computation:\n");
1316 isis_spf_print(area
->spftree
[SPFTREE_IPV4
][level
- 1],
1319 vty_out(vty
, " IPv6 route computation:\n");
1320 isis_spf_print(area
->spftree
[SPFTREE_IPV6
][level
- 1],
1323 vty_out(vty
, " IPv6 dst-src route computation:\n");
1324 isis_spf_print(area
->spftree
[SPFTREE_DSTSRC
][level
-1],
1333 struct isis_lsp
*lsp_for_arg(struct lspdb_head
*head
, const char *argv
)
1335 char sysid
[255] = {0};
1338 uint8_t lspid
[ISIS_SYS_ID_LEN
+ 2] = {0};
1339 struct isis_dynhn
*dynhn
;
1340 struct isis_lsp
*lsp
= NULL
;
1346 * extract fragment and pseudo id from the string argv
1348 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1349 * (b) <systemid/hostname>.<pseudo-id> or
1350 * (c) <systemid/hostname> or
1351 * Where systemid is in the form:
1355 strlcpy(sysid
, argv
, sizeof(sysid
));
1356 if (argv
&& strlen(argv
) > 3) {
1357 pos
= argv
+ strlen(argv
) - 3;
1358 if (strncmp(pos
, "-", 1) == 0) {
1359 memcpy(number
, ++pos
, 2);
1360 lspid
[ISIS_SYS_ID_LEN
+ 1] =
1361 (uint8_t)strtol((char *)number
, NULL
, 16);
1363 if (strncmp(pos
, ".", 1) != 0)
1366 if (strncmp(pos
, ".", 1) == 0) {
1367 memcpy(number
, ++pos
, 2);
1368 lspid
[ISIS_SYS_ID_LEN
] =
1369 (uint8_t)strtol((char *)number
, NULL
, 16);
1370 sysid
[pos
- argv
- 1] = '\0';
1375 * Try to find the lsp-id if the argv
1378 * hostname.<pseudo-id>-<fragment>
1380 if (sysid2buff(lspid
, sysid
)) {
1381 lsp
= lsp_search(head
, lspid
);
1382 } else if ((dynhn
= dynhn_find_by_name(sysid
))) {
1383 memcpy(lspid
, dynhn
->id
, ISIS_SYS_ID_LEN
);
1384 lsp
= lsp_search(head
, lspid
);
1385 } else if (strncmp(cmd_hostname_get(), sysid
, 15) == 0) {
1386 memcpy(lspid
, isis
->sysid
, ISIS_SYS_ID_LEN
);
1387 lsp
= lsp_search(head
, lspid
);
1394 * This function supports following display options:
1395 * [ show isis database [detail] ]
1396 * [ show isis database <sysid> [detail] ]
1397 * [ show isis database <hostname> [detail] ]
1398 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1399 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1400 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1401 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1402 * [ show isis database detail <sysid> ]
1403 * [ show isis database detail <hostname> ]
1404 * [ show isis database detail <sysid>.<pseudo-id> ]
1405 * [ show isis database detail <hostname>.<pseudo-id> ]
1406 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1407 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1409 static int show_isis_database(struct vty
*vty
, const char *argv
, int ui_level
)
1411 struct listnode
*node
;
1412 struct isis_area
*area
;
1413 struct isis_lsp
*lsp
;
1414 int level
, lsp_count
;
1416 if (isis
->area_list
->count
== 0)
1419 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1420 vty_out(vty
, "Area %s:\n",
1421 area
->area_tag
? area
->area_tag
: "null");
1423 for (level
= 0; level
< ISIS_LEVELS
; level
++) {
1424 if (lspdb_count(&area
->lspdb
[level
]) > 0) {
1425 lsp
= lsp_for_arg(&area
->lspdb
[level
], argv
);
1427 if (lsp
!= NULL
|| argv
== NULL
) {
1429 "IS-IS Level-%d link-state database:\n",
1432 /* print the title in all cases */
1434 "LSP ID PduLen SeqNumber Chksum Holdtime ATT/P/OL\n");
1438 if (ui_level
== ISIS_UI_LEVEL_DETAIL
)
1445 } else if (argv
== NULL
) {
1446 lsp_count
= lsp_print_all(
1447 vty
, &area
->lspdb
[level
],
1448 ui_level
, area
->dynhostname
);
1450 vty_out(vty
, " %u LSPs\n\n",
1460 DEFUN (show_database
,
1462 "show " PROTO_NAME
" database [detail] [WORD]",
1465 "Link state database\n"
1466 "Detailed information\n"
1470 int uilevel
= argv_find(argv
, argc
, "detail", &idx
)
1471 ? ISIS_UI_LEVEL_DETAIL
1472 : ISIS_UI_LEVEL_BRIEF
;
1473 char *id
= argv_find(argv
, argc
, "WORD", &idx
) ? argv
[idx
]->arg
: NULL
;
1474 return show_isis_database(vty
, id
, uilevel
);
1479 * 'router openfabric' command
1481 DEFUN_NOSH (router_openfabric
,
1482 router_openfabric_cmd
,
1483 "router openfabric WORD",
1486 "ISO Routing area tag\n")
1489 return isis_area_get(vty
, argv
[idx_word
]->arg
);
1493 *'no router openfabric' command
1495 DEFUN (no_router_openfabric
,
1496 no_router_openfabric_cmd
,
1497 "no router openfabric WORD",
1501 "ISO Routing area tag\n")
1504 return isis_area_destroy(argv
[idx_word
]->arg
);
1506 #endif /* ifdef FABRICD */
1514 "A Network Entity Title for this process (OSI only)\n"
1515 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1518 return area_net_title(vty
, argv
[idx_word
]->arg
);
1528 "A Network Entity Title for this process (OSI only)\n"
1529 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1532 return area_clear_net_title(vty
, argv
[idx_word
]->arg
);
1534 #endif /* ifdef FABRICD */
1536 DEFUN (isis_topology
,
1538 "topology " ISIS_MT_NAMES
" [overload]",
1539 "Configure IS-IS topologies\n"
1540 ISIS_MT_DESCRIPTIONS
1541 "Set overload bit for topology\n")
1543 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1545 const char *arg
= argv
[1]->arg
;
1546 uint16_t mtid
= isis_str2mtid(arg
);
1548 if (area
->oldmetric
) {
1550 "Multi topology IS-IS can only be used with wide metrics\n");
1551 return CMD_WARNING_CONFIG_FAILED
;
1554 if (mtid
== (uint16_t)-1) {
1555 vty_out(vty
, "Don't know topology '%s'\n", arg
);
1556 return CMD_WARNING_CONFIG_FAILED
;
1558 if (mtid
== ISIS_MT_IPV4_UNICAST
) {
1559 vty_out(vty
, "Cannot configure IPv4 unicast topology\n");
1560 return CMD_WARNING_CONFIG_FAILED
;
1563 area_set_mt_enabled(area
, mtid
, true);
1564 area_set_mt_overload(area
, mtid
, (argc
== 3));
1568 DEFUN (no_isis_topology
,
1569 no_isis_topology_cmd
,
1570 "no topology " ISIS_MT_NAMES
" [overload]",
1572 "Configure IS-IS topologies\n"
1573 ISIS_MT_DESCRIPTIONS
1574 "Set overload bit for topology\n")
1576 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1578 const char *arg
= argv
[2]->arg
;
1579 uint16_t mtid
= isis_str2mtid(arg
);
1581 if (area
->oldmetric
) {
1583 "Multi topology IS-IS can only be used with wide metrics\n");
1584 return CMD_WARNING_CONFIG_FAILED
;
1587 if (mtid
== (uint16_t)-1) {
1588 vty_out(vty
, "Don't know topology '%s'\n", arg
);
1589 return CMD_WARNING_CONFIG_FAILED
;
1591 if (mtid
== ISIS_MT_IPV4_UNICAST
) {
1592 vty_out(vty
, "Cannot configure IPv4 unicast topology\n");
1593 return CMD_WARNING_CONFIG_FAILED
;
1596 area_set_mt_enabled(area
, mtid
, false);
1597 area_set_mt_overload(area
, mtid
, false);
1600 #endif /* ifdef FABRICD */
1602 void isis_area_lsp_mtu_set(struct isis_area
*area
, unsigned int lsp_mtu
)
1604 area
->lsp_mtu
= lsp_mtu
;
1605 lsp_regenerate_schedule(area
, IS_LEVEL_1_AND_2
, 1);
1608 static int isis_area_passwd_set(struct isis_area
*area
, int level
,
1609 uint8_t passwd_type
, const char *passwd
,
1612 struct isis_passwd
*dest
;
1613 struct isis_passwd modified
;
1616 assert((level
== IS_LEVEL_1
) || (level
== IS_LEVEL_2
));
1617 dest
= (level
== IS_LEVEL_1
) ? &area
->area_passwd
1618 : &area
->domain_passwd
;
1619 memset(&modified
, 0, sizeof(modified
));
1621 if (passwd_type
!= ISIS_PASSWD_TYPE_UNUSED
) {
1625 len
= strlen(passwd
);
1630 strlcpy((char *)modified
.passwd
, passwd
,
1631 sizeof(modified
.passwd
));
1632 modified
.type
= passwd_type
;
1633 modified
.snp_auth
= snp_auth
;
1636 if (memcmp(&modified
, dest
, sizeof(modified
))) {
1637 memcpy(dest
, &modified
, sizeof(modified
));
1638 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1644 int isis_area_passwd_unset(struct isis_area
*area
, int level
)
1646 return isis_area_passwd_set(area
, level
, ISIS_PASSWD_TYPE_UNUSED
, NULL
,
1650 int isis_area_passwd_cleartext_set(struct isis_area
*area
, int level
,
1651 const char *passwd
, uint8_t snp_auth
)
1653 return isis_area_passwd_set(area
, level
, ISIS_PASSWD_TYPE_CLEARTXT
,
1657 int isis_area_passwd_hmac_md5_set(struct isis_area
*area
, int level
,
1658 const char *passwd
, uint8_t snp_auth
)
1660 return isis_area_passwd_set(area
, level
, ISIS_PASSWD_TYPE_HMAC_MD5
,
1664 void isis_area_invalidate_routes(struct isis_area
*area
, int levels
)
1666 for (int level
= ISIS_LEVEL1
; level
<= ISIS_LEVEL2
; level
++) {
1667 if (!(level
& levels
))
1669 for (int tree
= SPFTREE_IPV4
; tree
< SPFTREE_COUNT
; tree
++) {
1670 isis_spf_invalidate_routes(
1671 area
->spftree
[tree
][level
- 1]);
1676 void isis_area_verify_routes(struct isis_area
*area
)
1678 for (int tree
= SPFTREE_IPV4
; tree
< SPFTREE_COUNT
; tree
++)
1679 isis_spf_verify_routes(area
, area
->spftree
[tree
]);
1682 static void area_resign_level(struct isis_area
*area
, int level
)
1684 isis_area_invalidate_routes(area
, level
);
1685 isis_area_verify_routes(area
);
1687 lsp_db_fini(&area
->lspdb
[level
- 1]);
1689 for (int tree
= SPFTREE_IPV4
; tree
< SPFTREE_COUNT
; tree
++) {
1690 if (area
->spftree
[tree
][level
- 1]) {
1691 isis_spftree_del(area
->spftree
[tree
][level
- 1]);
1692 area
->spftree
[tree
][level
- 1] = NULL
;
1696 THREAD_TIMER_OFF(area
->spf_timer
[level
- 1]);
1699 "ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.",
1700 area
->area_tag
, level
);
1701 THREAD_TIMER_OFF(area
->t_lsp_refresh
[level
- 1]);
1702 area
->lsp_regenerate_pending
[level
- 1] = 0;
1705 void isis_area_is_type_set(struct isis_area
*area
, int is_type
)
1707 struct listnode
*node
;
1708 struct isis_circuit
*circuit
;
1710 if (isis
->debugs
& DEBUG_EVENTS
)
1711 zlog_debug("ISIS-Evt (%s) system type change %s -> %s",
1712 area
->area_tag
, circuit_t2string(area
->is_type
),
1713 circuit_t2string(is_type
));
1715 if (area
->is_type
== is_type
)
1716 return; /* No change */
1718 switch (area
->is_type
) {
1720 if (is_type
== IS_LEVEL_2
)
1721 area_resign_level(area
, IS_LEVEL_1
);
1723 lsp_db_init(&area
->lspdb
[1]);
1726 case IS_LEVEL_1_AND_2
:
1727 if (is_type
== IS_LEVEL_1
)
1728 area_resign_level(area
, IS_LEVEL_2
);
1730 area_resign_level(area
, IS_LEVEL_1
);
1734 if (is_type
== IS_LEVEL_1
)
1735 area_resign_level(area
, IS_LEVEL_2
);
1737 lsp_db_init(&area
->lspdb
[0]);
1744 area
->is_type
= is_type
;
1746 /* override circuit's is_type */
1747 if (area
->is_type
!= IS_LEVEL_1_AND_2
) {
1748 for (ALL_LIST_ELEMENTS_RO(area
->circuit_list
, node
, circuit
))
1749 isis_circuit_is_type_set(circuit
, is_type
);
1752 spftree_area_init(area
);
1754 if (listcount(area
->area_addrs
) > 0) {
1755 if (is_type
& IS_LEVEL_1
)
1756 lsp_generate(area
, IS_LEVEL_1
);
1757 if (is_type
& IS_LEVEL_2
)
1758 lsp_generate(area
, IS_LEVEL_2
);
1760 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1765 void isis_area_metricstyle_set(struct isis_area
*area
, bool old_metric
,
1768 area
->oldmetric
= old_metric
;
1769 area
->newmetric
= new_metric
;
1770 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1773 void isis_area_overload_bit_set(struct isis_area
*area
, bool overload_bit
)
1775 char new_overload_bit
= overload_bit
? LSPBIT_OL
: 0;
1777 if (new_overload_bit
!= area
->overload_bit
) {
1778 area
->overload_bit
= new_overload_bit
;
1779 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1782 isis_notif_db_overload(area
, overload_bit
);
1783 #endif /* ifndef FABRICD */
1786 void isis_area_attached_bit_set(struct isis_area
*area
, bool attached_bit
)
1788 char new_attached_bit
= attached_bit
? LSPBIT_ATT
: 0;
1790 if (new_attached_bit
!= area
->attached_bit
) {
1791 area
->attached_bit
= new_attached_bit
;
1792 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 1);
1796 void isis_area_dynhostname_set(struct isis_area
*area
, bool dynhostname
)
1798 if (area
->dynhostname
!= dynhostname
) {
1799 area
->dynhostname
= dynhostname
;
1800 lsp_regenerate_schedule(area
, IS_LEVEL_1
| IS_LEVEL_2
, 0);
1804 void isis_area_max_lsp_lifetime_set(struct isis_area
*area
, int level
,
1805 uint16_t max_lsp_lifetime
)
1807 assert((level
== IS_LEVEL_1
) || (level
== IS_LEVEL_2
));
1809 if (area
->max_lsp_lifetime
[level
- 1] == max_lsp_lifetime
)
1812 area
->max_lsp_lifetime
[level
- 1] = max_lsp_lifetime
;
1813 lsp_regenerate_schedule(area
, level
, 1);
1816 void isis_area_lsp_refresh_set(struct isis_area
*area
, int level
,
1817 uint16_t lsp_refresh
)
1819 assert((level
== IS_LEVEL_1
) || (level
== IS_LEVEL_2
));
1821 if (area
->lsp_refresh
[level
- 1] == lsp_refresh
)
1824 area
->lsp_refresh
[level
- 1] = lsp_refresh
;
1825 lsp_regenerate_schedule(area
, level
, 1);
1829 DEFUN (log_adj_changes
,
1830 log_adj_changes_cmd
,
1831 "log-adjacency-changes",
1832 "Log changes in adjacency state\n")
1834 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1836 area
->log_adj_changes
= 1;
1841 DEFUN (no_log_adj_changes
,
1842 no_log_adj_changes_cmd
,
1843 "no log-adjacency-changes",
1845 "Stop logging changes in adjacency state\n")
1847 VTY_DECLVAR_CONTEXT(isis_area
, area
);
1849 area
->log_adj_changes
= 0;
1853 #endif /* ifdef FABRICD */
1855 /* IS-IS configuration write function */
1856 int isis_config_write(struct vty
*vty
)
1861 struct isis_area
*area
;
1862 struct listnode
*node
, *node2
;
1864 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1865 /* ISIS - Area name */
1866 vty_out(vty
, "router " PROTO_NAME
" %s\n", area
->area_tag
);
1869 if (listcount(area
->area_addrs
) > 0) {
1870 struct area_addr
*area_addr
;
1871 for (ALL_LIST_ELEMENTS_RO(area
->area_addrs
,
1872 node2
, area_addr
)) {
1873 vty_out(vty
, " net %s\n",
1875 area_addr
->area_addr
,
1882 /* ISIS - Dynamic hostname - Defaults to true so only
1885 if (!area
->dynhostname
) {
1886 vty_out(vty
, " no hostname dynamic\n");
1889 /* ISIS - Metric-Style - when true displays wide */
1891 if (area
->newmetric
) {
1892 if (!area
->oldmetric
)
1893 vty_out(vty
, " metric-style wide\n");
1896 " metric-style transition\n");
1899 vty_out(vty
, " metric-style narrow\n");
1903 /* ISIS - overload-bit */
1904 if (area
->overload_bit
) {
1905 vty_out(vty
, " set-overload-bit\n");
1908 /* ISIS - Area is-type (level-1-2 is default) */
1910 if (area
->is_type
== IS_LEVEL_1
) {
1911 vty_out(vty
, " is-type level-1\n");
1913 } else if (area
->is_type
== IS_LEVEL_2
) {
1914 vty_out(vty
, " is-type level-2-only\n");
1918 write
+= isis_redist_config_write(vty
, area
, AF_INET
);
1919 write
+= isis_redist_config_write(vty
, area
, AF_INET6
);
1920 /* ISIS - Lsp generation interval */
1921 if (area
->lsp_gen_interval
[0]
1922 == area
->lsp_gen_interval
[1]) {
1923 if (area
->lsp_gen_interval
[0]
1924 != DEFAULT_MIN_LSP_GEN_INTERVAL
) {
1925 vty_out(vty
, " lsp-gen-interval %d\n",
1926 area
->lsp_gen_interval
[0]);
1930 if (area
->lsp_gen_interval
[0]
1931 != DEFAULT_MIN_LSP_GEN_INTERVAL
) {
1933 " lsp-gen-interval level-1 %d\n",
1934 area
->lsp_gen_interval
[0]);
1937 if (area
->lsp_gen_interval
[1]
1938 != DEFAULT_MIN_LSP_GEN_INTERVAL
) {
1940 " lsp-gen-interval level-2 %d\n",
1941 area
->lsp_gen_interval
[1]);
1945 /* ISIS - LSP lifetime */
1946 if (area
->max_lsp_lifetime
[0]
1947 == area
->max_lsp_lifetime
[1]) {
1948 if (area
->max_lsp_lifetime
[0]
1949 != DEFAULT_LSP_LIFETIME
) {
1950 vty_out(vty
, " max-lsp-lifetime %u\n",
1951 area
->max_lsp_lifetime
[0]);
1955 if (area
->max_lsp_lifetime
[0]
1956 != DEFAULT_LSP_LIFETIME
) {
1958 " max-lsp-lifetime level-1 %u\n",
1959 area
->max_lsp_lifetime
[0]);
1962 if (area
->max_lsp_lifetime
[1]
1963 != DEFAULT_LSP_LIFETIME
) {
1965 " max-lsp-lifetime level-2 %u\n",
1966 area
->max_lsp_lifetime
[1]);
1970 /* ISIS - LSP refresh interval */
1971 if (area
->lsp_refresh
[0] == area
->lsp_refresh
[1]) {
1972 if (area
->lsp_refresh
[0]
1973 != DEFAULT_MAX_LSP_GEN_INTERVAL
) {
1975 " lsp-refresh-interval %u\n",
1976 area
->lsp_refresh
[0]);
1980 if (area
->lsp_refresh
[0]
1981 != DEFAULT_MAX_LSP_GEN_INTERVAL
) {
1983 " lsp-refresh-interval level-1 %u\n",
1984 area
->lsp_refresh
[0]);
1987 if (area
->lsp_refresh
[1]
1988 != DEFAULT_MAX_LSP_GEN_INTERVAL
) {
1990 " lsp-refresh-interval level-2 %u\n",
1991 area
->lsp_refresh
[1]);
1995 if (area
->lsp_mtu
!= DEFAULT_LSP_MTU
) {
1996 vty_out(vty
, " lsp-mtu %u\n", area
->lsp_mtu
);
1999 if (area
->purge_originator
) {
2000 vty_out(vty
, " purge-originator\n");
2004 /* Minimum SPF interval. */
2005 if (area
->min_spf_interval
[0]
2006 == area
->min_spf_interval
[1]) {
2007 if (area
->min_spf_interval
[0]
2008 != MINIMUM_SPF_INTERVAL
) {
2009 vty_out(vty
, " spf-interval %d\n",
2010 area
->min_spf_interval
[0]);
2014 if (area
->min_spf_interval
[0]
2015 != MINIMUM_SPF_INTERVAL
) {
2017 " spf-interval level-1 %d\n",
2018 area
->min_spf_interval
[0]);
2021 if (area
->min_spf_interval
[1]
2022 != MINIMUM_SPF_INTERVAL
) {
2024 " spf-interval level-2 %d\n",
2025 area
->min_spf_interval
[1]);
2030 /* IETF SPF interval */
2031 if (area
->spf_delay_ietf
[0]) {
2033 " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld\n",
2034 spf_backoff_init_delay(
2035 area
->spf_delay_ietf
[0]),
2036 spf_backoff_short_delay(
2037 area
->spf_delay_ietf
[0]),
2038 spf_backoff_long_delay(
2039 area
->spf_delay_ietf
[0]),
2040 spf_backoff_holddown(
2041 area
->spf_delay_ietf
[0]),
2042 spf_backoff_timetolearn(
2043 area
->spf_delay_ietf
[0]));
2047 /* Authentication passwords. */
2048 if (area
->area_passwd
.type
2049 == ISIS_PASSWD_TYPE_HMAC_MD5
) {
2050 vty_out(vty
, " area-password md5 %s",
2051 area
->area_passwd
.passwd
);
2052 if (CHECK_FLAG(area
->area_passwd
.snp_auth
,
2054 vty_out(vty
, " authenticate snp ");
2056 area
->area_passwd
.snp_auth
,
2058 vty_out(vty
, "validate");
2060 vty_out(vty
, "send-only");
2064 } else if (area
->area_passwd
.type
2065 == ISIS_PASSWD_TYPE_CLEARTXT
) {
2066 vty_out(vty
, " area-password clear %s",
2067 area
->area_passwd
.passwd
);
2068 if (CHECK_FLAG(area
->area_passwd
.snp_auth
,
2070 vty_out(vty
, " authenticate snp ");
2072 area
->area_passwd
.snp_auth
,
2074 vty_out(vty
, "validate");
2076 vty_out(vty
, "send-only");
2081 if (area
->domain_passwd
.type
2082 == ISIS_PASSWD_TYPE_HMAC_MD5
) {
2083 vty_out(vty
, " domain-password md5 %s",
2084 area
->domain_passwd
.passwd
);
2085 if (CHECK_FLAG(area
->domain_passwd
.snp_auth
,
2087 vty_out(vty
, " authenticate snp ");
2088 if (CHECK_FLAG(area
->domain_passwd
2091 vty_out(vty
, "validate");
2093 vty_out(vty
, "send-only");
2097 } else if (area
->domain_passwd
.type
2098 == ISIS_PASSWD_TYPE_CLEARTXT
) {
2099 vty_out(vty
, " domain-password clear %s",
2100 area
->domain_passwd
.passwd
);
2101 if (CHECK_FLAG(area
->domain_passwd
.snp_auth
,
2103 vty_out(vty
, " authenticate snp ");
2104 if (CHECK_FLAG(area
->domain_passwd
2107 vty_out(vty
, "validate");
2109 vty_out(vty
, "send-only");
2115 if (area
->log_adj_changes
) {
2116 vty_out(vty
, " log-adjacency-changes\n");
2120 write
+= area_write_mt_settings(area
, vty
);
2121 write
+= fabricd_write_settings(area
, vty
);
2129 /* IS-IS configuration write function */
2130 int isis_config_write(struct vty
*vty
)
2133 struct lyd_node
*dnode
;
2135 dnode
= yang_dnode_get(running_config
->dnode
, "/frr-isisd:isis");
2137 nb_cli_show_dnode_cmds(vty
, dnode
, false);
2143 #endif /* ifdef FABRICD */
2145 struct cmd_node router_node
= {ROUTER_NODE
, "%s(config-router)# ", 1};
2147 void isis_init(void)
2149 /* Install IS-IS top node */
2150 install_node(&router_node
, isis_config_write
);
2152 install_element(VIEW_NODE
, &show_isis_summary_cmd
);
2154 install_element(VIEW_NODE
, &show_isis_spf_ietf_cmd
);
2156 install_element(VIEW_NODE
, &show_isis_interface_cmd
);
2157 install_element(VIEW_NODE
, &show_isis_interface_detail_cmd
);
2158 install_element(VIEW_NODE
, &show_isis_interface_arg_cmd
);
2160 install_element(VIEW_NODE
, &show_isis_neighbor_cmd
);
2161 install_element(VIEW_NODE
, &show_isis_neighbor_detail_cmd
);
2162 install_element(VIEW_NODE
, &show_isis_neighbor_arg_cmd
);
2163 install_element(VIEW_NODE
, &clear_isis_neighbor_cmd
);
2164 install_element(VIEW_NODE
, &clear_isis_neighbor_arg_cmd
);
2166 install_element(VIEW_NODE
, &show_hostname_cmd
);
2167 install_element(VIEW_NODE
, &show_database_cmd
);
2169 install_element(ENABLE_NODE
, &show_debugging_isis_cmd
);
2171 install_node(&debug_node
, config_write_debug
);
2173 install_element(ENABLE_NODE
, &debug_isis_adj_cmd
);
2174 install_element(ENABLE_NODE
, &no_debug_isis_adj_cmd
);
2175 install_element(ENABLE_NODE
, &debug_isis_tx_queue_cmd
);
2176 install_element(ENABLE_NODE
, &no_debug_isis_tx_queue_cmd
);
2177 install_element(ENABLE_NODE
, &debug_isis_flooding_cmd
);
2178 install_element(ENABLE_NODE
, &no_debug_isis_flooding_cmd
);
2179 install_element(ENABLE_NODE
, &debug_isis_snp_cmd
);
2180 install_element(ENABLE_NODE
, &no_debug_isis_snp_cmd
);
2181 install_element(ENABLE_NODE
, &debug_isis_upd_cmd
);
2182 install_element(ENABLE_NODE
, &no_debug_isis_upd_cmd
);
2183 install_element(ENABLE_NODE
, &debug_isis_spfevents_cmd
);
2184 install_element(ENABLE_NODE
, &no_debug_isis_spfevents_cmd
);
2185 install_element(ENABLE_NODE
, &debug_isis_rtevents_cmd
);
2186 install_element(ENABLE_NODE
, &no_debug_isis_rtevents_cmd
);
2187 install_element(ENABLE_NODE
, &debug_isis_events_cmd
);
2188 install_element(ENABLE_NODE
, &no_debug_isis_events_cmd
);
2189 install_element(ENABLE_NODE
, &debug_isis_packet_dump_cmd
);
2190 install_element(ENABLE_NODE
, &no_debug_isis_packet_dump_cmd
);
2191 install_element(ENABLE_NODE
, &debug_isis_lsp_gen_cmd
);
2192 install_element(ENABLE_NODE
, &no_debug_isis_lsp_gen_cmd
);
2193 install_element(ENABLE_NODE
, &debug_isis_lsp_sched_cmd
);
2194 install_element(ENABLE_NODE
, &no_debug_isis_lsp_sched_cmd
);
2195 install_element(ENABLE_NODE
, &debug_isis_bfd_cmd
);
2196 install_element(ENABLE_NODE
, &no_debug_isis_bfd_cmd
);
2198 install_element(CONFIG_NODE
, &debug_isis_adj_cmd
);
2199 install_element(CONFIG_NODE
, &no_debug_isis_adj_cmd
);
2200 install_element(CONFIG_NODE
, &debug_isis_tx_queue_cmd
);
2201 install_element(CONFIG_NODE
, &no_debug_isis_tx_queue_cmd
);
2202 install_element(CONFIG_NODE
, &debug_isis_flooding_cmd
);
2203 install_element(CONFIG_NODE
, &no_debug_isis_flooding_cmd
);
2204 install_element(CONFIG_NODE
, &debug_isis_snp_cmd
);
2205 install_element(CONFIG_NODE
, &no_debug_isis_snp_cmd
);
2206 install_element(CONFIG_NODE
, &debug_isis_upd_cmd
);
2207 install_element(CONFIG_NODE
, &no_debug_isis_upd_cmd
);
2208 install_element(CONFIG_NODE
, &debug_isis_spfevents_cmd
);
2209 install_element(CONFIG_NODE
, &no_debug_isis_spfevents_cmd
);
2210 install_element(CONFIG_NODE
, &debug_isis_rtevents_cmd
);
2211 install_element(CONFIG_NODE
, &no_debug_isis_rtevents_cmd
);
2212 install_element(CONFIG_NODE
, &debug_isis_events_cmd
);
2213 install_element(CONFIG_NODE
, &no_debug_isis_events_cmd
);
2214 install_element(CONFIG_NODE
, &debug_isis_packet_dump_cmd
);
2215 install_element(CONFIG_NODE
, &no_debug_isis_packet_dump_cmd
);
2216 install_element(CONFIG_NODE
, &debug_isis_lsp_gen_cmd
);
2217 install_element(CONFIG_NODE
, &no_debug_isis_lsp_gen_cmd
);
2218 install_element(CONFIG_NODE
, &debug_isis_lsp_sched_cmd
);
2219 install_element(CONFIG_NODE
, &no_debug_isis_lsp_sched_cmd
);
2220 install_element(CONFIG_NODE
, &debug_isis_bfd_cmd
);
2221 install_element(CONFIG_NODE
, &no_debug_isis_bfd_cmd
);
2223 install_default(ROUTER_NODE
);
2226 install_element(CONFIG_NODE
, &router_openfabric_cmd
);
2227 install_element(CONFIG_NODE
, &no_router_openfabric_cmd
);
2229 install_element(ROUTER_NODE
, &net_cmd
);
2230 install_element(ROUTER_NODE
, &no_net_cmd
);
2232 install_element(ROUTER_NODE
, &isis_topology_cmd
);
2233 install_element(ROUTER_NODE
, &no_isis_topology_cmd
);
2235 install_element(ROUTER_NODE
, &log_adj_changes_cmd
);
2236 install_element(ROUTER_NODE
, &no_log_adj_changes_cmd
);
2237 #endif /* ifdef FABRICD */
2239 spf_backoff_cmd_init();