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