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