]>
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; |
e740f9c1 | 84 | |
66b9a381 DL |
85 | DEFINE_MGROUP(ISISD, "isisd"); |
86 | ||
87 | DEFINE_MTYPE_STATIC(ISISD, ISIS, "ISIS process"); | |
88 | DEFINE_MTYPE_STATIC(ISISD, ISIS_NAME, "ISIS process name"); | |
89 | DEFINE_MTYPE_STATIC(ISISD, ISIS_AREA, "ISIS area"); | |
90 | DEFINE_MTYPE(ISISD, ISIS_AREA_ADDR, "ISIS area address"); | |
91 | DEFINE_MTYPE(ISISD, ISIS_ACL_NAME, "ISIS access-list name"); | |
92 | ||
96244aca | 93 | DEFINE_QOBJ_TYPE(isis_area); |
676a4ea3 | 94 | |
eab88f36 K |
95 | /* ISIS process wide configuration. */ |
96 | static struct isis_master isis_master; | |
97 | ||
98 | /* ISIS process wide configuration pointer to export. */ | |
99 | struct isis_master *im; | |
100 | ||
1ee746d9 | 101 | #ifndef FABRICD |
102 | DEFINE_HOOK(isis_hook_db_overload, (const struct isis_area *area), (area)); | |
103 | #endif /* ifndef FABRICD */ | |
104 | ||
41b36e90 PJ |
105 | /* |
106 | * Prototypes. | |
107 | */ | |
41b36e90 | 108 | int isis_area_get(struct vty *, const char *); |
3f045a08 JB |
109 | int area_net_title(struct vty *, const char *); |
110 | int area_clear_net_title(struct vty *, const char *); | |
eab88f36 K |
111 | int show_isis_interface_common(struct vty *, const char *ifname, char, |
112 | const char *vrf_name, bool all_vrf); | |
113 | int show_isis_neighbor_common(struct vty *, const char *id, char, | |
114 | const char *vrf_name, bool all_vrf); | |
115 | int clear_isis_neighbor_common(struct vty *, const char *id, const char *vrf_name, | |
116 | bool all_vrf); | |
117 | ||
eab88f36 K |
118 | /* Link ISIS instance to VRF. */ |
119 | void isis_vrf_link(struct isis *isis, struct vrf *vrf) | |
120 | { | |
121 | isis->vrf_id = vrf->vrf_id; | |
122 | if (vrf->info != (void *)isis) | |
123 | vrf->info = (void *)isis; | |
124 | } | |
125 | ||
126 | /* Unlink ISIS instance to VRF. */ | |
127 | void isis_vrf_unlink(struct isis *isis, struct vrf *vrf) | |
128 | { | |
129 | if (vrf->info == (void *)isis) | |
130 | vrf->info = NULL; | |
131 | isis->vrf_id = VRF_UNKNOWN; | |
132 | } | |
133 | ||
134 | struct isis *isis_lookup_by_vrfid(vrf_id_t vrf_id) | |
135 | { | |
36944791 RW |
136 | struct isis *isis; |
137 | struct listnode *node; | |
41b36e90 | 138 | |
36944791 | 139 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) |
eab88f36 K |
140 | if (isis->vrf_id == vrf_id) |
141 | return isis; | |
36944791 | 142 | |
eab88f36 K |
143 | return NULL; |
144 | } | |
145 | ||
146 | struct isis *isis_lookup_by_vrfname(const char *vrfname) | |
147 | { | |
36944791 RW |
148 | struct isis *isis; |
149 | struct listnode *node; | |
eab88f36 | 150 | |
36944791 | 151 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) |
eab88f36 K |
152 | if (isis->name && vrfname && strcmp(isis->name, vrfname) == 0) |
153 | return isis; | |
36944791 | 154 | |
eab88f36 K |
155 | return NULL; |
156 | } | |
157 | ||
36944791 | 158 | struct isis *isis_lookup_by_sysid(const uint8_t *sysid) |
eab88f36 | 159 | { |
36944791 RW |
160 | struct isis *isis; |
161 | struct listnode *node; | |
162 | ||
163 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) | |
eab88f36 K |
164 | if (!memcmp(isis->sysid, sysid, ISIS_SYS_ID_LEN)) |
165 | return isis; | |
36944791 | 166 | |
eab88f36 K |
167 | return NULL; |
168 | } | |
169 | ||
170 | void isis_master_init(struct thread_master *master) | |
171 | { | |
172 | memset(&isis_master, 0, sizeof(struct isis_master)); | |
173 | im = &isis_master; | |
174 | im->isis = list_new(); | |
175 | im->master = master; | |
176 | } | |
41b36e90 | 177 | |
65251ce8 | 178 | void isis_global_instance_create(const char *vrf_name) |
d62a17ae | 179 | { |
36944791 | 180 | struct isis *isis; |
eab88f36 | 181 | |
65251ce8 | 182 | isis = isis_lookup_by_vrfname(vrf_name); |
bcf22081 IR |
183 | if (isis == NULL) |
184 | isis_new(vrf_name); | |
eab88f36 K |
185 | } |
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 K |
202 | |
203 | if (IS_DEBUG_EVENTS) | |
204 | zlog_debug( | |
205 | "%s: Create new isis instance with vrf_name %s vrf_id %u", | |
206 | __func__, isis->name, isis->vrf_id); | |
207 | ||
d62a17ae | 208 | /* |
209 | * Default values | |
210 | */ | |
211 | isis->max_area_addrs = 3; | |
eab88f36 | 212 | isis->process_id = getpid(); |
d62a17ae | 213 | isis->router_id = 0; |
214 | isis->area_list = list_new(); | |
d62a17ae | 215 | isis->uptime = time(NULL); |
1ee746d9 | 216 | isis->snmp_notifications = 1; |
eab88f36 K |
217 | dyn_cache_init(isis); |
218 | ||
bcf22081 IR |
219 | listnode_add(im->isis, isis); |
220 | ||
eab88f36 | 221 | return isis; |
d62a17ae | 222 | } |
223 | ||
bcf22081 IR |
224 | void isis_finish(struct isis *isis) |
225 | { | |
226 | struct vrf *vrf = NULL; | |
227 | ||
228 | listnode_delete(im->isis, isis); | |
229 | ||
230 | vrf = vrf_lookup_by_name(isis->name); | |
231 | if (vrf) | |
232 | isis_vrf_unlink(isis, vrf); | |
233 | XFREE(MTYPE_ISIS_NAME, isis->name); | |
234 | ||
235 | isis_redist_free(isis); | |
236 | list_delete(&isis->area_list); | |
237 | XFREE(MTYPE_ISIS, isis); | |
238 | } | |
239 | ||
240 | void isis_area_add_circuit(struct isis_area *area, struct isis_circuit *circuit) | |
241 | { | |
242 | isis_csm_state_change(ISIS_ENABLE, circuit, area); | |
243 | ||
244 | area->ip_circuits += circuit->ip_router; | |
245 | area->ipv6_circuits += circuit->ipv6_router; | |
246 | ||
247 | area->lfa_protected_links[0] += circuit->lfa_protection[0]; | |
248 | area->rlfa_protected_links[0] += circuit->rlfa_protection[0]; | |
249 | area->tilfa_protected_links[0] += circuit->tilfa_protection[0]; | |
250 | ||
251 | area->lfa_protected_links[1] += circuit->lfa_protection[1]; | |
252 | area->rlfa_protected_links[1] += circuit->rlfa_protection[1]; | |
253 | area->tilfa_protected_links[1] += circuit->tilfa_protection[1]; | |
254 | } | |
255 | ||
256 | void isis_area_del_circuit(struct isis_area *area, struct isis_circuit *circuit) | |
257 | { | |
258 | area->ip_circuits -= circuit->ip_router; | |
259 | area->ipv6_circuits -= circuit->ipv6_router; | |
260 | ||
261 | area->lfa_protected_links[0] -= circuit->lfa_protection[0]; | |
262 | area->rlfa_protected_links[0] -= circuit->rlfa_protection[0]; | |
263 | area->tilfa_protected_links[0] -= circuit->tilfa_protection[0]; | |
264 | ||
265 | area->lfa_protected_links[1] -= circuit->lfa_protection[1]; | |
266 | area->rlfa_protected_links[1] -= circuit->rlfa_protection[1]; | |
267 | area->tilfa_protected_links[1] -= circuit->tilfa_protection[1]; | |
268 | ||
269 | isis_csm_state_change(ISIS_DISABLE, circuit, area); | |
270 | } | |
271 | ||
eab88f36 | 272 | struct isis_area *isis_area_create(const char *area_tag, const char *vrf_name) |
d62a17ae | 273 | { |
274 | struct isis_area *area; | |
eab88f36 K |
275 | struct isis *isis = NULL; |
276 | struct vrf *vrf = NULL; | |
bcf22081 IR |
277 | struct interface *ifp; |
278 | struct isis_circuit *circuit; | |
279 | ||
d62a17ae | 280 | area = XCALLOC(MTYPE_ISIS_AREA, sizeof(struct isis_area)); |
281 | ||
bcf22081 IR |
282 | if (!vrf_name) |
283 | vrf_name = VRF_DEFAULT_NAME; | |
284 | ||
285 | vrf = vrf_lookup_by_name(vrf_name); | |
286 | isis = isis_lookup_by_vrfname(vrf_name); | |
287 | ||
288 | if (isis == NULL) | |
289 | isis = isis_new(vrf_name); | |
7b36d36e RW |
290 | |
291 | listnode_add(isis->area_list, area); | |
292 | area->isis = isis; | |
293 | ||
d62a17ae | 294 | /* |
65f18157 | 295 | * Fabricd runs only as level-2. |
26eb18e2 | 296 | * For IS-IS, the default is level-1-2 |
d62a17ae | 297 | */ |
26eb18e2 | 298 | if (fabricd) |
65f18157 | 299 | area->is_type = IS_LEVEL_2; |
cc50ddb2 EDP |
300 | else |
301 | area->is_type = yang_get_default_enum( | |
302 | "/frr-isisd:isis/instance/is-type"); | |
d62a17ae | 303 | |
304 | /* | |
305 | * intialize the databases | |
306 | */ | |
4bef0ec4 DL |
307 | if (area->is_type & IS_LEVEL_1) |
308 | lsp_db_init(&area->lspdb[0]); | |
309 | if (area->is_type & IS_LEVEL_2) | |
310 | lsp_db_init(&area->lspdb[1]); | |
d62a17ae | 311 | |
312 | spftree_area_init(area); | |
313 | ||
314 | area->circuit_list = list_new(); | |
75eddbc3 | 315 | area->adjacency_list = list_new(); |
d62a17ae | 316 | area->area_addrs = list_new(); |
52a7c25e RW |
317 | if (!CHECK_FLAG(im->options, F_ISIS_UNIT_TEST)) |
318 | thread_add_timer(master, lsp_tick, area, 1, &area->t_tick); | |
d62a17ae | 319 | flags_initialize(&area->flags); |
320 | ||
26f6acaf RW |
321 | isis_sr_area_init(area); |
322 | ||
d62a17ae | 323 | /* |
324 | * Default values | |
325 | */ | |
cc50ddb2 EDP |
326 | #ifndef FABRICD |
327 | enum isis_metric_style default_style; | |
328 | ||
329 | area->max_lsp_lifetime[0] = yang_get_default_uint16( | |
d2c970ff | 330 | "/frr-isisd:isis/instance/lsp/timers/level-1/maximum-lifetime"); |
cc50ddb2 | 331 | area->max_lsp_lifetime[1] = yang_get_default_uint16( |
d2c970ff | 332 | "/frr-isisd:isis/instance/lsp/timers/level-2/maximum-lifetime"); |
cc50ddb2 | 333 | area->lsp_refresh[0] = yang_get_default_uint16( |
d2c970ff | 334 | "/frr-isisd:isis/instance/lsp/timers/level-1/refresh-interval"); |
cc50ddb2 | 335 | area->lsp_refresh[1] = yang_get_default_uint16( |
d2c970ff | 336 | "/frr-isisd:isis/instance/lsp/timers/level-2/refresh-interval"); |
cc50ddb2 | 337 | area->lsp_gen_interval[0] = yang_get_default_uint16( |
d2c970ff | 338 | "/frr-isisd:isis/instance/lsp/timers/level-1/generation-interval"); |
cc50ddb2 | 339 | area->lsp_gen_interval[1] = yang_get_default_uint16( |
d2c970ff | 340 | "/frr-isisd:isis/instance/lsp/timers/level-2/generation-interval"); |
cc50ddb2 EDP |
341 | area->min_spf_interval[0] = yang_get_default_uint16( |
342 | "/frr-isisd:isis/instance/spf/minimum-interval/level-1"); | |
343 | area->min_spf_interval[1] = yang_get_default_uint16( | |
344 | "/frr-isisd:isis/instance/spf/minimum-interval/level-1"); | |
345 | area->dynhostname = yang_get_default_bool( | |
346 | "/frr-isisd:isis/instance/dynamic-hostname"); | |
347 | default_style = | |
348 | yang_get_default_enum("/frr-isisd:isis/instance/metric-style"); | |
349 | area->oldmetric = default_style == ISIS_WIDE_METRIC ? 0 : 1; | |
350 | area->newmetric = default_style == ISIS_NARROW_METRIC ? 0 : 1; | |
351 | area->lsp_frag_threshold = 90; /* not currently configurable */ | |
352 | area->lsp_mtu = | |
353 | yang_get_default_uint16("/frr-isisd:isis/instance/lsp/mtu"); | |
e886416f RW |
354 | area->lfa_load_sharing[0] = yang_get_default_bool( |
355 | "/frr-isisd:isis/instance/fast-reroute/level-1/lfa/load-sharing"); | |
356 | area->lfa_load_sharing[1] = yang_get_default_bool( | |
357 | "/frr-isisd:isis/instance/fast-reroute/level-2/lfa/load-sharing"); | |
f3abc412 | 358 | area->attached_bit_send = |
359 | yang_get_default_bool("/frr-isisd:isis/instance/attach-send"); | |
360 | area->attached_bit_rcv_ignore = yang_get_default_bool( | |
361 | "/frr-isisd:isis/instance/attach-receive-ignore"); | |
362 | ||
cc50ddb2 | 363 | #else |
d62a17ae | 364 | area->max_lsp_lifetime[0] = DEFAULT_LSP_LIFETIME; /* 1200 */ |
365 | area->max_lsp_lifetime[1] = DEFAULT_LSP_LIFETIME; /* 1200 */ | |
366 | area->lsp_refresh[0] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */ | |
367 | area->lsp_refresh[1] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */ | |
368 | area->lsp_gen_interval[0] = DEFAULT_MIN_LSP_GEN_INTERVAL; | |
369 | area->lsp_gen_interval[1] = DEFAULT_MIN_LSP_GEN_INTERVAL; | |
370 | area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL; | |
371 | area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL; | |
372 | area->dynhostname = 1; | |
373 | area->oldmetric = 0; | |
374 | area->newmetric = 1; | |
375 | area->lsp_frag_threshold = 90; | |
376 | area->lsp_mtu = DEFAULT_LSP_MTU; | |
e886416f RW |
377 | area->lfa_load_sharing[0] = true; |
378 | area->lfa_load_sharing[1] = true; | |
f3abc412 | 379 | area->attached_bit_send = true; |
380 | area->attached_bit_rcv_ignore = false; | |
cc50ddb2 | 381 | #endif /* ifndef FABRICD */ |
e886416f RW |
382 | area->lfa_priority_limit[0] = SPF_PREFIX_PRIO_LOW; |
383 | area->lfa_priority_limit[1] = SPF_PREFIX_PRIO_LOW; | |
384 | isis_lfa_tiebreakers_init(area, ISIS_LEVEL1); | |
385 | isis_lfa_tiebreakers_init(area, ISIS_LEVEL2); | |
d62a17ae | 386 | |
387 | area_mt_init(area); | |
41b36e90 | 388 | |
d62a17ae | 389 | area->area_tag = strdup(area_tag); |
eab88f36 | 390 | |
8e6fb83b | 391 | if (fabricd) |
b30e837b | 392 | area->fabricd = fabricd_new(area); |
9196731f CF |
393 | |
394 | area->lsp_refresh_arg[0].area = area; | |
395 | area->lsp_refresh_arg[0].level = IS_LEVEL_1; | |
396 | area->lsp_refresh_arg[1].area = area; | |
397 | area->lsp_refresh_arg[1].level = IS_LEVEL_2; | |
398 | ||
690497fb G |
399 | area->bfd_signalled_down = false; |
400 | area->bfd_force_spf_refresh = false; | |
401 | ||
d62a17ae | 402 | QOBJ_REG(area, isis_area); |
eb5d44eb | 403 | |
bcf22081 IR |
404 | if (vrf) { |
405 | FOR_ALL_INTERFACES (vrf, ifp) { | |
406 | if (ifp->ifindex == IFINDEX_INTERNAL) | |
407 | continue; | |
408 | ||
409 | circuit = ifp->info; | |
410 | if (circuit) | |
411 | isis_area_add_circuit(area, circuit); | |
412 | } | |
413 | } | |
414 | ||
d62a17ae | 415 | return area; |
416 | } | |
3f045a08 | 417 | |
65251ce8 | 418 | struct isis_area *isis_area_lookup_by_vrf(const char *area_tag, |
419 | const char *vrf_name) | |
420 | { | |
421 | struct isis_area *area; | |
422 | struct listnode *node; | |
423 | struct isis *isis = NULL; | |
424 | ||
425 | isis = isis_lookup_by_vrfname(vrf_name); | |
426 | if (isis == NULL) | |
427 | return NULL; | |
428 | ||
429 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) | |
430 | if (strcmp(area->area_tag, area_tag) == 0) | |
431 | return area; | |
432 | ||
433 | return NULL; | |
434 | } | |
435 | ||
eab88f36 | 436 | struct isis_area *isis_area_lookup(const char *area_tag, vrf_id_t vrf_id) |
d62a17ae | 437 | { |
438 | struct isis_area *area; | |
439 | struct listnode *node; | |
36944791 | 440 | struct isis *isis; |
eab88f36 K |
441 | |
442 | isis = isis_lookup_by_vrfid(vrf_id); | |
443 | if (isis == NULL) | |
444 | return NULL; | |
3f045a08 | 445 | |
d62a17ae | 446 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) |
447 | if ((area->area_tag == NULL && area_tag == NULL) | |
448 | || (area->area_tag && area_tag | |
449 | && strcmp(area->area_tag, area_tag) == 0)) | |
450 | return area; | |
3f045a08 | 451 | |
d62a17ae | 452 | return NULL; |
453 | } | |
3f045a08 | 454 | |
d62a17ae | 455 | int isis_area_get(struct vty *vty, const char *area_tag) |
456 | { | |
457 | struct isis_area *area; | |
5475ecf7 | 458 | |
eab88f36 | 459 | area = isis_area_lookup(area_tag, VRF_DEFAULT); |
03f7e182 | 460 | |
d62a17ae | 461 | if (area) { |
7c0cbd0e | 462 | VTY_PUSH_CONTEXT(ROUTER_NODE, area); |
d62a17ae | 463 | return CMD_SUCCESS; |
464 | } | |
465 | ||
eab88f36 | 466 | area = isis_area_create(area_tag, VRF_DEFAULT_NAME); |
3f045a08 | 467 | |
e740f9c1 | 468 | if (IS_DEBUG_EVENTS) |
d62a17ae | 469 | zlog_debug("New IS-IS area instance %s", area->area_tag); |
3f045a08 | 470 | |
7c0cbd0e | 471 | VTY_PUSH_CONTEXT(ROUTER_NODE, area); |
f3ccedaa | 472 | |
d62a17ae | 473 | return CMD_SUCCESS; |
474 | } | |
3f045a08 | 475 | |
77d73edf | 476 | /* return the number of Level1 and level-1-2 routers or |
477 | * the number of Level2 and level-1-2 routers configured | |
478 | */ | |
479 | int isis_area_count(const struct isis *isis, int levels) | |
480 | { | |
481 | struct isis_area *area; | |
482 | struct listnode *node; | |
483 | int count = 0; | |
484 | ||
485 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) | |
486 | if (area->is_type & levels) | |
487 | count++; | |
488 | ||
489 | return count; | |
490 | } | |
491 | ||
14c6e772 | 492 | void isis_area_destroy(struct isis_area *area) |
eb5d44eb | 493 | { |
d62a17ae | 494 | struct listnode *node, *nnode; |
495 | struct isis_circuit *circuit; | |
496 | struct area_addr *addr; | |
eb5d44eb | 497 | |
d62a17ae | 498 | QOBJ_UNREG(area); |
499 | ||
b30e837b CF |
500 | if (fabricd) |
501 | fabricd_finish(area->fabricd); | |
502 | ||
2e2a8b91 OD |
503 | /* Disable MPLS if necessary before flooding LSP */ |
504 | if (IS_MPLS_TE(area->mta)) | |
505 | area->mta->status = disable; | |
506 | ||
d62a17ae | 507 | if (area->circuit_list) { |
508 | for (ALL_LIST_ELEMENTS(area->circuit_list, node, nnode, | |
bcf22081 IR |
509 | circuit)) |
510 | isis_area_del_circuit(area, circuit); | |
511 | ||
6a154c88 | 512 | list_delete(&area->circuit_list); |
d62a17ae | 513 | } |
75eddbc3 | 514 | list_delete(&area->adjacency_list); |
d62a17ae | 515 | |
4bef0ec4 DL |
516 | lsp_db_fini(&area->lspdb[0]); |
517 | lsp_db_fini(&area->lspdb[1]); | |
d62a17ae | 518 | |
3dace42d | 519 | /* invalidate and verify to delete all routes from zebra */ |
688ea1cb | 520 | isis_area_invalidate_routes(area, area->is_type); |
3dace42d CF |
521 | isis_area_verify_routes(area); |
522 | ||
26f6acaf RW |
523 | isis_sr_area_term(area); |
524 | ||
d62a17ae | 525 | spftree_area_del(area); |
526 | ||
8f15843b DS |
527 | if (area->spf_timer[0]) |
528 | isis_spf_timer_free(THREAD_ARG(area->spf_timer[0])); | |
50478845 | 529 | thread_cancel(&area->spf_timer[0]); |
8f15843b DS |
530 | if (area->spf_timer[1]) |
531 | isis_spf_timer_free(THREAD_ARG(area->spf_timer[1])); | |
50478845 | 532 | thread_cancel(&area->spf_timer[1]); |
d62a17ae | 533 | |
534 | spf_backoff_free(area->spf_delay_ietf[0]); | |
535 | spf_backoff_free(area->spf_delay_ietf[1]); | |
536 | ||
52a7c25e RW |
537 | if (!CHECK_FLAG(im->options, F_ISIS_UNIT_TEST)) |
538 | isis_redist_area_finish(area); | |
d62a17ae | 539 | |
540 | for (ALL_LIST_ELEMENTS(area->area_addrs, node, nnode, addr)) { | |
541 | list_delete_node(area->area_addrs, node); | |
542 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
543 | } | |
544 | area->area_addrs = NULL; | |
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 | ||
50478845 MS |
556 | thread_cancel(&area->t_tick); |
557 | thread_cancel(&area->t_lsp_refresh[0]); | |
558 | thread_cancel(&area->t_lsp_refresh[1]); | |
16fe8cff | 559 | thread_cancel(&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 | ||
eab88f36 K |
569 | if (listcount(area->isis->area_list) == 0) { |
570 | memset(area->isis->sysid, 0, ISIS_SYS_ID_LEN); | |
571 | area->isis->sysid_set = 0; | |
572 | } | |
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 | ||
598 | static int isis_vrf_enable(struct vrf *vrf) | |
599 | { | |
600 | struct isis *isis; | |
601 | vrf_id_t old_vrf_id; | |
602 | ||
603 | if (IS_DEBUG_EVENTS) | |
604 | zlog_debug("%s: VRF %s id %u enabled", __func__, vrf->name, | |
605 | vrf->vrf_id); | |
606 | ||
607 | isis = isis_lookup_by_vrfname(vrf->name); | |
608 | if (isis) { | |
65251ce8 | 609 | old_vrf_id = isis->vrf_id; |
610 | /* We have instance configured, link to VRF and make it "up". */ | |
611 | isis_vrf_link(isis, vrf); | |
612 | if (IS_DEBUG_EVENTS) | |
613 | zlog_debug( | |
614 | "%s: isis linked to vrf %s vrf_id %u (old id %u)", | |
615 | __func__, vrf->name, isis->vrf_id, old_vrf_id); | |
616 | if (old_vrf_id != isis->vrf_id) { | |
164ab896 IR |
617 | /* start zebra redist to us for new vrf */ |
618 | isis_zebra_vrf_register(isis); | |
65251ce8 | 619 | } |
620 | } | |
621 | ||
622 | return 0; | |
623 | } | |
624 | ||
625 | static int isis_vrf_disable(struct vrf *vrf) | |
626 | { | |
627 | struct isis *isis; | |
628 | vrf_id_t old_vrf_id = VRF_UNKNOWN; | |
629 | ||
630 | if (vrf->vrf_id == VRF_DEFAULT) | |
631 | return 0; | |
632 | ||
633 | if (IS_DEBUG_EVENTS) | |
634 | zlog_debug("%s: VRF %s id %d disabled.", __func__, vrf->name, | |
635 | vrf->vrf_id); | |
636 | isis = isis_lookup_by_vrfname(vrf->name); | |
637 | if (isis) { | |
638 | old_vrf_id = isis->vrf_id; | |
639 | ||
164ab896 IR |
640 | isis_zebra_vrf_deregister(isis); |
641 | ||
65251ce8 | 642 | /* We have instance configured, unlink |
643 | * from VRF and make it "down". | |
644 | */ | |
645 | isis_vrf_unlink(isis, vrf); | |
646 | if (IS_DEBUG_EVENTS) | |
647 | zlog_debug("%s: isis old_vrf_id %d unlinked", __func__, | |
648 | old_vrf_id); | |
649 | } | |
650 | ||
651 | return 0; | |
652 | } | |
653 | ||
654 | void isis_vrf_init(void) | |
655 | { | |
656 | vrf_init(isis_vrf_new, isis_vrf_enable, isis_vrf_disable, | |
657 | isis_vrf_delete, isis_vrf_enable); | |
658 | } | |
659 | ||
eab88f36 K |
660 | void isis_terminate() |
661 | { | |
36944791 | 662 | struct isis *isis; |
eab88f36 K |
663 | struct listnode *node, *nnode; |
664 | ||
13bf3830 IR |
665 | bfd_protocol_integration_set_shutdown(true); |
666 | ||
eab88f36 K |
667 | if (listcount(im->isis) == 0) |
668 | return; | |
669 | ||
670 | for (ALL_LIST_ELEMENTS(im->isis, node, nnode, isis)) | |
671 | isis_finish(isis); | |
d62a17ae | 672 | } |
673 | ||
e886416f RW |
674 | void isis_filter_update(struct access_list *access) |
675 | { | |
676 | struct isis *isis; | |
677 | struct isis_area *area; | |
678 | struct listnode *node, *anode; | |
679 | ||
680 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { | |
681 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { | |
682 | for (int i = SPF_PREFIX_PRIO_CRITICAL; | |
683 | i <= SPF_PREFIX_PRIO_MEDIUM; i++) { | |
684 | struct spf_prefix_priority_acl *ppa; | |
685 | ||
686 | ppa = &area->spf_prefix_priorities[i]; | |
687 | ppa->list_v4 = | |
688 | access_list_lookup(AFI_IP, ppa->name); | |
689 | ppa->list_v6 = | |
690 | access_list_lookup(AFI_IP6, ppa->name); | |
691 | } | |
692 | lsp_regenerate_schedule(area, area->is_type, 0); | |
693 | } | |
694 | } | |
695 | } | |
696 | ||
16fe8cff RW |
697 | void isis_prefix_list_update(struct prefix_list *plist) |
698 | { | |
699 | struct isis *isis; | |
700 | struct isis_area *area; | |
701 | struct listnode *node, *anode; | |
702 | ||
703 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { | |
704 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { | |
705 | for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; | |
706 | level++) { | |
707 | const char *plist_name = | |
708 | prefix_list_name(plist); | |
709 | ||
710 | if (!area->rlfa_plist_name[level - 1]) | |
711 | continue; | |
712 | ||
713 | if (!strmatch(area->rlfa_plist_name[level - 1], | |
714 | plist_name)) | |
715 | continue; | |
716 | ||
717 | area->rlfa_plist[level - 1] = | |
718 | prefix_list_lookup(AFI_IP, plist_name); | |
719 | lsp_regenerate_schedule(area, area->is_type, 0); | |
720 | } | |
721 | } | |
722 | } | |
723 | } | |
724 | ||
22af6a80 | 725 | #ifdef FABRICD |
d62a17ae | 726 | static void area_set_mt_enabled(struct isis_area *area, uint16_t mtid, |
727 | bool enabled) | |
728 | { | |
729 | struct isis_area_mt_setting *setting; | |
730 | ||
731 | setting = area_get_mt_setting(area, mtid); | |
732 | if (setting->enabled != enabled) { | |
733 | setting->enabled = enabled; | |
734 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
735 | } | |
736 | } | |
737 | ||
738 | static void area_set_mt_overload(struct isis_area *area, uint16_t mtid, | |
739 | bool overload) | |
740 | { | |
741 | struct isis_area_mt_setting *setting; | |
742 | ||
743 | setting = area_get_mt_setting(area, mtid); | |
744 | if (setting->overload != overload) { | |
745 | setting->overload = overload; | |
746 | if (setting->enabled) | |
747 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, | |
748 | 0); | |
749 | } | |
750 | } | |
22af6a80 | 751 | #endif /* ifdef FABRICD */ |
d62a17ae | 752 | |
753 | int area_net_title(struct vty *vty, const char *net_title) | |
754 | { | |
755 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
756 | struct area_addr *addr; | |
757 | struct area_addr *addrp; | |
758 | struct listnode *node; | |
eb5d44eb | 759 | |
d7c0a89a | 760 | uint8_t buff[255]; |
d62a17ae | 761 | |
762 | /* We check that we are not over the maximal number of addresses */ | |
eab88f36 | 763 | if (listcount(area->area_addrs) >= area->isis->max_area_addrs) { |
d62a17ae | 764 | vty_out(vty, |
765 | "Maximum of area addresses (%d) already reached \n", | |
eab88f36 | 766 | area->isis->max_area_addrs); |
d62a17ae | 767 | return CMD_ERR_NOTHING_TODO; |
768 | } | |
769 | ||
770 | addr = XMALLOC(MTYPE_ISIS_AREA_ADDR, sizeof(struct area_addr)); | |
771 | addr->addr_len = dotformat2buff(buff, net_title); | |
772 | memcpy(addr->area_addr, buff, addr->addr_len); | |
eb5d44eb | 773 | #ifdef EXTREME_DEBUG |
d62a17ae | 774 | zlog_debug("added area address %s for area %s (address length %d)", |
775 | net_title, area->area_tag, addr->addr_len); | |
eb5d44eb | 776 | #endif /* EXTREME_DEBUG */ |
d62a17ae | 777 | if (addr->addr_len < 8 || addr->addr_len > 20) { |
778 | vty_out(vty, | |
779 | "area address must be at least 8..20 octets long (%d)\n", | |
780 | addr->addr_len); | |
781 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
a5fdb4c5 | 782 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 783 | } |
784 | ||
785 | if (addr->area_addr[addr->addr_len - 1] != 0) { | |
786 | vty_out(vty, | |
787 | "nsel byte (last byte) in area address must be 0\n"); | |
788 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
a5fdb4c5 | 789 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 790 | } |
791 | ||
eab88f36 | 792 | if (area->isis->sysid_set == 0) { |
d62a17ae | 793 | /* |
794 | * First area address - get the SystemID for this router | |
795 | */ | |
eab88f36 K |
796 | memcpy(area->isis->sysid, GETSYSID(addr), ISIS_SYS_ID_LEN); |
797 | area->isis->sysid_set = 1; | |
e740f9c1 | 798 | if (IS_DEBUG_EVENTS) |
d62a17ae | 799 | zlog_debug("Router has SystemID %s", |
eab88f36 | 800 | sysid_print(area->isis->sysid)); |
d62a17ae | 801 | } else { |
802 | /* | |
803 | * Check that the SystemID portions match | |
804 | */ | |
eab88f36 K |
805 | if (memcmp(area->isis->sysid, GETSYSID(addr), |
806 | ISIS_SYS_ID_LEN)) { | |
d62a17ae | 807 | vty_out(vty, |
808 | "System ID must not change when defining additional area addresses\n"); | |
809 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
a5fdb4c5 | 810 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 811 | } |
812 | ||
813 | /* now we see that we don't already have this address */ | |
814 | for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) { | |
815 | if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) | |
816 | != (addr->addr_len)) | |
817 | continue; | |
818 | if (!memcmp(addrp->area_addr, addr->area_addr, | |
819 | addr->addr_len)) { | |
820 | XFREE(MTYPE_ISIS_AREA_ADDR, addr); | |
821 | return CMD_SUCCESS; /* silent fail */ | |
822 | } | |
823 | } | |
824 | } | |
825 | ||
826 | /* | |
827 | * Forget the systemID part of the address | |
828 | */ | |
829 | addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN); | |
830 | listnode_add(area->area_addrs, addr); | |
831 | ||
832 | /* only now we can safely generate our LSPs for this area */ | |
833 | if (listcount(area->area_addrs) > 0) { | |
834 | if (area->is_type & IS_LEVEL_1) | |
835 | lsp_generate(area, IS_LEVEL_1); | |
836 | if (area->is_type & IS_LEVEL_2) | |
837 | lsp_generate(area, IS_LEVEL_2); | |
838 | } | |
839 | ||
840 | return CMD_SUCCESS; | |
841 | } | |
842 | ||
843 | int area_clear_net_title(struct vty *vty, const char *net_title) | |
844 | { | |
845 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
846 | struct area_addr addr, *addrp = NULL; | |
847 | struct listnode *node; | |
d7c0a89a | 848 | uint8_t buff[255]; |
d62a17ae | 849 | |
850 | addr.addr_len = dotformat2buff(buff, net_title); | |
851 | if (addr.addr_len < 8 || addr.addr_len > 20) { | |
852 | vty_out(vty, | |
853 | "Unsupported area address length %d, should be 8...20 \n", | |
854 | addr.addr_len); | |
a5fdb4c5 | 855 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 856 | } |
857 | ||
858 | memcpy(addr.area_addr, buff, (int)addr.addr_len); | |
859 | ||
860 | for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) | |
861 | if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len | |
862 | && !memcmp(addrp->area_addr, addr.area_addr, addr.addr_len)) | |
863 | break; | |
864 | ||
865 | if (!addrp) { | |
866 | vty_out(vty, "No area address %s for area %s \n", net_title, | |
867 | area->area_tag); | |
868 | return CMD_ERR_NO_MATCH; | |
869 | } | |
870 | ||
871 | listnode_delete(area->area_addrs, addrp); | |
872 | XFREE(MTYPE_ISIS_AREA_ADDR, addrp); | |
873 | ||
874 | /* | |
875 | * Last area address - reset the SystemID for this router | |
876 | */ | |
877 | if (listcount(area->area_addrs) == 0) { | |
eab88f36 K |
878 | memset(area->isis->sysid, 0, ISIS_SYS_ID_LEN); |
879 | area->isis->sysid_set = 0; | |
e740f9c1 | 880 | if (IS_DEBUG_EVENTS) |
d62a17ae | 881 | zlog_debug("Router has no SystemID"); |
882 | } | |
883 | ||
884 | return CMD_SUCCESS; | |
eb5d44eb | 885 | } |
886 | ||
eb5d44eb | 887 | /* |
3f045a08 | 888 | * 'show isis interface' command |
eb5d44eb | 889 | */ |
890 | ||
eab88f36 K |
891 | int show_isis_interface_common(struct vty *vty, const char *ifname, char detail, |
892 | const char *vrf_name, bool all_vrf) | |
eb5d44eb | 893 | { |
36944791 | 894 | struct listnode *anode, *cnode, *inode; |
d62a17ae | 895 | struct isis_area *area; |
896 | struct isis_circuit *circuit; | |
36944791 | 897 | struct isis *isis; |
eb5d44eb | 898 | |
eab88f36 | 899 | if (!im) { |
d62a17ae | 900 | vty_out(vty, "IS-IS Routing Process not enabled\n"); |
901 | return CMD_SUCCESS; | |
902 | } | |
eab88f36 K |
903 | if (vrf_name) { |
904 | if (all_vrf) { | |
36944791 | 905 | for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { |
eab88f36 K |
906 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, |
907 | anode, area)) { | |
908 | vty_out(vty, "Area %s:\n", | |
909 | area->area_tag); | |
910 | ||
911 | if (detail == ISIS_UI_LEVEL_BRIEF) | |
912 | vty_out(vty, | |
913 | " Interface CircId State Type Level\n"); | |
914 | ||
915 | for (ALL_LIST_ELEMENTS_RO( | |
916 | area->circuit_list, cnode, | |
917 | circuit)) | |
918 | if (!ifname) | |
919 | isis_circuit_print_vty( | |
920 | circuit, vty, | |
921 | detail); | |
922 | else if (strcmp(circuit->interface->name, ifname) == 0) | |
923 | isis_circuit_print_vty( | |
924 | circuit, vty, | |
925 | detail); | |
926 | } | |
927 | } | |
36944791 | 928 | return CMD_SUCCESS; |
eab88f36 K |
929 | } |
930 | isis = isis_lookup_by_vrfname(vrf_name); | |
931 | if (isis != NULL) { | |
932 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, | |
933 | area)) { | |
934 | vty_out(vty, "Area %s:\n", area->area_tag); | |
eb5d44eb | 935 | |
eab88f36 K |
936 | if (detail == ISIS_UI_LEVEL_BRIEF) |
937 | vty_out(vty, | |
938 | " Interface CircId State Type Level\n"); | |
939 | ||
940 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, | |
941 | cnode, circuit)) | |
942 | if (!ifname) | |
943 | isis_circuit_print_vty( | |
944 | circuit, vty, detail); | |
945 | else if ( | |
946 | strcmp(circuit->interface->name, | |
947 | ifname) | |
948 | == 0) | |
949 | isis_circuit_print_vty( | |
950 | circuit, vty, detail); | |
951 | } | |
952 | } | |
d62a17ae | 953 | } |
f390d2c7 | 954 | |
d62a17ae | 955 | return CMD_SUCCESS; |
eb5d44eb | 956 | } |
957 | ||
eab88f36 K |
958 | DEFUN(show_isis_interface, |
959 | show_isis_interface_cmd, | |
960 | "show " PROTO_NAME " [vrf <NAME|all>] interface", | |
961 | SHOW_STR | |
962 | PROTO_HELP | |
963 | VRF_CMD_HELP_STR | |
964 | "All VRFs\n" | |
965 | "IS-IS interface\n") | |
eb5d44eb | 966 | { |
eab88f36 K |
967 | const char *vrf_name = VRF_DEFAULT_NAME; |
968 | bool all_vrf = false; | |
969 | int idx_vrf = 0; | |
970 | ||
971 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
972 | return show_isis_interface_common(vty, NULL, ISIS_UI_LEVEL_BRIEF, | |
973 | vrf_name, all_vrf); | |
eb5d44eb | 974 | } |
975 | ||
eab88f36 K |
976 | DEFUN(show_isis_interface_detail, |
977 | show_isis_interface_detail_cmd, | |
978 | "show " PROTO_NAME " [vrf <NAME|all>] interface detail", | |
979 | SHOW_STR | |
980 | PROTO_HELP | |
981 | VRF_CMD_HELP_STR | |
982 | "All VRFs\n" | |
983 | "IS-IS interface\n" | |
984 | "show detailed information\n") | |
3f045a08 | 985 | { |
eab88f36 K |
986 | const char *vrf_name = VRF_DEFAULT_NAME; |
987 | bool all_vrf = false; | |
988 | int idx_vrf = 0; | |
989 | ||
990 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
991 | return show_isis_interface_common(vty, NULL, ISIS_UI_LEVEL_DETAIL, | |
992 | vrf_name, all_vrf); | |
3f045a08 | 993 | } |
eb5d44eb | 994 | |
eab88f36 K |
995 | DEFUN(show_isis_interface_arg, |
996 | show_isis_interface_arg_cmd, | |
997 | "show " PROTO_NAME " [vrf <NAME|all>] interface WORD", | |
998 | SHOW_STR | |
999 | PROTO_HELP | |
1000 | VRF_CMD_HELP_STR | |
1001 | "All VRFs\n" | |
1002 | "IS-IS interface\n" | |
1003 | "IS-IS interface name\n") | |
3f045a08 | 1004 | { |
eab88f36 K |
1005 | int idx_word = 0; |
1006 | const char *vrf_name = VRF_DEFAULT_NAME; | |
1007 | bool all_vrf = false; | |
1008 | int idx_vrf = 0; | |
3f045a08 | 1009 | |
eab88f36 K |
1010 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
1011 | ||
1012 | char *ifname = argv_find(argv, argc, "WORD", &idx_word) | |
1013 | ? argv[idx_word]->arg | |
1014 | : NULL; | |
1015 | return show_isis_interface_common(vty, ifname, ISIS_UI_LEVEL_DETAIL, | |
1016 | vrf_name, all_vrf); | |
1017 | } | |
3f045a08 | 1018 | |
eab88f36 K |
1019 | static void isis_neighbor_common(struct vty *vty, const char *id, char detail, |
1020 | struct isis *isis, uint8_t *sysid) | |
d62a17ae | 1021 | { |
1022 | struct listnode *anode, *cnode, *node; | |
1023 | struct isis_area *area; | |
1024 | struct isis_circuit *circuit; | |
1025 | struct list *adjdb; | |
1026 | struct isis_adjacency *adj; | |
d62a17ae | 1027 | int i; |
1028 | ||
d62a17ae | 1029 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { |
1030 | vty_out(vty, "Area %s:\n", area->area_tag); | |
1031 | ||
1032 | if (detail == ISIS_UI_LEVEL_BRIEF) | |
1033 | vty_out(vty, | |
1034 | " System Id Interface L State Holdtime SNPA\n"); | |
1035 | ||
1036 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) { | |
1037 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { | |
1038 | for (i = 0; i < 2; i++) { | |
1039 | adjdb = circuit->u.bc.adjdb[i]; | |
1040 | if (adjdb && adjdb->count) { | |
1041 | for (ALL_LIST_ELEMENTS_RO( | |
1042 | adjdb, node, adj)) | |
1043 | if (!id | |
eab88f36 K |
1044 | || !memcmp( |
1045 | adj->sysid, | |
1046 | sysid, | |
1047 | ISIS_SYS_ID_LEN)) | |
d62a17ae | 1048 | isis_adj_print_vty( |
1049 | adj, | |
1050 | vty, | |
1051 | detail); | |
1052 | } | |
1053 | } | |
1054 | } else if (circuit->circ_type == CIRCUIT_T_P2P | |
1055 | && circuit->u.p2p.neighbor) { | |
1056 | adj = circuit->u.p2p.neighbor; | |
1057 | if (!id | |
1058 | || !memcmp(adj->sysid, sysid, | |
1059 | ISIS_SYS_ID_LEN)) | |
1060 | isis_adj_print_vty(adj, vty, detail); | |
1061 | } | |
1062 | } | |
1063 | } | |
1064 | ||
3f045a08 | 1065 | } |
3f045a08 | 1066 | /* |
eab88f36 | 1067 | * 'show isis neighbor' command |
3f045a08 | 1068 | */ |
eab88f36 K |
1069 | |
1070 | int show_isis_neighbor_common(struct vty *vty, const char *id, char detail, | |
1071 | const char *vrf_name, bool all_vrf) | |
d62a17ae | 1072 | { |
36944791 | 1073 | struct listnode *node; |
d62a17ae | 1074 | struct isis_dynhn *dynhn; |
d7c0a89a | 1075 | uint8_t sysid[ISIS_SYS_ID_LEN]; |
36944791 | 1076 | struct isis *isis; |
d62a17ae | 1077 | |
eab88f36 | 1078 | if (!im) { |
d62a17ae | 1079 | vty_out(vty, "IS-IS Routing Process not enabled\n"); |
1080 | return CMD_SUCCESS; | |
1081 | } | |
1082 | ||
1083 | memset(sysid, 0, ISIS_SYS_ID_LEN); | |
1084 | if (id) { | |
1085 | if (sysid2buff(sysid, id) == 0) { | |
1086 | dynhn = dynhn_find_by_name(id); | |
1087 | if (dynhn == NULL) { | |
1088 | vty_out(vty, "Invalid system id %s\n", id); | |
1089 | return CMD_SUCCESS; | |
1090 | } | |
1091 | memcpy(sysid, dynhn->id, ISIS_SYS_ID_LEN); | |
1092 | } | |
1093 | } | |
1094 | ||
eab88f36 K |
1095 | if (vrf_name) { |
1096 | if (all_vrf) { | |
36944791 | 1097 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { |
eab88f36 K |
1098 | isis_neighbor_common(vty, id, detail, isis, |
1099 | sysid); | |
1100 | } | |
36944791 | 1101 | return CMD_SUCCESS; |
eab88f36 K |
1102 | } |
1103 | isis = isis_lookup_by_vrfname(vrf_name); | |
1104 | if (isis != NULL) | |
1105 | isis_neighbor_common(vty, id, detail, isis, sysid); | |
1106 | } | |
1107 | ||
1108 | return CMD_SUCCESS; | |
1109 | } | |
1110 | ||
1111 | static void isis_neighbor_common_clear(struct vty *vty, const char *id, | |
1112 | uint8_t *sysid, struct isis *isis) | |
1113 | { | |
36944791 | 1114 | struct listnode *anode, *cnode, *node, *nnode; |
eab88f36 K |
1115 | struct isis_area *area; |
1116 | struct isis_circuit *circuit; | |
1117 | struct list *adjdb; | |
1118 | struct isis_adjacency *adj; | |
1119 | int i; | |
1120 | ||
d62a17ae | 1121 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { |
36944791 | 1122 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) { |
d62a17ae | 1123 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { |
1124 | for (i = 0; i < 2; i++) { | |
1125 | adjdb = circuit->u.bc.adjdb[i]; | |
1126 | if (adjdb && adjdb->count) { | |
1127 | for (ALL_LIST_ELEMENTS( | |
1128 | adjdb, node, nnode, | |
1129 | adj)) | |
1130 | if (!id | |
eab88f36 K |
1131 | || !memcmp( |
1132 | adj->sysid, | |
1133 | sysid, | |
1134 | ISIS_SYS_ID_LEN)) | |
d62a17ae | 1135 | isis_adj_state_change( |
16167b31 | 1136 | &adj, |
d62a17ae | 1137 | ISIS_ADJ_DOWN, |
1138 | "clear user request"); | |
1139 | } | |
1140 | } | |
1141 | } else if (circuit->circ_type == CIRCUIT_T_P2P | |
1142 | && circuit->u.p2p.neighbor) { | |
1143 | adj = circuit->u.p2p.neighbor; | |
1144 | if (!id | |
1145 | || !memcmp(adj->sysid, sysid, | |
1146 | ISIS_SYS_ID_LEN)) | |
1147 | isis_adj_state_change( | |
16167b31 | 1148 | &adj, ISIS_ADJ_DOWN, |
d62a17ae | 1149 | "clear user request"); |
1150 | } | |
1151 | } | |
1152 | } | |
3f045a08 | 1153 | } |
eab88f36 K |
1154 | /* |
1155 | * 'clear isis neighbor' command | |
1156 | */ | |
1157 | int clear_isis_neighbor_common(struct vty *vty, const char *id, const char *vrf_name, | |
1158 | bool all_vrf) | |
eb5d44eb | 1159 | { |
36944791 | 1160 | struct listnode *node; |
eab88f36 K |
1161 | struct isis_dynhn *dynhn; |
1162 | uint8_t sysid[ISIS_SYS_ID_LEN]; | |
36944791 | 1163 | struct isis *isis; |
eb5d44eb | 1164 | |
eab88f36 K |
1165 | if (!im) { |
1166 | vty_out(vty, "IS-IS Routing Process not enabled\n"); | |
1167 | return CMD_SUCCESS; | |
1168 | } | |
3f045a08 | 1169 | |
eab88f36 K |
1170 | memset(sysid, 0, ISIS_SYS_ID_LEN); |
1171 | if (id) { | |
1172 | if (sysid2buff(sysid, id) == 0) { | |
1173 | dynhn = dynhn_find_by_name(id); | |
1174 | if (dynhn == NULL) { | |
1175 | vty_out(vty, "Invalid system id %s\n", id); | |
1176 | return CMD_SUCCESS; | |
1177 | } | |
1178 | memcpy(sysid, dynhn->id, ISIS_SYS_ID_LEN); | |
1179 | } | |
1180 | } | |
1181 | if (vrf_name) { | |
1182 | if (all_vrf) { | |
36944791 | 1183 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) |
eab88f36 K |
1184 | isis_neighbor_common_clear(vty, id, sysid, |
1185 | isis); | |
36944791 | 1186 | return CMD_SUCCESS; |
eab88f36 K |
1187 | } |
1188 | isis = isis_lookup_by_vrfname(vrf_name); | |
1189 | if (isis != NULL) | |
1190 | isis_neighbor_common_clear(vty, id, sysid, isis); | |
1191 | } | |
3f045a08 | 1192 | |
eab88f36 | 1193 | return CMD_SUCCESS; |
3f045a08 JB |
1194 | } |
1195 | ||
eab88f36 K |
1196 | DEFUN(show_isis_neighbor, |
1197 | show_isis_neighbor_cmd, | |
1198 | "show " PROTO_NAME " [vrf <NAME|all>] neighbor", | |
1199 | SHOW_STR | |
1200 | PROTO_HELP | |
1201 | VRF_CMD_HELP_STR | |
1202 | "All vrfs\n" | |
1203 | "IS-IS neighbor adjacencies\n") | |
1204 | { | |
1205 | const char *vrf_name = VRF_DEFAULT_NAME; | |
1206 | bool all_vrf = false; | |
1207 | int idx_vrf = 0; | |
1208 | ||
1209 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
1210 | return show_isis_neighbor_common(vty, NULL, ISIS_UI_LEVEL_BRIEF, | |
1211 | vrf_name, all_vrf); | |
1212 | } | |
1213 | ||
1214 | DEFUN(show_isis_neighbor_detail, | |
1215 | show_isis_neighbor_detail_cmd, | |
1216 | "show " PROTO_NAME " [vrf <NAME|all>] neighbor detail", | |
1217 | SHOW_STR | |
1218 | PROTO_HELP | |
1219 | VRF_CMD_HELP_STR | |
1220 | "all vrfs\n" | |
1221 | "IS-IS neighbor adjacencies\n" | |
1222 | "show detailed information\n") | |
1223 | { | |
1224 | const char *vrf_name = VRF_DEFAULT_NAME; | |
1225 | bool all_vrf = false; | |
1226 | int idx_vrf = 0; | |
1227 | ||
1228 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
1229 | ||
1230 | return show_isis_neighbor_common(vty, NULL, ISIS_UI_LEVEL_DETAIL, | |
1231 | vrf_name, all_vrf); | |
1232 | } | |
1233 | ||
1234 | DEFUN(show_isis_neighbor_arg, | |
1235 | show_isis_neighbor_arg_cmd, | |
1236 | "show " PROTO_NAME " [vrf <NAME|all>] neighbor WORD", | |
1237 | SHOW_STR | |
1238 | PROTO_HELP | |
1239 | VRF_CMD_HELP_STR | |
1240 | "All vrfs\n" | |
1241 | "IS-IS neighbor adjacencies\n" | |
1242 | "System id\n") | |
1243 | { | |
1244 | int idx_word = 0; | |
1245 | const char *vrf_name = VRF_DEFAULT_NAME; | |
1246 | bool all_vrf = false; | |
1247 | int idx_vrf = 0; | |
1248 | ||
1249 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
1250 | char *id = argv_find(argv, argc, "WORD", &idx_word) | |
1251 | ? argv[idx_word]->arg | |
1252 | : NULL; | |
1253 | ||
1254 | return show_isis_neighbor_common(vty, id, ISIS_UI_LEVEL_DETAIL, | |
1255 | vrf_name, all_vrf); | |
1256 | } | |
1257 | ||
1258 | DEFUN(clear_isis_neighbor, | |
1259 | clear_isis_neighbor_cmd, | |
1260 | "clear " PROTO_NAME " [vrf <NAME|all>] neighbor", | |
1261 | CLEAR_STR | |
1262 | PROTO_HELP | |
1263 | VRF_CMD_HELP_STR | |
1264 | "All vrfs\n" | |
1265 | "IS-IS neighbor adjacencies\n") | |
1266 | { | |
1267 | const char *vrf_name = VRF_DEFAULT_NAME; | |
1268 | bool all_vrf = false; | |
1269 | int idx_vrf = 0; | |
1270 | ||
1271 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
1272 | return clear_isis_neighbor_common(vty, NULL, vrf_name, all_vrf); | |
1273 | } | |
1274 | ||
1275 | DEFUN(clear_isis_neighbor_arg, | |
1276 | clear_isis_neighbor_arg_cmd, | |
1277 | "clear " PROTO_NAME " [vrf <NAME|all>] neighbor WORD", | |
1278 | CLEAR_STR | |
1279 | PROTO_HELP | |
1280 | VRF_CMD_HELP_STR | |
1281 | "All vrfs\n" | |
1282 | "IS-IS neighbor adjacencies\n" | |
1283 | "System id\n") | |
1284 | { | |
1285 | int idx_word = 0; | |
1286 | const char *vrf_name = VRF_DEFAULT_NAME; | |
1287 | bool all_vrf = false; | |
1288 | int idx_vrf = 0; | |
1289 | ||
1290 | char *id = argv_find(argv, argc, "WORD", &idx_word) | |
1291 | ? argv[idx_word]->arg | |
1292 | : NULL; | |
1293 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
1294 | return clear_isis_neighbor_common(vty, id, vrf_name, all_vrf); | |
3f045a08 JB |
1295 | } |
1296 | ||
eb5d44eb | 1297 | /* |
1298 | * 'isis debug', 'show debugging' | |
1299 | */ | |
d62a17ae | 1300 | void print_debug(struct vty *vty, int flags, int onoff) |
1301 | { | |
5627d3fe | 1302 | const char *onoffs = onoff ? "on" : "off"; |
d62a17ae | 1303 | |
1304 | if (flags & DEBUG_ADJ_PACKETS) | |
1305 | vty_out(vty, | |
1306 | "IS-IS Adjacency related packets debugging is %s\n", | |
1307 | onoffs); | |
161fa356 CF |
1308 | if (flags & DEBUG_TX_QUEUE) |
1309 | vty_out(vty, "IS-IS TX queue debugging is %s\n", | |
1310 | onoffs); | |
d62a17ae | 1311 | if (flags & DEBUG_SNP_PACKETS) |
1312 | vty_out(vty, "IS-IS CSNP/PSNP packets debugging is %s\n", | |
1313 | onoffs); | |
1314 | if (flags & DEBUG_SPF_EVENTS) | |
1315 | vty_out(vty, "IS-IS SPF events debugging is %s\n", onoffs); | |
26f6acaf RW |
1316 | if (flags & DEBUG_SR) |
1317 | vty_out(vty, "IS-IS Segment Routing events debugging is %s\n", | |
1318 | onoffs); | |
2866b119 RW |
1319 | if (flags & DEBUG_LFA) |
1320 | vty_out(vty, "IS-IS LFA events debugging is %s\n", onoffs); | |
d62a17ae | 1321 | if (flags & DEBUG_UPDATE_PACKETS) |
1322 | vty_out(vty, "IS-IS Update related packet debugging is %s\n", | |
1323 | onoffs); | |
1324 | if (flags & DEBUG_RTE_EVENTS) | |
1325 | vty_out(vty, "IS-IS Route related debuggin is %s\n", onoffs); | |
1326 | if (flags & DEBUG_EVENTS) | |
1327 | vty_out(vty, "IS-IS Event debugging is %s\n", onoffs); | |
1328 | if (flags & DEBUG_PACKET_DUMP) | |
1329 | vty_out(vty, "IS-IS Packet dump debugging is %s\n", onoffs); | |
1330 | if (flags & DEBUG_LSP_GEN) | |
1331 | vty_out(vty, "IS-IS LSP generation debugging is %s\n", onoffs); | |
1332 | if (flags & DEBUG_LSP_SCHED) | |
1333 | vty_out(vty, "IS-IS LSP scheduling debugging is %s\n", onoffs); | |
ddb33326 CF |
1334 | if (flags & DEBUG_FLOODING) |
1335 | vty_out(vty, "IS-IS Flooding debugging is %s\n", onoffs); | |
2815f817 CF |
1336 | if (flags & DEBUG_BFD) |
1337 | vty_out(vty, "IS-IS BFD debugging is %s\n", onoffs); | |
1cbf96a8 | 1338 | if (flags & DEBUG_LDP_SYNC) |
1339 | vty_out(vty, "IS-IS ldp-sync debugging is %s\n", onoffs); | |
eb5d44eb | 1340 | } |
1341 | ||
87f6dc50 DS |
1342 | DEFUN_NOSH (show_debugging, |
1343 | show_debugging_isis_cmd, | |
7c0cbd0e | 1344 | "show debugging [" PROTO_NAME "]", |
87f6dc50 DS |
1345 | SHOW_STR |
1346 | "State of each debugging option\n" | |
7c0cbd0e | 1347 | PROTO_HELP) |
eb5d44eb | 1348 | { |
7c0cbd0e | 1349 | vty_out(vty, PROTO_NAME " debugging status:\n"); |
87f6dc50 | 1350 | |
e740f9c1 | 1351 | if (IS_DEBUG_ADJ_PACKETS) |
1352 | print_debug(vty, DEBUG_ADJ_PACKETS, 1); | |
1353 | if (IS_DEBUG_TX_QUEUE) | |
1354 | print_debug(vty, DEBUG_TX_QUEUE, 1); | |
1355 | if (IS_DEBUG_SNP_PACKETS) | |
1356 | print_debug(vty, DEBUG_SNP_PACKETS, 1); | |
1357 | if (IS_DEBUG_SPF_EVENTS) | |
1358 | print_debug(vty, DEBUG_SPF_EVENTS, 1); | |
1359 | if (IS_DEBUG_SR) | |
1360 | print_debug(vty, DEBUG_SR, 1); | |
1361 | if (IS_DEBUG_UPDATE_PACKETS) | |
1362 | print_debug(vty, DEBUG_UPDATE_PACKETS, 1); | |
1363 | if (IS_DEBUG_RTE_EVENTS) | |
1364 | print_debug(vty, DEBUG_RTE_EVENTS, 1); | |
1365 | if (IS_DEBUG_EVENTS) | |
1366 | print_debug(vty, DEBUG_EVENTS, 1); | |
1367 | if (IS_DEBUG_PACKET_DUMP) | |
1368 | print_debug(vty, DEBUG_PACKET_DUMP, 1); | |
1369 | if (IS_DEBUG_LSP_GEN) | |
1370 | print_debug(vty, DEBUG_LSP_GEN, 1); | |
1371 | if (IS_DEBUG_LSP_SCHED) | |
1372 | print_debug(vty, DEBUG_LSP_SCHED, 1); | |
1373 | if (IS_DEBUG_FLOODING) | |
1374 | print_debug(vty, DEBUG_FLOODING, 1); | |
1375 | if (IS_DEBUG_BFD) | |
1376 | print_debug(vty, DEBUG_BFD, 1); | |
1cbf96a8 | 1377 | if (IS_DEBUG_LDP_SYNC) |
1378 | print_debug(vty, DEBUG_LDP_SYNC, 1); | |
098fc8a9 FR |
1379 | if (IS_DEBUG_LFA) |
1380 | print_debug(vty, DEBUG_LFA, 1); | |
1381 | ||
d62a17ae | 1382 | return CMD_SUCCESS; |
eb5d44eb | 1383 | } |
1384 | ||
612c2c15 | 1385 | static int config_write_debug(struct vty *vty); |
9e867fe6 | 1386 | /* Debug node. */ |
62b346ee | 1387 | static struct cmd_node debug_node = { |
f4b8291f | 1388 | .name = "debug", |
62b346ee DL |
1389 | .node = DEBUG_NODE, |
1390 | .prompt = "", | |
612c2c15 | 1391 | .config_write = config_write_debug, |
62b346ee | 1392 | }; |
d62a17ae | 1393 | |
1394 | static int config_write_debug(struct vty *vty) | |
1395 | { | |
1396 | int write = 0; | |
d62a17ae | 1397 | |
e740f9c1 | 1398 | if (IS_DEBUG_ADJ_PACKETS) { |
7c0cbd0e | 1399 | vty_out(vty, "debug " PROTO_NAME " adj-packets\n"); |
d62a17ae | 1400 | write++; |
1401 | } | |
e740f9c1 | 1402 | if (IS_DEBUG_TX_QUEUE) { |
161fa356 CF |
1403 | vty_out(vty, "debug " PROTO_NAME " tx-queue\n"); |
1404 | write++; | |
1405 | } | |
e740f9c1 | 1406 | if (IS_DEBUG_SNP_PACKETS) { |
7c0cbd0e | 1407 | vty_out(vty, "debug " PROTO_NAME " snp-packets\n"); |
d62a17ae | 1408 | write++; |
1409 | } | |
e740f9c1 | 1410 | if (IS_DEBUG_SPF_EVENTS) { |
7c0cbd0e | 1411 | vty_out(vty, "debug " PROTO_NAME " spf-events\n"); |
d62a17ae | 1412 | write++; |
1413 | } | |
e740f9c1 | 1414 | if (IS_DEBUG_SR) { |
26f6acaf RW |
1415 | vty_out(vty, "debug " PROTO_NAME " sr-events\n"); |
1416 | write++; | |
1417 | } | |
2866b119 RW |
1418 | if (IS_DEBUG_LFA) { |
1419 | vty_out(vty, "debug " PROTO_NAME " lfa\n"); | |
c951ee6e RW |
1420 | write++; |
1421 | } | |
e740f9c1 | 1422 | if (IS_DEBUG_UPDATE_PACKETS) { |
7c0cbd0e | 1423 | vty_out(vty, "debug " PROTO_NAME " update-packets\n"); |
d62a17ae | 1424 | write++; |
1425 | } | |
e740f9c1 | 1426 | if (IS_DEBUG_RTE_EVENTS) { |
7c0cbd0e | 1427 | vty_out(vty, "debug " PROTO_NAME " route-events\n"); |
d62a17ae | 1428 | write++; |
1429 | } | |
e740f9c1 | 1430 | if (IS_DEBUG_EVENTS) { |
7c0cbd0e | 1431 | vty_out(vty, "debug " PROTO_NAME " events\n"); |
d62a17ae | 1432 | write++; |
1433 | } | |
e740f9c1 | 1434 | if (IS_DEBUG_PACKET_DUMP) { |
7c0cbd0e | 1435 | vty_out(vty, "debug " PROTO_NAME " packet-dump\n"); |
d62a17ae | 1436 | write++; |
1437 | } | |
e740f9c1 | 1438 | if (IS_DEBUG_LSP_GEN) { |
7c0cbd0e | 1439 | vty_out(vty, "debug " PROTO_NAME " lsp-gen\n"); |
d62a17ae | 1440 | write++; |
1441 | } | |
e740f9c1 | 1442 | if (IS_DEBUG_LSP_SCHED) { |
7c0cbd0e | 1443 | vty_out(vty, "debug " PROTO_NAME " lsp-sched\n"); |
d62a17ae | 1444 | write++; |
1445 | } | |
e740f9c1 | 1446 | if (IS_DEBUG_FLOODING) { |
d4cff91a CF |
1447 | vty_out(vty, "debug " PROTO_NAME " flooding\n"); |
1448 | write++; | |
1449 | } | |
e740f9c1 | 1450 | if (IS_DEBUG_BFD) { |
2815f817 CF |
1451 | vty_out(vty, "debug " PROTO_NAME " bfd\n"); |
1452 | write++; | |
1453 | } | |
1cbf96a8 | 1454 | if (IS_DEBUG_LDP_SYNC) { |
1455 | vty_out(vty, "debug " PROTO_NAME " ldp-sync\n"); | |
1456 | write++; | |
1457 | } | |
d62a17ae | 1458 | write += spf_backoff_write_config(vty); |
1459 | ||
1460 | return write; | |
9e867fe6 | 1461 | } |
1462 | ||
eb5d44eb | 1463 | DEFUN (debug_isis_adj, |
1464 | debug_isis_adj_cmd, | |
7c0cbd0e | 1465 | "debug " PROTO_NAME " adj-packets", |
eb5d44eb | 1466 | DEBUG_STR |
7c0cbd0e | 1467 | PROTO_HELP |
f390d2c7 | 1468 | "IS-IS Adjacency related packets\n") |
eb5d44eb | 1469 | { |
e740f9c1 | 1470 | debug_adj_pkt |= DEBUG_ADJ_PACKETS; |
d62a17ae | 1471 | print_debug(vty, DEBUG_ADJ_PACKETS, 1); |
eb5d44eb | 1472 | |
d62a17ae | 1473 | return CMD_SUCCESS; |
eb5d44eb | 1474 | } |
1475 | ||
1476 | DEFUN (no_debug_isis_adj, | |
1477 | no_debug_isis_adj_cmd, | |
7c0cbd0e | 1478 | "no debug " PROTO_NAME " adj-packets", |
16cedbb0 | 1479 | NO_STR |
eb5d44eb | 1480 | UNDEBUG_STR |
7c0cbd0e | 1481 | PROTO_HELP |
f390d2c7 | 1482 | "IS-IS Adjacency related packets\n") |
eb5d44eb | 1483 | { |
e740f9c1 | 1484 | debug_adj_pkt &= ~DEBUG_ADJ_PACKETS; |
d62a17ae | 1485 | print_debug(vty, DEBUG_ADJ_PACKETS, 0); |
eb5d44eb | 1486 | |
d62a17ae | 1487 | return CMD_SUCCESS; |
eb5d44eb | 1488 | } |
1489 | ||
161fa356 CF |
1490 | DEFUN (debug_isis_tx_queue, |
1491 | debug_isis_tx_queue_cmd, | |
1492 | "debug " PROTO_NAME " tx-queue", | |
1493 | DEBUG_STR | |
1494 | PROTO_HELP | |
1495 | "IS-IS TX queues\n") | |
1496 | { | |
e740f9c1 | 1497 | debug_tx_queue |= DEBUG_TX_QUEUE; |
161fa356 CF |
1498 | print_debug(vty, DEBUG_TX_QUEUE, 1); |
1499 | ||
1500 | return CMD_SUCCESS; | |
1501 | } | |
1502 | ||
1503 | DEFUN (no_debug_isis_tx_queue, | |
1504 | no_debug_isis_tx_queue_cmd, | |
1505 | "no debug " PROTO_NAME " tx-queue", | |
1506 | NO_STR | |
1507 | UNDEBUG_STR | |
1508 | PROTO_HELP | |
1509 | "IS-IS TX queues\n") | |
1510 | { | |
e740f9c1 | 1511 | debug_tx_queue &= ~DEBUG_TX_QUEUE; |
161fa356 CF |
1512 | print_debug(vty, DEBUG_TX_QUEUE, 0); |
1513 | ||
1514 | return CMD_SUCCESS; | |
1515 | } | |
1516 | ||
ddb33326 CF |
1517 | DEFUN (debug_isis_flooding, |
1518 | debug_isis_flooding_cmd, | |
1519 | "debug " PROTO_NAME " flooding", | |
1520 | DEBUG_STR | |
1521 | PROTO_HELP | |
1522 | "Flooding algorithm\n") | |
1523 | { | |
e740f9c1 | 1524 | debug_flooding |= DEBUG_FLOODING; |
ddb33326 CF |
1525 | print_debug(vty, DEBUG_FLOODING, 1); |
1526 | ||
1527 | return CMD_SUCCESS; | |
1528 | } | |
1529 | ||
1530 | DEFUN (no_debug_isis_flooding, | |
1531 | no_debug_isis_flooding_cmd, | |
1532 | "no debug " PROTO_NAME " flooding", | |
1533 | NO_STR | |
1534 | UNDEBUG_STR | |
1535 | PROTO_HELP | |
1536 | "Flooding algorithm\n") | |
1537 | { | |
e740f9c1 | 1538 | debug_flooding &= ~DEBUG_FLOODING; |
ddb33326 CF |
1539 | print_debug(vty, DEBUG_FLOODING, 0); |
1540 | ||
1541 | return CMD_SUCCESS; | |
1542 | } | |
1543 | ||
eb5d44eb | 1544 | DEFUN (debug_isis_snp, |
1545 | debug_isis_snp_cmd, | |
7c0cbd0e | 1546 | "debug " PROTO_NAME " snp-packets", |
eb5d44eb | 1547 | DEBUG_STR |
7c0cbd0e | 1548 | PROTO_HELP |
f390d2c7 | 1549 | "IS-IS CSNP/PSNP packets\n") |
eb5d44eb | 1550 | { |
e740f9c1 | 1551 | debug_snp_pkt |= DEBUG_SNP_PACKETS; |
d62a17ae | 1552 | print_debug(vty, DEBUG_SNP_PACKETS, 1); |
eb5d44eb | 1553 | |
d62a17ae | 1554 | return CMD_SUCCESS; |
eb5d44eb | 1555 | } |
1556 | ||
1557 | DEFUN (no_debug_isis_snp, | |
1558 | no_debug_isis_snp_cmd, | |
7c0cbd0e | 1559 | "no debug " PROTO_NAME " snp-packets", |
16cedbb0 | 1560 | NO_STR |
eb5d44eb | 1561 | UNDEBUG_STR |
7c0cbd0e | 1562 | PROTO_HELP |
f390d2c7 | 1563 | "IS-IS CSNP/PSNP packets\n") |
eb5d44eb | 1564 | { |
e740f9c1 | 1565 | debug_snp_pkt &= ~DEBUG_SNP_PACKETS; |
d62a17ae | 1566 | print_debug(vty, DEBUG_SNP_PACKETS, 0); |
f390d2c7 | 1567 | |
d62a17ae | 1568 | return CMD_SUCCESS; |
eb5d44eb | 1569 | } |
1570 | ||
eb5d44eb | 1571 | DEFUN (debug_isis_upd, |
1572 | debug_isis_upd_cmd, | |
7c0cbd0e | 1573 | "debug " PROTO_NAME " update-packets", |
eb5d44eb | 1574 | DEBUG_STR |
7c0cbd0e | 1575 | PROTO_HELP |
f390d2c7 | 1576 | "IS-IS Update related packets\n") |
eb5d44eb | 1577 | { |
e740f9c1 | 1578 | debug_update_pkt |= DEBUG_UPDATE_PACKETS; |
d62a17ae | 1579 | print_debug(vty, DEBUG_UPDATE_PACKETS, 1); |
eb5d44eb | 1580 | |
d62a17ae | 1581 | return CMD_SUCCESS; |
eb5d44eb | 1582 | } |
1583 | ||
1584 | DEFUN (no_debug_isis_upd, | |
1585 | no_debug_isis_upd_cmd, | |
7c0cbd0e | 1586 | "no debug " PROTO_NAME " update-packets", |
16cedbb0 | 1587 | NO_STR |
eb5d44eb | 1588 | UNDEBUG_STR |
7c0cbd0e | 1589 | PROTO_HELP |
f390d2c7 | 1590 | "IS-IS Update related packets\n") |
eb5d44eb | 1591 | { |
e740f9c1 | 1592 | debug_update_pkt &= ~DEBUG_UPDATE_PACKETS; |
d62a17ae | 1593 | print_debug(vty, DEBUG_UPDATE_PACKETS, 0); |
f390d2c7 | 1594 | |
d62a17ae | 1595 | return CMD_SUCCESS; |
eb5d44eb | 1596 | } |
1597 | ||
eb5d44eb | 1598 | DEFUN (debug_isis_spfevents, |
1599 | debug_isis_spfevents_cmd, | |
7c0cbd0e | 1600 | "debug " PROTO_NAME " spf-events", |
eb5d44eb | 1601 | DEBUG_STR |
7c0cbd0e | 1602 | PROTO_HELP |
f390d2c7 | 1603 | "IS-IS Shortest Path First Events\n") |
eb5d44eb | 1604 | { |
e740f9c1 | 1605 | debug_spf_events |= DEBUG_SPF_EVENTS; |
d62a17ae | 1606 | print_debug(vty, DEBUG_SPF_EVENTS, 1); |
eb5d44eb | 1607 | |
d62a17ae | 1608 | return CMD_SUCCESS; |
eb5d44eb | 1609 | } |
1610 | ||
1611 | DEFUN (no_debug_isis_spfevents, | |
1612 | no_debug_isis_spfevents_cmd, | |
7c0cbd0e | 1613 | "no debug " PROTO_NAME " spf-events", |
16cedbb0 | 1614 | NO_STR |
eb5d44eb | 1615 | UNDEBUG_STR |
7c0cbd0e | 1616 | PROTO_HELP |
f390d2c7 | 1617 | "IS-IS Shortest Path First Events\n") |
eb5d44eb | 1618 | { |
e740f9c1 | 1619 | debug_spf_events &= ~DEBUG_SPF_EVENTS; |
d62a17ae | 1620 | print_debug(vty, DEBUG_SPF_EVENTS, 0); |
f390d2c7 | 1621 | |
d62a17ae | 1622 | return CMD_SUCCESS; |
eb5d44eb | 1623 | } |
1624 | ||
26f6acaf RW |
1625 | DEFUN (debug_isis_srevents, |
1626 | debug_isis_srevents_cmd, | |
1627 | "debug " PROTO_NAME " sr-events", | |
1628 | DEBUG_STR | |
1629 | PROTO_HELP | |
1630 | "IS-IS Segment Routing Events\n") | |
1631 | { | |
e740f9c1 | 1632 | debug_sr |= DEBUG_SR; |
26f6acaf RW |
1633 | print_debug(vty, DEBUG_SR, 1); |
1634 | ||
1635 | return CMD_SUCCESS; | |
1636 | } | |
1637 | ||
1638 | DEFUN (no_debug_isis_srevents, | |
1639 | no_debug_isis_srevents_cmd, | |
1640 | "no debug " PROTO_NAME " sr-events", | |
1641 | NO_STR | |
1642 | UNDEBUG_STR | |
1643 | PROTO_HELP | |
1644 | "IS-IS Segment Routing Events\n") | |
1645 | { | |
e740f9c1 | 1646 | debug_sr &= ~DEBUG_SR; |
26f6acaf RW |
1647 | print_debug(vty, DEBUG_SR, 0); |
1648 | ||
1649 | return CMD_SUCCESS; | |
1650 | } | |
1651 | ||
2866b119 RW |
1652 | DEFUN (debug_isis_lfa, |
1653 | debug_isis_lfa_cmd, | |
1654 | "debug " PROTO_NAME " lfa", | |
c951ee6e RW |
1655 | DEBUG_STR |
1656 | PROTO_HELP | |
2866b119 | 1657 | "IS-IS LFA Events\n") |
c951ee6e | 1658 | { |
2866b119 RW |
1659 | debug_lfa |= DEBUG_LFA; |
1660 | print_debug(vty, DEBUG_LFA, 1); | |
c951ee6e RW |
1661 | |
1662 | return CMD_SUCCESS; | |
1663 | } | |
1664 | ||
2866b119 RW |
1665 | DEFUN (no_debug_isis_lfa, |
1666 | no_debug_isis_lfa_cmd, | |
1667 | "no debug " PROTO_NAME " lfa", | |
c951ee6e RW |
1668 | NO_STR |
1669 | UNDEBUG_STR | |
1670 | PROTO_HELP | |
2866b119 | 1671 | "IS-IS LFA Events\n") |
c951ee6e | 1672 | { |
2866b119 RW |
1673 | debug_lfa &= ~DEBUG_LFA; |
1674 | print_debug(vty, DEBUG_LFA, 0); | |
c951ee6e RW |
1675 | |
1676 | return CMD_SUCCESS; | |
1677 | } | |
1678 | ||
eb5d44eb | 1679 | DEFUN (debug_isis_rtevents, |
1680 | debug_isis_rtevents_cmd, | |
7c0cbd0e | 1681 | "debug " PROTO_NAME " route-events", |
eb5d44eb | 1682 | DEBUG_STR |
7c0cbd0e | 1683 | PROTO_HELP |
f390d2c7 | 1684 | "IS-IS Route related events\n") |
eb5d44eb | 1685 | { |
e740f9c1 | 1686 | debug_rte_events |= DEBUG_RTE_EVENTS; |
d62a17ae | 1687 | print_debug(vty, DEBUG_RTE_EVENTS, 1); |
eb5d44eb | 1688 | |
d62a17ae | 1689 | return CMD_SUCCESS; |
eb5d44eb | 1690 | } |
1691 | ||
1692 | DEFUN (no_debug_isis_rtevents, | |
1693 | no_debug_isis_rtevents_cmd, | |
7c0cbd0e | 1694 | "no debug " PROTO_NAME " route-events", |
16cedbb0 | 1695 | NO_STR |
eb5d44eb | 1696 | UNDEBUG_STR |
7c0cbd0e | 1697 | PROTO_HELP |
f390d2c7 | 1698 | "IS-IS Route related events\n") |
eb5d44eb | 1699 | { |
e740f9c1 | 1700 | debug_rte_events &= ~DEBUG_RTE_EVENTS; |
d62a17ae | 1701 | print_debug(vty, DEBUG_RTE_EVENTS, 0); |
f390d2c7 | 1702 | |
d62a17ae | 1703 | return CMD_SUCCESS; |
eb5d44eb | 1704 | } |
1705 | ||
1706 | DEFUN (debug_isis_events, | |
1707 | debug_isis_events_cmd, | |
7c0cbd0e | 1708 | "debug " PROTO_NAME " events", |
eb5d44eb | 1709 | DEBUG_STR |
7c0cbd0e | 1710 | PROTO_HELP |
f1082d19 | 1711 | "IS-IS Events\n") |
eb5d44eb | 1712 | { |
e740f9c1 | 1713 | debug_events |= DEBUG_EVENTS; |
d62a17ae | 1714 | print_debug(vty, DEBUG_EVENTS, 1); |
eb5d44eb | 1715 | |
d62a17ae | 1716 | return CMD_SUCCESS; |
eb5d44eb | 1717 | } |
1718 | ||
1719 | DEFUN (no_debug_isis_events, | |
1720 | no_debug_isis_events_cmd, | |
7c0cbd0e | 1721 | "no debug " PROTO_NAME " events", |
16cedbb0 | 1722 | NO_STR |
eb5d44eb | 1723 | UNDEBUG_STR |
7c0cbd0e | 1724 | PROTO_HELP |
f390d2c7 | 1725 | "IS-IS Events\n") |
eb5d44eb | 1726 | { |
e740f9c1 | 1727 | debug_events &= ~DEBUG_EVENTS; |
d62a17ae | 1728 | print_debug(vty, DEBUG_EVENTS, 0); |
f390d2c7 | 1729 | |
d62a17ae | 1730 | return CMD_SUCCESS; |
eb5d44eb | 1731 | } |
1732 | ||
3f045a08 JB |
1733 | DEFUN (debug_isis_packet_dump, |
1734 | debug_isis_packet_dump_cmd, | |
7c0cbd0e | 1735 | "debug " PROTO_NAME " packet-dump", |
3f045a08 | 1736 | DEBUG_STR |
7c0cbd0e | 1737 | PROTO_HELP |
3f045a08 JB |
1738 | "IS-IS packet dump\n") |
1739 | { | |
e740f9c1 | 1740 | debug_pkt_dump |= DEBUG_PACKET_DUMP; |
d62a17ae | 1741 | print_debug(vty, DEBUG_PACKET_DUMP, 1); |
3f045a08 | 1742 | |
d62a17ae | 1743 | return CMD_SUCCESS; |
3f045a08 JB |
1744 | } |
1745 | ||
1746 | DEFUN (no_debug_isis_packet_dump, | |
1747 | no_debug_isis_packet_dump_cmd, | |
7c0cbd0e | 1748 | "no debug " PROTO_NAME " packet-dump", |
16cedbb0 | 1749 | NO_STR |
3f045a08 | 1750 | UNDEBUG_STR |
7c0cbd0e | 1751 | PROTO_HELP |
3f045a08 JB |
1752 | "IS-IS packet dump\n") |
1753 | { | |
e740f9c1 | 1754 | debug_pkt_dump &= ~DEBUG_PACKET_DUMP; |
d62a17ae | 1755 | print_debug(vty, DEBUG_PACKET_DUMP, 0); |
3f045a08 | 1756 | |
d62a17ae | 1757 | return CMD_SUCCESS; |
3f045a08 JB |
1758 | } |
1759 | ||
14872644 CF |
1760 | DEFUN (debug_isis_lsp_gen, |
1761 | debug_isis_lsp_gen_cmd, | |
7c0cbd0e | 1762 | "debug " PROTO_NAME " lsp-gen", |
14872644 | 1763 | DEBUG_STR |
7c0cbd0e | 1764 | PROTO_HELP |
14872644 CF |
1765 | "IS-IS generation of own LSPs\n") |
1766 | { | |
e740f9c1 | 1767 | debug_lsp_gen |= DEBUG_LSP_GEN; |
d62a17ae | 1768 | print_debug(vty, DEBUG_LSP_GEN, 1); |
14872644 | 1769 | |
d62a17ae | 1770 | return CMD_SUCCESS; |
14872644 CF |
1771 | } |
1772 | ||
1773 | DEFUN (no_debug_isis_lsp_gen, | |
1774 | no_debug_isis_lsp_gen_cmd, | |
7c0cbd0e | 1775 | "no debug " PROTO_NAME " lsp-gen", |
16cedbb0 | 1776 | NO_STR |
14872644 | 1777 | UNDEBUG_STR |
7c0cbd0e | 1778 | PROTO_HELP |
14872644 CF |
1779 | "IS-IS generation of own LSPs\n") |
1780 | { | |
e740f9c1 | 1781 | debug_lsp_gen &= ~DEBUG_LSP_GEN; |
d62a17ae | 1782 | print_debug(vty, DEBUG_LSP_GEN, 0); |
14872644 | 1783 | |
d62a17ae | 1784 | return CMD_SUCCESS; |
14872644 CF |
1785 | } |
1786 | ||
414766a1 CF |
1787 | DEFUN (debug_isis_lsp_sched, |
1788 | debug_isis_lsp_sched_cmd, | |
7c0cbd0e | 1789 | "debug " PROTO_NAME " lsp-sched", |
414766a1 | 1790 | DEBUG_STR |
7c0cbd0e | 1791 | PROTO_HELP |
414766a1 CF |
1792 | "IS-IS scheduling of LSP generation\n") |
1793 | { | |
e740f9c1 | 1794 | debug_lsp_sched |= DEBUG_LSP_SCHED; |
d62a17ae | 1795 | print_debug(vty, DEBUG_LSP_SCHED, 1); |
414766a1 | 1796 | |
d62a17ae | 1797 | return CMD_SUCCESS; |
414766a1 CF |
1798 | } |
1799 | ||
49d41a26 DS |
1800 | DEFUN (no_debug_isis_lsp_sched, |
1801 | no_debug_isis_lsp_sched_cmd, | |
7c0cbd0e | 1802 | "no debug " PROTO_NAME " lsp-sched", |
16cedbb0 | 1803 | NO_STR |
49d41a26 | 1804 | UNDEBUG_STR |
7c0cbd0e | 1805 | PROTO_HELP |
49d41a26 DS |
1806 | "IS-IS scheduling of LSP generation\n") |
1807 | { | |
e740f9c1 | 1808 | debug_lsp_sched &= ~DEBUG_LSP_SCHED; |
d62a17ae | 1809 | print_debug(vty, DEBUG_LSP_SCHED, 0); |
49d41a26 | 1810 | |
d62a17ae | 1811 | return CMD_SUCCESS; |
49d41a26 DS |
1812 | } |
1813 | ||
2815f817 CF |
1814 | DEFUN (debug_isis_bfd, |
1815 | debug_isis_bfd_cmd, | |
1816 | "debug " PROTO_NAME " bfd", | |
1817 | DEBUG_STR | |
1818 | PROTO_HELP | |
1819 | PROTO_NAME " interaction with BFD\n") | |
1820 | { | |
e740f9c1 | 1821 | debug_bfd |= DEBUG_BFD; |
2815f817 CF |
1822 | print_debug(vty, DEBUG_BFD, 1); |
1823 | ||
1824 | return CMD_SUCCESS; | |
1825 | } | |
1826 | ||
1827 | DEFUN (no_debug_isis_bfd, | |
1828 | no_debug_isis_bfd_cmd, | |
1829 | "no debug " PROTO_NAME " bfd", | |
1830 | NO_STR | |
1831 | UNDEBUG_STR | |
1832 | PROTO_HELP | |
1833 | PROTO_NAME " interaction with BFD\n") | |
1834 | { | |
e740f9c1 | 1835 | debug_bfd &= ~DEBUG_BFD; |
2815f817 CF |
1836 | print_debug(vty, DEBUG_BFD, 0); |
1837 | ||
1838 | return CMD_SUCCESS; | |
1839 | } | |
1840 | ||
1cbf96a8 | 1841 | DEFUN(debug_isis_ldp_sync, debug_isis_ldp_sync_cmd, |
1842 | "debug " PROTO_NAME " ldp-sync", | |
1843 | DEBUG_STR PROTO_HELP PROTO_NAME " interaction with LDP-Sync\n") | |
1844 | { | |
1845 | debug_ldp_sync |= DEBUG_LDP_SYNC; | |
1846 | print_debug(vty, DEBUG_LDP_SYNC, 1); | |
1847 | ||
1848 | return CMD_SUCCESS; | |
1849 | } | |
1850 | ||
1851 | DEFUN(no_debug_isis_ldp_sync, no_debug_isis_ldp_sync_cmd, | |
1852 | "no debug " PROTO_NAME " ldp-sync", | |
1853 | NO_STR UNDEBUG_STR PROTO_HELP PROTO_NAME " interaction with LDP-Sync\n") | |
1854 | { | |
1855 | debug_ldp_sync &= ~DEBUG_LDP_SYNC; | |
1856 | print_debug(vty, DEBUG_LDP_SYNC, 0); | |
1857 | ||
1858 | return CMD_SUCCESS; | |
1859 | } | |
1860 | ||
1861 | DEFUN (show_hostname, | |
1862 | show_hostname_cmd, | |
1863 | "show " PROTO_NAME " hostname", | |
1864 | SHOW_STR | |
1865 | PROTO_HELP | |
1866 | "IS-IS Dynamic hostname mapping\n") | |
eb5d44eb | 1867 | { |
36944791 | 1868 | struct listnode *node; |
eab88f36 K |
1869 | const char *vrf_name = VRF_DEFAULT_NAME; |
1870 | bool all_vrf = false; | |
1871 | int idx_vrf = 0; | |
36944791 | 1872 | struct isis *isis; |
eab88f36 K |
1873 | |
1874 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
1875 | if (vrf_name) { | |
1876 | if (all_vrf) { | |
36944791 | 1877 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) |
eab88f36 | 1878 | dynhn_print_all(vty, isis); |
36944791 RW |
1879 | |
1880 | return CMD_SUCCESS; | |
eab88f36 K |
1881 | } |
1882 | isis = isis_lookup_by_vrfname(vrf_name); | |
1883 | if (isis != NULL) | |
1884 | dynhn_print_all(vty, isis); | |
1885 | } | |
f390d2c7 | 1886 | |
d62a17ae | 1887 | return CMD_SUCCESS; |
eb5d44eb | 1888 | } |
1889 | ||
eab88f36 | 1890 | static void isis_spf_ietf_common(struct vty *vty, struct isis *isis) |
03f7e182 | 1891 | { |
d62a17ae | 1892 | struct listnode *node; |
1893 | struct isis_area *area; | |
d62a17ae | 1894 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { |
eab88f36 K |
1895 | |
1896 | vty_out(vty, "vrf : %s\n", isis->name); | |
d62a17ae | 1897 | vty_out(vty, "Area %s:\n", |
1898 | area->area_tag ? area->area_tag : "null"); | |
1899 | ||
1900 | for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { | |
1901 | if ((area->is_type & level) == 0) | |
1902 | continue; | |
1903 | ||
1904 | vty_out(vty, " Level-%d:\n", level); | |
1905 | vty_out(vty, " SPF delay status: "); | |
1906 | if (area->spf_timer[level - 1]) { | |
1907 | struct timeval remain = thread_timer_remain( | |
1908 | area->spf_timer[level - 1]); | |
a97986ff DL |
1909 | vty_out(vty, "Pending, due in %lld msec\n", |
1910 | (long long)remain.tv_sec * 1000 | |
d62a17ae | 1911 | + remain.tv_usec / 1000); |
1912 | } else { | |
1913 | vty_out(vty, "Not scheduled\n"); | |
1914 | } | |
1915 | ||
1916 | if (area->spf_delay_ietf[level - 1]) { | |
1917 | vty_out(vty, | |
1918 | " Using draft-ietf-rtgwg-backoff-algo-04\n"); | |
1919 | spf_backoff_show( | |
1920 | area->spf_delay_ietf[level - 1], vty, | |
1921 | " "); | |
1922 | } else { | |
1923 | vty_out(vty, " Using legacy backoff algo\n"); | |
1924 | } | |
1925 | } | |
1926 | } | |
eab88f36 K |
1927 | } |
1928 | ||
1929 | DEFUN(show_isis_spf_ietf, show_isis_spf_ietf_cmd, | |
1930 | "show " PROTO_NAME " [vrf <NAME|all>] spf-delay-ietf", | |
1931 | SHOW_STR PROTO_HELP VRF_CMD_HELP_STR | |
1932 | "All VRFs\n" | |
1933 | "SPF delay IETF information\n") | |
1934 | { | |
36944791 RW |
1935 | struct listnode *node; |
1936 | struct isis *isis; | |
eab88f36 K |
1937 | int idx_vrf = 0; |
1938 | const char *vrf_name = VRF_DEFAULT_NAME; | |
1939 | bool all_vrf = false; | |
1940 | ||
1941 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf) | |
1942 | ||
1943 | if (!im) { | |
1944 | vty_out(vty, "ISIS is not running\n"); | |
1945 | return CMD_SUCCESS; | |
1946 | } | |
1947 | ||
1948 | if (vrf_name) { | |
1949 | if (all_vrf) { | |
36944791 | 1950 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) |
eab88f36 | 1951 | isis_spf_ietf_common(vty, isis); |
36944791 RW |
1952 | |
1953 | return CMD_SUCCESS; | |
eab88f36 K |
1954 | } |
1955 | isis = isis_lookup_by_vrfname(vrf_name); | |
1956 | if (isis != NULL) | |
1957 | isis_spf_ietf_common(vty, isis); | |
1958 | } | |
1959 | ||
d62a17ae | 1960 | return CMD_SUCCESS; |
03f7e182 SL |
1961 | } |
1962 | ||
eab88f36 | 1963 | static void common_isis_summary(struct vty *vty, struct isis *isis) |
3f045a08 | 1964 | { |
d62a17ae | 1965 | struct listnode *node, *node2; |
1966 | struct isis_area *area; | |
d62a17ae | 1967 | int level; |
1968 | ||
eab88f36 | 1969 | vty_out(vty, "vrf : %s\n", isis->name); |
d62a17ae | 1970 | vty_out(vty, "Process Id : %ld\n", isis->process_id); |
1971 | if (isis->sysid_set) | |
1972 | vty_out(vty, "System Id : %s\n", | |
1973 | sysid_print(isis->sysid)); | |
1974 | ||
1975 | vty_out(vty, "Up time : "); | |
1976 | vty_out_timestr(vty, isis->uptime); | |
1977 | vty_out(vty, "\n"); | |
1978 | ||
1979 | if (isis->area_list) | |
1980 | vty_out(vty, "Number of areas : %d\n", isis->area_list->count); | |
1981 | ||
1982 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { | |
1983 | vty_out(vty, "Area %s:\n", | |
1984 | area->area_tag ? area->area_tag : "null"); | |
1985 | ||
92ed0cde CF |
1986 | if (fabricd) { |
1987 | uint8_t tier = fabricd_tier(area); | |
1988 | if (tier == ISIS_TIER_UNDEFINED) | |
1989 | vty_out(vty, " Tier: undefined\n"); | |
1990 | else | |
6cde4b45 | 1991 | vty_out(vty, " Tier: %hhu\n", tier); |
92ed0cde CF |
1992 | } |
1993 | ||
d62a17ae | 1994 | if (listcount(area->area_addrs) > 0) { |
1995 | struct area_addr *area_addr; | |
1996 | for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node2, | |
1997 | area_addr)) { | |
1998 | vty_out(vty, " Net: %s\n", | |
1999 | isonet_print(area_addr->area_addr, | |
2000 | area_addr->addr_len | |
2001 | + ISIS_SYS_ID_LEN | |
2002 | + 1)); | |
2003 | } | |
2004 | } | |
2005 | ||
39bb53d6 CF |
2006 | vty_out(vty, " TX counters per PDU type:\n"); |
2007 | pdu_counter_print(vty, " ", area->pdu_tx_counters); | |
86d6f80d CF |
2008 | vty_out(vty, " LSP RXMT: %" PRIu64 "\n", |
2009 | area->lsp_rxmt_count); | |
39bb53d6 CF |
2010 | vty_out(vty, " RX counters per PDU type:\n"); |
2011 | pdu_counter_print(vty, " ", area->pdu_rx_counters); | |
2012 | ||
d62a17ae | 2013 | for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { |
2014 | if ((area->is_type & level) == 0) | |
2015 | continue; | |
2016 | ||
2017 | vty_out(vty, " Level-%d:\n", level); | |
062f4d36 CF |
2018 | |
2019 | vty_out(vty, " LSP0 regenerated: %" PRIu64 "\n", | |
2020 | area->lsp_gen_count[level - 1]); | |
2021 | ||
6f004b60 CF |
2022 | vty_out(vty, " LSPs purged: %" PRIu64 "\n", |
2023 | area->lsp_purge_count[level - 1]); | |
2024 | ||
d62a17ae | 2025 | if (area->spf_timer[level - 1]) |
2026 | vty_out(vty, " SPF: (pending)\n"); | |
2027 | else | |
2028 | vty_out(vty, " SPF:\n"); | |
2029 | ||
2030 | vty_out(vty, " minimum interval : %d", | |
2031 | area->min_spf_interval[level - 1]); | |
2032 | if (area->spf_delay_ietf[level - 1]) | |
2033 | vty_out(vty, | |
2034 | " (not used, IETF SPF delay activated)"); | |
2035 | vty_out(vty, "\n"); | |
2036 | ||
a6f71d37 RW |
2037 | if (area->ip_circuits) { |
2038 | vty_out(vty, " IPv4 route computation:\n"); | |
2039 | isis_spf_print( | |
2040 | area->spftree[SPFTREE_IPV4][level - 1], | |
2041 | vty); | |
2042 | } | |
d62a17ae | 2043 | |
a6f71d37 RW |
2044 | if (area->ipv6_circuits) { |
2045 | vty_out(vty, " IPv6 route computation:\n"); | |
2046 | isis_spf_print( | |
2047 | area->spftree[SPFTREE_IPV6][level - 1], | |
2048 | vty); | |
2049 | } | |
321c1bbb | 2050 | |
a6f71d37 RW |
2051 | if (area->ipv6_circuits |
2052 | && isis_area_ipv6_dstsrc_enabled(area)) { | |
2053 | vty_out(vty, | |
2054 | " IPv6 dst-src route computation:\n"); | |
2055 | isis_spf_print(area->spftree[SPFTREE_DSTSRC] | |
2056 | [level - 1], | |
2057 | vty); | |
2058 | } | |
d62a17ae | 2059 | } |
2060 | } | |
eab88f36 K |
2061 | } |
2062 | ||
2063 | DEFUN(show_isis_summary, show_isis_summary_cmd, | |
2064 | "show " PROTO_NAME " [vrf <NAME|all>] summary", | |
2065 | SHOW_STR PROTO_HELP VRF_CMD_HELP_STR | |
2066 | "All VRFs\n" | |
2067 | "summary\n") | |
2068 | { | |
36944791 | 2069 | struct listnode *node; |
eab88f36 | 2070 | int idx_vrf = 0; |
36944791 | 2071 | struct isis *isis; |
eab88f36 K |
2072 | const char *vrf_name = VRF_DEFAULT_NAME; |
2073 | bool all_vrf = false; | |
2074 | ||
2075 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf) | |
2076 | if (!im) { | |
2077 | vty_out(vty, PROTO_NAME " is not running\n"); | |
2078 | return CMD_SUCCESS; | |
2079 | } | |
2080 | if (vrf_name) { | |
2081 | if (all_vrf) { | |
36944791 | 2082 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) |
eab88f36 | 2083 | common_isis_summary(vty, isis); |
36944791 RW |
2084 | |
2085 | return CMD_SUCCESS; | |
eab88f36 K |
2086 | } |
2087 | isis = isis_lookup_by_vrfname(vrf_name); | |
2088 | if (isis != NULL) | |
2089 | common_isis_summary(vty, isis); | |
2090 | } | |
2091 | ||
d62a17ae | 2092 | vty_out(vty, "\n"); |
2093 | ||
2094 | return CMD_SUCCESS; | |
eb5d44eb | 2095 | } |
2096 | ||
eab88f36 K |
2097 | struct isis_lsp *lsp_for_arg(struct lspdb_head *head, const char *argv, |
2098 | struct isis *isis) | |
d62a17ae | 2099 | { |
eb2bcb28 | 2100 | char sysid[255] = {0}; |
d7c0a89a | 2101 | uint8_t number[3]; |
eb2bcb28 CF |
2102 | const char *pos; |
2103 | uint8_t lspid[ISIS_SYS_ID_LEN + 2] = {0}; | |
2104 | struct isis_dynhn *dynhn; | |
2105 | struct isis_lsp *lsp = NULL; | |
d62a17ae | 2106 | |
eb2bcb28 CF |
2107 | if (!argv) |
2108 | return NULL; | |
d62a17ae | 2109 | |
2110 | /* | |
2111 | * extract fragment and pseudo id from the string argv | |
2112 | * in the forms: | |
2113 | * (a) <systemid/hostname>.<pseudo-id>-<framenent> or | |
2114 | * (b) <systemid/hostname>.<pseudo-id> or | |
2115 | * (c) <systemid/hostname> or | |
2116 | * Where systemid is in the form: | |
2117 | * xxxx.xxxx.xxxx | |
2118 | */ | |
2119 | if (argv) | |
e28544ed | 2120 | strlcpy(sysid, argv, sizeof(sysid)); |
d62a17ae | 2121 | if (argv && strlen(argv) > 3) { |
2122 | pos = argv + strlen(argv) - 3; | |
2123 | if (strncmp(pos, "-", 1) == 0) { | |
2124 | memcpy(number, ++pos, 2); | |
2125 | lspid[ISIS_SYS_ID_LEN + 1] = | |
d7c0a89a | 2126 | (uint8_t)strtol((char *)number, NULL, 16); |
d62a17ae | 2127 | pos -= 4; |
2128 | if (strncmp(pos, ".", 1) != 0) | |
eb2bcb28 | 2129 | return NULL; |
d62a17ae | 2130 | } |
2131 | if (strncmp(pos, ".", 1) == 0) { | |
2132 | memcpy(number, ++pos, 2); | |
2133 | lspid[ISIS_SYS_ID_LEN] = | |
d7c0a89a | 2134 | (uint8_t)strtol((char *)number, NULL, 16); |
d62a17ae | 2135 | sysid[pos - argv - 1] = '\0'; |
2136 | } | |
2137 | } | |
2138 | ||
eb2bcb28 CF |
2139 | /* |
2140 | * Try to find the lsp-id if the argv | |
2141 | * string is in | |
2142 | * the form | |
2143 | * hostname.<pseudo-id>-<fragment> | |
2144 | */ | |
2145 | if (sysid2buff(lspid, sysid)) { | |
4bef0ec4 | 2146 | lsp = lsp_search(head, lspid); |
eb2bcb28 CF |
2147 | } else if ((dynhn = dynhn_find_by_name(sysid))) { |
2148 | memcpy(lspid, dynhn->id, ISIS_SYS_ID_LEN); | |
4bef0ec4 | 2149 | lsp = lsp_search(head, lspid); |
eb2bcb28 CF |
2150 | } else if (strncmp(cmd_hostname_get(), sysid, 15) == 0) { |
2151 | memcpy(lspid, isis->sysid, ISIS_SYS_ID_LEN); | |
4bef0ec4 | 2152 | lsp = lsp_search(head, lspid); |
eb2bcb28 CF |
2153 | } |
2154 | ||
2155 | return lsp; | |
2156 | } | |
2157 | ||
52a7c25e RW |
2158 | void show_isis_database_lspdb(struct vty *vty, struct isis_area *area, |
2159 | int level, struct lspdb_head *lspdb, | |
2160 | const char *argv, int ui_level) | |
2161 | { | |
2162 | struct isis_lsp *lsp; | |
2163 | int lsp_count; | |
2164 | ||
2165 | if (lspdb_count(lspdb) > 0) { | |
2166 | lsp = lsp_for_arg(lspdb, argv, area->isis); | |
2167 | ||
2168 | if (lsp != NULL || argv == NULL) { | |
2169 | vty_out(vty, "IS-IS Level-%d link-state database:\n", | |
2170 | level + 1); | |
2171 | ||
2172 | /* print the title in all cases */ | |
2173 | vty_out(vty, | |
2174 | "LSP ID PduLen SeqNumber Chksum Holdtime ATT/P/OL\n"); | |
2175 | } | |
2176 | ||
2177 | if (lsp) { | |
2178 | if (ui_level == ISIS_UI_LEVEL_DETAIL) | |
2179 | lsp_print_detail(lsp, vty, area->dynhostname, | |
2180 | area->isis); | |
2181 | else | |
2182 | lsp_print(lsp, vty, area->dynhostname, | |
2183 | area->isis); | |
2184 | } else if (argv == NULL) { | |
2185 | lsp_count = | |
2186 | lsp_print_all(vty, lspdb, ui_level, | |
2187 | area->dynhostname, area->isis); | |
2188 | ||
2189 | vty_out(vty, " %u LSPs\n\n", lsp_count); | |
2190 | } | |
2191 | } | |
2192 | } | |
2193 | ||
2194 | static void show_isis_database_common(struct vty *vty, const char *argv, | |
2195 | int ui_level, struct isis *isis) | |
eb2bcb28 CF |
2196 | { |
2197 | struct listnode *node; | |
2198 | struct isis_area *area; | |
52a7c25e | 2199 | int level; |
eb2bcb28 CF |
2200 | |
2201 | if (isis->area_list->count == 0) | |
52a7c25e | 2202 | return; |
eb2bcb28 | 2203 | |
d62a17ae | 2204 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { |
2205 | vty_out(vty, "Area %s:\n", | |
2206 | area->area_tag ? area->area_tag : "null"); | |
2207 | ||
52a7c25e RW |
2208 | for (level = 0; level < ISIS_LEVELS; level++) |
2209 | show_isis_database_lspdb(vty, area, level, | |
2210 | &area->lspdb[level], argv, | |
2211 | ui_level); | |
d62a17ae | 2212 | } |
eab88f36 K |
2213 | } |
2214 | /* | |
2215 | * This function supports following display options: | |
2216 | * [ show isis database [detail] ] | |
2217 | * [ show isis database <sysid> [detail] ] | |
2218 | * [ show isis database <hostname> [detail] ] | |
2219 | * [ show isis database <sysid>.<pseudo-id> [detail] ] | |
2220 | * [ show isis database <hostname>.<pseudo-id> [detail] ] | |
2221 | * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ] | |
2222 | * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ] | |
2223 | * [ show isis database detail <sysid> ] | |
2224 | * [ show isis database detail <hostname> ] | |
2225 | * [ show isis database detail <sysid>.<pseudo-id> ] | |
2226 | * [ show isis database detail <hostname>.<pseudo-id> ] | |
2227 | * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ] | |
2228 | * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ] | |
2229 | */ | |
2230 | static int show_isis_database(struct vty *vty, const char *argv, int ui_level, | |
2231 | const char *vrf_name, bool all_vrf) | |
2232 | { | |
36944791 RW |
2233 | struct listnode *node; |
2234 | struct isis *isis; | |
eab88f36 K |
2235 | |
2236 | if (vrf_name) { | |
2237 | if (all_vrf) { | |
36944791 | 2238 | for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) |
eab88f36 K |
2239 | show_isis_database_common(vty, argv, ui_level, |
2240 | isis); | |
36944791 RW |
2241 | |
2242 | return CMD_SUCCESS; | |
eab88f36 K |
2243 | } |
2244 | isis = isis_lookup_by_vrfname(vrf_name); | |
36944791 | 2245 | if (isis) |
eab88f36 K |
2246 | show_isis_database_common(vty, argv, ui_level, isis); |
2247 | } | |
d62a17ae | 2248 | |
2249 | return CMD_SUCCESS; | |
eb5d44eb | 2250 | } |
2251 | ||
eab88f36 K |
2252 | DEFUN(show_database, show_database_cmd, |
2253 | "show " PROTO_NAME " [vrf <NAME|all>] database [detail] [WORD]", | |
2254 | SHOW_STR PROTO_HELP VRF_CMD_HELP_STR | |
2255 | "All VRFs\n" | |
2256 | "Link state database\n" | |
2257 | "Detailed information\n" | |
2258 | "LSP ID\n") | |
3f045a08 | 2259 | { |
d62a17ae | 2260 | int idx = 0; |
eab88f36 K |
2261 | int idx_vrf = 0; |
2262 | const char *vrf_name = VRF_DEFAULT_NAME; | |
2263 | bool all_vrf = false; | |
d62a17ae | 2264 | int uilevel = argv_find(argv, argc, "detail", &idx) |
2265 | ? ISIS_UI_LEVEL_DETAIL | |
2266 | : ISIS_UI_LEVEL_BRIEF; | |
2267 | char *id = argv_find(argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; | |
eab88f36 K |
2268 | ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
2269 | return show_isis_database(vty, id, uilevel, vrf_name, all_vrf); | |
3f045a08 JB |
2270 | } |
2271 | ||
aaf2fd21 | 2272 | #ifdef FABRICD |
d62a17ae | 2273 | /* |
aaf2fd21 | 2274 | * 'router openfabric' command |
3f045a08 | 2275 | */ |
aaf2fd21 EDP |
2276 | DEFUN_NOSH (router_openfabric, |
2277 | router_openfabric_cmd, | |
2278 | "router openfabric WORD", | |
3f045a08 | 2279 | ROUTER_STR |
7c0cbd0e | 2280 | PROTO_HELP |
efd7904e | 2281 | "ISO Routing area tag\n") |
3f045a08 | 2282 | { |
d62a17ae | 2283 | int idx_word = 2; |
2284 | return isis_area_get(vty, argv[idx_word]->arg); | |
3f045a08 JB |
2285 | } |
2286 | ||
d62a17ae | 2287 | /* |
aaf2fd21 | 2288 | *'no router openfabric' command |
3f045a08 | 2289 | */ |
aaf2fd21 EDP |
2290 | DEFUN (no_router_openfabric, |
2291 | no_router_openfabric_cmd, | |
2292 | "no router openfabric WORD", | |
7c0cbd0e CF |
2293 | NO_STR |
2294 | ROUTER_STR | |
2295 | PROTO_HELP | |
2296 | "ISO Routing area tag\n") | |
eb5d44eb | 2297 | { |
14c6e772 RW |
2298 | struct isis_area *area; |
2299 | const char *area_tag; | |
d62a17ae | 2300 | int idx_word = 3; |
14c6e772 RW |
2301 | |
2302 | area_tag = argv[idx_word]->arg; | |
eab88f36 | 2303 | area = isis_area_lookup(area_tag, VRF_DEFAULT); |
14c6e772 RW |
2304 | if (area == NULL) { |
2305 | zlog_warn("%s: could not find area with area-tag %s", | |
2306 | __func__, area_tag); | |
2307 | return CMD_ERR_NO_MATCH; | |
2308 | } | |
2309 | ||
2310 | isis_area_destroy(area); | |
2311 | return CMD_SUCCESS; | |
eb5d44eb | 2312 | } |
aaf2fd21 | 2313 | #endif /* ifdef FABRICD */ |
f084ea55 | 2314 | #ifdef FABRICD |
eb5d44eb | 2315 | /* |
2316 | * 'net' command | |
2317 | */ | |
2318 | DEFUN (net, | |
2319 | net_cmd, | |
2320 | "net WORD", | |
2321 | "A Network Entity Title for this process (OSI only)\n" | |
f390d2c7 | 2322 | "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") |
eb5d44eb | 2323 | { |
d62a17ae | 2324 | int idx_word = 1; |
2325 | return area_net_title(vty, argv[idx_word]->arg); | |
eb5d44eb | 2326 | } |
2327 | ||
eb5d44eb | 2328 | /* |
2329 | * 'no net' command | |
2330 | */ | |
2331 | DEFUN (no_net, | |
2332 | no_net_cmd, | |
2333 | "no net WORD", | |
2334 | NO_STR | |
2335 | "A Network Entity Title for this process (OSI only)\n" | |
f390d2c7 | 2336 | "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") |
eb5d44eb | 2337 | { |
d62a17ae | 2338 | int idx_word = 2; |
2339 | return area_clear_net_title(vty, argv[idx_word]->arg); | |
eb5d44eb | 2340 | } |
f084ea55 | 2341 | #endif /* ifdef FABRICD */ |
22af6a80 | 2342 | #ifdef FABRICD |
064f4896 CF |
2343 | DEFUN (isis_topology, |
2344 | isis_topology_cmd, | |
2345 | "topology " ISIS_MT_NAMES " [overload]", | |
2346 | "Configure IS-IS topologies\n" | |
2347 | ISIS_MT_DESCRIPTIONS | |
2348 | "Set overload bit for topology\n") | |
2349 | { | |
d62a17ae | 2350 | VTY_DECLVAR_CONTEXT(isis_area, area); |
064f4896 | 2351 | |
d62a17ae | 2352 | const char *arg = argv[1]->arg; |
2353 | uint16_t mtid = isis_str2mtid(arg); | |
c3ea3906 | 2354 | |
d62a17ae | 2355 | if (area->oldmetric) { |
2356 | vty_out(vty, | |
2357 | "Multi topology IS-IS can only be used with wide metrics\n"); | |
a5fdb4c5 | 2358 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 2359 | } |
c3ea3906 | 2360 | |
d62a17ae | 2361 | if (mtid == (uint16_t)-1) { |
2362 | vty_out(vty, "Don't know topology '%s'\n", arg); | |
a5fdb4c5 | 2363 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 2364 | } |
2365 | if (mtid == ISIS_MT_IPV4_UNICAST) { | |
2366 | vty_out(vty, "Cannot configure IPv4 unicast topology\n"); | |
a5fdb4c5 | 2367 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 2368 | } |
064f4896 | 2369 | |
d62a17ae | 2370 | area_set_mt_enabled(area, mtid, true); |
2371 | area_set_mt_overload(area, mtid, (argc == 3)); | |
2372 | return CMD_SUCCESS; | |
064f4896 CF |
2373 | } |
2374 | ||
2375 | DEFUN (no_isis_topology, | |
2376 | no_isis_topology_cmd, | |
2377 | "no topology " ISIS_MT_NAMES " [overload]", | |
2378 | NO_STR | |
2379 | "Configure IS-IS topologies\n" | |
2380 | ISIS_MT_DESCRIPTIONS | |
2381 | "Set overload bit for topology\n") | |
2382 | { | |
d62a17ae | 2383 | VTY_DECLVAR_CONTEXT(isis_area, area); |
064f4896 | 2384 | |
d62a17ae | 2385 | const char *arg = argv[2]->arg; |
2386 | uint16_t mtid = isis_str2mtid(arg); | |
c3ea3906 | 2387 | |
d62a17ae | 2388 | if (area->oldmetric) { |
2389 | vty_out(vty, | |
2390 | "Multi topology IS-IS can only be used with wide metrics\n"); | |
a5fdb4c5 | 2391 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 2392 | } |
c3ea3906 | 2393 | |
d62a17ae | 2394 | if (mtid == (uint16_t)-1) { |
2395 | vty_out(vty, "Don't know topology '%s'\n", arg); | |
a5fdb4c5 | 2396 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 2397 | } |
2398 | if (mtid == ISIS_MT_IPV4_UNICAST) { | |
2399 | vty_out(vty, "Cannot configure IPv4 unicast topology\n"); | |
a5fdb4c5 | 2400 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 2401 | } |
064f4896 | 2402 | |
d62a17ae | 2403 | area_set_mt_enabled(area, mtid, false); |
2404 | area_set_mt_overload(area, mtid, false); | |
2405 | return CMD_SUCCESS; | |
064f4896 | 2406 | } |
22af6a80 | 2407 | #endif /* ifdef FABRICD */ |
064f4896 | 2408 | |
6754fc66 | 2409 | void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu) |
b20ccb3a | 2410 | { |
d62a17ae | 2411 | area->lsp_mtu = lsp_mtu; |
2412 | lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1); | |
2413 | } | |
2414 | ||
2415 | static int isis_area_passwd_set(struct isis_area *area, int level, | |
d7c0a89a QY |
2416 | uint8_t passwd_type, const char *passwd, |
2417 | uint8_t snp_auth) | |
d62a17ae | 2418 | { |
2419 | struct isis_passwd *dest; | |
2420 | struct isis_passwd modified; | |
2421 | int len; | |
2422 | ||
2423 | assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2)); | |
2424 | dest = (level == IS_LEVEL_1) ? &area->area_passwd | |
2425 | : &area->domain_passwd; | |
2426 | memset(&modified, 0, sizeof(modified)); | |
2427 | ||
2428 | if (passwd_type != ISIS_PASSWD_TYPE_UNUSED) { | |
2429 | if (!passwd) | |
2430 | return -1; | |
2431 | ||
2432 | len = strlen(passwd); | |
2433 | if (len > 254) | |
2434 | return -1; | |
2435 | ||
2436 | modified.len = len; | |
e28544ed QY |
2437 | strlcpy((char *)modified.passwd, passwd, |
2438 | sizeof(modified.passwd)); | |
d62a17ae | 2439 | modified.type = passwd_type; |
2440 | modified.snp_auth = snp_auth; | |
2441 | } | |
2442 | ||
2443 | if (memcmp(&modified, dest, sizeof(modified))) { | |
2444 | memcpy(dest, &modified, sizeof(modified)); | |
2445 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
2446 | } | |
2447 | ||
2448 | return 0; | |
2449 | } | |
2450 | ||
2451 | int isis_area_passwd_unset(struct isis_area *area, int level) | |
2452 | { | |
2453 | return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_UNUSED, NULL, | |
2454 | 0); | |
2455 | } | |
2456 | ||
2457 | int isis_area_passwd_cleartext_set(struct isis_area *area, int level, | |
d7c0a89a | 2458 | const char *passwd, uint8_t snp_auth) |
d62a17ae | 2459 | { |
2460 | return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_CLEARTXT, | |
2461 | passwd, snp_auth); | |
2462 | } | |
2463 | ||
2464 | int isis_area_passwd_hmac_md5_set(struct isis_area *area, int level, | |
d7c0a89a | 2465 | const char *passwd, uint8_t snp_auth) |
d62a17ae | 2466 | { |
2467 | return isis_area_passwd_set(area, level, ISIS_PASSWD_TYPE_HMAC_MD5, | |
2468 | passwd, snp_auth); | |
b20ccb3a CF |
2469 | } |
2470 | ||
3dace42d CF |
2471 | void isis_area_invalidate_routes(struct isis_area *area, int levels) |
2472 | { | |
2473 | for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) { | |
2474 | if (!(level & levels)) | |
2475 | continue; | |
be985ba0 CF |
2476 | for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) { |
2477 | isis_spf_invalidate_routes( | |
2478 | area->spftree[tree][level - 1]); | |
2479 | } | |
3dace42d CF |
2480 | } |
2481 | } | |
2482 | ||
2483 | void isis_area_verify_routes(struct isis_area *area) | |
2484 | { | |
be985ba0 CF |
2485 | for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) |
2486 | isis_spf_verify_routes(area, area->spftree[tree]); | |
3dace42d CF |
2487 | } |
2488 | ||
d62a17ae | 2489 | static void area_resign_level(struct isis_area *area, int level) |
3f045a08 | 2490 | { |
3dace42d CF |
2491 | isis_area_invalidate_routes(area, level); |
2492 | isis_area_verify_routes(area); | |
2493 | ||
4bef0ec4 | 2494 | lsp_db_fini(&area->lspdb[level - 1]); |
be985ba0 CF |
2495 | |
2496 | for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) { | |
2497 | if (area->spftree[tree][level - 1]) { | |
2498 | isis_spftree_del(area->spftree[tree][level - 1]); | |
2499 | area->spftree[tree][level - 1] = NULL; | |
2500 | } | |
d62a17ae | 2501 | } |
be985ba0 | 2502 | |
8f15843b DS |
2503 | if (area->spf_timer[level - 1]) |
2504 | isis_spf_timer_free(THREAD_ARG(area->spf_timer[level - 1])); | |
2505 | ||
50478845 | 2506 | thread_cancel(&area->spf_timer[level - 1]); |
3f045a08 | 2507 | |
d62a17ae | 2508 | sched_debug( |
2509 | "ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.", | |
2510 | area->area_tag, level); | |
50478845 | 2511 | thread_cancel(&area->t_lsp_refresh[level - 1]); |
d62a17ae | 2512 | area->lsp_regenerate_pending[level - 1] = 0; |
2513 | } | |
3f045a08 | 2514 | |
d62a17ae | 2515 | void isis_area_is_type_set(struct isis_area *area, int is_type) |
2516 | { | |
2517 | struct listnode *node; | |
2518 | struct isis_circuit *circuit; | |
3f045a08 | 2519 | |
e740f9c1 | 2520 | if (IS_DEBUG_EVENTS) |
d62a17ae | 2521 | zlog_debug("ISIS-Evt (%s) system type change %s -> %s", |
2522 | area->area_tag, circuit_t2string(area->is_type), | |
2523 | circuit_t2string(is_type)); | |
f390d2c7 | 2524 | |
d62a17ae | 2525 | if (area->is_type == is_type) |
2526 | return; /* No change */ | |
2527 | ||
2528 | switch (area->is_type) { | |
2529 | case IS_LEVEL_1: | |
2530 | if (is_type == IS_LEVEL_2) | |
2531 | area_resign_level(area, IS_LEVEL_1); | |
2532 | ||
4bef0ec4 | 2533 | lsp_db_init(&area->lspdb[1]); |
d62a17ae | 2534 | break; |
2535 | ||
2536 | case IS_LEVEL_1_AND_2: | |
2537 | if (is_type == IS_LEVEL_1) | |
2538 | area_resign_level(area, IS_LEVEL_2); | |
2539 | else | |
2540 | area_resign_level(area, IS_LEVEL_1); | |
2541 | break; | |
2542 | ||
2543 | case IS_LEVEL_2: | |
2544 | if (is_type == IS_LEVEL_1) | |
2545 | area_resign_level(area, IS_LEVEL_2); | |
2546 | ||
4bef0ec4 | 2547 | lsp_db_init(&area->lspdb[0]); |
d62a17ae | 2548 | break; |
2549 | ||
2550 | default: | |
2551 | break; | |
2552 | } | |
2553 | ||
2554 | area->is_type = is_type; | |
2555 | ||
2556 | /* override circuit's is_type */ | |
2557 | if (area->is_type != IS_LEVEL_1_AND_2) { | |
2558 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) | |
2559 | isis_circuit_is_type_set(circuit, is_type); | |
2560 | } | |
2561 | ||
2562 | spftree_area_init(area); | |
2563 | ||
2564 | if (listcount(area->area_addrs) > 0) { | |
2565 | if (is_type & IS_LEVEL_1) | |
2566 | lsp_generate(area, IS_LEVEL_1); | |
2567 | if (is_type & IS_LEVEL_2) | |
2568 | lsp_generate(area, IS_LEVEL_2); | |
2569 | } | |
2570 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
2571 | ||
2572 | return; | |
eb5d44eb | 2573 | } |
2574 | ||
a38a72db CF |
2575 | void isis_area_metricstyle_set(struct isis_area *area, bool old_metric, |
2576 | bool new_metric) | |
e38e0df0 | 2577 | { |
e0df3206 EDP |
2578 | area->oldmetric = old_metric; |
2579 | area->newmetric = new_metric; | |
2580 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
e38e0df0 SV |
2581 | } |
2582 | ||
a38a72db | 2583 | void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit) |
eb5d44eb | 2584 | { |
d62a17ae | 2585 | char new_overload_bit = overload_bit ? LSPBIT_OL : 0; |
eb5d44eb | 2586 | |
d62a17ae | 2587 | if (new_overload_bit != area->overload_bit) { |
2588 | area->overload_bit = new_overload_bit; | |
1ee746d9 | 2589 | |
2590 | if (new_overload_bit) | |
2591 | area->overload_counter++; | |
2592 | ||
2593 | #ifndef FABRICD | |
2594 | hook_call(isis_hook_db_overload, area); | |
2595 | #endif /* ifndef FABRICD */ | |
2596 | ||
d62a17ae | 2597 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); |
2598 | } | |
9414b6f6 EDP |
2599 | #ifndef FABRICD |
2600 | isis_notif_db_overload(area, overload_bit); | |
2601 | #endif /* ifndef FABRICD */ | |
3f045a08 JB |
2602 | } |
2603 | ||
f3abc412 | 2604 | void isis_area_attached_bit_send_set(struct isis_area *area, bool attached_bit) |
2605 | { | |
2606 | ||
2607 | if (attached_bit != area->attached_bit_send) { | |
2608 | area->attached_bit_send = attached_bit; | |
2609 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
2610 | } | |
2611 | } | |
2612 | ||
2613 | void isis_area_attached_bit_receive_set(struct isis_area *area, | |
2614 | bool attached_bit) | |
3f045a08 | 2615 | { |
3f045a08 | 2616 | |
f3abc412 | 2617 | if (attached_bit != area->attached_bit_rcv_ignore) { |
2618 | area->attached_bit_rcv_ignore = attached_bit; | |
d62a17ae | 2619 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); |
2620 | } | |
eb5d44eb | 2621 | } |
2622 | ||
a38a72db | 2623 | void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname) |
eb5d44eb | 2624 | { |
d62a17ae | 2625 | if (area->dynhostname != dynhostname) { |
2626 | area->dynhostname = dynhostname; | |
2627 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
2628 | } | |
eb5d44eb | 2629 | } |
2630 | ||
d62a17ae | 2631 | void isis_area_max_lsp_lifetime_set(struct isis_area *area, int level, |
2632 | uint16_t max_lsp_lifetime) | |
eb5d44eb | 2633 | { |
d62a17ae | 2634 | assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2)); |
eb5d44eb | 2635 | |
d62a17ae | 2636 | if (area->max_lsp_lifetime[level - 1] == max_lsp_lifetime) |
2637 | return; | |
3f045a08 | 2638 | |
d62a17ae | 2639 | area->max_lsp_lifetime[level - 1] = max_lsp_lifetime; |
2640 | lsp_regenerate_schedule(area, level, 1); | |
3f045a08 JB |
2641 | } |
2642 | ||
d62a17ae | 2643 | void isis_area_lsp_refresh_set(struct isis_area *area, int level, |
2644 | uint16_t lsp_refresh) | |
3f045a08 | 2645 | { |
d62a17ae | 2646 | assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2)); |
eb5d44eb | 2647 | |
d62a17ae | 2648 | if (area->lsp_refresh[level - 1] == lsp_refresh) |
2649 | return; | |
eb5d44eb | 2650 | |
d62a17ae | 2651 | area->lsp_refresh[level - 1] = lsp_refresh; |
2652 | lsp_regenerate_schedule(area, level, 1); | |
3f045a08 JB |
2653 | } |
2654 | ||
2adf66ff | 2655 | #ifdef FABRICD |
3f045a08 JB |
2656 | DEFUN (log_adj_changes, |
2657 | log_adj_changes_cmd, | |
2658 | "log-adjacency-changes", | |
2659 | "Log changes in adjacency state\n") | |
2660 | { | |
d62a17ae | 2661 | VTY_DECLVAR_CONTEXT(isis_area, area); |
eb5d44eb | 2662 | |
d62a17ae | 2663 | area->log_adj_changes = 1; |
eb5d44eb | 2664 | |
d62a17ae | 2665 | return CMD_SUCCESS; |
eb5d44eb | 2666 | } |
2667 | ||
3f045a08 JB |
2668 | DEFUN (no_log_adj_changes, |
2669 | no_log_adj_changes_cmd, | |
2670 | "no log-adjacency-changes", | |
d7fa34c1 | 2671 | NO_STR |
3f045a08 | 2672 | "Stop logging changes in adjacency state\n") |
eb5d44eb | 2673 | { |
d62a17ae | 2674 | VTY_DECLVAR_CONTEXT(isis_area, area); |
f390d2c7 | 2675 | |
d62a17ae | 2676 | area->log_adj_changes = 0; |
eb5d44eb | 2677 | |
d62a17ae | 2678 | return CMD_SUCCESS; |
eb5d44eb | 2679 | } |
2adf66ff | 2680 | #endif /* ifdef FABRICD */ |
20600086 | 2681 | #ifdef FABRICD |
eb5d44eb | 2682 | /* IS-IS configuration write function */ |
612c2c15 | 2683 | static int isis_config_write(struct vty *vty) |
d62a17ae | 2684 | { |
2685 | int write = 0; | |
eab88f36 | 2686 | struct isis_area *area; |
36944791 RW |
2687 | struct listnode *node, *node2, *inode; |
2688 | struct isis *isis; | |
eab88f36 K |
2689 | |
2690 | if (!im) { | |
2691 | vty_out(vty, "IS-IS Routing Process not enabled\n"); | |
2692 | return CMD_SUCCESS; | |
2693 | } | |
d62a17ae | 2694 | |
36944791 | 2695 | for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { |
d62a17ae | 2696 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { |
2697 | /* ISIS - Area name */ | |
7c0cbd0e | 2698 | vty_out(vty, "router " PROTO_NAME " %s\n", area->area_tag); |
d62a17ae | 2699 | write++; |
2700 | /* ISIS - Net */ | |
2701 | if (listcount(area->area_addrs) > 0) { | |
2702 | struct area_addr *area_addr; | |
2703 | for (ALL_LIST_ELEMENTS_RO(area->area_addrs, | |
2704 | node2, area_addr)) { | |
2705 | vty_out(vty, " net %s\n", | |
2706 | isonet_print( | |
2707 | area_addr->area_addr, | |
2708 | area_addr->addr_len | |
2709 | + ISIS_SYS_ID_LEN | |
2710 | + 1)); | |
2711 | write++; | |
2712 | } | |
2713 | } | |
2714 | /* ISIS - Dynamic hostname - Defaults to true so only | |
2715 | * display if | |
2716 | * false. */ | |
2717 | if (!area->dynhostname) { | |
2718 | vty_out(vty, " no hostname dynamic\n"); | |
2719 | write++; | |
2720 | } | |
2721 | /* ISIS - Metric-Style - when true displays wide */ | |
65f18157 CF |
2722 | if (!fabricd) { |
2723 | if (area->newmetric) { | |
2724 | if (!area->oldmetric) | |
2725 | vty_out(vty, " metric-style wide\n"); | |
2726 | else | |
2727 | vty_out(vty, | |
2728 | " metric-style transition\n"); | |
2729 | write++; | |
2730 | } else { | |
2731 | vty_out(vty, " metric-style narrow\n"); | |
2732 | write++; | |
2733 | } | |
d62a17ae | 2734 | } |
2735 | /* ISIS - overload-bit */ | |
2736 | if (area->overload_bit) { | |
2737 | vty_out(vty, " set-overload-bit\n"); | |
2738 | write++; | |
2739 | } | |
2740 | /* ISIS - Area is-type (level-1-2 is default) */ | |
65f18157 CF |
2741 | if (!fabricd) { |
2742 | if (area->is_type == IS_LEVEL_1) { | |
2743 | vty_out(vty, " is-type level-1\n"); | |
2744 | write++; | |
2745 | } else if (area->is_type == IS_LEVEL_2) { | |
2746 | vty_out(vty, " is-type level-2-only\n"); | |
2747 | write++; | |
2748 | } | |
d62a17ae | 2749 | } |
2750 | write += isis_redist_config_write(vty, area, AF_INET); | |
2751 | write += isis_redist_config_write(vty, area, AF_INET6); | |
2752 | /* ISIS - Lsp generation interval */ | |
2753 | if (area->lsp_gen_interval[0] | |
2754 | == area->lsp_gen_interval[1]) { | |
2755 | if (area->lsp_gen_interval[0] | |
2756 | != DEFAULT_MIN_LSP_GEN_INTERVAL) { | |
2757 | vty_out(vty, " lsp-gen-interval %d\n", | |
2758 | area->lsp_gen_interval[0]); | |
2759 | write++; | |
2760 | } | |
2761 | } else { | |
2762 | if (area->lsp_gen_interval[0] | |
2763 | != DEFAULT_MIN_LSP_GEN_INTERVAL) { | |
2764 | vty_out(vty, | |
2765 | " lsp-gen-interval level-1 %d\n", | |
2766 | area->lsp_gen_interval[0]); | |
2767 | write++; | |
2768 | } | |
2769 | if (area->lsp_gen_interval[1] | |
2770 | != DEFAULT_MIN_LSP_GEN_INTERVAL) { | |
2771 | vty_out(vty, | |
2772 | " lsp-gen-interval level-2 %d\n", | |
2773 | area->lsp_gen_interval[1]); | |
2774 | write++; | |
2775 | } | |
2776 | } | |
2777 | /* ISIS - LSP lifetime */ | |
2778 | if (area->max_lsp_lifetime[0] | |
2779 | == area->max_lsp_lifetime[1]) { | |
2780 | if (area->max_lsp_lifetime[0] | |
2781 | != DEFAULT_LSP_LIFETIME) { | |
2782 | vty_out(vty, " max-lsp-lifetime %u\n", | |
2783 | area->max_lsp_lifetime[0]); | |
2784 | write++; | |
2785 | } | |
2786 | } else { | |
2787 | if (area->max_lsp_lifetime[0] | |
2788 | != DEFAULT_LSP_LIFETIME) { | |
2789 | vty_out(vty, | |
2790 | " max-lsp-lifetime level-1 %u\n", | |
2791 | area->max_lsp_lifetime[0]); | |
2792 | write++; | |
2793 | } | |
2794 | if (area->max_lsp_lifetime[1] | |
2795 | != DEFAULT_LSP_LIFETIME) { | |
2796 | vty_out(vty, | |
2797 | " max-lsp-lifetime level-2 %u\n", | |
2798 | area->max_lsp_lifetime[1]); | |
2799 | write++; | |
2800 | } | |
2801 | } | |
2802 | /* ISIS - LSP refresh interval */ | |
2803 | if (area->lsp_refresh[0] == area->lsp_refresh[1]) { | |
2804 | if (area->lsp_refresh[0] | |
2805 | != DEFAULT_MAX_LSP_GEN_INTERVAL) { | |
2806 | vty_out(vty, | |
2807 | " lsp-refresh-interval %u\n", | |
2808 | area->lsp_refresh[0]); | |
2809 | write++; | |
2810 | } | |
2811 | } else { | |
2812 | if (area->lsp_refresh[0] | |
2813 | != DEFAULT_MAX_LSP_GEN_INTERVAL) { | |
2814 | vty_out(vty, | |
2815 | " lsp-refresh-interval level-1 %u\n", | |
2816 | area->lsp_refresh[0]); | |
2817 | write++; | |
2818 | } | |
2819 | if (area->lsp_refresh[1] | |
2820 | != DEFAULT_MAX_LSP_GEN_INTERVAL) { | |
2821 | vty_out(vty, | |
2822 | " lsp-refresh-interval level-2 %u\n", | |
2823 | area->lsp_refresh[1]); | |
2824 | write++; | |
2825 | } | |
2826 | } | |
2827 | if (area->lsp_mtu != DEFAULT_LSP_MTU) { | |
2828 | vty_out(vty, " lsp-mtu %u\n", area->lsp_mtu); | |
2829 | write++; | |
2830 | } | |
2c92bee4 CF |
2831 | if (area->purge_originator) { |
2832 | vty_out(vty, " purge-originator\n"); | |
2833 | write++; | |
2834 | } | |
d62a17ae | 2835 | |
2836 | /* Minimum SPF interval. */ | |
2837 | if (area->min_spf_interval[0] | |
2838 | == area->min_spf_interval[1]) { | |
2839 | if (area->min_spf_interval[0] | |
2840 | != MINIMUM_SPF_INTERVAL) { | |
2841 | vty_out(vty, " spf-interval %d\n", | |
2842 | area->min_spf_interval[0]); | |
2843 | write++; | |
2844 | } | |
2845 | } else { | |
2846 | if (area->min_spf_interval[0] | |
2847 | != MINIMUM_SPF_INTERVAL) { | |
2848 | vty_out(vty, | |
2849 | " spf-interval level-1 %d\n", | |
2850 | area->min_spf_interval[0]); | |
2851 | write++; | |
2852 | } | |
2853 | if (area->min_spf_interval[1] | |
2854 | != MINIMUM_SPF_INTERVAL) { | |
2855 | vty_out(vty, | |
2856 | " spf-interval level-2 %d\n", | |
2857 | area->min_spf_interval[1]); | |
2858 | write++; | |
2859 | } | |
2860 | } | |
2861 | ||
2862 | /* IETF SPF interval */ | |
2863 | if (area->spf_delay_ietf[0]) { | |
2864 | vty_out(vty, | |
2865 | " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld\n", | |
2866 | spf_backoff_init_delay( | |
2867 | area->spf_delay_ietf[0]), | |
2868 | spf_backoff_short_delay( | |
2869 | area->spf_delay_ietf[0]), | |
2870 | spf_backoff_long_delay( | |
2871 | area->spf_delay_ietf[0]), | |
2872 | spf_backoff_holddown( | |
2873 | area->spf_delay_ietf[0]), | |
2874 | spf_backoff_timetolearn( | |
2875 | area->spf_delay_ietf[0])); | |
2876 | write++; | |
2877 | } | |
2878 | ||
2879 | /* Authentication passwords. */ | |
2880 | if (area->area_passwd.type | |
2881 | == ISIS_PASSWD_TYPE_HMAC_MD5) { | |
2882 | vty_out(vty, " area-password md5 %s", | |
2883 | area->area_passwd.passwd); | |
2884 | if (CHECK_FLAG(area->area_passwd.snp_auth, | |
2885 | SNP_AUTH_SEND)) { | |
2886 | vty_out(vty, " authenticate snp "); | |
2887 | if (CHECK_FLAG( | |
2888 | area->area_passwd.snp_auth, | |
2889 | SNP_AUTH_RECV)) | |
2890 | vty_out(vty, "validate"); | |
2891 | else | |
2892 | vty_out(vty, "send-only"); | |
2893 | } | |
2894 | vty_out(vty, "\n"); | |
2895 | write++; | |
2896 | } else if (area->area_passwd.type | |
2897 | == ISIS_PASSWD_TYPE_CLEARTXT) { | |
2898 | vty_out(vty, " area-password clear %s", | |
2899 | area->area_passwd.passwd); | |
2900 | if (CHECK_FLAG(area->area_passwd.snp_auth, | |
2901 | SNP_AUTH_SEND)) { | |
2902 | vty_out(vty, " authenticate snp "); | |
2903 | if (CHECK_FLAG( | |
2904 | area->area_passwd.snp_auth, | |
2905 | SNP_AUTH_RECV)) | |
2906 | vty_out(vty, "validate"); | |
2907 | else | |
2908 | vty_out(vty, "send-only"); | |
2909 | } | |
2910 | vty_out(vty, "\n"); | |
2911 | write++; | |
2912 | } | |
2913 | if (area->domain_passwd.type | |
2914 | == ISIS_PASSWD_TYPE_HMAC_MD5) { | |
2915 | vty_out(vty, " domain-password md5 %s", | |
2916 | area->domain_passwd.passwd); | |
2917 | if (CHECK_FLAG(area->domain_passwd.snp_auth, | |
2918 | SNP_AUTH_SEND)) { | |
2919 | vty_out(vty, " authenticate snp "); | |
2920 | if (CHECK_FLAG(area->domain_passwd | |
2921 | .snp_auth, | |
2922 | SNP_AUTH_RECV)) | |
2923 | vty_out(vty, "validate"); | |
2924 | else | |
2925 | vty_out(vty, "send-only"); | |
2926 | } | |
2927 | vty_out(vty, "\n"); | |
2928 | write++; | |
2929 | } else if (area->domain_passwd.type | |
2930 | == ISIS_PASSWD_TYPE_CLEARTXT) { | |
2931 | vty_out(vty, " domain-password clear %s", | |
2932 | area->domain_passwd.passwd); | |
2933 | if (CHECK_FLAG(area->domain_passwd.snp_auth, | |
2934 | SNP_AUTH_SEND)) { | |
2935 | vty_out(vty, " authenticate snp "); | |
2936 | if (CHECK_FLAG(area->domain_passwd | |
2937 | .snp_auth, | |
2938 | SNP_AUTH_RECV)) | |
2939 | vty_out(vty, "validate"); | |
2940 | else | |
2941 | vty_out(vty, "send-only"); | |
2942 | } | |
2943 | vty_out(vty, "\n"); | |
2944 | write++; | |
2945 | } | |
2946 | ||
2947 | if (area->log_adj_changes) { | |
2948 | vty_out(vty, " log-adjacency-changes\n"); | |
2949 | write++; | |
2950 | } | |
2951 | ||
2952 | write += area_write_mt_settings(area, vty); | |
92ed0cde | 2953 | write += fabricd_write_settings(area, vty); |
d62a17ae | 2954 | } |
d62a17ae | 2955 | } |
2956 | ||
2957 | return write; | |
2958 | } | |
2959 | ||
f4b8291f DL |
2960 | struct cmd_node router_node = { |
2961 | .name = "openfabric", | |
2962 | .node = OPENFABRIC_NODE, | |
2963 | .parent_node = CONFIG_NODE, | |
2964 | .prompt = "%s(config-router)# ", | |
2965 | .config_write = isis_config_write, | |
2966 | }; | |
20600086 EDP |
2967 | #else |
2968 | /* IS-IS configuration write function */ | |
612c2c15 | 2969 | static int isis_config_write(struct vty *vty) |
20600086 EDP |
2970 | { |
2971 | int write = 0; | |
2972 | struct lyd_node *dnode; | |
2973 | ||
2974 | dnode = yang_dnode_get(running_config->dnode, "/frr-isisd:isis"); | |
cc50ddb2 | 2975 | if (dnode) { |
20600086 | 2976 | nb_cli_show_dnode_cmds(vty, dnode, false); |
cc50ddb2 EDP |
2977 | write++; |
2978 | } | |
20600086 EDP |
2979 | |
2980 | return write; | |
2981 | } | |
20600086 | 2982 | |
62b346ee | 2983 | struct cmd_node router_node = { |
f4b8291f DL |
2984 | .name = "isis", |
2985 | .node = ISIS_NODE, | |
24389580 | 2986 | .parent_node = CONFIG_NODE, |
62b346ee | 2987 | .prompt = "%s(config-router)# ", |
612c2c15 | 2988 | .config_write = isis_config_write, |
62b346ee | 2989 | }; |
f4b8291f | 2990 | #endif /* ifdef FABRICD */ |
d62a17ae | 2991 | |
4d762f26 | 2992 | void isis_init(void) |
d62a17ae | 2993 | { |
2994 | /* Install IS-IS top node */ | |
612c2c15 | 2995 | install_node(&router_node); |
d62a17ae | 2996 | |
2997 | install_element(VIEW_NODE, &show_isis_summary_cmd); | |
2998 | ||
2999 | install_element(VIEW_NODE, &show_isis_spf_ietf_cmd); | |
3000 | ||
3001 | install_element(VIEW_NODE, &show_isis_interface_cmd); | |
3002 | install_element(VIEW_NODE, &show_isis_interface_detail_cmd); | |
3003 | install_element(VIEW_NODE, &show_isis_interface_arg_cmd); | |
3004 | ||
3005 | install_element(VIEW_NODE, &show_isis_neighbor_cmd); | |
3006 | install_element(VIEW_NODE, &show_isis_neighbor_detail_cmd); | |
3007 | install_element(VIEW_NODE, &show_isis_neighbor_arg_cmd); | |
2b55d953 IR |
3008 | install_element(ENABLE_NODE, &clear_isis_neighbor_cmd); |
3009 | install_element(ENABLE_NODE, &clear_isis_neighbor_arg_cmd); | |
d62a17ae | 3010 | |
3011 | install_element(VIEW_NODE, &show_hostname_cmd); | |
3012 | install_element(VIEW_NODE, &show_database_cmd); | |
3013 | ||
3014 | install_element(ENABLE_NODE, &show_debugging_isis_cmd); | |
3015 | ||
612c2c15 | 3016 | install_node(&debug_node); |
d62a17ae | 3017 | |
3018 | install_element(ENABLE_NODE, &debug_isis_adj_cmd); | |
3019 | install_element(ENABLE_NODE, &no_debug_isis_adj_cmd); | |
161fa356 CF |
3020 | install_element(ENABLE_NODE, &debug_isis_tx_queue_cmd); |
3021 | install_element(ENABLE_NODE, &no_debug_isis_tx_queue_cmd); | |
ddb33326 CF |
3022 | install_element(ENABLE_NODE, &debug_isis_flooding_cmd); |
3023 | install_element(ENABLE_NODE, &no_debug_isis_flooding_cmd); | |
d62a17ae | 3024 | install_element(ENABLE_NODE, &debug_isis_snp_cmd); |
3025 | install_element(ENABLE_NODE, &no_debug_isis_snp_cmd); | |
3026 | install_element(ENABLE_NODE, &debug_isis_upd_cmd); | |
3027 | install_element(ENABLE_NODE, &no_debug_isis_upd_cmd); | |
3028 | install_element(ENABLE_NODE, &debug_isis_spfevents_cmd); | |
3029 | install_element(ENABLE_NODE, &no_debug_isis_spfevents_cmd); | |
26f6acaf RW |
3030 | install_element(ENABLE_NODE, &debug_isis_srevents_cmd); |
3031 | install_element(ENABLE_NODE, &no_debug_isis_srevents_cmd); | |
2866b119 RW |
3032 | install_element(ENABLE_NODE, &debug_isis_lfa_cmd); |
3033 | install_element(ENABLE_NODE, &no_debug_isis_lfa_cmd); | |
d62a17ae | 3034 | install_element(ENABLE_NODE, &debug_isis_rtevents_cmd); |
3035 | install_element(ENABLE_NODE, &no_debug_isis_rtevents_cmd); | |
3036 | install_element(ENABLE_NODE, &debug_isis_events_cmd); | |
3037 | install_element(ENABLE_NODE, &no_debug_isis_events_cmd); | |
3038 | install_element(ENABLE_NODE, &debug_isis_packet_dump_cmd); | |
3039 | install_element(ENABLE_NODE, &no_debug_isis_packet_dump_cmd); | |
3040 | install_element(ENABLE_NODE, &debug_isis_lsp_gen_cmd); | |
3041 | install_element(ENABLE_NODE, &no_debug_isis_lsp_gen_cmd); | |
3042 | install_element(ENABLE_NODE, &debug_isis_lsp_sched_cmd); | |
3043 | install_element(ENABLE_NODE, &no_debug_isis_lsp_sched_cmd); | |
2815f817 CF |
3044 | install_element(ENABLE_NODE, &debug_isis_bfd_cmd); |
3045 | install_element(ENABLE_NODE, &no_debug_isis_bfd_cmd); | |
1cbf96a8 | 3046 | install_element(ENABLE_NODE, &debug_isis_ldp_sync_cmd); |
3047 | install_element(ENABLE_NODE, &no_debug_isis_ldp_sync_cmd); | |
d62a17ae | 3048 | |
3049 | install_element(CONFIG_NODE, &debug_isis_adj_cmd); | |
3050 | install_element(CONFIG_NODE, &no_debug_isis_adj_cmd); | |
161fa356 CF |
3051 | install_element(CONFIG_NODE, &debug_isis_tx_queue_cmd); |
3052 | install_element(CONFIG_NODE, &no_debug_isis_tx_queue_cmd); | |
ddb33326 CF |
3053 | install_element(CONFIG_NODE, &debug_isis_flooding_cmd); |
3054 | install_element(CONFIG_NODE, &no_debug_isis_flooding_cmd); | |
d62a17ae | 3055 | install_element(CONFIG_NODE, &debug_isis_snp_cmd); |
3056 | install_element(CONFIG_NODE, &no_debug_isis_snp_cmd); | |
3057 | install_element(CONFIG_NODE, &debug_isis_upd_cmd); | |
3058 | install_element(CONFIG_NODE, &no_debug_isis_upd_cmd); | |
3059 | install_element(CONFIG_NODE, &debug_isis_spfevents_cmd); | |
3060 | install_element(CONFIG_NODE, &no_debug_isis_spfevents_cmd); | |
26f6acaf RW |
3061 | install_element(CONFIG_NODE, &debug_isis_srevents_cmd); |
3062 | install_element(CONFIG_NODE, &no_debug_isis_srevents_cmd); | |
2866b119 RW |
3063 | install_element(CONFIG_NODE, &debug_isis_lfa_cmd); |
3064 | install_element(CONFIG_NODE, &no_debug_isis_lfa_cmd); | |
d62a17ae | 3065 | install_element(CONFIG_NODE, &debug_isis_rtevents_cmd); |
3066 | install_element(CONFIG_NODE, &no_debug_isis_rtevents_cmd); | |
3067 | install_element(CONFIG_NODE, &debug_isis_events_cmd); | |
3068 | install_element(CONFIG_NODE, &no_debug_isis_events_cmd); | |
3069 | install_element(CONFIG_NODE, &debug_isis_packet_dump_cmd); | |
3070 | install_element(CONFIG_NODE, &no_debug_isis_packet_dump_cmd); | |
3071 | install_element(CONFIG_NODE, &debug_isis_lsp_gen_cmd); | |
3072 | install_element(CONFIG_NODE, &no_debug_isis_lsp_gen_cmd); | |
3073 | install_element(CONFIG_NODE, &debug_isis_lsp_sched_cmd); | |
3074 | install_element(CONFIG_NODE, &no_debug_isis_lsp_sched_cmd); | |
2815f817 CF |
3075 | install_element(CONFIG_NODE, &debug_isis_bfd_cmd); |
3076 | install_element(CONFIG_NODE, &no_debug_isis_bfd_cmd); | |
1cbf96a8 | 3077 | install_element(CONFIG_NODE, &debug_isis_ldp_sync_cmd); |
3078 | install_element(CONFIG_NODE, &no_debug_isis_ldp_sync_cmd); | |
d62a17ae | 3079 | |
7c0cbd0e | 3080 | install_default(ROUTER_NODE); |
d62a17ae | 3081 | |
aaf2fd21 EDP |
3082 | #ifdef FABRICD |
3083 | install_element(CONFIG_NODE, &router_openfabric_cmd); | |
3084 | install_element(CONFIG_NODE, &no_router_openfabric_cmd); | |
2adf66ff | 3085 | |
7c0cbd0e CF |
3086 | install_element(ROUTER_NODE, &net_cmd); |
3087 | install_element(ROUTER_NODE, &no_net_cmd); | |
2adf66ff | 3088 | |
7c0cbd0e CF |
3089 | install_element(ROUTER_NODE, &isis_topology_cmd); |
3090 | install_element(ROUTER_NODE, &no_isis_topology_cmd); | |
2adf66ff | 3091 | |
7c0cbd0e CF |
3092 | install_element(ROUTER_NODE, &log_adj_changes_cmd); |
3093 | install_element(ROUTER_NODE, &no_log_adj_changes_cmd); | |
2adf66ff | 3094 | #endif /* ifdef FABRICD */ |
d62a17ae | 3095 | |
3096 | spf_backoff_cmd_init(); | |
eb5d44eb | 3097 | } |