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