]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
eb5d44eb | 2 | /* |
3 | * IS-IS Rout(e)ing protocol - isisd.c | |
4 | * | |
5 | * Copyright (C) 2001,2002 Sampo Saaristo | |
d62a17ae | 6 | * Tampere University of Technology |
eb5d44eb | 7 | * Institute of Communications Engineering |
eb5d44eb | 8 | */ |
9 | ||
eb5d44eb | 10 | #include <zebra.h> |
eb5d44eb | 11 | |
12 | #include "thread.h" | |
13 | #include "vty.h" | |
14 | #include "command.h" | |
15 | #include "log.h" | |
16 | #include "memory.h" | |
3f045a08 | 17 | #include "time.h" |
eb5d44eb | 18 | #include "linklist.h" |
19 | #include "if.h" | |
20 | #include "hash.h" | |
e886416f | 21 | #include "filter.h" |
16fe8cff | 22 | #include "plist.h" |
eb5d44eb | 23 | #include "stream.h" |
24 | #include "prefix.h" | |
25 | #include "table.h" | |
676a4ea3 | 26 | #include "qobj.h" |
65251ce8 | 27 | #include "zclient.h" |
eab88f36 | 28 | #include "vrf.h" |
03f7e182 | 29 | #include "spf_backoff.h" |
aaf2fd21 | 30 | #include "lib/northbound_cli.h" |
13bf3830 | 31 | #include "bfd.h" |
eb5d44eb | 32 | |
eb5d44eb | 33 | #include "isisd/isis_constants.h" |
34 | #include "isisd/isis_common.h" | |
eb5d44eb | 35 | #include "isisd/isis_flags.h" |
3f045a08 JB |
36 | #include "isisd/isis_circuit.h" |
37 | #include "isisd/isis_csm.h" | |
eb5d44eb | 38 | #include "isisd/isisd.h" |
39 | #include "isisd/isis_dynhn.h" | |
40 | #include "isisd/isis_adjacency.h" | |
41 | #include "isisd/isis_pdu.h" | |
42 | #include "isisd/isis_misc.h" | |
43 | #include "isisd/isis_constants.h" | |
eb5d44eb | 44 | #include "isisd/isis_lsp.h" |
45 | #include "isisd/isis_spf.h" | |
46 | #include "isisd/isis_route.h" | |
47 | #include "isisd/isis_zebra.h" | |
48 | #include "isisd/isis_events.h" | |
f8c06e2c | 49 | #include "isisd/isis_te.h" |
064f4896 | 50 | #include "isisd/isis_mt.h" |
26f6acaf | 51 | #include "isisd/isis_sr.h" |
8e6fb83b | 52 | #include "isisd/fabricd.h" |
2a1c520e | 53 | #include "isisd/isis_nb.h" |
eb5d44eb | 54 | |
e740f9c1 | 55 | /* For debug statement. */ |
56 | unsigned long debug_adj_pkt; | |
57 | unsigned long debug_snp_pkt; | |
58 | unsigned long debug_update_pkt; | |
59 | unsigned long debug_spf_events; | |
60 | unsigned long debug_rte_events; | |
61 | unsigned long debug_events; | |
62 | unsigned long debug_pkt_dump; | |
63 | unsigned long debug_lsp_gen; | |
64 | unsigned long debug_lsp_sched; | |
65 | unsigned long debug_flooding; | |
66 | unsigned long debug_bfd; | |
67 | unsigned long debug_tx_queue; | |
68 | unsigned long debug_sr; | |
1cbf96a8 | 69 | unsigned long debug_ldp_sync; |
2866b119 | 70 | unsigned long debug_lfa; |
d9884a75 | 71 | unsigned long debug_te; |
e740f9c1 | 72 | |
66b9a381 DL |
73 | DEFINE_MGROUP(ISISD, "isisd"); |
74 | ||
75 | DEFINE_MTYPE_STATIC(ISISD, ISIS, "ISIS process"); | |
76 | DEFINE_MTYPE_STATIC(ISISD, ISIS_NAME, "ISIS process name"); | |
77 | DEFINE_MTYPE_STATIC(ISISD, ISIS_AREA, "ISIS area"); | |
78 | DEFINE_MTYPE(ISISD, ISIS_AREA_ADDR, "ISIS area address"); | |
79 | DEFINE_MTYPE(ISISD, ISIS_ACL_NAME, "ISIS access-list name"); | |
dcfe3c16 | 80 | DEFINE_MTYPE(ISISD, ISIS_PLIST_NAME, "ISIS prefix-list name"); |
66b9a381 | 81 | |
96244aca | 82 | DEFINE_QOBJ_TYPE(isis_area); |
676a4ea3 | 83 | |
eab88f36 K |
84 | /* ISIS process wide configuration. */ |
85 | static struct isis_master isis_master; | |
86 | ||
87 | /* ISIS process wide configuration pointer to export. */ | |
88 | struct isis_master *im; | |
89 | ||
1ee746d9 | 90 | #ifndef FABRICD |
91 | DEFINE_HOOK(isis_hook_db_overload, (const struct isis_area *area), (area)); | |
92 | #endif /* ifndef FABRICD */ | |
93 | ||
41b36e90 PJ |
94 | /* |
95 | * Prototypes. | |
96 | */ | |
41b36e90 | 97 | int isis_area_get(struct vty *, const char *); |
3f045a08 JB |
98 | int area_net_title(struct vty *, const char *); |
99 | int area_clear_net_title(struct vty *, const char *); | |
9fee4d4c JG |
100 | int show_isis_interface_common(struct vty *, struct json_object *json, |
101 | const char *ifname, char, const char *vrf_name, | |
eab88f36 | 102 | bool all_vrf); |
9fee4d4c JG |
103 | int show_isis_interface_common_vty(struct vty *, const char *ifname, char, |
104 | const char *vrf_name, bool all_vrf); | |
105 | int show_isis_interface_common_json(struct json_object *json, | |
106 | const char *ifname, char, | |
107 | const char *vrf_name, bool all_vrf); | |
a21177f2 JG |
108 | int show_isis_neighbor_common(struct vty *, struct json_object *json, |
109 | const char *id, char, const char *vrf_name, | |
110 | bool all_vrf); | |
111 | int clear_isis_neighbor_common(struct vty *, const char *id, | |
112 | const char *vrf_name, bool all_vrf); | |
eab88f36 | 113 | |
eab88f36 K |
114 | /* Link ISIS instance to VRF. */ |
115 | void isis_vrf_link(struct isis *isis, struct vrf *vrf) | |
116 | { | |
117 | isis->vrf_id = vrf->vrf_id; | |
118 | if (vrf->info != (void *)isis) | |
119 | vrf->info = (void *)isis; | |
120 | } | |
121 | ||
122 | /* Unlink ISIS instance to VRF. */ | |
123 | void isis_vrf_unlink(struct isis *isis, struct vrf *vrf) | |
124 | { | |
125 | if (vrf->info == (void *)isis) | |
126 | vrf->info = NULL; | |
127 | isis->vrf_id = VRF_UNKNOWN; | |
128 | } | |
129 | ||
130 | struct isis *isis_lookup_by_vrfid(vrf_id_t vrf_id) | |
131 | { | |
36944791 RW |
132 | struct isis *isis; |
133 | struct listnode *node; | |
41b36e90 | 134 | |
36944791 | 135 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) |
eab88f36 K |
136 | if (isis->vrf_id == vrf_id) |
137 | return isis; | |
36944791 | 138 | |
eab88f36 K |
139 | return NULL; |
140 | } | |
141 | ||
142 | struct isis *isis_lookup_by_vrfname(const char *vrfname) | |
143 | { | |
36944791 RW |
144 | struct isis *isis; |
145 | struct listnode *node; | |
eab88f36 | 146 | |
36944791 | 147 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) |
eab88f36 K |
148 | if (isis->name && vrfname && strcmp(isis->name, vrfname) == 0) |
149 | return isis; | |
36944791 | 150 | |
eab88f36 K |
151 | return NULL; |
152 | } | |
153 | ||
36944791 | 154 | struct isis *isis_lookup_by_sysid(const uint8_t *sysid) |
eab88f36 | 155 | { |
36944791 RW |
156 | struct isis *isis; |
157 | struct listnode *node; | |
158 | ||
159 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) | |
eab88f36 K |
160 | if (!memcmp(isis->sysid, sysid, ISIS_SYS_ID_LEN)) |
161 | return isis; | |
36944791 | 162 | |
eab88f36 K |
163 | return NULL; |
164 | } | |
165 | ||
166 | void isis_master_init(struct thread_master *master) | |
167 | { | |
6006b807 | 168 | memset(&isis_master, 0, sizeof(isis_master)); |
eab88f36 K |
169 | im = &isis_master; |
170 | im->isis = list_new(); | |
171 | im->master = master; | |
172 | } | |
41b36e90 | 173 | |
65251ce8 | 174 | struct isis *isis_new(const char *vrf_name) |
eab88f36 | 175 | { |
36944791 RW |
176 | struct vrf *vrf; |
177 | struct isis *isis; | |
eab88f36 | 178 | |
d62a17ae | 179 | isis = XCALLOC(MTYPE_ISIS, sizeof(struct isis)); |
bcf22081 IR |
180 | |
181 | isis->name = XSTRDUP(MTYPE_ISIS_NAME, vrf_name); | |
182 | ||
65251ce8 | 183 | vrf = vrf_lookup_by_name(vrf_name); |
eab88f36 | 184 | |
bcf22081 | 185 | if (vrf) |
eab88f36 | 186 | isis_vrf_link(isis, vrf); |
bcf22081 | 187 | else |
65251ce8 | 188 | isis->vrf_id = VRF_UNKNOWN; |
eab88f36 | 189 | |
8c6482db IR |
190 | isis_zebra_vrf_register(isis); |
191 | ||
eab88f36 K |
192 | if (IS_DEBUG_EVENTS) |
193 | zlog_debug( | |
194 | "%s: Create new isis instance with vrf_name %s vrf_id %u", | |
195 | __func__, isis->name, isis->vrf_id); | |
196 | ||
d62a17ae | 197 | /* |
198 | * Default values | |
199 | */ | |
a2cac12a | 200 | isis->max_area_addrs = ISIS_DEFAULT_MAX_AREA_ADDRESSES; |
eab88f36 | 201 | isis->process_id = getpid(); |
d62a17ae | 202 | isis->router_id = 0; |
203 | isis->area_list = list_new(); | |
d62a17ae | 204 | isis->uptime = time(NULL); |
1ee746d9 | 205 | isis->snmp_notifications = 1; |
eab88f36 K |
206 | dyn_cache_init(isis); |
207 | ||
bcf22081 IR |
208 | listnode_add(im->isis, isis); |
209 | ||
eab88f36 | 210 | return isis; |
d62a17ae | 211 | } |
212 | ||
bcf22081 IR |
213 | void isis_finish(struct isis *isis) |
214 | { | |
1fa63850 OD |
215 | struct isis_area *area; |
216 | struct listnode *node, *nnode; | |
217 | ||
218 | for (ALL_LIST_ELEMENTS(isis->area_list, node, nnode, area)) | |
219 | isis_area_destroy(area); | |
220 | ||
bcf22081 IR |
221 | struct vrf *vrf = NULL; |
222 | ||
223 | listnode_delete(im->isis, isis); | |
224 | ||
8c6482db IR |
225 | isis_zebra_vrf_deregister(isis); |
226 | ||
bcf22081 IR |
227 | vrf = vrf_lookup_by_name(isis->name); |
228 | if (vrf) | |
229 | isis_vrf_unlink(isis, vrf); | |
230 | XFREE(MTYPE_ISIS_NAME, isis->name); | |
231 | ||
232 | isis_redist_free(isis); | |
233 | list_delete(&isis->area_list); | |
240f48b3 | 234 | dyn_cache_finish(isis); |
bcf22081 IR |
235 | XFREE(MTYPE_ISIS, isis); |
236 | } | |
237 | ||
238 | void isis_area_add_circuit(struct isis_area *area, struct isis_circuit *circuit) | |
239 | { | |
240 | isis_csm_state_change(ISIS_ENABLE, circuit, area); | |
241 | ||
242 | area->ip_circuits += circuit->ip_router; | |
243 | area->ipv6_circuits += circuit->ipv6_router; | |
244 | ||
245 | area->lfa_protected_links[0] += circuit->lfa_protection[0]; | |
246 | area->rlfa_protected_links[0] += circuit->rlfa_protection[0]; | |
247 | area->tilfa_protected_links[0] += circuit->tilfa_protection[0]; | |
248 | ||
249 | area->lfa_protected_links[1] += circuit->lfa_protection[1]; | |
250 | area->rlfa_protected_links[1] += circuit->rlfa_protection[1]; | |
251 | area->tilfa_protected_links[1] += circuit->tilfa_protection[1]; | |
252 | } | |
253 | ||
254 | void isis_area_del_circuit(struct isis_area *area, struct isis_circuit *circuit) | |
255 | { | |
256 | area->ip_circuits -= circuit->ip_router; | |
257 | area->ipv6_circuits -= circuit->ipv6_router; | |
258 | ||
259 | area->lfa_protected_links[0] -= circuit->lfa_protection[0]; | |
260 | area->rlfa_protected_links[0] -= circuit->rlfa_protection[0]; | |
261 | area->tilfa_protected_links[0] -= circuit->tilfa_protection[0]; | |
262 | ||
263 | area->lfa_protected_links[1] -= circuit->lfa_protection[1]; | |
264 | area->rlfa_protected_links[1] -= circuit->rlfa_protection[1]; | |
265 | area->tilfa_protected_links[1] -= circuit->tilfa_protection[1]; | |
266 | ||
267 | isis_csm_state_change(ISIS_DISABLE, circuit, area); | |
268 | } | |
269 | ||
1fa63850 OD |
270 | static void delete_area_addr(void *arg) |
271 | { | |
272 | struct area_addr *addr = (struct area_addr *)arg; | |
273 | ||
274 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
275 | } | |
276 | ||
eab88f36 | 277 | struct isis_area *isis_area_create(const char *area_tag, const char *vrf_name) |
d62a17ae | 278 | { |
279 | struct isis_area *area; | |
eab88f36 K |
280 | struct isis *isis = NULL; |
281 | struct vrf *vrf = NULL; | |
bcf22081 IR |
282 | struct interface *ifp; |
283 | struct isis_circuit *circuit; | |
284 | ||
d62a17ae | 285 | area = XCALLOC(MTYPE_ISIS_AREA, sizeof(struct isis_area)); |
286 | ||
bcf22081 IR |
287 | if (!vrf_name) |
288 | vrf_name = VRF_DEFAULT_NAME; | |
289 | ||
290 | vrf = vrf_lookup_by_name(vrf_name); | |
291 | isis = isis_lookup_by_vrfname(vrf_name); | |
292 | ||
293 | if (isis == NULL) | |
294 | isis = isis_new(vrf_name); | |
7b36d36e RW |
295 | |
296 | listnode_add(isis->area_list, area); | |
297 | area->isis = isis; | |
298 | ||
d62a17ae | 299 | /* |
65f18157 | 300 | * Fabricd runs only as level-2. |
26eb18e2 | 301 | * For IS-IS, the default is level-1-2 |
d62a17ae | 302 | */ |
26eb18e2 | 303 | if (fabricd) |
65f18157 | 304 | area->is_type = IS_LEVEL_2; |
cc50ddb2 EDP |
305 | else |
306 | area->is_type = yang_get_default_enum( | |
307 | "/frr-isisd:isis/instance/is-type"); | |
d62a17ae | 308 | |
309 | /* | |
310 | * intialize the databases | |
311 | */ | |
4bef0ec4 DL |
312 | if (area->is_type & IS_LEVEL_1) |
313 | lsp_db_init(&area->lspdb[0]); | |
314 | if (area->is_type & IS_LEVEL_2) | |
315 | lsp_db_init(&area->lspdb[1]); | |
d62a17ae | 316 | |
317 | spftree_area_init(area); | |
318 | ||
319 | area->circuit_list = list_new(); | |
75eddbc3 | 320 | area->adjacency_list = list_new(); |
d62a17ae | 321 | area->area_addrs = list_new(); |
1fa63850 OD |
322 | area->area_addrs->del = delete_area_addr; |
323 | ||
52a7c25e RW |
324 | if (!CHECK_FLAG(im->options, F_ISIS_UNIT_TEST)) |
325 | thread_add_timer(master, lsp_tick, area, 1, &area->t_tick); | |
d62a17ae | 326 | flags_initialize(&area->flags); |
327 | ||
26f6acaf RW |
328 | isis_sr_area_init(area); |
329 | ||
d62a17ae | 330 | /* |
331 | * Default values | |
332 | */ | |
cc50ddb2 EDP |
333 | #ifndef FABRICD |
334 | enum isis_metric_style default_style; | |
335 | ||
336 | area->max_lsp_lifetime[0] = yang_get_default_uint16( | |
d2c970ff | 337 | "/frr-isisd:isis/instance/lsp/timers/level-1/maximum-lifetime"); |
cc50ddb2 | 338 | area->max_lsp_lifetime[1] = yang_get_default_uint16( |
d2c970ff | 339 | "/frr-isisd:isis/instance/lsp/timers/level-2/maximum-lifetime"); |
cc50ddb2 | 340 | area->lsp_refresh[0] = yang_get_default_uint16( |
d2c970ff | 341 | "/frr-isisd:isis/instance/lsp/timers/level-1/refresh-interval"); |
cc50ddb2 | 342 | area->lsp_refresh[1] = yang_get_default_uint16( |
d2c970ff | 343 | "/frr-isisd:isis/instance/lsp/timers/level-2/refresh-interval"); |
cc50ddb2 | 344 | area->lsp_gen_interval[0] = yang_get_default_uint16( |
d2c970ff | 345 | "/frr-isisd:isis/instance/lsp/timers/level-1/generation-interval"); |
cc50ddb2 | 346 | area->lsp_gen_interval[1] = yang_get_default_uint16( |
d2c970ff | 347 | "/frr-isisd:isis/instance/lsp/timers/level-2/generation-interval"); |
cc50ddb2 EDP |
348 | area->min_spf_interval[0] = yang_get_default_uint16( |
349 | "/frr-isisd:isis/instance/spf/minimum-interval/level-1"); | |
350 | area->min_spf_interval[1] = yang_get_default_uint16( | |
351 | "/frr-isisd:isis/instance/spf/minimum-interval/level-1"); | |
352 | area->dynhostname = yang_get_default_bool( | |
353 | "/frr-isisd:isis/instance/dynamic-hostname"); | |
354 | default_style = | |
355 | yang_get_default_enum("/frr-isisd:isis/instance/metric-style"); | |
356 | area->oldmetric = default_style == ISIS_WIDE_METRIC ? 0 : 1; | |
357 | area->newmetric = default_style == ISIS_NARROW_METRIC ? 0 : 1; | |
358 | area->lsp_frag_threshold = 90; /* not currently configurable */ | |
359 | area->lsp_mtu = | |
360 | yang_get_default_uint16("/frr-isisd:isis/instance/lsp/mtu"); | |
e886416f RW |
361 | area->lfa_load_sharing[0] = yang_get_default_bool( |
362 | "/frr-isisd:isis/instance/fast-reroute/level-1/lfa/load-sharing"); | |
363 | area->lfa_load_sharing[1] = yang_get_default_bool( | |
364 | "/frr-isisd:isis/instance/fast-reroute/level-2/lfa/load-sharing"); | |
f3abc412 | 365 | area->attached_bit_send = |
366 | yang_get_default_bool("/frr-isisd:isis/instance/attach-send"); | |
367 | area->attached_bit_rcv_ignore = yang_get_default_bool( | |
368 | "/frr-isisd:isis/instance/attach-receive-ignore"); | |
369 | ||
cc50ddb2 | 370 | #else |
d62a17ae | 371 | area->max_lsp_lifetime[0] = DEFAULT_LSP_LIFETIME; /* 1200 */ |
372 | area->max_lsp_lifetime[1] = DEFAULT_LSP_LIFETIME; /* 1200 */ | |
373 | area->lsp_refresh[0] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */ | |
374 | area->lsp_refresh[1] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */ | |
375 | area->lsp_gen_interval[0] = DEFAULT_MIN_LSP_GEN_INTERVAL; | |
376 | area->lsp_gen_interval[1] = DEFAULT_MIN_LSP_GEN_INTERVAL; | |
377 | area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL; | |
378 | area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL; | |
379 | area->dynhostname = 1; | |
380 | area->oldmetric = 0; | |
381 | area->newmetric = 1; | |
382 | area->lsp_frag_threshold = 90; | |
383 | area->lsp_mtu = DEFAULT_LSP_MTU; | |
e886416f RW |
384 | area->lfa_load_sharing[0] = true; |
385 | area->lfa_load_sharing[1] = true; | |
f3abc412 | 386 | area->attached_bit_send = true; |
387 | area->attached_bit_rcv_ignore = false; | |
cc50ddb2 | 388 | #endif /* ifndef FABRICD */ |
e886416f RW |
389 | area->lfa_priority_limit[0] = SPF_PREFIX_PRIO_LOW; |
390 | area->lfa_priority_limit[1] = SPF_PREFIX_PRIO_LOW; | |
391 | isis_lfa_tiebreakers_init(area, ISIS_LEVEL1); | |
392 | isis_lfa_tiebreakers_init(area, ISIS_LEVEL2); | |
d62a17ae | 393 | |
394 | area_mt_init(area); | |
41b36e90 | 395 | |
d62a17ae | 396 | area->area_tag = strdup(area_tag); |
eab88f36 | 397 | |
8e6fb83b | 398 | if (fabricd) |
b30e837b | 399 | area->fabricd = fabricd_new(area); |
9196731f CF |
400 | |
401 | area->lsp_refresh_arg[0].area = area; | |
402 | area->lsp_refresh_arg[0].level = IS_LEVEL_1; | |
403 | area->lsp_refresh_arg[1].area = area; | |
404 | area->lsp_refresh_arg[1].level = IS_LEVEL_2; | |
405 | ||
690497fb G |
406 | area->bfd_signalled_down = false; |
407 | area->bfd_force_spf_refresh = false; | |
408 | ||
d62a17ae | 409 | QOBJ_REG(area, isis_area); |
eb5d44eb | 410 | |
bcf22081 IR |
411 | if (vrf) { |
412 | FOR_ALL_INTERFACES (vrf, ifp) { | |
413 | if (ifp->ifindex == IFINDEX_INTERNAL) | |
414 | continue; | |
415 | ||
416 | circuit = ifp->info; | |
6eadfc2d | 417 | if (circuit && strmatch(circuit->tag, area->area_tag)) |
bcf22081 IR |
418 | isis_area_add_circuit(area, circuit); |
419 | } | |
420 | } | |
421 | ||
d62a17ae | 422 | return area; |
423 | } | |
3f045a08 | 424 | |
65251ce8 | 425 | struct isis_area *isis_area_lookup_by_vrf(const char *area_tag, |
426 | const char *vrf_name) | |
427 | { | |
428 | struct isis_area *area; | |
429 | struct listnode *node; | |
430 | struct isis *isis = NULL; | |
431 | ||
432 | isis = isis_lookup_by_vrfname(vrf_name); | |
433 | if (isis == NULL) | |
434 | return NULL; | |
435 | ||
436 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) | |
437 | if (strcmp(area->area_tag, area_tag) == 0) | |
438 | return area; | |
439 | ||
440 | return NULL; | |
441 | } | |
442 | ||
eab88f36 | 443 | struct isis_area *isis_area_lookup(const char *area_tag, vrf_id_t vrf_id) |
d62a17ae | 444 | { |
445 | struct isis_area *area; | |
446 | struct listnode *node; | |
36944791 | 447 | struct isis *isis; |
eab88f36 K |
448 | |
449 | isis = isis_lookup_by_vrfid(vrf_id); | |
450 | if (isis == NULL) | |
451 | return NULL; | |
3f045a08 | 452 | |
d62a17ae | 453 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) |
454 | if ((area->area_tag == NULL && area_tag == NULL) | |
455 | || (area->area_tag && area_tag | |
456 | && strcmp(area->area_tag, area_tag) == 0)) | |
457 | return area; | |
3f045a08 | 458 | |
d62a17ae | 459 | return NULL; |
460 | } | |
3f045a08 | 461 | |
d62a17ae | 462 | int isis_area_get(struct vty *vty, const char *area_tag) |
463 | { | |
464 | struct isis_area *area; | |
5475ecf7 | 465 | |
eab88f36 | 466 | area = isis_area_lookup(area_tag, VRF_DEFAULT); |
03f7e182 | 467 | |
d62a17ae | 468 | if (area) { |
7c0cbd0e | 469 | VTY_PUSH_CONTEXT(ROUTER_NODE, area); |
d62a17ae | 470 | return CMD_SUCCESS; |
471 | } | |
472 | ||
eab88f36 | 473 | area = isis_area_create(area_tag, VRF_DEFAULT_NAME); |
3f045a08 | 474 | |
e740f9c1 | 475 | if (IS_DEBUG_EVENTS) |
d62a17ae | 476 | zlog_debug("New IS-IS area instance %s", area->area_tag); |
3f045a08 | 477 | |
7c0cbd0e | 478 | VTY_PUSH_CONTEXT(ROUTER_NODE, area); |
f3ccedaa | 479 | |
d62a17ae | 480 | return CMD_SUCCESS; |
481 | } | |
3f045a08 | 482 | |
14c6e772 | 483 | void isis_area_destroy(struct isis_area *area) |
eb5d44eb | 484 | { |
d62a17ae | 485 | struct listnode *node, *nnode; |
486 | struct isis_circuit *circuit; | |
eb5d44eb | 487 | |
d62a17ae | 488 | QOBJ_UNREG(area); |
489 | ||
b30e837b CF |
490 | if (fabricd) |
491 | fabricd_finish(area->fabricd); | |
492 | ||
d62a17ae | 493 | if (area->circuit_list) { |
494 | for (ALL_LIST_ELEMENTS(area->circuit_list, node, nnode, | |
bcf22081 IR |
495 | circuit)) |
496 | isis_area_del_circuit(area, circuit); | |
497 | ||
6a154c88 | 498 | list_delete(&area->circuit_list); |
d62a17ae | 499 | } |
1fa63850 OD |
500 | if (area->flags.free_idcs) |
501 | list_delete(&area->flags.free_idcs); | |
502 | ||
75eddbc3 | 503 | list_delete(&area->adjacency_list); |
d62a17ae | 504 | |
4bef0ec4 DL |
505 | lsp_db_fini(&area->lspdb[0]); |
506 | lsp_db_fini(&area->lspdb[1]); | |
d62a17ae | 507 | |
3dace42d | 508 | /* invalidate and verify to delete all routes from zebra */ |
688ea1cb | 509 | isis_area_invalidate_routes(area, area->is_type); |
3dace42d CF |
510 | isis_area_verify_routes(area); |
511 | ||
26f6acaf RW |
512 | isis_sr_area_term(area); |
513 | ||
1fa63850 OD |
514 | isis_mpls_te_term(area); |
515 | ||
d62a17ae | 516 | spftree_area_del(area); |
517 | ||
8f15843b DS |
518 | if (area->spf_timer[0]) |
519 | isis_spf_timer_free(THREAD_ARG(area->spf_timer[0])); | |
fa935aa7 | 520 | THREAD_OFF(area->spf_timer[0]); |
8f15843b DS |
521 | if (area->spf_timer[1]) |
522 | isis_spf_timer_free(THREAD_ARG(area->spf_timer[1])); | |
fa935aa7 | 523 | THREAD_OFF(area->spf_timer[1]); |
d62a17ae | 524 | |
525 | spf_backoff_free(area->spf_delay_ietf[0]); | |
526 | spf_backoff_free(area->spf_delay_ietf[1]); | |
527 | ||
52a7c25e RW |
528 | if (!CHECK_FLAG(im->options, F_ISIS_UNIT_TEST)) |
529 | isis_redist_area_finish(area); | |
d62a17ae | 530 | |
1fa63850 | 531 | list_delete(&area->area_addrs); |
d62a17ae | 532 | |
e886416f RW |
533 | for (int i = SPF_PREFIX_PRIO_CRITICAL; i <= SPF_PREFIX_PRIO_MEDIUM; |
534 | i++) { | |
535 | struct spf_prefix_priority_acl *ppa; | |
536 | ||
537 | ppa = &area->spf_prefix_priorities[i]; | |
538 | XFREE(MTYPE_ISIS_ACL_NAME, ppa->name); | |
539 | } | |
540 | isis_lfa_tiebreakers_clear(area, ISIS_LEVEL1); | |
541 | isis_lfa_tiebreakers_clear(area, ISIS_LEVEL2); | |
542 | ||
fa935aa7 DS |
543 | THREAD_OFF(area->t_tick); |
544 | THREAD_OFF(area->t_lsp_refresh[0]); | |
545 | THREAD_OFF(area->t_lsp_refresh[1]); | |
546 | THREAD_OFF(area->t_rlfa_rib_update); | |
d62a17ae | 547 | |
548 | thread_cancel_event(master, area); | |
549 | ||
eab88f36 | 550 | listnode_delete(area->isis->area_list, area); |
d62a17ae | 551 | |
552 | free(area->area_tag); | |
553 | ||
554 | area_mt_finish(area); | |
555 | ||
dcfe3c16 DS |
556 | if (area->rlfa_plist_name[0]) |
557 | XFREE(MTYPE_ISIS_PLIST_NAME, area->rlfa_plist_name[0]); | |
558 | if (area->rlfa_plist_name[1]) | |
559 | XFREE(MTYPE_ISIS_PLIST_NAME, area->rlfa_plist_name[1]); | |
560 | ||
d62a17ae | 561 | XFREE(MTYPE_ISIS_AREA, area); |
562 | ||
eab88f36 K |
563 | } |
564 | ||
65251ce8 | 565 | /* This is hook function for vrf create called as part of vrf_init */ |
566 | static int isis_vrf_new(struct vrf *vrf) | |
567 | { | |
568 | if (IS_DEBUG_EVENTS) | |
569 | zlog_debug("%s: VRF Created: %s(%u)", __func__, vrf->name, | |
570 | vrf->vrf_id); | |
571 | ||
572 | return 0; | |
573 | } | |
574 | ||
575 | /* This is hook function for vrf delete call as part of vrf_init */ | |
576 | static int isis_vrf_delete(struct vrf *vrf) | |
577 | { | |
578 | if (IS_DEBUG_EVENTS) | |
579 | zlog_debug("%s: VRF Deletion: %s(%u)", __func__, vrf->name, | |
580 | vrf->vrf_id); | |
581 | ||
582 | return 0; | |
583 | } | |
584 | ||
8c6482db IR |
585 | static void isis_set_redist_vrf_bitmaps(struct isis *isis, bool set) |
586 | { | |
587 | struct listnode *node; | |
588 | struct isis_area *area; | |
589 | int type; | |
590 | int level; | |
591 | int protocol; | |
592 | ||
593 | char do_subscribe[REDIST_PROTOCOL_COUNT][ZEBRA_ROUTE_MAX + 1]; | |
594 | ||
595 | memset(do_subscribe, 0, sizeof(do_subscribe)); | |
596 | ||
597 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) | |
598 | for (protocol = 0; protocol < REDIST_PROTOCOL_COUNT; protocol++) | |
599 | for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++) | |
600 | for (level = 0; level < ISIS_LEVELS; level++) | |
601 | if (area->redist_settings[protocol] | |
602 | [type][level] | |
603 | .redist | |
604 | == 1) | |
605 | do_subscribe[protocol][type] = | |
606 | 1; | |
607 | ||
608 | for (protocol = 0; protocol < REDIST_PROTOCOL_COUNT; protocol++) | |
609 | for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++) { | |
610 | /* This field is actually controlling transmission of | |
611 | * the IS-IS | |
612 | * routes to Zebra and has nothing to do with | |
613 | * redistribution, | |
614 | * so skip it. */ | |
615 | if (type == PROTO_TYPE) | |
616 | continue; | |
617 | ||
618 | if (!do_subscribe[protocol][type]) | |
619 | continue; | |
620 | ||
621 | afi_t afi = afi_for_redist_protocol(protocol); | |
622 | ||
623 | if (type == DEFAULT_ROUTE) { | |
624 | if (set) | |
625 | vrf_bitmap_set( | |
626 | zclient->default_information | |
627 | [afi], | |
628 | isis->vrf_id); | |
629 | else | |
630 | vrf_bitmap_unset( | |
631 | zclient->default_information | |
632 | [afi], | |
633 | isis->vrf_id); | |
634 | } else { | |
635 | if (set) | |
636 | vrf_bitmap_set( | |
637 | zclient->redist[afi][type], | |
638 | isis->vrf_id); | |
639 | else | |
640 | vrf_bitmap_unset( | |
641 | zclient->redist[afi][type], | |
642 | isis->vrf_id); | |
643 | } | |
644 | } | |
645 | } | |
646 | ||
65251ce8 | 647 | static int isis_vrf_enable(struct vrf *vrf) |
648 | { | |
649 | struct isis *isis; | |
650 | vrf_id_t old_vrf_id; | |
651 | ||
652 | if (IS_DEBUG_EVENTS) | |
653 | zlog_debug("%s: VRF %s id %u enabled", __func__, vrf->name, | |
654 | vrf->vrf_id); | |
655 | ||
656 | isis = isis_lookup_by_vrfname(vrf->name); | |
29263027 | 657 | if (isis && isis->vrf_id != vrf->vrf_id) { |
65251ce8 | 658 | old_vrf_id = isis->vrf_id; |
659 | /* We have instance configured, link to VRF and make it "up". */ | |
660 | isis_vrf_link(isis, vrf); | |
661 | if (IS_DEBUG_EVENTS) | |
662 | zlog_debug( | |
663 | "%s: isis linked to vrf %s vrf_id %u (old id %u)", | |
664 | __func__, vrf->name, isis->vrf_id, old_vrf_id); | |
29263027 PG |
665 | /* start zebra redist to us for new vrf */ |
666 | isis_set_redist_vrf_bitmaps(isis, true); | |
8c6482db | 667 | |
29263027 | 668 | isis_zebra_vrf_register(isis); |
65251ce8 | 669 | } |
670 | ||
671 | return 0; | |
672 | } | |
673 | ||
674 | static int isis_vrf_disable(struct vrf *vrf) | |
675 | { | |
676 | struct isis *isis; | |
677 | vrf_id_t old_vrf_id = VRF_UNKNOWN; | |
678 | ||
679 | if (vrf->vrf_id == VRF_DEFAULT) | |
680 | return 0; | |
681 | ||
682 | if (IS_DEBUG_EVENTS) | |
683 | zlog_debug("%s: VRF %s id %d disabled.", __func__, vrf->name, | |
684 | vrf->vrf_id); | |
685 | isis = isis_lookup_by_vrfname(vrf->name); | |
686 | if (isis) { | |
687 | old_vrf_id = isis->vrf_id; | |
688 | ||
164ab896 IR |
689 | isis_zebra_vrf_deregister(isis); |
690 | ||
8c6482db IR |
691 | isis_set_redist_vrf_bitmaps(isis, false); |
692 | ||
65251ce8 | 693 | /* We have instance configured, unlink |
694 | * from VRF and make it "down". | |
695 | */ | |
696 | isis_vrf_unlink(isis, vrf); | |
697 | if (IS_DEBUG_EVENTS) | |
698 | zlog_debug("%s: isis old_vrf_id %d unlinked", __func__, | |
699 | old_vrf_id); | |
700 | } | |
701 | ||
702 | return 0; | |
703 | } | |
704 | ||
705 | void isis_vrf_init(void) | |
706 | { | |
707 | vrf_init(isis_vrf_new, isis_vrf_enable, isis_vrf_disable, | |
ac2cb9bf | 708 | isis_vrf_delete); |
f5eef2d5 | 709 | |
cfc369c4 | 710 | vrf_cmd_init(NULL); |
65251ce8 | 711 | } |
712 | ||
103372fd | 713 | void isis_terminate(void) |
eab88f36 | 714 | { |
36944791 | 715 | struct isis *isis; |
eab88f36 K |
716 | struct listnode *node, *nnode; |
717 | ||
13bf3830 IR |
718 | bfd_protocol_integration_set_shutdown(true); |
719 | ||
eab88f36 K |
720 | if (listcount(im->isis) == 0) |
721 | return; | |
722 | ||
723 | for (ALL_LIST_ELEMENTS(im->isis, node, nnode, isis)) | |
724 | isis_finish(isis); | |
d62a17ae | 725 | } |
726 | ||
e886416f RW |
727 | void isis_filter_update(struct access_list *access) |
728 | { | |
729 | struct isis *isis; | |
730 | struct isis_area *area; | |
731 | struct listnode *node, *anode; | |
732 | ||
733 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { | |
734 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { | |
735 | for (int i = SPF_PREFIX_PRIO_CRITICAL; | |
736 | i <= SPF_PREFIX_PRIO_MEDIUM; i++) { | |
737 | struct spf_prefix_priority_acl *ppa; | |
738 | ||
739 | ppa = &area->spf_prefix_priorities[i]; | |
740 | ppa->list_v4 = | |
741 | access_list_lookup(AFI_IP, ppa->name); | |
742 | ppa->list_v6 = | |
743 | access_list_lookup(AFI_IP6, ppa->name); | |
744 | } | |
745 | lsp_regenerate_schedule(area, area->is_type, 0); | |
746 | } | |
747 | } | |
748 | } | |
749 | ||
16fe8cff RW |
750 | void isis_prefix_list_update(struct prefix_list *plist) |
751 | { | |
752 | struct isis *isis; | |
753 | struct isis_area *area; | |
754 | struct listnode *node, *anode; | |
755 | ||
756 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { | |
757 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { | |
758 | for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; | |
759 | level++) { | |
760 | const char *plist_name = | |
761 | prefix_list_name(plist); | |
762 | ||
763 | if (!area->rlfa_plist_name[level - 1]) | |
764 | continue; | |
765 | ||
766 | if (!strmatch(area->rlfa_plist_name[level - 1], | |
767 | plist_name)) | |
768 | continue; | |
769 | ||
770 | area->rlfa_plist[level - 1] = | |
771 | prefix_list_lookup(AFI_IP, plist_name); | |
772 | lsp_regenerate_schedule(area, area->is_type, 0); | |
773 | } | |
774 | } | |
775 | } | |
776 | } | |
777 | ||
22af6a80 | 778 | #ifdef FABRICD |
d62a17ae | 779 | static void area_set_mt_enabled(struct isis_area *area, uint16_t mtid, |
780 | bool enabled) | |
781 | { | |
782 | struct isis_area_mt_setting *setting; | |
783 | ||
784 | setting = area_get_mt_setting(area, mtid); | |
785 | if (setting->enabled != enabled) { | |
786 | setting->enabled = enabled; | |
787 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
788 | } | |
789 | } | |
790 | ||
791 | static void area_set_mt_overload(struct isis_area *area, uint16_t mtid, | |
792 | bool overload) | |
793 | { | |
794 | struct isis_area_mt_setting *setting; | |
795 | ||
796 | setting = area_get_mt_setting(area, mtid); | |
797 | if (setting->overload != overload) { | |
798 | setting->overload = overload; | |
799 | if (setting->enabled) | |
800 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, | |
801 | 0); | |
802 | } | |
803 | } | |
22af6a80 | 804 | #endif /* ifdef FABRICD */ |
d62a17ae | 805 | |
806 | int area_net_title(struct vty *vty, const char *net_title) | |
807 | { | |
808 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
809 | struct area_addr *addr; | |
810 | struct area_addr *addrp; | |
811 | struct listnode *node; | |
eb5d44eb | 812 | |
d7c0a89a | 813 | uint8_t buff[255]; |
d62a17ae | 814 | |
815 | /* We check that we are not over the maximal number of addresses */ | |
eab88f36 | 816 | if (listcount(area->area_addrs) >= area->isis->max_area_addrs) { |
d62a17ae | 817 | vty_out(vty, |
818 | "Maximum of area addresses (%d) already reached \n", | |
eab88f36 | 819 | area->isis->max_area_addrs); |
d62a17ae | 820 | return CMD_ERR_NOTHING_TODO; |
821 | } | |
822 | ||
823 | addr = XMALLOC(MTYPE_ISIS_AREA_ADDR, sizeof(struct area_addr)); | |
824 | addr->addr_len = dotformat2buff(buff, net_title); | |
825 | memcpy(addr->area_addr, buff, addr->addr_len); | |
eb5d44eb | 826 | #ifdef EXTREME_DEBUG |
d62a17ae | 827 | zlog_debug("added area address %s for area %s (address length %d)", |
828 | net_title, area->area_tag, addr->addr_len); | |
eb5d44eb | 829 | #endif /* EXTREME_DEBUG */ |
d62a17ae | 830 | if (addr->addr_len < 8 || addr->addr_len > 20) { |
831 | vty_out(vty, | |
832 | "area address must be at least 8..20 octets long (%d)\n", | |
833 | addr->addr_len); | |
834 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
a5fdb4c5 | 835 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 836 | } |
837 | ||
838 | if (addr->area_addr[addr->addr_len - 1] != 0) { | |
839 | vty_out(vty, | |
840 | "nsel byte (last byte) in area address must be 0\n"); | |
841 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
a5fdb4c5 | 842 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 843 | } |
844 | ||
eab88f36 | 845 | if (area->isis->sysid_set == 0) { |
d62a17ae | 846 | /* |
847 | * First area address - get the SystemID for this router | |
848 | */ | |
eab88f36 K |
849 | memcpy(area->isis->sysid, GETSYSID(addr), ISIS_SYS_ID_LEN); |
850 | area->isis->sysid_set = 1; | |
e740f9c1 | 851 | if (IS_DEBUG_EVENTS) |
d62a17ae | 852 | zlog_debug("Router has SystemID %s", |
eab88f36 | 853 | sysid_print(area->isis->sysid)); |
d62a17ae | 854 | } else { |
855 | /* | |
856 | * Check that the SystemID portions match | |
857 | */ | |
eab88f36 K |
858 | if (memcmp(area->isis->sysid, GETSYSID(addr), |
859 | ISIS_SYS_ID_LEN)) { | |
d62a17ae | 860 | vty_out(vty, |
861 | "System ID must not change when defining additional area addresses\n"); | |
862 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
a5fdb4c5 | 863 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 864 | } |
865 | ||
866 | /* now we see that we don't already have this address */ | |
867 | for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) { | |
868 | if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) | |
869 | != (addr->addr_len)) | |
870 | continue; | |
871 | if (!memcmp(addrp->area_addr, addr->area_addr, | |
872 | addr->addr_len)) { | |
873 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
874 | return CMD_SUCCESS; /* silent fail */ | |
875 | } | |
876 | } | |
877 | } | |
878 | ||
879 | /* | |
880 | * Forget the systemID part of the address | |
881 | */ | |
882 | addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN); | |
883 | listnode_add(area->area_addrs, addr); | |
884 | ||
885 | /* only now we can safely generate our LSPs for this area */ | |
886 | if (listcount(area->area_addrs) > 0) { | |
887 | if (area->is_type & IS_LEVEL_1) | |
888 | lsp_generate(area, IS_LEVEL_1); | |
889 | if (area->is_type & IS_LEVEL_2) | |
890 | lsp_generate(area, IS_LEVEL_2); | |
891 | } | |
892 | ||
893 | return CMD_SUCCESS; | |
894 | } | |
895 | ||
896 | int area_clear_net_title(struct vty *vty, const char *net_title) | |
897 | { | |
898 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
899 | struct area_addr addr, *addrp = NULL; | |
900 | struct listnode *node; | |
d7c0a89a | 901 | uint8_t buff[255]; |
d62a17ae | 902 | |
903 | addr.addr_len = dotformat2buff(buff, net_title); | |
904 | if (addr.addr_len < 8 || addr.addr_len > 20) { | |
905 | vty_out(vty, | |
906 | "Unsupported area address length %d, should be 8...20 \n", | |
907 | addr.addr_len); | |
a5fdb4c5 | 908 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 909 | } |
910 | ||
911 | memcpy(addr.area_addr, buff, (int)addr.addr_len); | |
912 | ||
913 | for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) | |
914 | if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len | |
915 | && !memcmp(addrp->area_addr, addr.area_addr, addr.addr_len)) | |
916 | break; | |
917 | ||
918 | if (!addrp) { | |
919 | vty_out(vty, "No area address %s for area %s \n", net_title, | |
920 | area->area_tag); | |
921 | return CMD_ERR_NO_MATCH; | |
922 | } | |
923 | ||
924 | listnode_delete(area->area_addrs, addrp); | |
925 | XFREE(MTYPE_ISIS_AREA_ADDR, addrp); | |
926 | ||
927 | /* | |
928 | * Last area address - reset the SystemID for this router | |
929 | */ | |
930 | if (listcount(area->area_addrs) == 0) { | |
eab88f36 K |
931 | memset(area->isis->sysid, 0, ISIS_SYS_ID_LEN); |
932 | area->isis->sysid_set = 0; | |
e740f9c1 | 933 | if (IS_DEBUG_EVENTS) |
d62a17ae | 934 | zlog_debug("Router has no SystemID"); |
935 | } | |
936 | ||
937 | return CMD_SUCCESS; | |
eb5d44eb | 938 | } |
939 | ||
eb5d44eb | 940 | /* |
3f045a08 | 941 | * 'show isis interface' command |
eb5d44eb | 942 | */ |
9fee4d4c JG |
943 | int show_isis_interface_common(struct vty *vty, struct json_object *json, |
944 | const char *ifname, char detail, | |
eab88f36 | 945 | const char *vrf_name, bool all_vrf) |
9fee4d4c JG |
946 | { |
947 | if (json) { | |
948 | return show_isis_interface_common_json(json, ifname, detail, | |
949 | vrf_name, all_vrf); | |
950 | } else { | |
951 | return show_isis_interface_common_vty(vty, ifname, detail, | |
952 | vrf_name, all_vrf); | |
953 | } | |
954 | } | |
955 | ||
956 | int show_isis_interface_common_json(struct json_object *json, | |
957 | const char *ifname, char detail, | |
958 | const char *vrf_name, bool all_vrf) | |
959 | { | |
960 | struct listnode *anode, *cnode, *inode; | |
961 | struct isis_area *area; | |
962 | struct isis_circuit *circuit; | |
963 | struct isis *isis; | |
964 | struct json_object *areas_json, *area_json; | |
a21177f2 | 965 | struct json_object *circuits_json, *circuit_json; |
9fee4d4c JG |
966 | if (!im) { |
967 | // IS-IS Routing Process not enabled | |
968 | json_object_string_add(json, "is-is-routing-process-enabled", | |
969 | "no"); | |
970 | return CMD_SUCCESS; | |
971 | } | |
972 | if (vrf_name) { | |
973 | if (all_vrf) { | |
974 | for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { | |
975 | areas_json = json_object_new_array(); | |
976 | json_object_object_add(json, "areas", | |
977 | areas_json); | |
978 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, | |
979 | anode, area)) { | |
980 | area_json = json_object_new_object(); | |
981 | json_object_string_add( | |
982 | area_json, "area", | |
983 | area->area_tag ? area->area_tag | |
984 | : "null"); | |
a21177f2 JG |
985 | circuits_json = json_object_new_array(); |
986 | json_object_object_add(area_json, | |
987 | "circuits", | |
988 | circuits_json); | |
9fee4d4c JG |
989 | for (ALL_LIST_ELEMENTS_RO( |
990 | area->circuit_list, cnode, | |
a21177f2 JG |
991 | circuit)) { |
992 | circuit_json = | |
993 | json_object_new_object(); | |
994 | json_object_int_add( | |
995 | circuit_json, "circuit", | |
996 | circuit->circuit_id); | |
9fee4d4c JG |
997 | if (!ifname) |
998 | isis_circuit_print_json( | |
999 | circuit, | |
a21177f2 | 1000 | circuit_json, |
9fee4d4c JG |
1001 | detail); |
1002 | else if (strcmp(circuit->interface->name, ifname) == 0) | |
1003 | isis_circuit_print_json( | |
1004 | circuit, | |
a21177f2 | 1005 | circuit_json, |
9fee4d4c | 1006 | detail); |
a21177f2 JG |
1007 | json_object_array_add( |
1008 | circuits_json, | |
1009 | circuit_json); | |
1010 | } | |
9fee4d4c JG |
1011 | json_object_array_add(areas_json, |
1012 | area_json); | |
1013 | } | |
1014 | } | |
1015 | return CMD_SUCCESS; | |
1016 | } | |
1017 | isis = isis_lookup_by_vrfname(vrf_name); | |
1018 | if (isis != NULL) { | |
1019 | areas_json = json_object_new_array(); | |
1020 | json_object_object_add(json, "areas", areas_json); | |
1021 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, | |
1022 | area)) { | |
1023 | area_json = json_object_new_object(); | |
1024 | json_object_string_add(area_json, "area", | |
1025 | area->area_tag | |
1026 | ? area->area_tag | |
1027 | : "null"); | |
1028 | ||
a21177f2 JG |
1029 | circuits_json = json_object_new_array(); |
1030 | json_object_object_add(area_json, "circuits", | |
1031 | circuits_json); | |
9fee4d4c | 1032 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, |
a21177f2 JG |
1033 | cnode, circuit)) { |
1034 | circuit_json = json_object_new_object(); | |
1035 | json_object_int_add( | |
1036 | circuit_json, "circuit", | |
1037 | circuit->circuit_id); | |
9fee4d4c JG |
1038 | if (!ifname) |
1039 | isis_circuit_print_json( | |
a21177f2 | 1040 | circuit, circuit_json, |
9fee4d4c JG |
1041 | detail); |
1042 | else if ( | |
1043 | strcmp(circuit->interface->name, | |
1044 | ifname) == 0) | |
1045 | isis_circuit_print_json( | |
a21177f2 | 1046 | circuit, circuit_json, |
9fee4d4c | 1047 | detail); |
a21177f2 JG |
1048 | json_object_array_add(circuits_json, |
1049 | circuit_json); | |
1050 | } | |
9fee4d4c JG |
1051 | json_object_array_add(areas_json, area_json); |
1052 | } | |
1053 | } | |
1054 | } | |
1055 | return CMD_SUCCESS; | |
1056 | } | |
1057 | ||
1058 | int show_isis_interface_common_vty(struct vty *vty, const char *ifname, | |
1059 | char detail, const char *vrf_name, | |
1060 | bool all_vrf) | |
eb5d44eb | 1061 | { |
36944791 | 1062 | struct listnode *anode, *cnode, *inode; |
d62a17ae | 1063 | struct isis_area *area; |
1064 | struct isis_circuit *circuit; | |
36944791 | 1065 | struct isis *isis; |
eb5d44eb | 1066 | |
eab88f36 | 1067 | if (!im) { |
d62a17ae | 1068 | vty_out(vty, "IS-IS Routing Process not enabled\n"); |
1069 | return CMD_SUCCESS; | |
1070 | } | |
eab88f36 K |
1071 | if (vrf_name) { |
1072 | if (all_vrf) { | |
36944791 | 1073 | for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { |
eab88f36 K |
1074 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, |
1075 | anode, area)) { | |
1076 | vty_out(vty, "Area %s:\n", | |
1077 | area->area_tag); | |
1078 | ||
1079 | if (detail == ISIS_UI_LEVEL_BRIEF) | |
1080 | vty_out(vty, | |
1081 | " Interface CircId State Type Level\n"); | |
1082 | ||
1083 | for (ALL_LIST_ELEMENTS_RO( | |
1084 | area->circuit_list, cnode, | |
1085 | circuit)) | |
1086 | if (!ifname) | |
1087 | isis_circuit_print_vty( | |
1088 | circuit, vty, | |
1089 | detail); | |
1090 | else if (strcmp(circuit->interface->name, ifname) == 0) | |
1091 | isis_circuit_print_vty( | |
1092 | circuit, vty, | |
1093 | detail); | |
1094 | } | |
1095 | } | |
36944791 | 1096 | return CMD_SUCCESS; |
eab88f36 K |
1097 | } |
1098 | isis = isis_lookup_by_vrfname(vrf_name); | |
1099 | if (isis != NULL) { | |
1100 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, | |
1101 | area)) { | |
1102 | vty_out(vty, "Area %s:\n", area->area_tag); | |
eb5d44eb | 1103 | |
eab88f36 K |
1104 | if (detail == ISIS_UI_LEVEL_BRIEF) |
1105 | vty_out(vty, | |
1106 | " Interface CircId State Type Level\n"); | |
1107 | ||
1108 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, | |
1109 | cnode, circuit)) | |
1110 | if (!ifname) | |
1111 | isis_circuit_print_vty( | |
1112 | circuit, vty, detail); | |
1113 | else if ( | |
1114 | strcmp(circuit->interface->name, | |
9fee4d4c | 1115 | ifname) == 0) |
eab88f36 K |
1116 | isis_circuit_print_vty( |
1117 | circuit, vty, detail); | |
1118 | } | |
1119 | } | |
d62a17ae | 1120 | } |
f390d2c7 | 1121 | |
d62a17ae | 1122 | return CMD_SUCCESS; |
eb5d44eb | 1123 | } |
1124 | ||
eab88f36 K |
1125 | DEFUN(show_isis_interface, |
1126 | show_isis_interface_cmd, | |
9fee4d4c | 1127 | "show " PROTO_NAME " [vrf <NAME|all>] interface [json]", |
eab88f36 K |
1128 | SHOW_STR |
1129 | PROTO_HELP | |
1130 | VRF_CMD_HELP_STR | |
1131 | "All VRFs\n" | |
9fee4d4c | 1132 | "json output\n" |
eab88f36 | 1133 | "IS-IS interface\n") |
eb5d44eb | 1134 | { |
9fee4d4c | 1135 | int res = CMD_SUCCESS; |
eab88f36 K |
1136 | const char *vrf_name = VRF_DEFAULT_NAME; |
1137 | bool all_vrf = false; | |
1138 | int idx_vrf = 0; | |
9fee4d4c JG |
1139 | bool uj = use_json(argc, argv); |
1140 | json_object *json = NULL; | |
eab88f36 K |
1141 | |
1142 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
9fee4d4c JG |
1143 | if (uj) |
1144 | json = json_object_new_object(); | |
1145 | res = show_isis_interface_common(vty, json, NULL, ISIS_UI_LEVEL_BRIEF, | |
1146 | vrf_name, all_vrf); | |
1147 | if (uj) | |
1148 | vty_json(vty, json); | |
1149 | return res; | |
eb5d44eb | 1150 | } |
1151 | ||
eab88f36 K |
1152 | DEFUN(show_isis_interface_detail, |
1153 | show_isis_interface_detail_cmd, | |
9fee4d4c | 1154 | "show " PROTO_NAME " [vrf <NAME|all>] interface detail [json]", |
eab88f36 K |
1155 | SHOW_STR |
1156 | PROTO_HELP | |
1157 | VRF_CMD_HELP_STR | |
1158 | "All VRFs\n" | |
1159 | "IS-IS interface\n" | |
9fee4d4c JG |
1160 | "show detailed information\n" |
1161 | "json output\n") | |
3f045a08 | 1162 | { |
9fee4d4c | 1163 | int res = CMD_SUCCESS; |
eab88f36 K |
1164 | const char *vrf_name = VRF_DEFAULT_NAME; |
1165 | bool all_vrf = false; | |
1166 | int idx_vrf = 0; | |
9fee4d4c JG |
1167 | bool uj = use_json(argc, argv); |
1168 | json_object *json = NULL; | |
eab88f36 K |
1169 | |
1170 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
9fee4d4c JG |
1171 | if (uj) |
1172 | json = json_object_new_object(); | |
1173 | res = show_isis_interface_common(vty, json, NULL, ISIS_UI_LEVEL_DETAIL, | |
1174 | vrf_name, all_vrf); | |
1175 | if (uj) | |
1176 | vty_json(vty, json); | |
1177 | return res; | |
3f045a08 | 1178 | } |
eb5d44eb | 1179 | |
eab88f36 K |
1180 | DEFUN(show_isis_interface_arg, |
1181 | show_isis_interface_arg_cmd, | |
9fee4d4c | 1182 | "show " PROTO_NAME " [vrf <NAME|all>] interface WORD [json]", |
eab88f36 K |
1183 | SHOW_STR |
1184 | PROTO_HELP | |
1185 | VRF_CMD_HELP_STR | |
1186 | "All VRFs\n" | |
1187 | "IS-IS interface\n" | |
9fee4d4c JG |
1188 | "IS-IS interface name\n" |
1189 | "json output\n") | |
3f045a08 | 1190 | { |
9fee4d4c | 1191 | int res = CMD_SUCCESS; |
eab88f36 K |
1192 | int idx_word = 0; |
1193 | const char *vrf_name = VRF_DEFAULT_NAME; | |
1194 | bool all_vrf = false; | |
1195 | int idx_vrf = 0; | |
9fee4d4c JG |
1196 | bool uj = use_json(argc, argv); |
1197 | json_object *json = NULL; | |
3f045a08 | 1198 | |
eab88f36 | 1199 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
9fee4d4c JG |
1200 | if (uj) |
1201 | json = json_object_new_object(); | |
eab88f36 K |
1202 | |
1203 | char *ifname = argv_find(argv, argc, "WORD", &idx_word) | |
1204 | ? argv[idx_word]->arg | |
1205 | : NULL; | |
9fee4d4c JG |
1206 | res = show_isis_interface_common( |
1207 | vty, json, ifname, ISIS_UI_LEVEL_DETAIL, vrf_name, all_vrf); | |
1208 | if (uj) | |
1209 | vty_json(vty, json); | |
1210 | return res; | |
eab88f36 | 1211 | } |
3f045a08 | 1212 | |
240f48b3 IR |
1213 | static int id_to_sysid(struct isis *isis, const char *id, uint8_t *sysid) |
1214 | { | |
1215 | struct isis_dynhn *dynhn; | |
1216 | ||
1217 | memset(sysid, 0, ISIS_SYS_ID_LEN); | |
1218 | if (id) { | |
1219 | if (sysid2buff(sysid, id) == 0) { | |
1220 | dynhn = dynhn_find_by_name(isis, id); | |
1221 | if (dynhn == NULL) | |
1222 | return -1; | |
1223 | memcpy(sysid, dynhn->id, ISIS_SYS_ID_LEN); | |
1224 | } | |
1225 | } | |
1226 | ||
1227 | return 0; | |
1228 | } | |
1229 | ||
a21177f2 JG |
1230 | static void isis_neighbor_common_json(struct json_object *json, const char *id, |
1231 | char detail, struct isis *isis, | |
1232 | uint8_t *sysid) | |
1233 | { | |
1234 | struct listnode *anode, *cnode, *node; | |
1235 | struct isis_area *area; | |
1236 | struct isis_circuit *circuit; | |
1237 | struct list *adjdb; | |
1238 | struct isis_adjacency *adj; | |
1239 | struct json_object *areas_json, *area_json; | |
1240 | struct json_object *circuits_json, *circuit_json; | |
1241 | int i; | |
1242 | ||
1243 | areas_json = json_object_new_array(); | |
1244 | json_object_object_add(json, "areas", areas_json); | |
1245 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { | |
1246 | area_json = json_object_new_object(); | |
1247 | json_object_string_add(area_json, "area", | |
1248 | area->area_tag ? area->area_tag | |
1249 | : "null"); | |
1250 | circuits_json = json_object_new_array(); | |
1251 | json_object_object_add(area_json, "circuits", circuits_json); | |
1252 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) { | |
1253 | circuit_json = json_object_new_object(); | |
1254 | json_object_int_add(circuit_json, "circuit", | |
1255 | circuit->circuit_id); | |
1256 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { | |
1257 | for (i = 0; i < 2; i++) { | |
1258 | adjdb = circuit->u.bc.adjdb[i]; | |
1259 | if (adjdb && adjdb->count) { | |
1260 | for (ALL_LIST_ELEMENTS_RO( | |
1261 | adjdb, node, adj)) | |
1262 | if (!id || | |
1263 | !memcmp(adj->sysid, | |
1264 | sysid, | |
1265 | ISIS_SYS_ID_LEN)) | |
1266 | isis_adj_print_json( | |
1267 | adj, | |
1268 | circuit_json, | |
1269 | detail); | |
1270 | } | |
1271 | } | |
1272 | } else if (circuit->circ_type == CIRCUIT_T_P2P && | |
1273 | circuit->u.p2p.neighbor) { | |
1274 | adj = circuit->u.p2p.neighbor; | |
1275 | if (!id || | |
1276 | !memcmp(adj->sysid, sysid, ISIS_SYS_ID_LEN)) | |
1277 | isis_adj_print_json(adj, circuit_json, | |
1278 | detail); | |
1279 | } | |
1280 | json_object_array_add(circuits_json, circuit_json); | |
1281 | } | |
1282 | json_object_array_add(areas_json, area_json); | |
1283 | } | |
1284 | } | |
1285 | ||
1286 | static void isis_neighbor_common_vty(struct vty *vty, const char *id, | |
1287 | char detail, struct isis *isis, | |
1288 | uint8_t *sysid) | |
d62a17ae | 1289 | { |
1290 | struct listnode *anode, *cnode, *node; | |
1291 | struct isis_area *area; | |
1292 | struct isis_circuit *circuit; | |
1293 | struct list *adjdb; | |
1294 | struct isis_adjacency *adj; | |
d62a17ae | 1295 | int i; |
1296 | ||
d62a17ae | 1297 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { |
1298 | vty_out(vty, "Area %s:\n", area->area_tag); | |
1299 | ||
1300 | if (detail == ISIS_UI_LEVEL_BRIEF) | |
1301 | vty_out(vty, | |
1302 | " System Id Interface L State Holdtime SNPA\n"); | |
1303 | ||
1304 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) { | |
1305 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { | |
1306 | for (i = 0; i < 2; i++) { | |
1307 | adjdb = circuit->u.bc.adjdb[i]; | |
1308 | if (adjdb && adjdb->count) { | |
1309 | for (ALL_LIST_ELEMENTS_RO( | |
1310 | adjdb, node, adj)) | |
a21177f2 JG |
1311 | if (!id || |
1312 | !memcmp(adj->sysid, | |
eab88f36 K |
1313 | sysid, |
1314 | ISIS_SYS_ID_LEN)) | |
d62a17ae | 1315 | isis_adj_print_vty( |
1316 | adj, | |
1317 | vty, | |
1318 | detail); | |
1319 | } | |
1320 | } | |
a21177f2 JG |
1321 | } else if (circuit->circ_type == CIRCUIT_T_P2P && |
1322 | circuit->u.p2p.neighbor) { | |
d62a17ae | 1323 | adj = circuit->u.p2p.neighbor; |
a21177f2 JG |
1324 | if (!id || |
1325 | !memcmp(adj->sysid, sysid, ISIS_SYS_ID_LEN)) | |
d62a17ae | 1326 | isis_adj_print_vty(adj, vty, detail); |
1327 | } | |
1328 | } | |
1329 | } | |
a21177f2 | 1330 | } |
d62a17ae | 1331 | |
a21177f2 JG |
1332 | static void isis_neighbor_common(struct vty *vty, struct json_object *json, |
1333 | const char *id, char detail, struct isis *isis, | |
1334 | uint8_t *sysid) | |
1335 | { | |
1336 | if (json) { | |
1337 | isis_neighbor_common_json(json, id, detail,isis,sysid); | |
1338 | } else { | |
1339 | isis_neighbor_common_vty(vty, id, detail,isis,sysid); | |
1340 | } | |
3f045a08 | 1341 | } |
a21177f2 | 1342 | |
3f045a08 | 1343 | /* |
eab88f36 | 1344 | * 'show isis neighbor' command |
3f045a08 | 1345 | */ |
eab88f36 | 1346 | |
a21177f2 JG |
1347 | int show_isis_neighbor_common(struct vty *vty, struct json_object *json, |
1348 | const char *id, char detail, const char *vrf_name, | |
1349 | bool all_vrf) | |
d62a17ae | 1350 | { |
36944791 | 1351 | struct listnode *node; |
d7c0a89a | 1352 | uint8_t sysid[ISIS_SYS_ID_LEN]; |
36944791 | 1353 | struct isis *isis; |
d62a17ae | 1354 | |
eab88f36 | 1355 | if (!im) { |
d62a17ae | 1356 | vty_out(vty, "IS-IS Routing Process not enabled\n"); |
1357 | return CMD_SUCCESS; | |
1358 | } | |
1359 | ||
eab88f36 K |
1360 | if (vrf_name) { |
1361 | if (all_vrf) { | |
36944791 | 1362 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { |
240f48b3 IR |
1363 | if (id_to_sysid(isis, id, sysid)) { |
1364 | vty_out(vty, "Invalid system id %s\n", | |
1365 | id); | |
1366 | return CMD_SUCCESS; | |
1367 | } | |
a21177f2 JG |
1368 | isis_neighbor_common(vty, json, id, detail, |
1369 | isis, sysid); | |
eab88f36 | 1370 | } |
36944791 | 1371 | return CMD_SUCCESS; |
eab88f36 K |
1372 | } |
1373 | isis = isis_lookup_by_vrfname(vrf_name); | |
240f48b3 IR |
1374 | if (isis != NULL) { |
1375 | if (id_to_sysid(isis, id, sysid)) { | |
1376 | vty_out(vty, "Invalid system id %s\n", id); | |
1377 | return CMD_SUCCESS; | |
1378 | } | |
a21177f2 JG |
1379 | isis_neighbor_common(vty, json, id, detail, isis, |
1380 | sysid); | |
240f48b3 | 1381 | } |
eab88f36 K |
1382 | } |
1383 | ||
1384 | return CMD_SUCCESS; | |
1385 | } | |
1386 | ||
1387 | static void isis_neighbor_common_clear(struct vty *vty, const char *id, | |
1388 | uint8_t *sysid, struct isis *isis) | |
1389 | { | |
36944791 | 1390 | struct listnode *anode, *cnode, *node, *nnode; |
eab88f36 K |
1391 | struct isis_area *area; |
1392 | struct isis_circuit *circuit; | |
1393 | struct list *adjdb; | |
1394 | struct isis_adjacency *adj; | |
1395 | int i; | |
1396 | ||
d62a17ae | 1397 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { |
36944791 | 1398 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) { |
d62a17ae | 1399 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { |
1400 | for (i = 0; i < 2; i++) { | |
1401 | adjdb = circuit->u.bc.adjdb[i]; | |
1402 | if (adjdb && adjdb->count) { | |
1403 | for (ALL_LIST_ELEMENTS( | |
1404 | adjdb, node, nnode, | |
1405 | adj)) | |
1406 | if (!id | |
eab88f36 K |
1407 | || !memcmp( |
1408 | adj->sysid, | |
1409 | sysid, | |
1410 | ISIS_SYS_ID_LEN)) | |
d62a17ae | 1411 | isis_adj_state_change( |
16167b31 | 1412 | &adj, |
d62a17ae | 1413 | ISIS_ADJ_DOWN, |
1414 | "clear user request"); | |
1415 | } | |
1416 | } | |
1417 | } else if (circuit->circ_type == CIRCUIT_T_P2P | |
1418 | && circuit->u.p2p.neighbor) { | |
1419 | adj = circuit->u.p2p.neighbor; | |
1420 | if (!id | |
1421 | || !memcmp(adj->sysid, sysid, | |
1422 | ISIS_SYS_ID_LEN)) | |
1423 | isis_adj_state_change( | |
16167b31 | 1424 | &adj, ISIS_ADJ_DOWN, |
d62a17ae | 1425 | "clear user request"); |
1426 | } | |
1427 | } | |
1428 | } | |
3f045a08 | 1429 | } |
eab88f36 K |
1430 | /* |
1431 | * 'clear isis neighbor' command | |
1432 | */ | |
1433 | int clear_isis_neighbor_common(struct vty *vty, const char *id, const char *vrf_name, | |
1434 | bool all_vrf) | |
eb5d44eb | 1435 | { |
36944791 | 1436 | struct listnode *node; |
eab88f36 | 1437 | uint8_t sysid[ISIS_SYS_ID_LEN]; |
36944791 | 1438 | struct isis *isis; |
eb5d44eb | 1439 | |
eab88f36 K |
1440 | if (!im) { |
1441 | vty_out(vty, "IS-IS Routing Process not enabled\n"); | |
1442 | return CMD_SUCCESS; | |
1443 | } | |
3f045a08 | 1444 | |
eab88f36 K |
1445 | if (vrf_name) { |
1446 | if (all_vrf) { | |
240f48b3 IR |
1447 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { |
1448 | if (id_to_sysid(isis, id, sysid)) { | |
1449 | vty_out(vty, "Invalid system id %s\n", | |
1450 | id); | |
1451 | return CMD_SUCCESS; | |
1452 | } | |
eab88f36 K |
1453 | isis_neighbor_common_clear(vty, id, sysid, |
1454 | isis); | |
240f48b3 | 1455 | } |
36944791 | 1456 | return CMD_SUCCESS; |
eab88f36 K |
1457 | } |
1458 | isis = isis_lookup_by_vrfname(vrf_name); | |
240f48b3 IR |
1459 | if (isis != NULL) { |
1460 | if (id_to_sysid(isis, id, sysid)) { | |
1461 | vty_out(vty, "Invalid system id %s\n", id); | |
1462 | return CMD_SUCCESS; | |
1463 | } | |
eab88f36 | 1464 | isis_neighbor_common_clear(vty, id, sysid, isis); |
240f48b3 | 1465 | } |
eab88f36 | 1466 | } |
3f045a08 | 1467 | |
eab88f36 | 1468 | return CMD_SUCCESS; |
3f045a08 JB |
1469 | } |
1470 | ||
eab88f36 K |
1471 | DEFUN(show_isis_neighbor, |
1472 | show_isis_neighbor_cmd, | |
a21177f2 | 1473 | "show " PROTO_NAME " [vrf <NAME|all>] neighbor [json]", |
eab88f36 K |
1474 | SHOW_STR |
1475 | PROTO_HELP | |
1476 | VRF_CMD_HELP_STR | |
1477 | "All vrfs\n" | |
a21177f2 JG |
1478 | "IS-IS neighbor adjacencies\n" |
1479 | "json output\n") | |
eab88f36 | 1480 | { |
a21177f2 | 1481 | int res = CMD_SUCCESS; |
eab88f36 K |
1482 | const char *vrf_name = VRF_DEFAULT_NAME; |
1483 | bool all_vrf = false; | |
1484 | int idx_vrf = 0; | |
a21177f2 JG |
1485 | bool uj = use_json(argc, argv); |
1486 | json_object *json = NULL; | |
eab88f36 K |
1487 | |
1488 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
a21177f2 JG |
1489 | if (uj) |
1490 | json = json_object_new_object(); | |
1491 | res = show_isis_neighbor_common(vty, json, NULL, ISIS_UI_LEVEL_BRIEF, | |
1492 | vrf_name, all_vrf); | |
1493 | if (uj) | |
1494 | vty_json(vty, json); | |
1495 | return res; | |
eab88f36 K |
1496 | } |
1497 | ||
1498 | DEFUN(show_isis_neighbor_detail, | |
1499 | show_isis_neighbor_detail_cmd, | |
a21177f2 | 1500 | "show " PROTO_NAME " [vrf <NAME|all>] neighbor detail [json]", |
eab88f36 K |
1501 | SHOW_STR |
1502 | PROTO_HELP | |
1503 | VRF_CMD_HELP_STR | |
1504 | "all vrfs\n" | |
1505 | "IS-IS neighbor adjacencies\n" | |
a21177f2 JG |
1506 | "show detailed information\n" |
1507 | "json output\n") | |
eab88f36 | 1508 | { |
a21177f2 | 1509 | int res = CMD_SUCCESS; |
eab88f36 K |
1510 | const char *vrf_name = VRF_DEFAULT_NAME; |
1511 | bool all_vrf = false; | |
1512 | int idx_vrf = 0; | |
a21177f2 JG |
1513 | bool uj = use_json(argc, argv); |
1514 | json_object *json = NULL; | |
eab88f36 K |
1515 | |
1516 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
a21177f2 JG |
1517 | if (uj) |
1518 | json = json_object_new_object(); | |
eab88f36 | 1519 | |
a21177f2 JG |
1520 | res = show_isis_neighbor_common(vty, json, NULL, ISIS_UI_LEVEL_DETAIL, |
1521 | vrf_name, all_vrf); | |
1522 | if (uj) | |
1523 | vty_json(vty, json); | |
1524 | return res; | |
eab88f36 K |
1525 | } |
1526 | ||
1527 | DEFUN(show_isis_neighbor_arg, | |
1528 | show_isis_neighbor_arg_cmd, | |
a21177f2 | 1529 | "show " PROTO_NAME " [vrf <NAME|all>] neighbor WORD [json]", |
eab88f36 K |
1530 | SHOW_STR |
1531 | PROTO_HELP | |
1532 | VRF_CMD_HELP_STR | |
1533 | "All vrfs\n" | |
1534 | "IS-IS neighbor adjacencies\n" | |
a21177f2 JG |
1535 | "System id\n" |
1536 | "json output\n") | |
eab88f36 | 1537 | { |
a21177f2 | 1538 | int res = CMD_SUCCESS; |
eab88f36 K |
1539 | int idx_word = 0; |
1540 | const char *vrf_name = VRF_DEFAULT_NAME; | |
1541 | bool all_vrf = false; | |
1542 | int idx_vrf = 0; | |
a21177f2 JG |
1543 | bool uj = use_json(argc, argv); |
1544 | json_object *json = NULL; | |
eab88f36 K |
1545 | |
1546 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
a21177f2 JG |
1547 | if (uj) |
1548 | json = json_object_new_object(); | |
eab88f36 K |
1549 | char *id = argv_find(argv, argc, "WORD", &idx_word) |
1550 | ? argv[idx_word]->arg | |
1551 | : NULL; | |
1552 | ||
a21177f2 JG |
1553 | res = show_isis_neighbor_common(vty, json, id, ISIS_UI_LEVEL_DETAIL, |
1554 | vrf_name, all_vrf); | |
1555 | if (uj) | |
1556 | vty_json(vty, json); | |
1557 | return res; | |
eab88f36 K |
1558 | } |
1559 | ||
1560 | DEFUN(clear_isis_neighbor, | |
1561 | clear_isis_neighbor_cmd, | |
1562 | "clear " PROTO_NAME " [vrf <NAME|all>] neighbor", | |
1563 | CLEAR_STR | |
1564 | PROTO_HELP | |
1565 | VRF_CMD_HELP_STR | |
1566 | "All vrfs\n" | |
1567 | "IS-IS neighbor adjacencies\n") | |
1568 | { | |
1569 | const char *vrf_name = VRF_DEFAULT_NAME; | |
1570 | bool all_vrf = false; | |
1571 | int idx_vrf = 0; | |
1572 | ||
1573 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
1574 | return clear_isis_neighbor_common(vty, NULL, vrf_name, all_vrf); | |
1575 | } | |
1576 | ||
1577 | DEFUN(clear_isis_neighbor_arg, | |
1578 | clear_isis_neighbor_arg_cmd, | |
1579 | "clear " PROTO_NAME " [vrf <NAME|all>] neighbor WORD", | |
1580 | CLEAR_STR | |
1581 | PROTO_HELP | |
1582 | VRF_CMD_HELP_STR | |
1583 | "All vrfs\n" | |
1584 | "IS-IS neighbor adjacencies\n" | |
1585 | "System id\n") | |
1586 | { | |
1587 | int idx_word = 0; | |
1588 | const char *vrf_name = VRF_DEFAULT_NAME; | |
1589 | bool all_vrf = false; | |
1590 | int idx_vrf = 0; | |
1591 | ||
1592 | char *id = argv_find(argv, argc, "WORD", &idx_word) | |
1593 | ? argv[idx_word]->arg | |
1594 | : NULL; | |
1595 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
1596 | return clear_isis_neighbor_common(vty, id, vrf_name, all_vrf); | |
3f045a08 JB |
1597 | } |
1598 | ||
eb5d44eb | 1599 | /* |
1600 | * 'isis debug', 'show debugging' | |
1601 | */ | |
d62a17ae | 1602 | void print_debug(struct vty *vty, int flags, int onoff) |
1603 | { | |
5627d3fe | 1604 | const char *onoffs = onoff ? "on" : "off"; |
d62a17ae | 1605 | |
1606 | if (flags & DEBUG_ADJ_PACKETS) | |
1607 | vty_out(vty, | |
1608 | "IS-IS Adjacency related packets debugging is %s\n", | |
1609 | onoffs); | |
161fa356 CF |
1610 | if (flags & DEBUG_TX_QUEUE) |
1611 | vty_out(vty, "IS-IS TX queue debugging is %s\n", | |
1612 | onoffs); | |
d62a17ae | 1613 | if (flags & DEBUG_SNP_PACKETS) |
1614 | vty_out(vty, "IS-IS CSNP/PSNP packets debugging is %s\n", | |
1615 | onoffs); | |
1616 | if (flags & DEBUG_SPF_EVENTS) | |
1617 | vty_out(vty, "IS-IS SPF events debugging is %s\n", onoffs); | |
26f6acaf RW |
1618 | if (flags & DEBUG_SR) |
1619 | vty_out(vty, "IS-IS Segment Routing events debugging is %s\n", | |
1620 | onoffs); | |
d9884a75 OD |
1621 | if (flags & DEBUG_TE) |
1622 | vty_out(vty, | |
1623 | "IS-IS Traffic Engineering events debugging is %s\n", | |
1624 | onoffs); | |
2866b119 RW |
1625 | if (flags & DEBUG_LFA) |
1626 | vty_out(vty, "IS-IS LFA events debugging is %s\n", onoffs); | |
d62a17ae | 1627 | if (flags & DEBUG_UPDATE_PACKETS) |
1628 | vty_out(vty, "IS-IS Update related packet debugging is %s\n", | |
1629 | onoffs); | |
1630 | if (flags & DEBUG_RTE_EVENTS) | |
cdfb430e | 1631 | vty_out(vty, "IS-IS Route related debugging is %s\n", onoffs); |
d62a17ae | 1632 | if (flags & DEBUG_EVENTS) |
1633 | vty_out(vty, "IS-IS Event debugging is %s\n", onoffs); | |
1634 | if (flags & DEBUG_PACKET_DUMP) | |
1635 | vty_out(vty, "IS-IS Packet dump debugging is %s\n", onoffs); | |
1636 | if (flags & DEBUG_LSP_GEN) | |
1637 | vty_out(vty, "IS-IS LSP generation debugging is %s\n", onoffs); | |
1638 | if (flags & DEBUG_LSP_SCHED) | |
1639 | vty_out(vty, "IS-IS LSP scheduling debugging is %s\n", onoffs); | |
ddb33326 CF |
1640 | if (flags & DEBUG_FLOODING) |
1641 | vty_out(vty, "IS-IS Flooding debugging is %s\n", onoffs); | |
2815f817 CF |
1642 | if (flags & DEBUG_BFD) |
1643 | vty_out(vty, "IS-IS BFD debugging is %s\n", onoffs); | |
1cbf96a8 | 1644 | if (flags & DEBUG_LDP_SYNC) |
1645 | vty_out(vty, "IS-IS ldp-sync debugging is %s\n", onoffs); | |
eb5d44eb | 1646 | } |
1647 | ||
87f6dc50 DS |
1648 | DEFUN_NOSH (show_debugging, |
1649 | show_debugging_isis_cmd, | |
7c0cbd0e | 1650 | "show debugging [" PROTO_NAME "]", |
87f6dc50 DS |
1651 | SHOW_STR |
1652 | "State of each debugging option\n" | |
7c0cbd0e | 1653 | PROTO_HELP) |
eb5d44eb | 1654 | { |
7c0cbd0e | 1655 | vty_out(vty, PROTO_NAME " debugging status:\n"); |
87f6dc50 | 1656 | |
e740f9c1 | 1657 | if (IS_DEBUG_ADJ_PACKETS) |
1658 | print_debug(vty, DEBUG_ADJ_PACKETS, 1); | |
1659 | if (IS_DEBUG_TX_QUEUE) | |
1660 | print_debug(vty, DEBUG_TX_QUEUE, 1); | |
1661 | if (IS_DEBUG_SNP_PACKETS) | |
1662 | print_debug(vty, DEBUG_SNP_PACKETS, 1); | |
1663 | if (IS_DEBUG_SPF_EVENTS) | |
1664 | print_debug(vty, DEBUG_SPF_EVENTS, 1); | |
1665 | if (IS_DEBUG_SR) | |
1666 | print_debug(vty, DEBUG_SR, 1); | |
d9884a75 OD |
1667 | if (IS_DEBUG_TE) |
1668 | print_debug(vty, DEBUG_TE, 1); | |
e740f9c1 | 1669 | if (IS_DEBUG_UPDATE_PACKETS) |
1670 | print_debug(vty, DEBUG_UPDATE_PACKETS, 1); | |
1671 | if (IS_DEBUG_RTE_EVENTS) | |
1672 | print_debug(vty, DEBUG_RTE_EVENTS, 1); | |
1673 | if (IS_DEBUG_EVENTS) | |
1674 | print_debug(vty, DEBUG_EVENTS, 1); | |
1675 | if (IS_DEBUG_PACKET_DUMP) | |
1676 | print_debug(vty, DEBUG_PACKET_DUMP, 1); | |
1677 | if (IS_DEBUG_LSP_GEN) | |
1678 | print_debug(vty, DEBUG_LSP_GEN, 1); | |
1679 | if (IS_DEBUG_LSP_SCHED) | |
1680 | print_debug(vty, DEBUG_LSP_SCHED, 1); | |
1681 | if (IS_DEBUG_FLOODING) | |
1682 | print_debug(vty, DEBUG_FLOODING, 1); | |
1683 | if (IS_DEBUG_BFD) | |
1684 | print_debug(vty, DEBUG_BFD, 1); | |
1cbf96a8 | 1685 | if (IS_DEBUG_LDP_SYNC) |
1686 | print_debug(vty, DEBUG_LDP_SYNC, 1); | |
098fc8a9 FR |
1687 | if (IS_DEBUG_LFA) |
1688 | print_debug(vty, DEBUG_LFA, 1); | |
1689 | ||
cf00164b DS |
1690 | cmd_show_lib_debugs(vty); |
1691 | ||
d62a17ae | 1692 | return CMD_SUCCESS; |
eb5d44eb | 1693 | } |
1694 | ||
612c2c15 | 1695 | static int config_write_debug(struct vty *vty); |
9e867fe6 | 1696 | /* Debug node. */ |
62b346ee | 1697 | static struct cmd_node debug_node = { |
f4b8291f | 1698 | .name = "debug", |
62b346ee DL |
1699 | .node = DEBUG_NODE, |
1700 | .prompt = "", | |
612c2c15 | 1701 | .config_write = config_write_debug, |
62b346ee | 1702 | }; |
d62a17ae | 1703 | |
1704 | static int config_write_debug(struct vty *vty) | |
1705 | { | |
1706 | int write = 0; | |
d62a17ae | 1707 | |
e740f9c1 | 1708 | if (IS_DEBUG_ADJ_PACKETS) { |
7c0cbd0e | 1709 | vty_out(vty, "debug " PROTO_NAME " adj-packets\n"); |
d62a17ae | 1710 | write++; |
1711 | } | |
e740f9c1 | 1712 | if (IS_DEBUG_TX_QUEUE) { |
161fa356 CF |
1713 | vty_out(vty, "debug " PROTO_NAME " tx-queue\n"); |
1714 | write++; | |
1715 | } | |
e740f9c1 | 1716 | if (IS_DEBUG_SNP_PACKETS) { |
7c0cbd0e | 1717 | vty_out(vty, "debug " PROTO_NAME " snp-packets\n"); |
d62a17ae | 1718 | write++; |
1719 | } | |
e740f9c1 | 1720 | if (IS_DEBUG_SPF_EVENTS) { |
7c0cbd0e | 1721 | vty_out(vty, "debug " PROTO_NAME " spf-events\n"); |
d62a17ae | 1722 | write++; |
1723 | } | |
e740f9c1 | 1724 | if (IS_DEBUG_SR) { |
26f6acaf RW |
1725 | vty_out(vty, "debug " PROTO_NAME " sr-events\n"); |
1726 | write++; | |
1727 | } | |
d9884a75 OD |
1728 | if (IS_DEBUG_TE) { |
1729 | vty_out(vty, "debug " PROTO_NAME " te-events\n"); | |
1730 | write++; | |
1731 | } | |
2866b119 RW |
1732 | if (IS_DEBUG_LFA) { |
1733 | vty_out(vty, "debug " PROTO_NAME " lfa\n"); | |
c951ee6e RW |
1734 | write++; |
1735 | } | |
e740f9c1 | 1736 | if (IS_DEBUG_UPDATE_PACKETS) { |
7c0cbd0e | 1737 | vty_out(vty, "debug " PROTO_NAME " update-packets\n"); |
d62a17ae | 1738 | write++; |
1739 | } | |
e740f9c1 | 1740 | if (IS_DEBUG_RTE_EVENTS) { |
7c0cbd0e | 1741 | vty_out(vty, "debug " PROTO_NAME " route-events\n"); |
d62a17ae | 1742 | write++; |
1743 | } | |
e740f9c1 | 1744 | if (IS_DEBUG_EVENTS) { |
7c0cbd0e | 1745 | vty_out(vty, "debug " PROTO_NAME " events\n"); |
d62a17ae | 1746 | write++; |
1747 | } | |
e740f9c1 | 1748 | if (IS_DEBUG_PACKET_DUMP) { |
7c0cbd0e | 1749 | vty_out(vty, "debug " PROTO_NAME " packet-dump\n"); |
d62a17ae | 1750 | write++; |
1751 | } | |
e740f9c1 | 1752 | if (IS_DEBUG_LSP_GEN) { |
7c0cbd0e | 1753 | vty_out(vty, "debug " PROTO_NAME " lsp-gen\n"); |
d62a17ae | 1754 | write++; |
1755 | } | |
e740f9c1 | 1756 | if (IS_DEBUG_LSP_SCHED) { |
7c0cbd0e | 1757 | vty_out(vty, "debug " PROTO_NAME " lsp-sched\n"); |
d62a17ae | 1758 | write++; |
1759 | } | |
e740f9c1 | 1760 | if (IS_DEBUG_FLOODING) { |
d4cff91a CF |
1761 | vty_out(vty, "debug " PROTO_NAME " flooding\n"); |
1762 | write++; | |
1763 | } | |
e740f9c1 | 1764 | if (IS_DEBUG_BFD) { |
2815f817 CF |
1765 | vty_out(vty, "debug " PROTO_NAME " bfd\n"); |
1766 | write++; | |
1767 | } | |
1cbf96a8 | 1768 | if (IS_DEBUG_LDP_SYNC) { |
1769 | vty_out(vty, "debug " PROTO_NAME " ldp-sync\n"); | |
1770 | write++; | |
1771 | } | |
d62a17ae | 1772 | write += spf_backoff_write_config(vty); |
1773 | ||
1774 | return write; | |
9e867fe6 | 1775 | } |
1776 | ||
eb5d44eb | 1777 | DEFUN (debug_isis_adj, |
1778 | debug_isis_adj_cmd, | |
7c0cbd0e | 1779 | "debug " PROTO_NAME " adj-packets", |
eb5d44eb | 1780 | DEBUG_STR |
7c0cbd0e | 1781 | PROTO_HELP |
f390d2c7 | 1782 | "IS-IS Adjacency related packets\n") |
eb5d44eb | 1783 | { |
e740f9c1 | 1784 | debug_adj_pkt |= DEBUG_ADJ_PACKETS; |
d62a17ae | 1785 | print_debug(vty, DEBUG_ADJ_PACKETS, 1); |
eb5d44eb | 1786 | |
d62a17ae | 1787 | return CMD_SUCCESS; |
eb5d44eb | 1788 | } |
1789 | ||
1790 | DEFUN (no_debug_isis_adj, | |
1791 | no_debug_isis_adj_cmd, | |
7c0cbd0e | 1792 | "no debug " PROTO_NAME " adj-packets", |
16cedbb0 | 1793 | NO_STR |
eb5d44eb | 1794 | UNDEBUG_STR |
7c0cbd0e | 1795 | PROTO_HELP |
f390d2c7 | 1796 | "IS-IS Adjacency related packets\n") |
eb5d44eb | 1797 | { |
e740f9c1 | 1798 | debug_adj_pkt &= ~DEBUG_ADJ_PACKETS; |
d62a17ae | 1799 | print_debug(vty, DEBUG_ADJ_PACKETS, 0); |
eb5d44eb | 1800 | |
d62a17ae | 1801 | return CMD_SUCCESS; |
eb5d44eb | 1802 | } |
1803 | ||
161fa356 CF |
1804 | DEFUN (debug_isis_tx_queue, |
1805 | debug_isis_tx_queue_cmd, | |
1806 | "debug " PROTO_NAME " tx-queue", | |
1807 | DEBUG_STR | |
1808 | PROTO_HELP | |
1809 | "IS-IS TX queues\n") | |
1810 | { | |
e740f9c1 | 1811 | debug_tx_queue |= DEBUG_TX_QUEUE; |
161fa356 CF |
1812 | print_debug(vty, DEBUG_TX_QUEUE, 1); |
1813 | ||
1814 | return CMD_SUCCESS; | |
1815 | } | |
1816 | ||
1817 | DEFUN (no_debug_isis_tx_queue, | |
1818 | no_debug_isis_tx_queue_cmd, | |
1819 | "no debug " PROTO_NAME " tx-queue", | |
1820 | NO_STR | |
1821 | UNDEBUG_STR | |
1822 | PROTO_HELP | |
1823 | "IS-IS TX queues\n") | |
1824 | { | |
e740f9c1 | 1825 | debug_tx_queue &= ~DEBUG_TX_QUEUE; |
161fa356 CF |
1826 | print_debug(vty, DEBUG_TX_QUEUE, 0); |
1827 | ||
1828 | return CMD_SUCCESS; | |
1829 | } | |
1830 | ||
ddb33326 CF |
1831 | DEFUN (debug_isis_flooding, |
1832 | debug_isis_flooding_cmd, | |
1833 | "debug " PROTO_NAME " flooding", | |
1834 | DEBUG_STR | |
1835 | PROTO_HELP | |
1836 | "Flooding algorithm\n") | |
1837 | { | |
e740f9c1 | 1838 | debug_flooding |= DEBUG_FLOODING; |
ddb33326 CF |
1839 | print_debug(vty, DEBUG_FLOODING, 1); |
1840 | ||
1841 | return CMD_SUCCESS; | |
1842 | } | |
1843 | ||
1844 | DEFUN (no_debug_isis_flooding, | |
1845 | no_debug_isis_flooding_cmd, | |
1846 | "no debug " PROTO_NAME " flooding", | |
1847 | NO_STR | |
1848 | UNDEBUG_STR | |
1849 | PROTO_HELP | |
1850 | "Flooding algorithm\n") | |
1851 | { | |
e740f9c1 | 1852 | debug_flooding &= ~DEBUG_FLOODING; |
ddb33326 CF |
1853 | print_debug(vty, DEBUG_FLOODING, 0); |
1854 | ||
1855 | return CMD_SUCCESS; | |
1856 | } | |
1857 | ||
eb5d44eb | 1858 | DEFUN (debug_isis_snp, |
1859 | debug_isis_snp_cmd, | |
7c0cbd0e | 1860 | "debug " PROTO_NAME " snp-packets", |
eb5d44eb | 1861 | DEBUG_STR |
7c0cbd0e | 1862 | PROTO_HELP |
f390d2c7 | 1863 | "IS-IS CSNP/PSNP packets\n") |
eb5d44eb | 1864 | { |
e740f9c1 | 1865 | debug_snp_pkt |= DEBUG_SNP_PACKETS; |
d62a17ae | 1866 | print_debug(vty, DEBUG_SNP_PACKETS, 1); |
eb5d44eb | 1867 | |
d62a17ae | 1868 | return CMD_SUCCESS; |
eb5d44eb | 1869 | } |
1870 | ||
1871 | DEFUN (no_debug_isis_snp, | |
1872 | no_debug_isis_snp_cmd, | |
7c0cbd0e | 1873 | "no debug " PROTO_NAME " snp-packets", |
16cedbb0 | 1874 | NO_STR |
eb5d44eb | 1875 | UNDEBUG_STR |
7c0cbd0e | 1876 | PROTO_HELP |
f390d2c7 | 1877 | "IS-IS CSNP/PSNP packets\n") |
eb5d44eb | 1878 | { |
e740f9c1 | 1879 | debug_snp_pkt &= ~DEBUG_SNP_PACKETS; |
d62a17ae | 1880 | print_debug(vty, DEBUG_SNP_PACKETS, 0); |
f390d2c7 | 1881 | |
d62a17ae | 1882 | return CMD_SUCCESS; |
eb5d44eb | 1883 | } |
1884 | ||
eb5d44eb | 1885 | DEFUN (debug_isis_upd, |
1886 | debug_isis_upd_cmd, | |
7c0cbd0e | 1887 | "debug " PROTO_NAME " update-packets", |
eb5d44eb | 1888 | DEBUG_STR |
7c0cbd0e | 1889 | PROTO_HELP |
f390d2c7 | 1890 | "IS-IS Update related packets\n") |
eb5d44eb | 1891 | { |
e740f9c1 | 1892 | debug_update_pkt |= DEBUG_UPDATE_PACKETS; |
d62a17ae | 1893 | print_debug(vty, DEBUG_UPDATE_PACKETS, 1); |
eb5d44eb | 1894 | |
d62a17ae | 1895 | return CMD_SUCCESS; |
eb5d44eb | 1896 | } |
1897 | ||
1898 | DEFUN (no_debug_isis_upd, | |
1899 | no_debug_isis_upd_cmd, | |
7c0cbd0e | 1900 | "no debug " PROTO_NAME " update-packets", |
16cedbb0 | 1901 | NO_STR |
eb5d44eb | 1902 | UNDEBUG_STR |
7c0cbd0e | 1903 | PROTO_HELP |
f390d2c7 | 1904 | "IS-IS Update related packets\n") |
eb5d44eb | 1905 | { |
e740f9c1 | 1906 | debug_update_pkt &= ~DEBUG_UPDATE_PACKETS; |
d62a17ae | 1907 | print_debug(vty, DEBUG_UPDATE_PACKETS, 0); |
f390d2c7 | 1908 | |
d62a17ae | 1909 | return CMD_SUCCESS; |
eb5d44eb | 1910 | } |
1911 | ||
eb5d44eb | 1912 | DEFUN (debug_isis_spfevents, |
1913 | debug_isis_spfevents_cmd, | |
7c0cbd0e | 1914 | "debug " PROTO_NAME " spf-events", |
eb5d44eb | 1915 | DEBUG_STR |
7c0cbd0e | 1916 | PROTO_HELP |
f390d2c7 | 1917 | "IS-IS Shortest Path First Events\n") |
eb5d44eb | 1918 | { |
e740f9c1 | 1919 | debug_spf_events |= DEBUG_SPF_EVENTS; |
d62a17ae | 1920 | print_debug(vty, DEBUG_SPF_EVENTS, 1); |
eb5d44eb | 1921 | |
d62a17ae | 1922 | return CMD_SUCCESS; |
eb5d44eb | 1923 | } |
1924 | ||
1925 | DEFUN (no_debug_isis_spfevents, | |
1926 | no_debug_isis_spfevents_cmd, | |
7c0cbd0e | 1927 | "no debug " PROTO_NAME " spf-events", |
16cedbb0 | 1928 | NO_STR |
eb5d44eb | 1929 | UNDEBUG_STR |
7c0cbd0e | 1930 | PROTO_HELP |
f390d2c7 | 1931 | "IS-IS Shortest Path First Events\n") |
eb5d44eb | 1932 | { |
e740f9c1 | 1933 | debug_spf_events &= ~DEBUG_SPF_EVENTS; |
d62a17ae | 1934 | print_debug(vty, DEBUG_SPF_EVENTS, 0); |
f390d2c7 | 1935 | |
d62a17ae | 1936 | return CMD_SUCCESS; |
eb5d44eb | 1937 | } |
1938 | ||
26f6acaf RW |
1939 | DEFUN (debug_isis_srevents, |
1940 | debug_isis_srevents_cmd, | |
1941 | "debug " PROTO_NAME " sr-events", | |
1942 | DEBUG_STR | |
1943 | PROTO_HELP | |
1944 | "IS-IS Segment Routing Events\n") | |
1945 | { | |
e740f9c1 | 1946 | debug_sr |= DEBUG_SR; |
26f6acaf RW |
1947 | print_debug(vty, DEBUG_SR, 1); |
1948 | ||
1949 | return CMD_SUCCESS; | |
1950 | } | |
1951 | ||
1952 | DEFUN (no_debug_isis_srevents, | |
1953 | no_debug_isis_srevents_cmd, | |
1954 | "no debug " PROTO_NAME " sr-events", | |
1955 | NO_STR | |
1956 | UNDEBUG_STR | |
1957 | PROTO_HELP | |
1958 | "IS-IS Segment Routing Events\n") | |
1959 | { | |
e740f9c1 | 1960 | debug_sr &= ~DEBUG_SR; |
26f6acaf RW |
1961 | print_debug(vty, DEBUG_SR, 0); |
1962 | ||
1963 | return CMD_SUCCESS; | |
1964 | } | |
1965 | ||
d9884a75 OD |
1966 | DEFUN (debug_isis_teevents, |
1967 | debug_isis_teevents_cmd, | |
1968 | "debug " PROTO_NAME " te-events", | |
1969 | DEBUG_STR | |
1970 | PROTO_HELP | |
1971 | "IS-IS Traffic Engineering Events\n") | |
1972 | { | |
1973 | debug_te |= DEBUG_TE; | |
1974 | print_debug(vty, DEBUG_TE, 1); | |
1975 | ||
1976 | return CMD_SUCCESS; | |
1977 | } | |
1978 | ||
1979 | DEFUN (no_debug_isis_teevents, | |
1980 | no_debug_isis_teevents_cmd, | |
1981 | "no debug " PROTO_NAME " te-events", | |
1982 | NO_STR | |
1983 | UNDEBUG_STR | |
1984 | PROTO_HELP | |
1985 | "IS-IS Traffic Engineering Events\n") | |
1986 | { | |
1987 | debug_te &= ~DEBUG_TE; | |
1988 | print_debug(vty, DEBUG_TE, 0); | |
1989 | ||
1990 | return CMD_SUCCESS; | |
1991 | } | |
1992 | ||
2866b119 RW |
1993 | DEFUN (debug_isis_lfa, |
1994 | debug_isis_lfa_cmd, | |
1995 | "debug " PROTO_NAME " lfa", | |
c951ee6e RW |
1996 | DEBUG_STR |
1997 | PROTO_HELP | |
2866b119 | 1998 | "IS-IS LFA Events\n") |
c951ee6e | 1999 | { |
2866b119 RW |
2000 | debug_lfa |= DEBUG_LFA; |
2001 | print_debug(vty, DEBUG_LFA, 1); | |
c951ee6e RW |
2002 | |
2003 | return CMD_SUCCESS; | |
2004 | } | |
2005 | ||
2866b119 RW |
2006 | DEFUN (no_debug_isis_lfa, |
2007 | no_debug_isis_lfa_cmd, | |
2008 | "no debug " PROTO_NAME " lfa", | |
c951ee6e RW |
2009 | NO_STR |
2010 | UNDEBUG_STR | |
2011 | PROTO_HELP | |
2866b119 | 2012 | "IS-IS LFA Events\n") |
c951ee6e | 2013 | { |
2866b119 RW |
2014 | debug_lfa &= ~DEBUG_LFA; |
2015 | print_debug(vty, DEBUG_LFA, 0); | |
c951ee6e RW |
2016 | |
2017 | return CMD_SUCCESS; | |
2018 | } | |
2019 | ||
eb5d44eb | 2020 | DEFUN (debug_isis_rtevents, |
2021 | debug_isis_rtevents_cmd, | |
7c0cbd0e | 2022 | "debug " PROTO_NAME " route-events", |
eb5d44eb | 2023 | DEBUG_STR |
7c0cbd0e | 2024 | PROTO_HELP |
f390d2c7 | 2025 | "IS-IS Route related events\n") |
eb5d44eb | 2026 | { |
e740f9c1 | 2027 | debug_rte_events |= DEBUG_RTE_EVENTS; |
d62a17ae | 2028 | print_debug(vty, DEBUG_RTE_EVENTS, 1); |
eb5d44eb | 2029 | |
d62a17ae | 2030 | return CMD_SUCCESS; |
eb5d44eb | 2031 | } |
2032 | ||
2033 | DEFUN (no_debug_isis_rtevents, | |
2034 | no_debug_isis_rtevents_cmd, | |
7c0cbd0e | 2035 | "no debug " PROTO_NAME " route-events", |
16cedbb0 | 2036 | NO_STR |
eb5d44eb | 2037 | UNDEBUG_STR |
7c0cbd0e | 2038 | PROTO_HELP |
f390d2c7 | 2039 | "IS-IS Route related events\n") |
eb5d44eb | 2040 | { |
e740f9c1 | 2041 | debug_rte_events &= ~DEBUG_RTE_EVENTS; |
d62a17ae | 2042 | print_debug(vty, DEBUG_RTE_EVENTS, 0); |
f390d2c7 | 2043 | |
d62a17ae | 2044 | return CMD_SUCCESS; |
eb5d44eb | 2045 | } |
2046 | ||
2047 | DEFUN (debug_isis_events, | |
2048 | debug_isis_events_cmd, | |
7c0cbd0e | 2049 | "debug " PROTO_NAME " events", |
eb5d44eb | 2050 | DEBUG_STR |
7c0cbd0e | 2051 | PROTO_HELP |
f1082d19 | 2052 | "IS-IS Events\n") |
eb5d44eb | 2053 | { |
e740f9c1 | 2054 | debug_events |= DEBUG_EVENTS; |
d62a17ae | 2055 | print_debug(vty, DEBUG_EVENTS, 1); |
eb5d44eb | 2056 | |
d62a17ae | 2057 | return CMD_SUCCESS; |
eb5d44eb | 2058 | } |
2059 | ||
2060 | DEFUN (no_debug_isis_events, | |
2061 | no_debug_isis_events_cmd, | |
7c0cbd0e | 2062 | "no debug " PROTO_NAME " events", |
16cedbb0 | 2063 | NO_STR |
eb5d44eb | 2064 | UNDEBUG_STR |
7c0cbd0e | 2065 | PROTO_HELP |
f390d2c7 | 2066 | "IS-IS Events\n") |
eb5d44eb | 2067 | { |
e740f9c1 | 2068 | debug_events &= ~DEBUG_EVENTS; |
d62a17ae | 2069 | print_debug(vty, DEBUG_EVENTS, 0); |
f390d2c7 | 2070 | |
d62a17ae | 2071 | return CMD_SUCCESS; |
eb5d44eb | 2072 | } |
2073 | ||
3f045a08 JB |
2074 | DEFUN (debug_isis_packet_dump, |
2075 | debug_isis_packet_dump_cmd, | |
7c0cbd0e | 2076 | "debug " PROTO_NAME " packet-dump", |
3f045a08 | 2077 | DEBUG_STR |
7c0cbd0e | 2078 | PROTO_HELP |
3f045a08 JB |
2079 | "IS-IS packet dump\n") |
2080 | { | |
e740f9c1 | 2081 | debug_pkt_dump |= DEBUG_PACKET_DUMP; |
d62a17ae | 2082 | print_debug(vty, DEBUG_PACKET_DUMP, 1); |
3f045a08 | 2083 | |
d62a17ae | 2084 | return CMD_SUCCESS; |
3f045a08 JB |
2085 | } |
2086 | ||
2087 | DEFUN (no_debug_isis_packet_dump, | |
2088 | no_debug_isis_packet_dump_cmd, | |
7c0cbd0e | 2089 | "no debug " PROTO_NAME " packet-dump", |
16cedbb0 | 2090 | NO_STR |
3f045a08 | 2091 | UNDEBUG_STR |
7c0cbd0e | 2092 | PROTO_HELP |
3f045a08 JB |
2093 | "IS-IS packet dump\n") |
2094 | { | |
e740f9c1 | 2095 | debug_pkt_dump &= ~DEBUG_PACKET_DUMP; |
d62a17ae | 2096 | print_debug(vty, DEBUG_PACKET_DUMP, 0); |
3f045a08 | 2097 | |
d62a17ae | 2098 | return CMD_SUCCESS; |
3f045a08 JB |
2099 | } |
2100 | ||
14872644 CF |
2101 | DEFUN (debug_isis_lsp_gen, |
2102 | debug_isis_lsp_gen_cmd, | |
7c0cbd0e | 2103 | "debug " PROTO_NAME " lsp-gen", |
14872644 | 2104 | DEBUG_STR |
7c0cbd0e | 2105 | PROTO_HELP |
14872644 CF |
2106 | "IS-IS generation of own LSPs\n") |
2107 | { | |
e740f9c1 | 2108 | debug_lsp_gen |= DEBUG_LSP_GEN; |
d62a17ae | 2109 | print_debug(vty, DEBUG_LSP_GEN, 1); |
14872644 | 2110 | |
d62a17ae | 2111 | return CMD_SUCCESS; |
14872644 CF |
2112 | } |
2113 | ||
2114 | DEFUN (no_debug_isis_lsp_gen, | |
2115 | no_debug_isis_lsp_gen_cmd, | |
7c0cbd0e | 2116 | "no debug " PROTO_NAME " lsp-gen", |
16cedbb0 | 2117 | NO_STR |
14872644 | 2118 | UNDEBUG_STR |
7c0cbd0e | 2119 | PROTO_HELP |
14872644 CF |
2120 | "IS-IS generation of own LSPs\n") |
2121 | { | |
e740f9c1 | 2122 | debug_lsp_gen &= ~DEBUG_LSP_GEN; |
d62a17ae | 2123 | print_debug(vty, DEBUG_LSP_GEN, 0); |
14872644 | 2124 | |
d62a17ae | 2125 | return CMD_SUCCESS; |
14872644 CF |
2126 | } |
2127 | ||
414766a1 CF |
2128 | DEFUN (debug_isis_lsp_sched, |
2129 | debug_isis_lsp_sched_cmd, | |
7c0cbd0e | 2130 | "debug " PROTO_NAME " lsp-sched", |
414766a1 | 2131 | DEBUG_STR |
7c0cbd0e | 2132 | PROTO_HELP |
414766a1 CF |
2133 | "IS-IS scheduling of LSP generation\n") |
2134 | { | |
e740f9c1 | 2135 | debug_lsp_sched |= DEBUG_LSP_SCHED; |
d62a17ae | 2136 | print_debug(vty, DEBUG_LSP_SCHED, 1); |
414766a1 | 2137 | |
d62a17ae | 2138 | return CMD_SUCCESS; |
414766a1 CF |
2139 | } |
2140 | ||
49d41a26 DS |
2141 | DEFUN (no_debug_isis_lsp_sched, |
2142 | no_debug_isis_lsp_sched_cmd, | |
7c0cbd0e | 2143 | "no debug " PROTO_NAME " lsp-sched", |
16cedbb0 | 2144 | NO_STR |
49d41a26 | 2145 | UNDEBUG_STR |
7c0cbd0e | 2146 | PROTO_HELP |
49d41a26 DS |
2147 | "IS-IS scheduling of LSP generation\n") |
2148 | { | |
e740f9c1 | 2149 | debug_lsp_sched &= ~DEBUG_LSP_SCHED; |
d62a17ae | 2150 | print_debug(vty, DEBUG_LSP_SCHED, 0); |
49d41a26 | 2151 | |
d62a17ae | 2152 | return CMD_SUCCESS; |
49d41a26 DS |
2153 | } |
2154 | ||
2815f817 CF |
2155 | DEFUN (debug_isis_bfd, |
2156 | debug_isis_bfd_cmd, | |
2157 | "debug " PROTO_NAME " bfd", | |
2158 | DEBUG_STR | |
2159 | PROTO_HELP | |
2160 | PROTO_NAME " interaction with BFD\n") | |
2161 | { | |
e740f9c1 | 2162 | debug_bfd |= DEBUG_BFD; |
c7fd8c62 | 2163 | bfd_protocol_integration_set_debug(true); |
2815f817 CF |
2164 | print_debug(vty, DEBUG_BFD, 1); |
2165 | ||
2166 | return CMD_SUCCESS; | |
2167 | } | |
2168 | ||
2169 | DEFUN (no_debug_isis_bfd, | |
2170 | no_debug_isis_bfd_cmd, | |
2171 | "no debug " PROTO_NAME " bfd", | |
2172 | NO_STR | |
2173 | UNDEBUG_STR | |
2174 | PROTO_HELP | |
2175 | PROTO_NAME " interaction with BFD\n") | |
2176 | { | |
e740f9c1 | 2177 | debug_bfd &= ~DEBUG_BFD; |
c7fd8c62 | 2178 | bfd_protocol_integration_set_debug(false); |
2815f817 CF |
2179 | print_debug(vty, DEBUG_BFD, 0); |
2180 | ||
2181 | return CMD_SUCCESS; | |
2182 | } | |
2183 | ||
1cbf96a8 | 2184 | DEFUN(debug_isis_ldp_sync, debug_isis_ldp_sync_cmd, |
2185 | "debug " PROTO_NAME " ldp-sync", | |
2186 | DEBUG_STR PROTO_HELP PROTO_NAME " interaction with LDP-Sync\n") | |
2187 | { | |
2188 | debug_ldp_sync |= DEBUG_LDP_SYNC; | |
2189 | print_debug(vty, DEBUG_LDP_SYNC, 1); | |
2190 | ||
2191 | return CMD_SUCCESS; | |
2192 | } | |
2193 | ||
2194 | DEFUN(no_debug_isis_ldp_sync, no_debug_isis_ldp_sync_cmd, | |
2195 | "no debug " PROTO_NAME " ldp-sync", | |
2196 | NO_STR UNDEBUG_STR PROTO_HELP PROTO_NAME " interaction with LDP-Sync\n") | |
2197 | { | |
2198 | debug_ldp_sync &= ~DEBUG_LDP_SYNC; | |
2199 | print_debug(vty, DEBUG_LDP_SYNC, 0); | |
2200 | ||
2201 | return CMD_SUCCESS; | |
2202 | } | |
2203 | ||
2204 | DEFUN (show_hostname, | |
2205 | show_hostname_cmd, | |
2582d02c IR |
2206 | "show " PROTO_NAME " [vrf <NAME|all>] hostname", |
2207 | SHOW_STR PROTO_HELP VRF_CMD_HELP_STR | |
2208 | "All VRFs\n" | |
1cbf96a8 | 2209 | "IS-IS Dynamic hostname mapping\n") |
eb5d44eb | 2210 | { |
36944791 | 2211 | struct listnode *node; |
eab88f36 K |
2212 | const char *vrf_name = VRF_DEFAULT_NAME; |
2213 | bool all_vrf = false; | |
2214 | int idx_vrf = 0; | |
36944791 | 2215 | struct isis *isis; |
eab88f36 K |
2216 | |
2217 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
2218 | if (vrf_name) { | |
2219 | if (all_vrf) { | |
36944791 | 2220 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) |
eab88f36 | 2221 | dynhn_print_all(vty, isis); |
36944791 RW |
2222 | |
2223 | return CMD_SUCCESS; | |
eab88f36 K |
2224 | } |
2225 | isis = isis_lookup_by_vrfname(vrf_name); | |
2226 | if (isis != NULL) | |
2227 | dynhn_print_all(vty, isis); | |
2228 | } | |
f390d2c7 | 2229 | |
d62a17ae | 2230 | return CMD_SUCCESS; |
eb5d44eb | 2231 | } |
2232 | ||
eab88f36 | 2233 | static void isis_spf_ietf_common(struct vty *vty, struct isis *isis) |
03f7e182 | 2234 | { |
d62a17ae | 2235 | struct listnode *node; |
2236 | struct isis_area *area; | |
d62a17ae | 2237 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { |
eab88f36 K |
2238 | |
2239 | vty_out(vty, "vrf : %s\n", isis->name); | |
d62a17ae | 2240 | vty_out(vty, "Area %s:\n", |
2241 | area->area_tag ? area->area_tag : "null"); | |
2242 | ||
2243 | for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { | |
2244 | if ((area->is_type & level) == 0) | |
2245 | continue; | |
2246 | ||
2247 | vty_out(vty, " Level-%d:\n", level); | |
2248 | vty_out(vty, " SPF delay status: "); | |
2249 | if (area->spf_timer[level - 1]) { | |
2250 | struct timeval remain = thread_timer_remain( | |
2251 | area->spf_timer[level - 1]); | |
a97986ff DL |
2252 | vty_out(vty, "Pending, due in %lld msec\n", |
2253 | (long long)remain.tv_sec * 1000 | |
d62a17ae | 2254 | + remain.tv_usec / 1000); |
2255 | } else { | |
2256 | vty_out(vty, "Not scheduled\n"); | |
2257 | } | |
2258 | ||
2259 | if (area->spf_delay_ietf[level - 1]) { | |
2260 | vty_out(vty, | |
2261 | " Using draft-ietf-rtgwg-backoff-algo-04\n"); | |
2262 | spf_backoff_show( | |
2263 | area->spf_delay_ietf[level - 1], vty, | |
2264 | " "); | |
2265 | } else { | |
2266 | vty_out(vty, " Using legacy backoff algo\n"); | |
2267 | } | |
2268 | } | |
2269 | } | |
eab88f36 K |
2270 | } |
2271 | ||
2272 | DEFUN(show_isis_spf_ietf, show_isis_spf_ietf_cmd, | |
2273 | "show " PROTO_NAME " [vrf <NAME|all>] spf-delay-ietf", | |
2274 | SHOW_STR PROTO_HELP VRF_CMD_HELP_STR | |
2275 | "All VRFs\n" | |
2276 | "SPF delay IETF information\n") | |
2277 | { | |
36944791 RW |
2278 | struct listnode *node; |
2279 | struct isis *isis; | |
eab88f36 K |
2280 | int idx_vrf = 0; |
2281 | const char *vrf_name = VRF_DEFAULT_NAME; | |
2282 | bool all_vrf = false; | |
2283 | ||
2284 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf) | |
2285 | ||
2286 | if (!im) { | |
2287 | vty_out(vty, "ISIS is not running\n"); | |
2288 | return CMD_SUCCESS; | |
2289 | } | |
2290 | ||
2291 | if (vrf_name) { | |
2292 | if (all_vrf) { | |
36944791 | 2293 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) |
eab88f36 | 2294 | isis_spf_ietf_common(vty, isis); |
36944791 RW |
2295 | |
2296 | return CMD_SUCCESS; | |
eab88f36 K |
2297 | } |
2298 | isis = isis_lookup_by_vrfname(vrf_name); | |
2299 | if (isis != NULL) | |
2300 | isis_spf_ietf_common(vty, isis); | |
2301 | } | |
2302 | ||
d62a17ae | 2303 | return CMD_SUCCESS; |
03f7e182 SL |
2304 | } |
2305 | ||
471bb5da JG |
2306 | |
2307 | static const char *pdu_counter_index_to_name_json(enum pdu_counter_index index) | |
2308 | { | |
2309 | switch (index) { | |
2310 | case L1_LAN_HELLO_INDEX: | |
2311 | return "l1-iih"; | |
2312 | case L2_LAN_HELLO_INDEX: | |
2313 | return "l2-iih"; | |
2314 | case P2P_HELLO_INDEX: | |
2315 | return "p2p-iih"; | |
2316 | case L1_LINK_STATE_INDEX: | |
2317 | return "l1-lsp"; | |
2318 | case L2_LINK_STATE_INDEX: | |
2319 | return "l2-lsp"; | |
2320 | case FS_LINK_STATE_INDEX: | |
2321 | return "fs-lsp"; | |
2322 | case L1_COMPLETE_SEQ_NUM_INDEX: | |
2323 | return "l1-csnp"; | |
2324 | case L2_COMPLETE_SEQ_NUM_INDEX: | |
2325 | return "l2-csnp"; | |
2326 | case L1_PARTIAL_SEQ_NUM_INDEX: | |
2327 | return "l1-psnp"; | |
2328 | case L2_PARTIAL_SEQ_NUM_INDEX: | |
2329 | return "l2-psnp"; | |
a348c945 | 2330 | case PDU_COUNTER_SIZE: |
471bb5da JG |
2331 | return "???????"; |
2332 | } | |
a348c945 DS |
2333 | |
2334 | assert(!"Reached end of function where we are not expecting to"); | |
471bb5da JG |
2335 | } |
2336 | ||
2337 | static void common_isis_summary_json(struct json_object *json, | |
2338 | struct isis *isis) | |
2339 | { | |
2340 | int level; | |
2341 | json_object *areas_json, *area_json, *tx_pdu_json, *rx_pdu_json, | |
2342 | *levels_json, *level_json; | |
2343 | struct listnode *node, *node2; | |
2344 | struct isis_area *area; | |
2345 | time_t cur; | |
2346 | char uptime[MONOTIME_STRLEN]; | |
2347 | char stier[5]; | |
2348 | json_object_string_add(json, "vrf", isis->name); | |
2349 | json_object_int_add(json, "process-id", isis->process_id); | |
2350 | if (isis->sysid_set) | |
2351 | json_object_string_add(json, "system-id", | |
2352 | sysid_print(isis->sysid)); | |
2353 | ||
2354 | cur = time(NULL); | |
2355 | cur -= isis->uptime; | |
2356 | frrtime_to_interval(cur, uptime, sizeof(uptime)); | |
2357 | json_object_string_add(json, "up-time", uptime); | |
2358 | if (isis->area_list) | |
2359 | json_object_int_add(json, "number-areas", | |
2360 | isis->area_list->count); | |
2361 | areas_json = json_object_new_array(); | |
2362 | json_object_object_add(json, "areas", areas_json); | |
2363 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { | |
2364 | area_json = json_object_new_object(); | |
2365 | json_object_string_add(area_json, "area", | |
2366 | area->area_tag ? area->area_tag | |
2367 | : "null"); | |
2368 | ||
2369 | ||
2370 | if (fabricd) { | |
2371 | uint8_t tier = fabricd_tier(area); | |
2372 | snprintfrr(stier, sizeof(stier), "%s", &tier); | |
2373 | json_object_string_add(area_json, "tier", | |
2374 | tier == ISIS_TIER_UNDEFINED | |
2375 | ? "undefined" | |
2376 | : stier); | |
2377 | } | |
2378 | ||
2379 | if (listcount(area->area_addrs) > 0) { | |
2380 | struct area_addr *area_addr; | |
2381 | for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node2, | |
2382 | area_addr)) { | |
2383 | json_object_string_add( | |
2384 | area_json, "net", | |
2385 | isonet_print(area_addr->area_addr, | |
2386 | area_addr->addr_len + | |
2387 | ISIS_SYS_ID_LEN + | |
2388 | 1)); | |
2389 | } | |
2390 | } | |
2391 | ||
2392 | tx_pdu_json = json_object_new_object(); | |
2393 | json_object_object_add(area_json, "tx-pdu-type", tx_pdu_json); | |
2394 | for (int i = 0; i < PDU_COUNTER_SIZE; i++) { | |
2395 | if (!area->pdu_tx_counters[i]) | |
2396 | continue; | |
2397 | json_object_int_add(tx_pdu_json, | |
2398 | pdu_counter_index_to_name_json(i), | |
2399 | area->pdu_tx_counters[i]); | |
2400 | } | |
2401 | json_object_int_add(tx_pdu_json, "lsp-rxmt", | |
2402 | area->lsp_rxmt_count); | |
2403 | ||
2404 | rx_pdu_json = json_object_new_object(); | |
2405 | json_object_object_add(area_json, "rx-pdu-type", rx_pdu_json); | |
2406 | for (int i = 0; i < PDU_COUNTER_SIZE; i++) { | |
2407 | if (!area->pdu_rx_counters[i]) | |
2408 | continue; | |
2409 | json_object_int_add(rx_pdu_json, | |
2410 | pdu_counter_index_to_name_json(i), | |
2411 | area->pdu_rx_counters[i]); | |
2412 | } | |
2413 | ||
2414 | levels_json = json_object_new_array(); | |
2415 | json_object_object_add(area_json, "levels", levels_json); | |
2416 | for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { | |
2417 | if ((area->is_type & level) == 0) | |
2418 | continue; | |
2419 | level_json = json_object_new_object(); | |
2420 | json_object_int_add(level_json, "id", level); | |
2421 | json_object_int_add(level_json, "lsp0-regenerated", | |
2422 | area->lsp_gen_count[level - 1]); | |
2423 | json_object_int_add(level_json, "lsp-purged", | |
2424 | area->lsp_purge_count[level - 1]); | |
2425 | if (area->spf_timer[level - 1]) | |
2426 | json_object_string_add(level_json, "spf", | |
2427 | "pending"); | |
2428 | else | |
2429 | json_object_string_add(level_json, "spf", | |
2430 | "no pending"); | |
2431 | json_object_int_add(level_json, "minimum-interval", | |
2432 | area->min_spf_interval[level - 1]); | |
2433 | if (area->spf_delay_ietf[level - 1]) | |
2434 | json_object_string_add( | |
2435 | level_json, "ietf-spf-delay-activated", | |
2436 | "not used"); | |
2437 | if (area->ip_circuits) { | |
2438 | isis_spf_print_json( | |
2439 | area->spftree[SPFTREE_IPV4][level - 1], | |
2440 | level_json); | |
2441 | } | |
2442 | if (area->ipv6_circuits) { | |
2443 | isis_spf_print_json( | |
2444 | area->spftree[SPFTREE_IPV6][level - 1], | |
2445 | level_json); | |
2446 | } | |
2447 | json_object_array_add(levels_json, level_json); | |
2448 | } | |
2449 | json_object_array_add(areas_json, area_json); | |
2450 | } | |
2451 | } | |
2452 | ||
2453 | static void common_isis_summary_vty(struct vty *vty, struct isis *isis) | |
3f045a08 | 2454 | { |
d62a17ae | 2455 | struct listnode *node, *node2; |
2456 | struct isis_area *area; | |
d62a17ae | 2457 | int level; |
2458 | ||
eab88f36 | 2459 | vty_out(vty, "vrf : %s\n", isis->name); |
d62a17ae | 2460 | vty_out(vty, "Process Id : %ld\n", isis->process_id); |
2461 | if (isis->sysid_set) | |
2462 | vty_out(vty, "System Id : %s\n", | |
2463 | sysid_print(isis->sysid)); | |
2464 | ||
2465 | vty_out(vty, "Up time : "); | |
2466 | vty_out_timestr(vty, isis->uptime); | |
2467 | vty_out(vty, "\n"); | |
2468 | ||
2469 | if (isis->area_list) | |
2470 | vty_out(vty, "Number of areas : %d\n", isis->area_list->count); | |
2471 | ||
2472 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { | |
2473 | vty_out(vty, "Area %s:\n", | |
2474 | area->area_tag ? area->area_tag : "null"); | |
2475 | ||
92ed0cde CF |
2476 | if (fabricd) { |
2477 | uint8_t tier = fabricd_tier(area); | |
2478 | if (tier == ISIS_TIER_UNDEFINED) | |
2479 | vty_out(vty, " Tier: undefined\n"); | |
2480 | else | |
6cde4b45 | 2481 | vty_out(vty, " Tier: %hhu\n", tier); |
92ed0cde CF |
2482 | } |
2483 | ||
d62a17ae | 2484 | if (listcount(area->area_addrs) > 0) { |
2485 | struct area_addr *area_addr; | |
2486 | for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node2, | |
2487 | area_addr)) { | |
2488 | vty_out(vty, " Net: %s\n", | |
2489 | isonet_print(area_addr->area_addr, | |
2490 | area_addr->addr_len | |
2491 | + ISIS_SYS_ID_LEN | |
2492 | + 1)); | |
2493 | } | |
2494 | } | |
2495 | ||
39bb53d6 CF |
2496 | vty_out(vty, " TX counters per PDU type:\n"); |
2497 | pdu_counter_print(vty, " ", area->pdu_tx_counters); | |
86d6f80d CF |
2498 | vty_out(vty, " LSP RXMT: %" PRIu64 "\n", |
2499 | area->lsp_rxmt_count); | |
39bb53d6 CF |
2500 | vty_out(vty, " RX counters per PDU type:\n"); |
2501 | pdu_counter_print(vty, " ", area->pdu_rx_counters); | |
2502 | ||
d62a17ae | 2503 | for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { |
2504 | if ((area->is_type & level) == 0) | |
2505 | continue; | |
2506 | ||
2507 | vty_out(vty, " Level-%d:\n", level); | |
062f4d36 CF |
2508 | |
2509 | vty_out(vty, " LSP0 regenerated: %" PRIu64 "\n", | |
2510 | area->lsp_gen_count[level - 1]); | |
2511 | ||
6f004b60 CF |
2512 | vty_out(vty, " LSPs purged: %" PRIu64 "\n", |
2513 | area->lsp_purge_count[level - 1]); | |
2514 | ||
d62a17ae | 2515 | if (area->spf_timer[level - 1]) |
2516 | vty_out(vty, " SPF: (pending)\n"); | |
2517 | else | |
2518 | vty_out(vty, " SPF:\n"); | |
2519 | ||
2520 | vty_out(vty, " minimum interval : %d", | |
2521 | area->min_spf_interval[level - 1]); | |
2522 | if (area->spf_delay_ietf[level - 1]) | |
2523 | vty_out(vty, | |
2524 | " (not used, IETF SPF delay activated)"); | |
2525 | vty_out(vty, "\n"); | |
2526 | ||
a6f71d37 RW |
2527 | if (area->ip_circuits) { |
2528 | vty_out(vty, " IPv4 route computation:\n"); | |
2529 | isis_spf_print( | |
2530 | area->spftree[SPFTREE_IPV4][level - 1], | |
2531 | vty); | |
2532 | } | |
d62a17ae | 2533 | |
a6f71d37 RW |
2534 | if (area->ipv6_circuits) { |
2535 | vty_out(vty, " IPv6 route computation:\n"); | |
2536 | isis_spf_print( | |
2537 | area->spftree[SPFTREE_IPV6][level - 1], | |
2538 | vty); | |
2539 | } | |
321c1bbb | 2540 | |
a6f71d37 RW |
2541 | if (area->ipv6_circuits |
2542 | && isis_area_ipv6_dstsrc_enabled(area)) { | |
2543 | vty_out(vty, | |
2544 | " IPv6 dst-src route computation:\n"); | |
2545 | isis_spf_print(area->spftree[SPFTREE_DSTSRC] | |
2546 | [level - 1], | |
2547 | vty); | |
2548 | } | |
d62a17ae | 2549 | } |
2550 | } | |
eab88f36 K |
2551 | } |
2552 | ||
471bb5da JG |
2553 | static void common_isis_summary(struct vty *vty, struct json_object *json, |
2554 | struct isis *isis) | |
2555 | { | |
2556 | if (json) { | |
2557 | common_isis_summary_json(json, isis); | |
2558 | } else { | |
2559 | common_isis_summary_vty(vty, isis); | |
2560 | } | |
2561 | } | |
2562 | ||
eab88f36 | 2563 | DEFUN(show_isis_summary, show_isis_summary_cmd, |
471bb5da | 2564 | "show " PROTO_NAME " [vrf <NAME|all>] summary [json]", |
eab88f36 K |
2565 | SHOW_STR PROTO_HELP VRF_CMD_HELP_STR |
2566 | "All VRFs\n" | |
471bb5da | 2567 | "json output\n" |
eab88f36 K |
2568 | "summary\n") |
2569 | { | |
36944791 | 2570 | struct listnode *node; |
eab88f36 | 2571 | int idx_vrf = 0; |
36944791 | 2572 | struct isis *isis; |
eab88f36 K |
2573 | const char *vrf_name = VRF_DEFAULT_NAME; |
2574 | bool all_vrf = false; | |
471bb5da JG |
2575 | bool uj = use_json(argc, argv); |
2576 | json_object *json = NULL; | |
eab88f36 K |
2577 | |
2578 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf) | |
2579 | if (!im) { | |
2580 | vty_out(vty, PROTO_NAME " is not running\n"); | |
2581 | return CMD_SUCCESS; | |
2582 | } | |
471bb5da JG |
2583 | if (uj) |
2584 | json = json_object_new_object(); | |
eab88f36 K |
2585 | if (vrf_name) { |
2586 | if (all_vrf) { | |
36944791 | 2587 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) |
471bb5da | 2588 | common_isis_summary(vty, json, isis); |
36944791 RW |
2589 | |
2590 | return CMD_SUCCESS; | |
eab88f36 K |
2591 | } |
2592 | isis = isis_lookup_by_vrfname(vrf_name); | |
2593 | if (isis != NULL) | |
471bb5da | 2594 | common_isis_summary(vty, json, isis); |
eab88f36 K |
2595 | } |
2596 | ||
471bb5da JG |
2597 | if (uj) |
2598 | vty_json(vty, json); | |
d62a17ae | 2599 | |
2600 | return CMD_SUCCESS; | |
eb5d44eb | 2601 | } |
2602 | ||
1d88e63a DS |
2603 | struct isis_lsp *lsp_for_sysid(struct lspdb_head *head, const char *sysid_str, |
2604 | struct isis *isis) | |
d62a17ae | 2605 | { |
eb2bcb28 | 2606 | char sysid[255] = {0}; |
9ff7c74b | 2607 | uint8_t number[3] = {0}; |
eb2bcb28 CF |
2608 | const char *pos; |
2609 | uint8_t lspid[ISIS_SYS_ID_LEN + 2] = {0}; | |
2610 | struct isis_dynhn *dynhn; | |
2611 | struct isis_lsp *lsp = NULL; | |
d62a17ae | 2612 | |
1d88e63a | 2613 | if (!sysid_str) |
eb2bcb28 | 2614 | return NULL; |
d62a17ae | 2615 | |
2616 | /* | |
1d88e63a | 2617 | * extract fragment and pseudo id from the string sysid_str |
d62a17ae | 2618 | * in the forms: |
2619 | * (a) <systemid/hostname>.<pseudo-id>-<framenent> or | |
2620 | * (b) <systemid/hostname>.<pseudo-id> or | |
2621 | * (c) <systemid/hostname> or | |
2622 | * Where systemid is in the form: | |
2623 | * xxxx.xxxx.xxxx | |
2624 | */ | |
1d88e63a | 2625 | strlcpy(sysid, sysid_str, sizeof(sysid)); |
730649da | 2626 | |
1d88e63a DS |
2627 | if (strlen(sysid_str) > 3) { |
2628 | pos = sysid_str + strlen(sysid_str) - 3; | |
d62a17ae | 2629 | if (strncmp(pos, "-", 1) == 0) { |
2630 | memcpy(number, ++pos, 2); | |
2631 | lspid[ISIS_SYS_ID_LEN + 1] = | |
d7c0a89a | 2632 | (uint8_t)strtol((char *)number, NULL, 16); |
d62a17ae | 2633 | pos -= 4; |
2634 | if (strncmp(pos, ".", 1) != 0) | |
eb2bcb28 | 2635 | return NULL; |
d62a17ae | 2636 | } |
2637 | if (strncmp(pos, ".", 1) == 0) { | |
2638 | memcpy(number, ++pos, 2); | |
2639 | lspid[ISIS_SYS_ID_LEN] = | |
d7c0a89a | 2640 | (uint8_t)strtol((char *)number, NULL, 16); |
1d88e63a | 2641 | sysid[pos - sysid_str - 1] = '\0'; |
d62a17ae | 2642 | } |
2643 | } | |
2644 | ||
eb2bcb28 | 2645 | /* |
1d88e63a DS |
2646 | * Try to find the lsp-id if the sysid_str |
2647 | * is in the form | |
eb2bcb28 CF |
2648 | * hostname.<pseudo-id>-<fragment> |
2649 | */ | |
2650 | if (sysid2buff(lspid, sysid)) { | |
4bef0ec4 | 2651 | lsp = lsp_search(head, lspid); |
240f48b3 | 2652 | } else if ((dynhn = dynhn_find_by_name(isis, sysid))) { |
eb2bcb28 | 2653 | memcpy(lspid, dynhn->id, ISIS_SYS_ID_LEN); |
4bef0ec4 | 2654 | lsp = lsp_search(head, lspid); |
eb2bcb28 CF |
2655 | } else if (strncmp(cmd_hostname_get(), sysid, 15) == 0) { |
2656 | memcpy(lspid, isis->sysid, ISIS_SYS_ID_LEN); | |
4bef0ec4 | 2657 | lsp = lsp_search(head, lspid); |
eb2bcb28 CF |
2658 | } |
2659 | ||
2660 | return lsp; | |
2661 | } | |
2662 | ||
a2cac12a JG |
2663 | void show_isis_database_lspdb_json(struct json_object *json, |
2664 | struct isis_area *area, int level, | |
2665 | struct lspdb_head *lspdb, | |
2666 | const char *sysid_str, int ui_level) | |
2667 | { | |
2668 | struct isis_lsp *lsp; | |
2669 | int lsp_count; | |
2670 | ||
2671 | if (lspdb_count(lspdb) > 0) { | |
2672 | lsp = lsp_for_sysid(lspdb, sysid_str, area->isis); | |
2673 | ||
2674 | if (lsp != NULL || sysid_str == NULL) { | |
2675 | json_object_int_add(json, "id", level + 1); | |
2676 | } | |
2677 | ||
2678 | if (lsp) { | |
2679 | if (ui_level == ISIS_UI_LEVEL_DETAIL) | |
2680 | lsp_print_detail(lsp, NULL, json, | |
2681 | area->dynhostname, area->isis); | |
2682 | else | |
2683 | lsp_print_json(lsp, json, area->dynhostname, | |
2684 | area->isis); | |
2685 | } else if (sysid_str == NULL) { | |
2686 | lsp_count = | |
2687 | lsp_print_all(NULL, json, lspdb, ui_level, | |
2688 | area->dynhostname, area->isis); | |
2689 | ||
2690 | json_object_int_add(json, "count", lsp_count); | |
2691 | } | |
2692 | } | |
2693 | } | |
2694 | void show_isis_database_lspdb_vty(struct vty *vty, struct isis_area *area, | |
2695 | int level, struct lspdb_head *lspdb, | |
2696 | const char *sysid_str, int ui_level) | |
52a7c25e RW |
2697 | { |
2698 | struct isis_lsp *lsp; | |
2699 | int lsp_count; | |
2700 | ||
2701 | if (lspdb_count(lspdb) > 0) { | |
1d88e63a | 2702 | lsp = lsp_for_sysid(lspdb, sysid_str, area->isis); |
52a7c25e | 2703 | |
1d88e63a | 2704 | if (lsp != NULL || sysid_str == NULL) { |
52a7c25e RW |
2705 | vty_out(vty, "IS-IS Level-%d link-state database:\n", |
2706 | level + 1); | |
2707 | ||
2708 | /* print the title in all cases */ | |
2709 | vty_out(vty, | |
2710 | "LSP ID PduLen SeqNumber Chksum Holdtime ATT/P/OL\n"); | |
2711 | } | |
2712 | ||
2713 | if (lsp) { | |
2714 | if (ui_level == ISIS_UI_LEVEL_DETAIL) | |
a2cac12a JG |
2715 | lsp_print_detail(lsp, vty, NULL, |
2716 | area->dynhostname, area->isis); | |
52a7c25e | 2717 | else |
a2cac12a JG |
2718 | lsp_print_vty(lsp, vty, area->dynhostname, |
2719 | area->isis); | |
1d88e63a | 2720 | } else if (sysid_str == NULL) { |
52a7c25e | 2721 | lsp_count = |
a2cac12a | 2722 | lsp_print_all(vty, NULL, lspdb, ui_level, |
52a7c25e RW |
2723 | area->dynhostname, area->isis); |
2724 | ||
2725 | vty_out(vty, " %u LSPs\n\n", lsp_count); | |
2726 | } | |
2727 | } | |
2728 | } | |
2729 | ||
a2cac12a JG |
2730 | static void show_isis_database_json(struct json_object *json, const char *sysid_str, |
2731 | int ui_level, struct isis *isis) | |
2732 | { | |
2733 | struct listnode *node; | |
2734 | struct isis_area *area; | |
2735 | int level; | |
2736 | struct json_object *tag_area_json,*area_json, *lsp_json, *area_arr_json, *arr_json; | |
a2cac12a JG |
2737 | |
2738 | if (isis->area_list->count == 0) | |
2739 | return; | |
2740 | ||
2741 | area_arr_json = json_object_new_array(); | |
2742 | json_object_object_add(json, "areas", area_arr_json); | |
2743 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { | |
2744 | area_json = json_object_new_object(); | |
2745 | tag_area_json = json_object_new_object(); | |
2746 | json_object_string_add(tag_area_json, "name", | |
2747 | area->area_tag ? area->area_tag | |
2748 | : "null"); | |
2749 | ||
2750 | arr_json = json_object_new_array(); | |
2751 | json_object_object_add(area_json,"area",tag_area_json); | |
2752 | json_object_object_add(area_json,"levels",arr_json); | |
2753 | for (level = 0; level < ISIS_LEVELS; level++) { | |
2754 | lsp_json = json_object_new_object(); | |
2755 | show_isis_database_lspdb_json(lsp_json, area, level, | |
2756 | &area->lspdb[level], | |
2757 | sysid_str, ui_level); | |
2758 | json_object_array_add(arr_json, lsp_json); | |
2759 | } | |
2760 | json_object_array_add(area_arr_json, area_json); | |
a2cac12a JG |
2761 | } |
2762 | } | |
2763 | ||
2764 | static void show_isis_database_vty(struct vty *vty, const char *sysid_str, | |
52a7c25e | 2765 | int ui_level, struct isis *isis) |
eb2bcb28 CF |
2766 | { |
2767 | struct listnode *node; | |
2768 | struct isis_area *area; | |
52a7c25e | 2769 | int level; |
eb2bcb28 CF |
2770 | |
2771 | if (isis->area_list->count == 0) | |
52a7c25e | 2772 | return; |
eb2bcb28 | 2773 | |
d62a17ae | 2774 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { |
2775 | vty_out(vty, "Area %s:\n", | |
2776 | area->area_tag ? area->area_tag : "null"); | |
2777 | ||
52a7c25e | 2778 | for (level = 0; level < ISIS_LEVELS; level++) |
a2cac12a | 2779 | show_isis_database_lspdb_vty(vty, area, level, |
1d88e63a | 2780 | &area->lspdb[level], sysid_str, |
52a7c25e | 2781 | ui_level); |
d62a17ae | 2782 | } |
eab88f36 | 2783 | } |
a2cac12a JG |
2784 | |
2785 | static void show_isis_database_common(struct vty *vty, struct json_object *json, const char *sysid_str, | |
2786 | int ui_level, struct isis *isis) | |
2787 | { | |
2788 | if (json) { | |
2789 | show_isis_database_json(json, sysid_str, ui_level, isis); | |
2790 | } else { | |
2791 | show_isis_database_vty(vty, sysid_str, ui_level, isis); | |
2792 | } | |
2793 | } | |
2794 | ||
eab88f36 K |
2795 | /* |
2796 | * This function supports following display options: | |
2797 | * [ show isis database [detail] ] | |
2798 | * [ show isis database <sysid> [detail] ] | |
2799 | * [ show isis database <hostname> [detail] ] | |
2800 | * [ show isis database <sysid>.<pseudo-id> [detail] ] | |
2801 | * [ show isis database <hostname>.<pseudo-id> [detail] ] | |
2802 | * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ] | |
2803 | * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ] | |
2804 | * [ show isis database detail <sysid> ] | |
2805 | * [ show isis database detail <hostname> ] | |
2806 | * [ show isis database detail <sysid>.<pseudo-id> ] | |
2807 | * [ show isis database detail <hostname>.<pseudo-id> ] | |
2808 | * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ] | |
2809 | * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ] | |
2810 | */ | |
a2cac12a | 2811 | static int show_isis_database(struct vty *vty, struct json_object *json, const char *sysid_str, |
1d88e63a | 2812 | int ui_level, const char *vrf_name, bool all_vrf) |
eab88f36 | 2813 | { |
36944791 RW |
2814 | struct listnode *node; |
2815 | struct isis *isis; | |
eab88f36 K |
2816 | |
2817 | if (vrf_name) { | |
2818 | if (all_vrf) { | |
36944791 | 2819 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) |
a2cac12a | 2820 | show_isis_database_common(vty, json, sysid_str, |
1d88e63a | 2821 | ui_level, isis); |
36944791 RW |
2822 | |
2823 | return CMD_SUCCESS; | |
eab88f36 K |
2824 | } |
2825 | isis = isis_lookup_by_vrfname(vrf_name); | |
36944791 | 2826 | if (isis) |
a2cac12a JG |
2827 | show_isis_database_common(vty, json, sysid_str, |
2828 | ui_level, isis); | |
eab88f36 | 2829 | } |
d62a17ae | 2830 | |
2831 | return CMD_SUCCESS; | |
eb5d44eb | 2832 | } |
2833 | ||
eab88f36 | 2834 | DEFUN(show_database, show_database_cmd, |
a2cac12a | 2835 | "show " PROTO_NAME " [vrf <NAME|all>] database [detail] [WORD] [json]", |
eab88f36 K |
2836 | SHOW_STR PROTO_HELP VRF_CMD_HELP_STR |
2837 | "All VRFs\n" | |
2838 | "Link state database\n" | |
2839 | "Detailed information\n" | |
a2cac12a JG |
2840 | "LSP ID\n" |
2841 | "json output\n") | |
3f045a08 | 2842 | { |
a2cac12a | 2843 | int res = CMD_SUCCESS; |
d62a17ae | 2844 | int idx = 0; |
eab88f36 K |
2845 | int idx_vrf = 0; |
2846 | const char *vrf_name = VRF_DEFAULT_NAME; | |
2847 | bool all_vrf = false; | |
d62a17ae | 2848 | int uilevel = argv_find(argv, argc, "detail", &idx) |
2849 | ? ISIS_UI_LEVEL_DETAIL | |
2850 | : ISIS_UI_LEVEL_BRIEF; | |
2851 | char *id = argv_find(argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; | |
a2cac12a JG |
2852 | bool uj = use_json(argc, argv); |
2853 | json_object *json = NULL; | |
2854 | ||
eab88f36 | 2855 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
a2cac12a JG |
2856 | if (uj) |
2857 | json = json_object_new_object(); | |
2858 | ||
2859 | res = show_isis_database(vty, json, id, uilevel, vrf_name, all_vrf); | |
2860 | if (uj) | |
2861 | vty_json(vty, json); | |
2862 | return res; | |
3f045a08 JB |
2863 | } |
2864 | ||
aaf2fd21 | 2865 | #ifdef FABRICD |
d62a17ae | 2866 | /* |
aaf2fd21 | 2867 | * 'router openfabric' command |
3f045a08 | 2868 | */ |
aaf2fd21 EDP |
2869 | DEFUN_NOSH (router_openfabric, |
2870 | router_openfabric_cmd, | |
2871 | "router openfabric WORD", | |
3f045a08 | 2872 | ROUTER_STR |
7c0cbd0e | 2873 | PROTO_HELP |
efd7904e | 2874 | "ISO Routing area tag\n") |
3f045a08 | 2875 | { |
d62a17ae | 2876 | int idx_word = 2; |
2877 | return isis_area_get(vty, argv[idx_word]->arg); | |
3f045a08 JB |
2878 | } |
2879 | ||
d62a17ae | 2880 | /* |
aaf2fd21 | 2881 | *'no router openfabric' command |
3f045a08 | 2882 | */ |
aaf2fd21 EDP |
2883 | DEFUN (no_router_openfabric, |
2884 | no_router_openfabric_cmd, | |
2885 | "no router openfabric WORD", | |
7c0cbd0e CF |
2886 | NO_STR |
2887 | ROUTER_STR | |
2888 | PROTO_HELP | |
2889 | "ISO Routing area tag\n") | |
eb5d44eb | 2890 | { |
14c6e772 RW |
2891 | struct isis_area *area; |
2892 | const char *area_tag; | |
d62a17ae | 2893 | int idx_word = 3; |
14c6e772 RW |
2894 | |
2895 | area_tag = argv[idx_word]->arg; | |
eab88f36 | 2896 | area = isis_area_lookup(area_tag, VRF_DEFAULT); |
14c6e772 RW |
2897 | if (area == NULL) { |
2898 | zlog_warn("%s: could not find area with area-tag %s", | |
2899 | __func__, area_tag); | |
2900 | return CMD_ERR_NO_MATCH; | |
2901 | } | |
2902 | ||
2903 | isis_area_destroy(area); | |
2904 | return CMD_SUCCESS; | |
eb5d44eb | 2905 | } |
aaf2fd21 | 2906 | #endif /* ifdef FABRICD */ |
f084ea55 | 2907 | #ifdef FABRICD |
eb5d44eb | 2908 | /* |
2909 | * 'net' command | |
2910 | */ | |
2911 | DEFUN (net, | |
2912 | net_cmd, | |
2913 | "net WORD", | |
2914 | "A Network Entity Title for this process (OSI only)\n" | |
f390d2c7 | 2915 | "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") |
eb5d44eb | 2916 | { |
d62a17ae | 2917 | int idx_word = 1; |
2918 | return area_net_title(vty, argv[idx_word]->arg); | |
eb5d44eb | 2919 | } |
2920 | ||
eb5d44eb | 2921 | /* |
2922 | * 'no net' command | |
2923 | */ | |
2924 | DEFUN (no_net, | |
2925 | no_net_cmd, | |
2926 | "no net WORD", | |
2927 | NO_STR | |
2928 | "A Network Entity Title for this process (OSI only)\n" | |
f390d2c7 | 2929 | "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") |
eb5d44eb | 2930 | { |
d62a17ae | 2931 | int idx_word = 2; |
2932 | return area_clear_net_title(vty, argv[idx_word]->arg); | |
eb5d44eb | 2933 | } |
f084ea55 | 2934 | #endif /* ifdef FABRICD */ |
22af6a80 | 2935 | #ifdef FABRICD |
064f4896 CF |
2936 | DEFUN (isis_topology, |
2937 | isis_topology_cmd, | |
2938 | "topology " ISIS_MT_NAMES " [overload]", | |
2939 | "Configure IS-IS topologies\n" | |
2940 | ISIS_MT_DESCRIPTIONS | |
2941 | "Set overload bit for topology\n") | |
2942 | { | |
d62a17ae | 2943 | VTY_DECLVAR_CONTEXT(isis_area, area); |
064f4896 | 2944 | |
d62a17ae | 2945 | const char *arg = argv[1]->arg; |
2946 | uint16_t mtid = isis_str2mtid(arg); | |
c3ea3906 | 2947 | |
d62a17ae | 2948 | if (area->oldmetric) { |
2949 | vty_out(vty, | |
2950 | "Multi topology IS-IS can only be used with wide metrics\n"); | |
a5fdb4c5 | 2951 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 2952 | } |
c3ea3906 | 2953 | |
d62a17ae | 2954 | if (mtid == (uint16_t)-1) { |
2955 | vty_out(vty, "Don't know topology '%s'\n", arg); | |
a5fdb4c5 | 2956 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 2957 | } |
2958 | if (mtid == ISIS_MT_IPV4_UNICAST) { | |
2959 | vty_out(vty, "Cannot configure IPv4 unicast topology\n"); | |
a5fdb4c5 | 2960 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 2961 | } |
064f4896 | 2962 | |
d62a17ae | 2963 | area_set_mt_enabled(area, mtid, true); |
2964 | area_set_mt_overload(area, mtid, (argc == 3)); | |
2965 | return CMD_SUCCESS; | |
064f4896 CF |
2966 | } |
2967 | ||
2968 | DEFUN (no_isis_topology, | |
2969 | no_isis_topology_cmd, | |
2970 | "no topology " ISIS_MT_NAMES " [overload]", | |
2971 | NO_STR | |
2972 | "Configure IS-IS topologies\n" | |
2973 | ISIS_MT_DESCRIPTIONS | |
2974 | "Set overload bit for topology\n") | |
2975 | { | |
d62a17ae | 2976 | VTY_DECLVAR_CONTEXT(isis_area, area); |
064f4896 | 2977 | |
d62a17ae | 2978 | const char *arg = argv[2]->arg; |
2979 | uint16_t mtid = isis_str2mtid(arg); | |
c3ea3906 | 2980 | |
d62a17ae | 2981 | if (area->oldmetric) { |
2982 | vty_out(vty, | |
2983 | "Multi topology IS-IS can only be used with wide metrics\n"); | |
a5fdb4c5 | 2984 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 2985 | } |
c3ea3906 | 2986 | |
d62a17ae | 2987 | if (mtid == (uint16_t)-1) { |
2988 | vty_out(vty, "Don't know topology '%s'\n", arg); | |
a5fdb4c5 | 2989 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 2990 | } |
2991 | if (mtid == ISIS_MT_IPV4_UNICAST) { | |
2992 | vty_out(vty, "Cannot configure IPv4 unicast topology\n"); | |
a5fdb4c5 | 2993 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 2994 | } |
064f4896 | 2995 | |
d62a17ae | 2996 | area_set_mt_enabled(area, mtid, false); |
2997 | area_set_mt_overload(area, mtid, false); | |
2998 | return CMD_SUCCESS; | |
064f4896 | 2999 | } |
22af6a80 | 3000 | #endif /* ifdef FABRICD */ |
064f4896 | 3001 | |
6754fc66 | 3002 | void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu) |
b20ccb3a | 3003 | { |
d62a17ae | 3004 | area->lsp_mtu = lsp_mtu; |
3005 | lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1); | |
3006 | } | |
3007 | ||
3008 | static int isis_area_passwd_set(struct isis_area *area, int level, | |
d7c0a89a QY |
3009 | uint8_t passwd_type, const char *passwd, |
3010 | uint8_t snp_auth) | |
d62a17ae | 3011 | { |
3012 | struct isis_passwd *dest; | |
3013 | struct isis_passwd modified; | |
3014 | int len; | |
3015 | ||
3016 | assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2)); | |
3017 | dest = (level == IS_LEVEL_1) ? &area->area_passwd | |
3018 | : &area->domain_passwd; | |
3019 | memset(&modified, 0, sizeof(modified)); | |
3020 | ||
3021 | if (passwd_type != ISIS_PASSWD_TYPE_UNUSED) { | |
3022 | if (!passwd) | |
3023 | return -1; | |
3024 | ||
3025 | len = strlen(passwd); | |
3026 | if (len > 254) | |
3027 | return -1; | |
3028 | ||
3029 | modified.len = len; | |
e28544ed QY |
3030 | strlcpy((char *)modified.passwd, passwd, |
3031 | sizeof(modified.passwd)); | |
d62a17ae | 3032 | modified.type = passwd_type; |
3033 | modified.snp_auth = snp_auth; | |
3034 | } | |
3035 | ||
3036 | if (memcmp(&modified, dest, sizeof(modified))) { | |
3037 | memcpy(dest, &modified, sizeof(modified)); | |
3038 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
3039 | } | |
3040 | ||
3041 | return 0; | |
3042 | } | |
3043 | ||
3044 | int isis_area_passwd_unset(struct isis_area *area, int level) | |
3045 | { | |
3046 | return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_UNUSED, NULL, | |
3047 | 0); | |
3048 | } | |
3049 | ||
3050 | int isis_area_passwd_cleartext_set(struct isis_area *area, int level, | |
d7c0a89a | 3051 | const char *passwd, uint8_t snp_auth) |
d62a17ae | 3052 | { |
3053 | return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_CLEARTXT, | |
3054 | passwd, snp_auth); | |
3055 | } | |
3056 | ||
3057 | int isis_area_passwd_hmac_md5_set(struct isis_area *area, int level, | |
d7c0a89a | 3058 | const char *passwd, uint8_t snp_auth) |
d62a17ae | 3059 | { |
3060 | return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_HMAC_MD5, | |
3061 | passwd, snp_auth); | |
b20ccb3a CF |
3062 | } |
3063 | ||
3dace42d CF |
3064 | void isis_area_invalidate_routes(struct isis_area *area, int levels) |
3065 | { | |
3066 | for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) { | |
3067 | if (!(level & levels)) | |
3068 | continue; | |
be985ba0 CF |
3069 | for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) { |
3070 | isis_spf_invalidate_routes( | |
3071 | area->spftree[tree][level - 1]); | |
3072 | } | |
3dace42d CF |
3073 | } |
3074 | } | |
3075 | ||
3076 | void isis_area_verify_routes(struct isis_area *area) | |
3077 | { | |
be985ba0 CF |
3078 | for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) |
3079 | isis_spf_verify_routes(area, area->spftree[tree]); | |
3dace42d CF |
3080 | } |
3081 | ||
694fa867 LS |
3082 | void isis_area_switchover_routes(struct isis_area *area, int family, |
3083 | union g_addr *nexthop_ip, ifindex_t ifindex, | |
3084 | int level) | |
3085 | { | |
3086 | int tree; | |
3087 | ||
3088 | /* TODO SPFTREE_DSTSRC */ | |
3089 | if (family == AF_INET) | |
3090 | tree = SPFTREE_IPV4; | |
3091 | else if (family == AF_INET6) | |
3092 | tree = SPFTREE_IPV6; | |
3093 | else | |
3094 | return; | |
3095 | ||
3096 | isis_spf_switchover_routes(area, area->spftree[tree], family, | |
3097 | nexthop_ip, ifindex, level); | |
3098 | } | |
3099 | ||
3100 | ||
d62a17ae | 3101 | static void area_resign_level(struct isis_area *area, int level) |
3f045a08 | 3102 | { |
3dace42d CF |
3103 | isis_area_invalidate_routes(area, level); |
3104 | isis_area_verify_routes(area); | |
3105 | ||
4bef0ec4 | 3106 | lsp_db_fini(&area->lspdb[level - 1]); |
be985ba0 CF |
3107 | |
3108 | for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) { | |
3109 | if (area->spftree[tree][level - 1]) { | |
3110 | isis_spftree_del(area->spftree[tree][level - 1]); | |
3111 | area->spftree[tree][level - 1] = NULL; | |
3112 | } | |
d62a17ae | 3113 | } |
be985ba0 | 3114 | |
8f15843b DS |
3115 | if (area->spf_timer[level - 1]) |
3116 | isis_spf_timer_free(THREAD_ARG(area->spf_timer[level - 1])); | |
3117 | ||
fa935aa7 | 3118 | THREAD_OFF(area->spf_timer[level - 1]); |
3f045a08 | 3119 | |
d62a17ae | 3120 | sched_debug( |
3121 | "ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.", | |
3122 | area->area_tag, level); | |
fa935aa7 | 3123 | THREAD_OFF(area->t_lsp_refresh[level - 1]); |
d62a17ae | 3124 | area->lsp_regenerate_pending[level - 1] = 0; |
3125 | } | |
3f045a08 | 3126 | |
d62a17ae | 3127 | void isis_area_is_type_set(struct isis_area *area, int is_type) |
3128 | { | |
3129 | struct listnode *node; | |
3130 | struct isis_circuit *circuit; | |
3f045a08 | 3131 | |
e740f9c1 | 3132 | if (IS_DEBUG_EVENTS) |
d62a17ae | 3133 | zlog_debug("ISIS-Evt (%s) system type change %s -> %s", |
3134 | area->area_tag, circuit_t2string(area->is_type), | |
3135 | circuit_t2string(is_type)); | |
f390d2c7 | 3136 | |
d62a17ae | 3137 | if (area->is_type == is_type) |
3138 | return; /* No change */ | |
3139 | ||
3140 | switch (area->is_type) { | |
3141 | case IS_LEVEL_1: | |
3142 | if (is_type == IS_LEVEL_2) | |
3143 | area_resign_level(area, IS_LEVEL_1); | |
3144 | ||
4bef0ec4 | 3145 | lsp_db_init(&area->lspdb[1]); |
d62a17ae | 3146 | break; |
3147 | ||
3148 | case IS_LEVEL_1_AND_2: | |
3149 | if (is_type == IS_LEVEL_1) | |
3150 | area_resign_level(area, IS_LEVEL_2); | |
3151 | else | |
3152 | area_resign_level(area, IS_LEVEL_1); | |
3153 | break; | |
3154 | ||
3155 | case IS_LEVEL_2: | |
3156 | if (is_type == IS_LEVEL_1) | |
3157 | area_resign_level(area, IS_LEVEL_2); | |
3158 | ||
4bef0ec4 | 3159 | lsp_db_init(&area->lspdb[0]); |
d62a17ae | 3160 | break; |
3161 | ||
3162 | default: | |
3163 | break; | |
3164 | } | |
3165 | ||
3166 | area->is_type = is_type; | |
3167 | ||
2f9a06f0 IR |
3168 | /* |
3169 | * If area's IS type is strict Level-1 or Level-2, override circuit's | |
3170 | * IS type. Otherwise use circuit's configured IS type. | |
3171 | */ | |
d62a17ae | 3172 | if (area->is_type != IS_LEVEL_1_AND_2) { |
3173 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) | |
3174 | isis_circuit_is_type_set(circuit, is_type); | |
2f9a06f0 IR |
3175 | } else { |
3176 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) | |
3177 | isis_circuit_is_type_set(circuit, circuit->is_type_config); | |
d62a17ae | 3178 | } |
3179 | ||
3180 | spftree_area_init(area); | |
3181 | ||
3182 | if (listcount(area->area_addrs) > 0) { | |
3183 | if (is_type & IS_LEVEL_1) | |
3184 | lsp_generate(area, IS_LEVEL_1); | |
3185 | if (is_type & IS_LEVEL_2) | |
3186 | lsp_generate(area, IS_LEVEL_2); | |
3187 | } | |
3188 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
3189 | ||
3190 | return; | |
eb5d44eb | 3191 | } |
3192 | ||
a38a72db CF |
3193 | void isis_area_metricstyle_set(struct isis_area *area, bool old_metric, |
3194 | bool new_metric) | |
e38e0df0 | 3195 | { |
e0df3206 EDP |
3196 | area->oldmetric = old_metric; |
3197 | area->newmetric = new_metric; | |
3198 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
e38e0df0 SV |
3199 | } |
3200 | ||
a38a72db | 3201 | void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit) |
eb5d44eb | 3202 | { |
d62a17ae | 3203 | char new_overload_bit = overload_bit ? LSPBIT_OL : 0; |
eb5d44eb | 3204 | |
d62a17ae | 3205 | if (new_overload_bit != area->overload_bit) { |
3206 | area->overload_bit = new_overload_bit; | |
4afc7836 | 3207 | if (new_overload_bit) { |
1ee746d9 | 3208 | area->overload_counter++; |
4afc7836 IL |
3209 | } else { |
3210 | /* Cancel overload on startup timer if it's running */ | |
3211 | if (area->t_overload_on_startup_timer) { | |
3212 | THREAD_OFF(area->t_overload_on_startup_timer); | |
3213 | area->t_overload_on_startup_timer = NULL; | |
3214 | } | |
3215 | } | |
1ee746d9 | 3216 | |
3217 | #ifndef FABRICD | |
3218 | hook_call(isis_hook_db_overload, area); | |
3219 | #endif /* ifndef FABRICD */ | |
3220 | ||
d62a17ae | 3221 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); |
3222 | } | |
9414b6f6 EDP |
3223 | #ifndef FABRICD |
3224 | isis_notif_db_overload(area, overload_bit); | |
3225 | #endif /* ifndef FABRICD */ | |
3f045a08 JB |
3226 | } |
3227 | ||
01ea9b03 IL |
3228 | void isis_area_overload_on_startup_set(struct isis_area *area, |
3229 | uint32_t startup_time) | |
3230 | { | |
450841fe | 3231 | if (area->overload_on_startup_time != startup_time) { |
01ea9b03 | 3232 | area->overload_on_startup_time = startup_time; |
450841fe IL |
3233 | isis_restart_write_overload_time(area, startup_time); |
3234 | } | |
3235 | } | |
3236 | ||
3237 | /* | |
3238 | * Returns the path of the file (non-volatile memory) that contains restart | |
3239 | * information. | |
3240 | */ | |
103372fd | 3241 | char *isis_restart_filepath(void) |
450841fe IL |
3242 | { |
3243 | static char filepath[MAXPATHLEN]; | |
3244 | snprintf(filepath, sizeof(filepath), ISISD_RESTART, ""); | |
3245 | return filepath; | |
3246 | } | |
3247 | ||
3248 | /* | |
3249 | * Record in non-volatile memory the overload on startup time. | |
3250 | */ | |
3251 | void isis_restart_write_overload_time(struct isis_area *isis_area, | |
3252 | uint32_t overload_time) | |
3253 | { | |
3254 | char *filepath; | |
3255 | const char *area_name; | |
3256 | json_object *json; | |
3257 | json_object *json_areas; | |
3258 | json_object *json_area; | |
3259 | ||
3260 | filepath = isis_restart_filepath(); | |
3261 | area_name = isis_area->area_tag; | |
3262 | ||
3263 | json = json_object_from_file(filepath); | |
3264 | if (json == NULL) | |
3265 | json = json_object_new_object(); | |
3266 | ||
3267 | json_object_object_get_ex(json, "areas", &json_areas); | |
3268 | if (!json_areas) { | |
3269 | json_areas = json_object_new_object(); | |
3270 | json_object_object_add(json, "areas", json_areas); | |
3271 | } | |
3272 | ||
3273 | json_object_object_get_ex(json_areas, area_name, &json_area); | |
3274 | if (!json_area) { | |
3275 | json_area = json_object_new_object(); | |
3276 | json_object_object_add(json_areas, area_name, json_area); | |
3277 | } | |
3278 | ||
3279 | json_object_int_add(json_area, "overload_time", | |
3280 | isis_area->overload_on_startup_time); | |
3281 | json_object_to_file_ext(filepath, json, JSON_C_TO_STRING_PRETTY); | |
3282 | json_object_free(json); | |
3283 | } | |
3284 | ||
3285 | /* | |
3286 | * Fetch from non-volatile memory the overload on startup time. | |
3287 | */ | |
3288 | uint32_t isis_restart_read_overload_time(struct isis_area *isis_area) | |
3289 | { | |
3290 | char *filepath; | |
3291 | const char *area_name; | |
3292 | json_object *json; | |
3293 | json_object *json_areas; | |
3294 | json_object *json_area; | |
3295 | json_object *json_overload_time; | |
3296 | uint32_t overload_time = 0; | |
3297 | ||
3298 | filepath = isis_restart_filepath(); | |
3299 | area_name = isis_area->area_tag; | |
3300 | ||
3301 | json = json_object_from_file(filepath); | |
3302 | if (json == NULL) | |
3303 | json = json_object_new_object(); | |
3304 | ||
3305 | json_object_object_get_ex(json, "areas", &json_areas); | |
3306 | if (!json_areas) { | |
3307 | json_areas = json_object_new_object(); | |
3308 | json_object_object_add(json, "areas", json_areas); | |
3309 | } | |
3310 | ||
3311 | json_object_object_get_ex(json_areas, area_name, &json_area); | |
3312 | if (!json_area) { | |
3313 | json_area = json_object_new_object(); | |
3314 | json_object_object_add(json_areas, area_name, json_area); | |
3315 | } | |
3316 | ||
3317 | json_object_object_get_ex(json_area, "overload_time", | |
3318 | &json_overload_time); | |
3319 | if (json_overload_time) { | |
3320 | overload_time = json_object_get_int(json_overload_time); | |
3321 | } | |
3322 | ||
3323 | json_object_object_del(json_areas, area_name); | |
3324 | ||
3325 | json_object_to_file_ext(filepath, json, JSON_C_TO_STRING_PRETTY); | |
3326 | json_object_free(json); | |
3327 | ||
3328 | return overload_time; | |
01ea9b03 IL |
3329 | } |
3330 | ||
f3abc412 | 3331 | void isis_area_attached_bit_send_set(struct isis_area *area, bool attached_bit) |
3332 | { | |
3333 | ||
3334 | if (attached_bit != area->attached_bit_send) { | |
3335 | area->attached_bit_send = attached_bit; | |
3336 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
3337 | } | |
3338 | } | |
3339 | ||
3340 | void isis_area_attached_bit_receive_set(struct isis_area *area, | |
3341 | bool attached_bit) | |
3f045a08 | 3342 | { |
3f045a08 | 3343 | |
f3abc412 | 3344 | if (attached_bit != area->attached_bit_rcv_ignore) { |
3345 | area->attached_bit_rcv_ignore = attached_bit; | |
d62a17ae | 3346 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); |
3347 | } | |
eb5d44eb | 3348 | } |
3349 | ||
a38a72db | 3350 | void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname) |
eb5d44eb | 3351 | { |
d62a17ae | 3352 | if (area->dynhostname != dynhostname) { |
3353 | area->dynhostname = dynhostname; | |
3354 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
3355 | } | |
eb5d44eb | 3356 | } |
3357 | ||
d62a17ae | 3358 | void isis_area_max_lsp_lifetime_set(struct isis_area *area, int level, |
3359 | uint16_t max_lsp_lifetime) | |
eb5d44eb | 3360 | { |
d62a17ae | 3361 | assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2)); |
eb5d44eb | 3362 | |
d62a17ae | 3363 | if (area->max_lsp_lifetime[level - 1] == max_lsp_lifetime) |
3364 | return; | |
3f045a08 | 3365 | |
d62a17ae | 3366 | area->max_lsp_lifetime[level - 1] = max_lsp_lifetime; |
3367 | lsp_regenerate_schedule(area, level, 1); | |
3f045a08 JB |
3368 | } |
3369 | ||
d62a17ae | 3370 | void isis_area_lsp_refresh_set(struct isis_area *area, int level, |
3371 | uint16_t lsp_refresh) | |
3f045a08 | 3372 | { |
d62a17ae | 3373 | assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2)); |
eb5d44eb | 3374 | |
d62a17ae | 3375 | if (area->lsp_refresh[level - 1] == lsp_refresh) |
3376 | return; | |
eb5d44eb | 3377 | |
d62a17ae | 3378 | area->lsp_refresh[level - 1] = lsp_refresh; |
3379 | lsp_regenerate_schedule(area, level, 1); | |
3f045a08 JB |
3380 | } |
3381 | ||
2adf66ff | 3382 | #ifdef FABRICD |
3f045a08 JB |
3383 | DEFUN (log_adj_changes, |
3384 | log_adj_changes_cmd, | |
3385 | "log-adjacency-changes", | |
3386 | "Log changes in adjacency state\n") | |
3387 | { | |
d62a17ae | 3388 | VTY_DECLVAR_CONTEXT(isis_area, area); |
eb5d44eb | 3389 | |
d62a17ae | 3390 | area->log_adj_changes = 1; |
eb5d44eb | 3391 | |
d62a17ae | 3392 | return CMD_SUCCESS; |
eb5d44eb | 3393 | } |
3394 | ||
3f045a08 JB |
3395 | DEFUN (no_log_adj_changes, |
3396 | no_log_adj_changes_cmd, | |
3397 | "no log-adjacency-changes", | |
d7fa34c1 | 3398 | NO_STR |
3f045a08 | 3399 | "Stop logging changes in adjacency state\n") |
eb5d44eb | 3400 | { |
d62a17ae | 3401 | VTY_DECLVAR_CONTEXT(isis_area, area); |
f390d2c7 | 3402 | |
d62a17ae | 3403 | area->log_adj_changes = 0; |
eb5d44eb | 3404 | |
d62a17ae | 3405 | return CMD_SUCCESS; |
eb5d44eb | 3406 | } |
2adf66ff | 3407 | #endif /* ifdef FABRICD */ |
20600086 | 3408 | #ifdef FABRICD |
eb5d44eb | 3409 | /* IS-IS configuration write function */ |
612c2c15 | 3410 | static int isis_config_write(struct vty *vty) |
d62a17ae | 3411 | { |
3412 | int write = 0; | |
eab88f36 | 3413 | struct isis_area *area; |
36944791 RW |
3414 | struct listnode *node, *node2, *inode; |
3415 | struct isis *isis; | |
eab88f36 K |
3416 | |
3417 | if (!im) { | |
3418 | vty_out(vty, "IS-IS Routing Process not enabled\n"); | |
3419 | return CMD_SUCCESS; | |
3420 | } | |
d62a17ae | 3421 | |
36944791 | 3422 | for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { |
d62a17ae | 3423 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { |
3424 | /* ISIS - Area name */ | |
7c0cbd0e | 3425 | vty_out(vty, "router " PROTO_NAME " %s\n", area->area_tag); |
d62a17ae | 3426 | write++; |
3427 | /* ISIS - Net */ | |
3428 | if (listcount(area->area_addrs) > 0) { | |
3429 | struct area_addr *area_addr; | |
3430 | for (ALL_LIST_ELEMENTS_RO(area->area_addrs, | |
3431 | node2, area_addr)) { | |
3432 | vty_out(vty, " net %s\n", | |
3433 | isonet_print( | |
3434 | area_addr->area_addr, | |
3435 | area_addr->addr_len | |
3436 | + ISIS_SYS_ID_LEN | |
3437 | + 1)); | |
3438 | write++; | |
3439 | } | |
3440 | } | |
3441 | /* ISIS - Dynamic hostname - Defaults to true so only | |
3442 | * display if | |
3443 | * false. */ | |
3444 | if (!area->dynhostname) { | |
3445 | vty_out(vty, " no hostname dynamic\n"); | |
3446 | write++; | |
3447 | } | |
3448 | /* ISIS - Metric-Style - when true displays wide */ | |
65f18157 CF |
3449 | if (!fabricd) { |
3450 | if (area->newmetric) { | |
3451 | if (!area->oldmetric) | |
3452 | vty_out(vty, " metric-style wide\n"); | |
3453 | else | |
3454 | vty_out(vty, | |
3455 | " metric-style transition\n"); | |
3456 | write++; | |
3457 | } else { | |
3458 | vty_out(vty, " metric-style narrow\n"); | |
3459 | write++; | |
3460 | } | |
d62a17ae | 3461 | } |
3462 | /* ISIS - overload-bit */ | |
3463 | if (area->overload_bit) { | |
3464 | vty_out(vty, " set-overload-bit\n"); | |
3465 | write++; | |
3466 | } | |
3467 | /* ISIS - Area is-type (level-1-2 is default) */ | |
65f18157 CF |
3468 | if (!fabricd) { |
3469 | if (area->is_type == IS_LEVEL_1) { | |
3470 | vty_out(vty, " is-type level-1\n"); | |
3471 | write++; | |
3472 | } else if (area->is_type == IS_LEVEL_2) { | |
3473 | vty_out(vty, " is-type level-2-only\n"); | |
3474 | write++; | |
3475 | } | |
d62a17ae | 3476 | } |
3477 | write += isis_redist_config_write(vty, area, AF_INET); | |
3478 | write += isis_redist_config_write(vty, area, AF_INET6); | |
3479 | /* ISIS - Lsp generation interval */ | |
3480 | if (area->lsp_gen_interval[0] | |
3481 | == area->lsp_gen_interval[1]) { | |
3482 | if (area->lsp_gen_interval[0] | |
3483 | != DEFAULT_MIN_LSP_GEN_INTERVAL) { | |
3484 | vty_out(vty, " lsp-gen-interval %d\n", | |
3485 | area->lsp_gen_interval[0]); | |
3486 | write++; | |
3487 | } | |
3488 | } else { | |
3489 | if (area->lsp_gen_interval[0] | |
3490 | != DEFAULT_MIN_LSP_GEN_INTERVAL) { | |
3491 | vty_out(vty, | |
3492 | " lsp-gen-interval level-1 %d\n", | |
3493 | area->lsp_gen_interval[0]); | |
3494 | write++; | |
3495 | } | |
3496 | if (area->lsp_gen_interval[1] | |
3497 | != DEFAULT_MIN_LSP_GEN_INTERVAL) { | |
3498 | vty_out(vty, | |
3499 | " lsp-gen-interval level-2 %d\n", | |
3500 | area->lsp_gen_interval[1]); | |
3501 | write++; | |
3502 | } | |
3503 | } | |
3504 | /* ISIS - LSP lifetime */ | |
3505 | if (area->max_lsp_lifetime[0] | |
3506 | == area->max_lsp_lifetime[1]) { | |
3507 | if (area->max_lsp_lifetime[0] | |
3508 | != DEFAULT_LSP_LIFETIME) { | |
3509 | vty_out(vty, " max-lsp-lifetime %u\n", | |
3510 | area->max_lsp_lifetime[0]); | |
3511 | write++; | |
3512 | } | |
3513 | } else { | |
3514 | if (area->max_lsp_lifetime[0] | |
3515 | != DEFAULT_LSP_LIFETIME) { | |
3516 | vty_out(vty, | |
3517 | " max-lsp-lifetime level-1 %u\n", | |
3518 | area->max_lsp_lifetime[0]); | |
3519 | write++; | |
3520 | } | |
3521 | if (area->max_lsp_lifetime[1] | |
3522 | != DEFAULT_LSP_LIFETIME) { | |
3523 | vty_out(vty, | |
3524 | " max-lsp-lifetime level-2 %u\n", | |
3525 | area->max_lsp_lifetime[1]); | |
3526 | write++; | |
3527 | } | |
3528 | } | |
3529 | /* ISIS - LSP refresh interval */ | |
3530 | if (area->lsp_refresh[0] == area->lsp_refresh[1]) { | |
3531 | if (area->lsp_refresh[0] | |
3532 | != DEFAULT_MAX_LSP_GEN_INTERVAL) { | |
3533 | vty_out(vty, | |
3534 | " lsp-refresh-interval %u\n", | |
3535 | area->lsp_refresh[0]); | |
3536 | write++; | |
3537 | } | |
3538 | } else { | |
3539 | if (area->lsp_refresh[0] | |
3540 | != DEFAULT_MAX_LSP_GEN_INTERVAL) { | |
3541 | vty_out(vty, | |
3542 | " lsp-refresh-interval level-1 %u\n", | |
3543 | area->lsp_refresh[0]); | |
3544 | write++; | |
3545 | } | |
3546 | if (area->lsp_refresh[1] | |
3547 | != DEFAULT_MAX_LSP_GEN_INTERVAL) { | |
3548 | vty_out(vty, | |
3549 | " lsp-refresh-interval level-2 %u\n", | |
3550 | area->lsp_refresh[1]); | |
3551 | write++; | |
3552 | } | |
3553 | } | |
3554 | if (area->lsp_mtu != DEFAULT_LSP_MTU) { | |
3555 | vty_out(vty, " lsp-mtu %u\n", area->lsp_mtu); | |
3556 | write++; | |
3557 | } | |
2c92bee4 CF |
3558 | if (area->purge_originator) { |
3559 | vty_out(vty, " purge-originator\n"); | |
3560 | write++; | |
3561 | } | |
d62a17ae | 3562 | |
3563 | /* Minimum SPF interval. */ | |
3564 | if (area->min_spf_interval[0] | |
3565 | == area->min_spf_interval[1]) { | |
3566 | if (area->min_spf_interval[0] | |
3567 | != MINIMUM_SPF_INTERVAL) { | |
3568 | vty_out(vty, " spf-interval %d\n", | |
3569 | area->min_spf_interval[0]); | |
3570 | write++; | |
3571 | } | |
3572 | } else { | |
3573 | if (area->min_spf_interval[0] | |
3574 | != MINIMUM_SPF_INTERVAL) { | |
3575 | vty_out(vty, | |
3576 | " spf-interval level-1 %d\n", | |
3577 | area->min_spf_interval[0]); | |
3578 | write++; | |
3579 | } | |
3580 | if (area->min_spf_interval[1] | |
3581 | != MINIMUM_SPF_INTERVAL) { | |
3582 | vty_out(vty, | |
3583 | " spf-interval level-2 %d\n", | |
3584 | area->min_spf_interval[1]); | |
3585 | write++; | |
3586 | } | |
3587 | } | |
3588 | ||
3589 | /* IETF SPF interval */ | |
3590 | if (area->spf_delay_ietf[0]) { | |
3591 | vty_out(vty, | |
3592 | " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld\n", | |
3593 | spf_backoff_init_delay( | |
3594 | area->spf_delay_ietf[0]), | |
3595 | spf_backoff_short_delay( | |
3596 | area->spf_delay_ietf[0]), | |
3597 | spf_backoff_long_delay( | |
3598 | area->spf_delay_ietf[0]), | |
3599 | spf_backoff_holddown( | |
3600 | area->spf_delay_ietf[0]), | |
3601 | spf_backoff_timetolearn( | |
3602 | area->spf_delay_ietf[0])); | |
3603 | write++; | |
3604 | } | |
3605 | ||
3606 | /* Authentication passwords. */ | |
3607 | if (area->area_passwd.type | |
3608 | == ISIS_PASSWD_TYPE_HMAC_MD5) { | |
3609 | vty_out(vty, " area-password md5 %s", | |
3610 | area->area_passwd.passwd); | |
3611 | if (CHECK_FLAG(area->area_passwd.snp_auth, | |
3612 | SNP_AUTH_SEND)) { | |
3613 | vty_out(vty, " authenticate snp "); | |
3614 | if (CHECK_FLAG( | |
3615 | area->area_passwd.snp_auth, | |
3616 | SNP_AUTH_RECV)) | |
3617 | vty_out(vty, "validate"); | |
3618 | else | |
3619 | vty_out(vty, "send-only"); | |
3620 | } | |
3621 | vty_out(vty, "\n"); | |
3622 | write++; | |
3623 | } else if (area->area_passwd.type | |
3624 | == ISIS_PASSWD_TYPE_CLEARTXT) { | |
3625 | vty_out(vty, " area-password clear %s", | |
3626 | area->area_passwd.passwd); | |
3627 | if (CHECK_FLAG(area->area_passwd.snp_auth, | |
3628 | SNP_AUTH_SEND)) { | |
3629 | vty_out(vty, " authenticate snp "); | |
3630 | if (CHECK_FLAG( | |
3631 | area->area_passwd.snp_auth, | |
3632 | SNP_AUTH_RECV)) | |
3633 | vty_out(vty, "validate"); | |
3634 | else | |
3635 | vty_out(vty, "send-only"); | |
3636 | } | |
3637 | vty_out(vty, "\n"); | |
3638 | write++; | |
3639 | } | |
3640 | if (area->domain_passwd.type | |
3641 | == ISIS_PASSWD_TYPE_HMAC_MD5) { | |
3642 | vty_out(vty, " domain-password md5 %s", | |
3643 | area->domain_passwd.passwd); | |
3644 | if (CHECK_FLAG(area->domain_passwd.snp_auth, | |
3645 | SNP_AUTH_SEND)) { | |
3646 | vty_out(vty, " authenticate snp "); | |
3647 | if (CHECK_FLAG(area->domain_passwd | |
3648 | .snp_auth, | |
3649 | SNP_AUTH_RECV)) | |
3650 | vty_out(vty, "validate"); | |
3651 | else | |
3652 | vty_out(vty, "send-only"); | |
3653 | } | |
3654 | vty_out(vty, "\n"); | |
3655 | write++; | |
3656 | } else if (area->domain_passwd.type | |
3657 | == ISIS_PASSWD_TYPE_CLEARTXT) { | |
3658 | vty_out(vty, " domain-password clear %s", | |
3659 | area->domain_passwd.passwd); | |
3660 | if (CHECK_FLAG(area->domain_passwd.snp_auth, | |
3661 | SNP_AUTH_SEND)) { | |
3662 | vty_out(vty, " authenticate snp "); | |
3663 | if (CHECK_FLAG(area->domain_passwd | |
3664 | .snp_auth, | |
3665 | SNP_AUTH_RECV)) | |
3666 | vty_out(vty, "validate"); | |
3667 | else | |
3668 | vty_out(vty, "send-only"); | |
3669 | } | |
3670 | vty_out(vty, "\n"); | |
3671 | write++; | |
3672 | } | |
3673 | ||
3674 | if (area->log_adj_changes) { | |
3675 | vty_out(vty, " log-adjacency-changes\n"); | |
3676 | write++; | |
3677 | } | |
3678 | ||
3679 | write += area_write_mt_settings(area, vty); | |
92ed0cde | 3680 | write += fabricd_write_settings(area, vty); |
07679ad9 IR |
3681 | |
3682 | vty_out(vty, "exit\n"); | |
d62a17ae | 3683 | } |
d62a17ae | 3684 | } |
3685 | ||
3686 | return write; | |
3687 | } | |
3688 | ||
f4b8291f DL |
3689 | struct cmd_node router_node = { |
3690 | .name = "openfabric", | |
3691 | .node = OPENFABRIC_NODE, | |
3692 | .parent_node = CONFIG_NODE, | |
3693 | .prompt = "%s(config-router)# ", | |
3694 | .config_write = isis_config_write, | |
3695 | }; | |
20600086 EDP |
3696 | #else |
3697 | /* IS-IS configuration write function */ | |
612c2c15 | 3698 | static int isis_config_write(struct vty *vty) |
20600086 EDP |
3699 | { |
3700 | int write = 0; | |
3701 | struct lyd_node *dnode; | |
3702 | ||
3703 | dnode = yang_dnode_get(running_config->dnode, "/frr-isisd:isis"); | |
cc50ddb2 | 3704 | if (dnode) { |
20600086 | 3705 | nb_cli_show_dnode_cmds(vty, dnode, false); |
cc50ddb2 EDP |
3706 | write++; |
3707 | } | |
20600086 EDP |
3708 | |
3709 | return write; | |
3710 | } | |
20600086 | 3711 | |
62b346ee | 3712 | struct cmd_node router_node = { |
f4b8291f DL |
3713 | .name = "isis", |
3714 | .node = ISIS_NODE, | |
24389580 | 3715 | .parent_node = CONFIG_NODE, |
62b346ee | 3716 | .prompt = "%s(config-router)# ", |
612c2c15 | 3717 | .config_write = isis_config_write, |
62b346ee | 3718 | }; |
f4b8291f | 3719 | #endif /* ifdef FABRICD */ |
d62a17ae | 3720 | |
4d762f26 | 3721 | void isis_init(void) |
d62a17ae | 3722 | { |
3723 | /* Install IS-IS top node */ | |
612c2c15 | 3724 | install_node(&router_node); |
d62a17ae | 3725 | |
3726 | install_element(VIEW_NODE, &show_isis_summary_cmd); | |
3727 | ||
3728 | install_element(VIEW_NODE, &show_isis_spf_ietf_cmd); | |
3729 | ||
3730 | install_element(VIEW_NODE, &show_isis_interface_cmd); | |
3731 | install_element(VIEW_NODE, &show_isis_interface_detail_cmd); | |
3732 | install_element(VIEW_NODE, &show_isis_interface_arg_cmd); | |
3733 | ||
3734 | install_element(VIEW_NODE, &show_isis_neighbor_cmd); | |
3735 | install_element(VIEW_NODE, &show_isis_neighbor_detail_cmd); | |
3736 | install_element(VIEW_NODE, &show_isis_neighbor_arg_cmd); | |
2b55d953 IR |
3737 | install_element(ENABLE_NODE, &clear_isis_neighbor_cmd); |
3738 | install_element(ENABLE_NODE, &clear_isis_neighbor_arg_cmd); | |
d62a17ae | 3739 | |
3740 | install_element(VIEW_NODE, &show_hostname_cmd); | |
3741 | install_element(VIEW_NODE, &show_database_cmd); | |
3742 | ||
3743 | install_element(ENABLE_NODE, &show_debugging_isis_cmd); | |
3744 | ||
612c2c15 | 3745 | install_node(&debug_node); |
d62a17ae | 3746 | |
3747 | install_element(ENABLE_NODE, &debug_isis_adj_cmd); | |
3748 | install_element(ENABLE_NODE, &no_debug_isis_adj_cmd); | |
161fa356 CF |
3749 | install_element(ENABLE_NODE, &debug_isis_tx_queue_cmd); |
3750 | install_element(ENABLE_NODE, &no_debug_isis_tx_queue_cmd); | |
ddb33326 CF |
3751 | install_element(ENABLE_NODE, &debug_isis_flooding_cmd); |
3752 | install_element(ENABLE_NODE, &no_debug_isis_flooding_cmd); | |
d62a17ae | 3753 | install_element(ENABLE_NODE, &debug_isis_snp_cmd); |
3754 | install_element(ENABLE_NODE, &no_debug_isis_snp_cmd); | |
3755 | install_element(ENABLE_NODE, &debug_isis_upd_cmd); | |
3756 | install_element(ENABLE_NODE, &no_debug_isis_upd_cmd); | |
3757 | install_element(ENABLE_NODE, &debug_isis_spfevents_cmd); | |
3758 | install_element(ENABLE_NODE, &no_debug_isis_spfevents_cmd); | |
26f6acaf RW |
3759 | install_element(ENABLE_NODE, &debug_isis_srevents_cmd); |
3760 | install_element(ENABLE_NODE, &no_debug_isis_srevents_cmd); | |
d9884a75 OD |
3761 | install_element(ENABLE_NODE, &debug_isis_teevents_cmd); |
3762 | install_element(ENABLE_NODE, &no_debug_isis_teevents_cmd); | |
2866b119 RW |
3763 | install_element(ENABLE_NODE, &debug_isis_lfa_cmd); |
3764 | install_element(ENABLE_NODE, &no_debug_isis_lfa_cmd); | |
d62a17ae | 3765 | install_element(ENABLE_NODE, &debug_isis_rtevents_cmd); |
3766 | install_element(ENABLE_NODE, &no_debug_isis_rtevents_cmd); | |
3767 | install_element(ENABLE_NODE, &debug_isis_events_cmd); | |
3768 | install_element(ENABLE_NODE, &no_debug_isis_events_cmd); | |
3769 | install_element(ENABLE_NODE, &debug_isis_packet_dump_cmd); | |
3770 | install_element(ENABLE_NODE, &no_debug_isis_packet_dump_cmd); | |
3771 | install_element(ENABLE_NODE, &debug_isis_lsp_gen_cmd); | |
3772 | install_element(ENABLE_NODE, &no_debug_isis_lsp_gen_cmd); | |
3773 | install_element(ENABLE_NODE, &debug_isis_lsp_sched_cmd); | |
3774 | install_element(ENABLE_NODE, &no_debug_isis_lsp_sched_cmd); | |
2815f817 CF |
3775 | install_element(ENABLE_NODE, &debug_isis_bfd_cmd); |
3776 | install_element(ENABLE_NODE, &no_debug_isis_bfd_cmd); | |
1cbf96a8 | 3777 | install_element(ENABLE_NODE, &debug_isis_ldp_sync_cmd); |
3778 | install_element(ENABLE_NODE, &no_debug_isis_ldp_sync_cmd); | |
d62a17ae | 3779 | |
3780 | install_element(CONFIG_NODE, &debug_isis_adj_cmd); | |
3781 | install_element(CONFIG_NODE, &no_debug_isis_adj_cmd); | |
161fa356 CF |
3782 | install_element(CONFIG_NODE, &debug_isis_tx_queue_cmd); |
3783 | install_element(CONFIG_NODE, &no_debug_isis_tx_queue_cmd); | |
ddb33326 CF |
3784 | install_element(CONFIG_NODE, &debug_isis_flooding_cmd); |
3785 | install_element(CONFIG_NODE, &no_debug_isis_flooding_cmd); | |
d62a17ae | 3786 | install_element(CONFIG_NODE, &debug_isis_snp_cmd); |
3787 | install_element(CONFIG_NODE, &no_debug_isis_snp_cmd); | |
3788 | install_element(CONFIG_NODE, &debug_isis_upd_cmd); | |
3789 | install_element(CONFIG_NODE, &no_debug_isis_upd_cmd); | |
3790 | install_element(CONFIG_NODE, &debug_isis_spfevents_cmd); | |
3791 | install_element(CONFIG_NODE, &no_debug_isis_spfevents_cmd); | |
26f6acaf RW |
3792 | install_element(CONFIG_NODE, &debug_isis_srevents_cmd); |
3793 | install_element(CONFIG_NODE, &no_debug_isis_srevents_cmd); | |
d9884a75 OD |
3794 | install_element(CONFIG_NODE, &debug_isis_teevents_cmd); |
3795 | install_element(CONFIG_NODE, &no_debug_isis_teevents_cmd); | |
2866b119 RW |
3796 | install_element(CONFIG_NODE, &debug_isis_lfa_cmd); |
3797 | install_element(CONFIG_NODE, &no_debug_isis_lfa_cmd); | |
d62a17ae | 3798 | install_element(CONFIG_NODE, &debug_isis_rtevents_cmd); |
3799 | install_element(CONFIG_NODE, &no_debug_isis_rtevents_cmd); | |
3800 | install_element(CONFIG_NODE, &debug_isis_events_cmd); | |
3801 | install_element(CONFIG_NODE, &no_debug_isis_events_cmd); | |
3802 | install_element(CONFIG_NODE, &debug_isis_packet_dump_cmd); | |
3803 | install_element(CONFIG_NODE, &no_debug_isis_packet_dump_cmd); | |
3804 | install_element(CONFIG_NODE, &debug_isis_lsp_gen_cmd); | |
3805 | install_element(CONFIG_NODE, &no_debug_isis_lsp_gen_cmd); | |
3806 | install_element(CONFIG_NODE, &debug_isis_lsp_sched_cmd); | |
3807 | install_element(CONFIG_NODE, &no_debug_isis_lsp_sched_cmd); | |
2815f817 CF |
3808 | install_element(CONFIG_NODE, &debug_isis_bfd_cmd); |
3809 | install_element(CONFIG_NODE, &no_debug_isis_bfd_cmd); | |
1cbf96a8 | 3810 | install_element(CONFIG_NODE, &debug_isis_ldp_sync_cmd); |
3811 | install_element(CONFIG_NODE, &no_debug_isis_ldp_sync_cmd); | |
d62a17ae | 3812 | |
7c0cbd0e | 3813 | install_default(ROUTER_NODE); |
d62a17ae | 3814 | |
aaf2fd21 EDP |
3815 | #ifdef FABRICD |
3816 | install_element(CONFIG_NODE, &router_openfabric_cmd); | |
3817 | install_element(CONFIG_NODE, &no_router_openfabric_cmd); | |
2adf66ff | 3818 | |
7c0cbd0e CF |
3819 | install_element(ROUTER_NODE, &net_cmd); |
3820 | install_element(ROUTER_NODE, &no_net_cmd); | |
2adf66ff | 3821 | |
7c0cbd0e CF |
3822 | install_element(ROUTER_NODE, &isis_topology_cmd); |
3823 | install_element(ROUTER_NODE, &no_isis_topology_cmd); | |
2adf66ff | 3824 | |
7c0cbd0e CF |
3825 | install_element(ROUTER_NODE, &log_adj_changes_cmd); |
3826 | install_element(ROUTER_NODE, &no_log_adj_changes_cmd); | |
2adf66ff | 3827 | #endif /* ifdef FABRICD */ |
d62a17ae | 3828 | |
3829 | spf_backoff_cmd_init(); | |
eb5d44eb | 3830 | } |