]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_vty_fabricd.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / isisd / isis_vty_fabricd.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
ef020087
CF
2/*
3 * IS-IS Rout(e)ing protocol - isis_vty_fabricd.c
4 *
5 * This file contains the CLI that is specific to OpenFabric
6 *
7 * Copyright (C) 2018 Christian Franke, for NetDEF, Inc.
ef020087
CF
8 */
9#include <zebra.h>
10
11#include "command.h"
12
f2971ce3
RZ
13#include "lib/bfd.h"
14#include "isisd/isis_bfd.h"
1eb7c3a1 15#include "isisd/isisd.h"
1eb7c3a1
CF
16#include "isisd/fabricd.h"
17#include "isisd/isis_tlvs.h"
18#include "isisd/isis_misc.h"
19#include "isisd/isis_lsp.h"
aaf2fd21 20#include "isisd/isis_csm.h"
f084ea55 21#include "isisd/isis_circuit.h"
5336ba30 22#include "lib/spf_backoff.h"
83d043f6 23#include "isisd/isis_mt.h"
92ed0cde 24
f2971ce3
RZ
25static struct isis_circuit *isis_circuit_lookup(struct vty *vty)
26{
27 struct interface *ifp = VTY_GET_CONTEXT(interface);
28 struct isis_circuit *circuit;
29
30 if (!ifp) {
31 vty_out(vty, "Invalid interface \n");
32 return NULL;
33 }
34
35 circuit = circuit_scan_by_ifp(ifp);
36 if (!circuit) {
37 vty_out(vty, "ISIS is not enabled on circuit %s\n", ifp->name);
38 return NULL;
39 }
40
41 return circuit;
42}
43
92ed0cde
CF
44DEFUN (fabric_tier,
45 fabric_tier_cmd,
46 "fabric-tier (0-14)",
47 "Statically configure the tier to advertise\n"
48 "Tier to advertise\n")
49{
50 VTY_DECLVAR_CONTEXT(isis_area, area);
51
52 uint8_t tier = atoi(argv[1]->arg);
53
54 fabricd_configure_tier(area, tier);
55 return CMD_SUCCESS;
56}
57
58DEFUN (no_fabric_tier,
59 no_fabric_tier_cmd,
60 "no fabric-tier [(0-14)]",
61 NO_STR
62 "Statically configure the tier to advertise\n"
63 "Tier to advertise\n")
64{
65 VTY_DECLVAR_CONTEXT(isis_area, area);
66
67 fabricd_configure_tier(area, ISIS_TIER_UNDEFINED);
68 return CMD_SUCCESS;
69}
ef020087 70
e923107c
CF
71DEFUN (triggered_csnp,
72 triggered_csnp_cmd,
73 "triggered-csnp-delay (100-10000) [always]",
74 "Configure the delay for triggered CSNPs\n"
75 "Delay in milliseconds\n"
76 "Trigger CSNP for all LSPs, not only circuit-scoped\n")
77{
78 VTY_DECLVAR_CONTEXT(isis_area, area);
79
80 int csnp_delay = atoi(argv[1]->arg);
81 bool always_send_csnp = (argc == 3);
82
83 fabricd_configure_triggered_csnp(area, csnp_delay, always_send_csnp);
84 return CMD_SUCCESS;
85}
86
87DEFUN (no_triggered_csnp,
88 no_triggered_csnp_cmd,
89 "no triggered-csnp-delay [(100-10000) [always]]",
90 NO_STR
91 "Configure the delay for triggered CSNPs\n"
92 "Delay in milliseconds\n"
93 "Trigger CSNP for all LSPs, not only circuit-scoped\n")
94{
95 VTY_DECLVAR_CONTEXT(isis_area, area);
96
97 fabricd_configure_triggered_csnp(area, FABRICD_DEFAULT_CSNP_DELAY,
98 false);
99 return CMD_SUCCESS;
100}
101
eab88f36
K
102static void lsp_print_flooding(struct vty *vty, struct isis_lsp *lsp,
103 struct isis *isis)
1eb7c3a1
CF
104{
105 char lspid[255];
d0636ead 106 char buf[MONOTIME_STRLEN];
1eb7c3a1 107
7533cad7 108 lspid_print(lsp->hdr.lsp_id, lspid, sizeof(lspid), true, true, isis);
1eb7c3a1
CF
109 vty_out(vty, "Flooding information for %s\n", lspid);
110
111 if (!lsp->flooding_neighbors[TX_LSP_NORMAL]) {
a6b60da9 112 vty_out(vty, " Never received.\n");
1eb7c3a1
CF
113 return;
114 }
115
a6b60da9 116 vty_out(vty, " Last received on: %s (",
1eb7c3a1
CF
117 lsp->flooding_interface ?
118 lsp->flooding_interface : "(null)");
119
a6b60da9 120 time_t uptime = time(NULL) - lsp->flooding_time;
d0636ead
MS
121
122 frrtime_to_interval(uptime, buf, sizeof(buf));
123
124 vty_out(vty, "%s ago)\n", buf);
a6b60da9
CF
125
126 if (lsp->flooding_circuit_scoped) {
3efd0893 127 vty_out(vty, " Received as circuit-scoped LSP, so not flooded.\n");
a6b60da9
CF
128 return;
129 }
130
1eb7c3a1
CF
131 for (enum isis_tx_type type = TX_LSP_NORMAL;
132 type <= TX_LSP_CIRCUIT_SCOPED; type++) {
133 struct listnode *node;
134 uint8_t *neighbor_id;
135
136 vty_out(vty, " %s:\n",
137 (type == TX_LSP_NORMAL) ? "RF" : "DNR");
138 for (ALL_LIST_ELEMENTS_RO(lsp->flooding_neighbors[type],
139 node, neighbor_id)) {
140 vty_out(vty, " %s\n",
141 print_sys_hostname(neighbor_id));
142 }
143 }
144}
145
146DEFUN (show_lsp_flooding,
147 show_lsp_flooding_cmd,
148 "show openfabric flooding [WORD]",
149 SHOW_STR
150 PROTO_HELP
151 "Flooding information\n"
152 "LSP ID\n")
153{
154 const char *lspid = NULL;
155
89cdc4df 156 if (argc == 4)
1eb7c3a1 157 lspid = argv[3]->arg;
1eb7c3a1
CF
158
159 struct listnode *node;
160 struct isis_area *area;
eab88f36
K
161 struct isis *isis = NULL;
162
163 isis = isis_lookup_by_vrfid(VRF_DEFAULT);
164
165 if (isis == NULL) {
166 vty_out(vty, "IS-IS Routing Process not enabled\n");
167 return CMD_SUCCESS;
168 }
1eb7c3a1
CF
169
170 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
4bef0ec4
DL
171 struct lspdb_head *head = &area->lspdb[ISIS_LEVEL2 - 1];
172 struct isis_lsp *lsp;
1eb7c3a1 173
eab88f36
K
174 vty_out(vty, "Area %s:\n",
175 area->area_tag ? area->area_tag : "null");
1eb7c3a1 176 if (lspid) {
1d88e63a 177 lsp = lsp_for_sysid(head, lspid, isis);
1eb7c3a1 178 if (lsp)
eab88f36 179 lsp_print_flooding(vty, lsp, isis);
1eb7c3a1
CF
180 continue;
181 }
81fddbe7 182 frr_each (lspdb, head, lsp) {
eab88f36 183 lsp_print_flooding(vty, lsp, isis);
1eb7c3a1
CF
184 vty_out(vty, "\n");
185 }
186 }
187
188 return CMD_SUCCESS;
189}
190
aaf2fd21
EDP
191DEFUN (ip_router_isis,
192 ip_router_isis_cmd,
193 "ip router " PROTO_NAME " WORD",
194 "Interface Internet Protocol config commands\n"
195 "IP router interface commands\n"
196 PROTO_HELP
197 "Routing process tag\n")
198{
199 int idx_afi = 0;
200 int idx_word = 3;
201 VTY_DECLVAR_CONTEXT(interface, ifp);
202 struct isis_circuit *circuit;
203 struct isis_area *area;
204 const char *af = argv[idx_afi]->arg;
205 const char *area_tag = argv[idx_word]->arg;
206
207 /* Prevent more than one area per circuit */
208 circuit = circuit_scan_by_ifp(ifp);
209 if (circuit && circuit->area) {
210 if (strcmp(circuit->area->area_tag, area_tag)) {
211 vty_out(vty, "ISIS circuit is already defined on %s\n",
212 circuit->area->area_tag);
213 return CMD_ERR_NOTHING_TODO;
214 }
215 }
216
eab88f36 217 area = isis_area_lookup(area_tag, VRF_DEFAULT);
aaf2fd21 218 if (!area)
bcf22081 219 isis_area_create(area_tag, VRF_DEFAULT_NAME);
aaf2fd21 220
bcf22081
IR
221 if (!circuit) {
222 circuit = isis_circuit_new(ifp, area_tag);
aaf2fd21
EDP
223
224 if (circuit->state != C_STATE_CONF
225 && circuit->state != C_STATE_UP) {
226 vty_out(vty,
227 "Couldn't bring up interface, please check log.\n");
228 return CMD_WARNING_CONFIG_FAILED;
229 }
230 }
231
232 bool ip = circuit->ip_router, ipv6 = circuit->ipv6_router;
233 if (af[2] != '\0')
234 ipv6 = true;
235 else
236 ip = true;
237
238 isis_circuit_af_set(circuit, ip, ipv6);
239 return CMD_SUCCESS;
240}
241
242DEFUN (ip6_router_isis,
243 ip6_router_isis_cmd,
244 "ipv6 router " PROTO_NAME " WORD",
245 "Interface Internet Protocol config commands\n"
246 "IP router interface commands\n"
247 PROTO_HELP
248 "Routing process tag\n")
249{
250 return ip_router_isis(self, vty, argc, argv);
251}
252
253DEFUN (no_ip_router_isis,
254 no_ip_router_isis_cmd,
255 "no <ip|ipv6> router " PROTO_NAME " WORD",
256 NO_STR
257 "Interface Internet Protocol config commands\n"
258 "IP router interface commands\n"
259 "IP router interface commands\n"
260 PROTO_HELP
261 "Routing process tag\n")
262{
263 int idx_afi = 1;
264 int idx_word = 4;
265 VTY_DECLVAR_CONTEXT(interface, ifp);
266 struct isis_area *area;
267 struct isis_circuit *circuit;
268 const char *af = argv[idx_afi]->arg;
269 const char *area_tag = argv[idx_word]->arg;
270
eab88f36 271 area = isis_area_lookup(area_tag, VRF_DEFAULT);
aaf2fd21
EDP
272 if (!area) {
273 vty_out(vty, "Can't find ISIS instance %s\n",
274 area_tag);
275 return CMD_ERR_NO_MATCH;
276 }
277
bcf22081 278 circuit = circuit_scan_by_ifp(ifp);
aaf2fd21
EDP
279 if (!circuit) {
280 vty_out(vty, "ISIS is not enabled on circuit %s\n", ifp->name);
281 return CMD_ERR_NO_MATCH;
282 }
283
284 bool ip = circuit->ip_router, ipv6 = circuit->ipv6_router;
285 if (af[2] != '\0')
286 ipv6 = false;
287 else
288 ip = false;
289
290 isis_circuit_af_set(circuit, ip, ipv6);
bcf22081
IR
291
292 if (!ip && !ipv6)
293 isis_circuit_del(circuit);
294
aaf2fd21
EDP
295 return CMD_SUCCESS;
296}
297
f2971ce3
RZ
298DEFUN (isis_bfd,
299 isis_bfd_cmd,
300 PROTO_NAME " bfd",
301 PROTO_HELP
302 "Enable BFD support\n")
303{
304 struct isis_circuit *circuit = isis_circuit_lookup(vty);
305
306 if (!circuit)
307 return CMD_ERR_NO_MATCH;
308
13bf3830 309 if (circuit->bfd_config.enabled)
f2971ce3 310 return CMD_SUCCESS;
f2971ce3 311
13bf3830
IR
312 circuit->bfd_config.enabled = true;
313 isis_bfd_circuit_cmd(circuit);
f2971ce3
RZ
314
315 return CMD_SUCCESS;
316}
317
318DEFUN (no_isis_bfd,
319 no_isis_bfd_cmd,
320 "no " PROTO_NAME " bfd",
321 NO_STR
322 PROTO_HELP
323 "Disables BFD support\n"
324)
325{
326 struct isis_circuit *circuit = isis_circuit_lookup(vty);
327
328 if (!circuit)
329 return CMD_ERR_NO_MATCH;
330
13bf3830 331 if (!circuit->bfd_config.enabled)
f2971ce3
RZ
332 return CMD_SUCCESS;
333
13bf3830
IR
334 circuit->bfd_config.enabled = false;
335 isis_bfd_circuit_cmd(circuit);
336
f2971ce3
RZ
337 return CMD_SUCCESS;
338}
339
05a3f9f0
EDP
340DEFUN (set_overload_bit,
341 set_overload_bit_cmd,
342 "set-overload-bit",
343 "Set overload bit to avoid any transit traffic\n")
344{
345 VTY_DECLVAR_CONTEXT(isis_area, area);
346
347 isis_area_overload_bit_set(area, true);
348 return CMD_SUCCESS;
349}
350
351DEFUN (no_set_overload_bit,
352 no_set_overload_bit_cmd,
353 "no set-overload-bit",
354 "Reset overload bit to accept transit traffic\n"
355 "Reset overload bit\n")
356{
357 VTY_DECLVAR_CONTEXT(isis_area, area);
358
359 isis_area_overload_bit_set(area, false);
360 return CMD_SUCCESS;
361}
362
933536e3
EDP
363static int isis_vty_password_set(struct vty *vty, int argc,
364 struct cmd_token *argv[], int level)
365{
366 VTY_DECLVAR_CONTEXT(isis_area, area);
367
368 int idx_algo = 1;
369 int idx_password = 2;
370 int idx_snp_auth = 5;
371 uint8_t snp_auth = 0;
372
373 const char *passwd = argv[idx_password]->arg;
374 if (strlen(passwd) > 254) {
375 vty_out(vty, "Too long area password (>254)\n");
376 return CMD_WARNING_CONFIG_FAILED;
377 }
378
379 if (argc > idx_snp_auth) {
380 snp_auth = SNP_AUTH_SEND;
381 if (strmatch(argv[idx_snp_auth]->text, "validate"))
382 snp_auth |= SNP_AUTH_RECV;
383 }
384
385 if (strmatch(argv[idx_algo]->text, "clear")) {
386 return isis_area_passwd_cleartext_set(area, level,
387 passwd, snp_auth);
388 } else if (strmatch(argv[idx_algo]->text, "md5")) {
389 return isis_area_passwd_hmac_md5_set(area, level,
390 passwd, snp_auth);
391 }
392
393 return CMD_WARNING_CONFIG_FAILED;
394}
395
396DEFUN (domain_passwd,
397 domain_passwd_cmd,
398 "domain-password <clear|md5> WORD [authenticate snp <send-only|validate>]",
399 "Set the authentication password for a routing domain\n"
400 "Authentication type\n"
401 "Authentication type\n"
402 "Level-wide password\n"
403 "Authentication\n"
404 "SNP PDUs\n"
405 "Send but do not check PDUs on receiving\n"
406 "Send and check PDUs on receiving\n")
407{
408 return isis_vty_password_set(vty, argc, argv, IS_LEVEL_2);
409}
410
411DEFUN (no_domain_passwd,
412 no_domain_passwd_cmd,
413 "no domain-password",
414 NO_STR
415 "Set the authentication password for a routing domain\n")
416{
417 VTY_DECLVAR_CONTEXT(isis_area, area);
418
419 return isis_area_passwd_unset(area, IS_LEVEL_2);
420}
421
1d6fe72e
EDP
422static int
423isis_vty_lsp_gen_interval_set(struct vty *vty, int level, uint16_t interval)
424{
425 VTY_DECLVAR_CONTEXT(isis_area, area);
426 int lvl;
427
428 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) {
429 if (!(lvl & level))
430 continue;
431
432 if (interval >= area->lsp_refresh[lvl - 1]) {
433 vty_out(vty,
3efd0893 434 "LSP gen interval %us must be less than the LSP refresh interval %us\n",
1d6fe72e
EDP
435 interval, area->lsp_refresh[lvl - 1]);
436 return CMD_WARNING_CONFIG_FAILED;
437 }
438 }
439
440 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) {
441 if (!(lvl & level))
442 continue;
443 area->lsp_gen_interval[lvl - 1] = interval;
444 }
445
446 return CMD_SUCCESS;
447}
448
449DEFUN (lsp_gen_interval,
450 lsp_gen_interval_cmd,
451 "lsp-gen-interval (1-120)",
452 "Minimum interval between regenerating same LSP\n"
453 "Minimum interval in seconds\n")
454{
455 uint16_t interval = atoi(argv[1]->arg);
456
457 return isis_vty_lsp_gen_interval_set(vty, IS_LEVEL_1_AND_2, interval);
458}
459
460DEFUN (no_lsp_gen_interval,
461 no_lsp_gen_interval_cmd,
462 "no lsp-gen-interval [(1-120)]",
463 NO_STR
464 "Minimum interval between regenerating same LSP\n"
465 "Minimum interval in seconds\n")
466{
467 VTY_DECLVAR_CONTEXT(isis_area, area);
468
469 return isis_vty_lsp_gen_interval_set(vty, IS_LEVEL_1_AND_2,
470 DEFAULT_MIN_LSP_GEN_INTERVAL);
471}
7e869004
EDP
472
473static int
474isis_vty_lsp_refresh_set(struct vty *vty, int level, uint16_t interval)
475{
476 VTY_DECLVAR_CONTEXT(isis_area, area);
477 int lvl;
478
479 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) {
480 if (!(lvl & level))
481 continue;
482 if (interval <= area->lsp_gen_interval[lvl - 1]) {
483 vty_out(vty,
3efd0893 484 "LSP refresh interval %us must be greater than the configured LSP gen interval %us\n",
7e869004
EDP
485 interval, area->lsp_gen_interval[lvl - 1]);
486 return CMD_WARNING_CONFIG_FAILED;
487 }
488 if (interval > (area->max_lsp_lifetime[lvl - 1] - 300)) {
489 vty_out(vty,
3efd0893 490 "LSP refresh interval %us must be less than the configured LSP lifetime %us less 300\n",
7e869004
EDP
491 interval, area->max_lsp_lifetime[lvl - 1]);
492 return CMD_WARNING_CONFIG_FAILED;
493 }
494 }
495
496 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) {
497 if (!(lvl & level))
498 continue;
499 isis_area_lsp_refresh_set(area, lvl, interval);
500 }
501
502 return CMD_SUCCESS;
503}
504
505DEFUN (lsp_refresh_interval,
506 lsp_refresh_interval_cmd,
507 "lsp-refresh-interval (1-65235)",
508 "LSP refresh interval\n"
509 "LSP refresh interval in seconds\n")
510{
511 unsigned int interval = atoi(argv[1]->arg);
512 return isis_vty_lsp_refresh_set(vty, IS_LEVEL_1_AND_2, interval);
513}
514
515DEFUN (no_lsp_refresh_interval,
516 no_lsp_refresh_interval_cmd,
517 "no lsp-refresh-interval [(1-65235)]",
518 NO_STR
519 "LSP refresh interval\n"
520 "LSP refresh interval in seconds\n")
521{
522 return isis_vty_lsp_refresh_set(vty, IS_LEVEL_1_AND_2,
523 DEFAULT_MAX_LSP_GEN_INTERVAL);
524}
525
ea120aa0
EDP
526static int
527isis_vty_max_lsp_lifetime_set(struct vty *vty, int level, uint16_t interval)
528{
529 VTY_DECLVAR_CONTEXT(isis_area, area);
530 int lvl;
531 uint16_t refresh_interval = interval - 300;
532 int set_refresh_interval[ISIS_LEVELS] = {0, 0};
533
534 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++) {
535 if (!(lvl & level))
536 continue;
537
538 if (refresh_interval < area->lsp_refresh[lvl - 1]) {
539 vty_out(vty,
3efd0893 540 "Level %d Max LSP lifetime %us must be 300s greater than the configured LSP refresh interval %us\n",
ea120aa0
EDP
541 lvl, interval, area->lsp_refresh[lvl - 1]);
542 vty_out(vty,
3efd0893 543 "Automatically reducing level %d LSP refresh interval to %us\n",
ea120aa0
EDP
544 lvl, refresh_interval);
545 set_refresh_interval[lvl - 1] = 1;
546
547 if (refresh_interval
548 <= area->lsp_gen_interval[lvl - 1]) {
549 vty_out(vty,
3efd0893 550 "LSP refresh interval %us must be greater than the configured LSP gen interval %us\n",
ea120aa0
EDP
551 refresh_interval,
552 area->lsp_gen_interval[lvl - 1]);
553 return CMD_WARNING_CONFIG_FAILED;
554 }
555 }
556 }
557
558 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++) {
559 if (!(lvl & level))
560 continue;
561 isis_area_max_lsp_lifetime_set(area, lvl, interval);
562 if (set_refresh_interval[lvl - 1])
563 isis_area_lsp_refresh_set(area, lvl, refresh_interval);
564 }
565
566 return CMD_SUCCESS;
567}
568
569DEFUN (max_lsp_lifetime,
570 max_lsp_lifetime_cmd,
571 "max-lsp-lifetime (350-65535)",
572 "Maximum LSP lifetime\n"
573 "LSP lifetime in seconds\n")
574{
575 int lifetime = atoi(argv[1]->arg);
576
577 return isis_vty_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2, lifetime);
578}
579
580
581DEFUN (no_max_lsp_lifetime,
582 no_max_lsp_lifetime_cmd,
583 "no max-lsp-lifetime [(350-65535)]",
584 NO_STR
585 "Maximum LSP lifetime\n"
586 "LSP lifetime in seconds\n")
587{
588 return isis_vty_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2,
589 DEFAULT_LSP_LIFETIME);
590}
591
dcb1dcd6
EDP
592DEFUN (spf_interval,
593 spf_interval_cmd,
594 "spf-interval (1-120)",
595 "Minimum interval between SPF calculations\n"
596 "Minimum interval between consecutive SPFs in seconds\n")
597{
598 VTY_DECLVAR_CONTEXT(isis_area, area);
599 uint16_t interval = atoi(argv[1]->arg);
600
601 area->min_spf_interval[0] = interval;
602 area->min_spf_interval[1] = interval;
603
604 return CMD_SUCCESS;
605}
606
607DEFUN (no_spf_interval,
608 no_spf_interval_cmd,
609 "no spf-interval [(1-120)]",
610 NO_STR
611 "Minimum interval between SPF calculations\n"
612 "Minimum interval between consecutive SPFs in seconds\n")
613{
614 VTY_DECLVAR_CONTEXT(isis_area, area);
615
616 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
617 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
618
619 return CMD_SUCCESS;
620}
27a45d16
EDP
621
622static int isis_vty_lsp_mtu_set(struct vty *vty, unsigned int lsp_mtu)
623{
624 VTY_DECLVAR_CONTEXT(isis_area, area);
625 struct listnode *node;
626 struct isis_circuit *circuit;
627
628 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) {
629 if (circuit->state != C_STATE_INIT
630 && circuit->state != C_STATE_UP)
631 continue;
632 if (lsp_mtu > isis_circuit_pdu_size(circuit)) {
633 vty_out(vty,
634 "ISIS area contains circuit %s, which has a maximum PDU size of %zu.\n",
635 circuit->interface->name,
636 isis_circuit_pdu_size(circuit));
637 return CMD_WARNING_CONFIG_FAILED;
638 }
639 }
640
641 isis_area_lsp_mtu_set(area, lsp_mtu);
642 return CMD_SUCCESS;
643}
644
645DEFUN (area_lsp_mtu,
646 area_lsp_mtu_cmd,
647 "lsp-mtu (128-4352)",
648 "Configure the maximum size of generated LSPs\n"
649 "Maximum size of generated LSPs\n")
650{
651 int idx_number = 1;
652 unsigned int lsp_mtu;
653
654 lsp_mtu = strtoul(argv[idx_number]->arg, NULL, 10);
655
656 return isis_vty_lsp_mtu_set(vty, lsp_mtu);
657}
658
659DEFUN (no_area_lsp_mtu,
660 no_area_lsp_mtu_cmd,
661 "no lsp-mtu [(128-4352)]",
662 NO_STR
663 "Configure the maximum size of generated LSPs\n"
664 "Maximum size of generated LSPs\n")
665{
666 return isis_vty_lsp_mtu_set(vty, DEFAULT_LSP_MTU);
667}
668
5336ba30
EDP
669DEFUN (no_spf_delay_ietf,
670 no_spf_delay_ietf_cmd,
671 "no spf-delay-ietf",
672 NO_STR
673 "IETF SPF delay algorithm\n")
674{
675 VTY_DECLVAR_CONTEXT(isis_area, area);
676
677 spf_backoff_free(area->spf_delay_ietf[0]);
678 spf_backoff_free(area->spf_delay_ietf[1]);
679 area->spf_delay_ietf[0] = NULL;
680 area->spf_delay_ietf[1] = NULL;
681
682 return CMD_SUCCESS;
683}
684
685DEFUN (spf_delay_ietf,
686 spf_delay_ietf_cmd,
687 "spf-delay-ietf init-delay (0-60000) short-delay (0-60000) long-delay (0-60000) holddown (0-60000) time-to-learn (0-60000)",
688 "IETF SPF delay algorithm\n"
689 "Delay used while in QUIET state\n"
690 "Delay used while in QUIET state in milliseconds\n"
691 "Delay used while in SHORT_WAIT state\n"
692 "Delay used while in SHORT_WAIT state in milliseconds\n"
693 "Delay used while in LONG_WAIT\n"
694 "Delay used while in LONG_WAIT state in milliseconds\n"
695 "Time with no received IGP events before considering IGP stable\n"
696 "Time with no received IGP events before considering IGP stable (in milliseconds)\n"
697 "Maximum duration needed to learn all the events related to a single failure\n"
698 "Maximum duration needed to learn all the events related to a single failure (in milliseconds)\n")
699{
700 VTY_DECLVAR_CONTEXT(isis_area, area);
701
702 long init_delay = atol(argv[2]->arg);
703 long short_delay = atol(argv[4]->arg);
704 long long_delay = atol(argv[6]->arg);
705 long holddown = atol(argv[8]->arg);
706 long timetolearn = atol(argv[10]->arg);
707
708 size_t bufsiz = strlen(area->area_tag) + sizeof("IS-IS Lx");
709 char *buf = XCALLOC(MTYPE_TMP, bufsiz);
710
711 snprintf(buf, bufsiz, "IS-IS %s L1", area->area_tag);
712 spf_backoff_free(area->spf_delay_ietf[0]);
713 area->spf_delay_ietf[0] =
714 spf_backoff_new(master, buf, init_delay, short_delay,
715 long_delay, holddown, timetolearn);
716
717 snprintf(buf, bufsiz, "IS-IS %s L2", area->area_tag);
718 spf_backoff_free(area->spf_delay_ietf[1]);
719 area->spf_delay_ietf[1] =
720 spf_backoff_new(master, buf, init_delay, short_delay,
721 long_delay, holddown, timetolearn);
722
723 XFREE(MTYPE_TMP, buf);
724 return CMD_SUCCESS;
725}
726
66e45e10
EDP
727DEFUN (area_purge_originator,
728 area_purge_originator_cmd,
729 "[no] purge-originator",
730 NO_STR
731 "Use the RFC 6232 purge-originator\n")
732{
733 VTY_DECLVAR_CONTEXT(isis_area, area);
734
735 area->purge_originator = !!strcmp(argv[0]->text, "no");
736 return CMD_SUCCESS;
737}
738
a6a36c41
EDP
739DEFUN (isis_passive,
740 isis_passive_cmd,
741 PROTO_NAME " passive",
742 PROTO_HELP
743 "Configure the passive mode for interface\n")
744{
745 struct isis_circuit *circuit = isis_circuit_lookup(vty);
746 if (!circuit)
747 return CMD_ERR_NO_MATCH;
748
749 CMD_FERR_RETURN(isis_circuit_passive_set(circuit, 1),
750 "Cannot set passive: $ERR");
751 return CMD_SUCCESS;
752}
753
754DEFUN (no_isis_passive,
755 no_isis_passive_cmd,
756 "no " PROTO_NAME " passive",
757 NO_STR
758 PROTO_HELP
759 "Configure the passive mode for interface\n")
760{
761 struct isis_circuit *circuit = isis_circuit_lookup(vty);
762 if (!circuit)
763 return CMD_ERR_NO_MATCH;
764
765 CMD_FERR_RETURN(isis_circuit_passive_set(circuit, 0),
766 "Cannot set no passive: $ERR");
767 return CMD_SUCCESS;
768}
769
3e20c83a
EDP
770DEFUN (isis_passwd,
771 isis_passwd_cmd,
772 PROTO_NAME " password <md5|clear> WORD",
773 PROTO_HELP
774 "Configure the authentication password for a circuit\n"
775 "HMAC-MD5 authentication\n"
776 "Cleartext password\n"
777 "Circuit password\n")
778{
779 int idx_encryption = 2;
780 int idx_word = 3;
781 struct isis_circuit *circuit = isis_circuit_lookup(vty);
782 ferr_r rv;
783
784 if (!circuit)
785 return CMD_ERR_NO_MATCH;
786
787 if (argv[idx_encryption]->arg[0] == 'm')
788 rv = isis_circuit_passwd_hmac_md5_set(circuit,
789 argv[idx_word]->arg);
790 else
791 rv = isis_circuit_passwd_cleartext_set(circuit,
792 argv[idx_word]->arg);
793
794 CMD_FERR_RETURN(rv, "Failed to set circuit password: $ERR");
795 return CMD_SUCCESS;
796}
797
798DEFUN (no_isis_passwd,
799 no_isis_passwd_cmd,
800 "no " PROTO_NAME " password [<md5|clear> WORD]",
801 NO_STR
802 PROTO_HELP
803 "Configure the authentication password for a circuit\n"
804 "HMAC-MD5 authentication\n"
805 "Cleartext password\n"
806 "Circuit password\n")
807{
808 struct isis_circuit *circuit = isis_circuit_lookup(vty);
809 if (!circuit)
810 return CMD_ERR_NO_MATCH;
811
812 CMD_FERR_RETURN(isis_circuit_passwd_unset(circuit),
813 "Failed to unset circuit password: $ERR");
814 return CMD_SUCCESS;
815}
816
be49219c
EDP
817DEFUN (isis_metric,
818 isis_metric_cmd,
819 PROTO_NAME " metric (0-16777215)",
820 PROTO_HELP
821 "Set default metric for circuit\n"
822 "Default metric value\n")
823{
824 int idx_number = 2;
825 int met;
826 struct isis_circuit *circuit = isis_circuit_lookup(vty);
827 if (!circuit)
828 return CMD_ERR_NO_MATCH;
829
830 met = atoi(argv[idx_number]->arg);
831
832 /* RFC3787 section 5.1 */
833 if (circuit->area && circuit->area->oldmetric == 1
834 && met > MAX_NARROW_LINK_METRIC) {
835 vty_out(vty,
3efd0893 836 "Invalid metric %d - should be <0-63> when narrow metric type enabled\n",
be49219c
EDP
837 met);
838 return CMD_WARNING_CONFIG_FAILED;
839 }
840
841 /* RFC4444 */
842 if (circuit->area && circuit->area->newmetric == 1
843 && met > MAX_WIDE_LINK_METRIC) {
844 vty_out(vty,
3efd0893 845 "Invalid metric %d - should be <0-16777215> when wide metric type enabled\n",
be49219c
EDP
846 met);
847 return CMD_WARNING_CONFIG_FAILED;
848 }
849
850 CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_1, met),
851 "Failed to set L1 metric: $ERR");
852 CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_2, met),
853 "Failed to set L2 metric: $ERR");
854 return CMD_SUCCESS;
855}
856
857DEFUN (no_isis_metric,
858 no_isis_metric_cmd,
859 "no " PROTO_NAME " metric [(0-16777215)]",
860 NO_STR
861 PROTO_HELP
862 "Set default metric for circuit\n"
863 "Default metric value\n")
864{
865 struct isis_circuit *circuit = isis_circuit_lookup(vty);
866 if (!circuit)
867 return CMD_ERR_NO_MATCH;
868
869 CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_1,
870 DEFAULT_CIRCUIT_METRIC),
871 "Failed to set L1 metric: $ERR");
872 CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_2,
873 DEFAULT_CIRCUIT_METRIC),
874 "Failed to set L2 metric: $ERR");
875 return CMD_SUCCESS;
876}
877
356a2e3c
EDP
878DEFUN (isis_hello_interval,
879 isis_hello_interval_cmd,
880 PROTO_NAME " hello-interval (1-600)",
881 PROTO_HELP
882 "Set Hello interval\n"
883 "Holdtime 1 seconds, interval depends on multiplier\n")
884{
885 uint32_t interval = atoi(argv[2]->arg);
886 struct isis_circuit *circuit = isis_circuit_lookup(vty);
887 if (!circuit)
888 return CMD_ERR_NO_MATCH;
889
890 circuit->hello_interval[0] = interval;
891 circuit->hello_interval[1] = interval;
892
893 return CMD_SUCCESS;
894}
895
896DEFUN (no_isis_hello_interval,
897 no_isis_hello_interval_cmd,
898 "no " PROTO_NAME " hello-interval [(1-600)]",
899 NO_STR
900 PROTO_HELP
901 "Set Hello interval\n"
902 "Holdtime 1 second, interval depends on multiplier\n")
903{
904 struct isis_circuit *circuit = isis_circuit_lookup(vty);
905 if (!circuit)
906 return CMD_ERR_NO_MATCH;
907
908 circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL;
909 circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL;
910
911 return CMD_SUCCESS;
912}
913
4e75a67d
EDP
914DEFUN (isis_hello_multiplier,
915 isis_hello_multiplier_cmd,
916 PROTO_NAME " hello-multiplier (2-100)",
917 PROTO_HELP
918 "Set multiplier for Hello holding time\n"
919 "Hello multiplier value\n")
920{
921 uint16_t mult = atoi(argv[2]->arg);
922 struct isis_circuit *circuit = isis_circuit_lookup(vty);
923 if (!circuit)
924 return CMD_ERR_NO_MATCH;
925
926 circuit->hello_multiplier[0] = mult;
927 circuit->hello_multiplier[1] = mult;
928
929 return CMD_SUCCESS;
930}
931
932DEFUN (no_isis_hello_multiplier,
933 no_isis_hello_multiplier_cmd,
934 "no " PROTO_NAME " hello-multiplier [(2-100)]",
935 NO_STR
936 PROTO_HELP
937 "Set multiplier for Hello holding time\n"
938 "Hello multiplier value\n")
939{
940 struct isis_circuit *circuit = isis_circuit_lookup(vty);
941 if (!circuit)
942 return CMD_ERR_NO_MATCH;
943
944 circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER;
945 circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER;
946
947 return CMD_SUCCESS;
948}
949
9ce808b9
EDP
950DEFUN (csnp_interval,
951 csnp_interval_cmd,
952 PROTO_NAME " csnp-interval (1-600)",
953 PROTO_HELP
954 "Set CSNP interval in seconds\n"
955 "CSNP interval value\n")
956{
957 uint16_t interval = atoi(argv[2]->arg);
958 struct isis_circuit *circuit = isis_circuit_lookup(vty);
959 if (!circuit)
960 return CMD_ERR_NO_MATCH;
961
962 circuit->csnp_interval[0] = interval;
963 circuit->csnp_interval[1] = interval;
964
965 return CMD_SUCCESS;
966}
967
968DEFUN (no_csnp_interval,
969 no_csnp_interval_cmd,
970 "no " PROTO_NAME " csnp-interval [(1-600)]",
971 NO_STR
972 PROTO_HELP
973 "Set CSNP interval in seconds\n"
974 "CSNP interval value\n")
975{
976 struct isis_circuit *circuit = isis_circuit_lookup(vty);
977 if (!circuit)
978 return CMD_ERR_NO_MATCH;
979
980 circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL;
981 circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL;
982
983 return CMD_SUCCESS;
984}
985
986DEFUN (psnp_interval,
987 psnp_interval_cmd,
988 PROTO_NAME " psnp-interval (1-120)",
989 PROTO_HELP
990 "Set PSNP interval in seconds\n"
991 "PSNP interval value\n")
992{
993 uint16_t interval = atoi(argv[2]->arg);
994 struct isis_circuit *circuit = isis_circuit_lookup(vty);
995 if (!circuit)
996 return CMD_ERR_NO_MATCH;
997
998 circuit->psnp_interval[0] = interval;
999 circuit->psnp_interval[1] = interval;
1000
1001 return CMD_SUCCESS;
1002}
1003
1004DEFUN (no_psnp_interval,
1005 no_psnp_interval_cmd,
1006 "no " PROTO_NAME " psnp-interval [(1-120)]",
1007 NO_STR
1008 PROTO_HELP
1009 "Set PSNP interval in seconds\n"
1010 "PSNP interval value\n")
1011{
1012 struct isis_circuit *circuit = isis_circuit_lookup(vty);
1013 if (!circuit)
1014 return CMD_ERR_NO_MATCH;
1015
1016 circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL;
1017 circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL;
1018
1019 return CMD_SUCCESS;
1020}
1021
83d043f6
EDP
1022DEFUN (circuit_topology,
1023 circuit_topology_cmd,
1024 PROTO_NAME " topology " ISIS_MT_NAMES,
1025 PROTO_HELP
1026 "Configure interface IS-IS topologies\n"
1027 ISIS_MT_DESCRIPTIONS)
1028{
1029 struct isis_circuit *circuit = isis_circuit_lookup(vty);
1030 if (!circuit)
1031 return CMD_ERR_NO_MATCH;
1032 const char *arg = argv[2]->arg;
1033 uint16_t mtid = isis_str2mtid(arg);
1034
1035 if (circuit->area && circuit->area->oldmetric) {
1036 vty_out(vty,
1037 "Multi topology IS-IS can only be used with wide metrics\n");
1038 return CMD_WARNING_CONFIG_FAILED;
1039 }
1040
1041 if (mtid == (uint16_t)-1) {
1042 vty_out(vty, "Don't know topology '%s'\n", arg);
1043 return CMD_WARNING_CONFIG_FAILED;
1044 }
1045
1046 return isis_circuit_mt_enabled_set(circuit, mtid, true);
1047}
1048
1049DEFUN (no_circuit_topology,
1050 no_circuit_topology_cmd,
1051 "no " PROTO_NAME " topology " ISIS_MT_NAMES,
1052 NO_STR
1053 PROTO_HELP
1054 "Configure interface IS-IS topologies\n"
1055 ISIS_MT_DESCRIPTIONS)
1056{
1057 struct isis_circuit *circuit = isis_circuit_lookup(vty);
1058 if (!circuit)
1059 return CMD_ERR_NO_MATCH;
1060 const char *arg = argv[3]->arg;
1061 uint16_t mtid = isis_str2mtid(arg);
1062
1063 if (circuit->area && circuit->area->oldmetric) {
1064 vty_out(vty,
1065 "Multi topology IS-IS can only be used with wide metrics\n");
1066 return CMD_WARNING_CONFIG_FAILED;
1067 }
1068
1069 if (mtid == (uint16_t)-1) {
1070 vty_out(vty, "Don't know topology '%s'\n", arg);
1071 return CMD_WARNING_CONFIG_FAILED;
1072 }
1073
1074 return isis_circuit_mt_enabled_set(circuit, mtid, false);
1075}
1076
ef020087
CF
1077void isis_vty_daemon_init(void)
1078{
92ed0cde
CF
1079 install_element(ROUTER_NODE, &fabric_tier_cmd);
1080 install_element(ROUTER_NODE, &no_fabric_tier_cmd);
e923107c
CF
1081 install_element(ROUTER_NODE, &triggered_csnp_cmd);
1082 install_element(ROUTER_NODE, &no_triggered_csnp_cmd);
1eb7c3a1
CF
1083
1084 install_element(ENABLE_NODE, &show_lsp_flooding_cmd);
aaf2fd21
EDP
1085
1086 install_element(INTERFACE_NODE, &ip_router_isis_cmd);
1087 install_element(INTERFACE_NODE, &ip6_router_isis_cmd);
1088 install_element(INTERFACE_NODE, &no_ip_router_isis_cmd);
f2971ce3
RZ
1089 install_element(INTERFACE_NODE, &isis_bfd_cmd);
1090 install_element(INTERFACE_NODE, &no_isis_bfd_cmd);
05a3f9f0
EDP
1091
1092 install_element(ROUTER_NODE, &set_overload_bit_cmd);
1093 install_element(ROUTER_NODE, &no_set_overload_bit_cmd);
933536e3
EDP
1094
1095 install_element(ROUTER_NODE, &domain_passwd_cmd);
1096 install_element(ROUTER_NODE, &no_domain_passwd_cmd);
1d6fe72e
EDP
1097
1098 install_element(ROUTER_NODE, &lsp_gen_interval_cmd);
1099 install_element(ROUTER_NODE, &no_lsp_gen_interval_cmd);
7e869004
EDP
1100
1101 install_element(ROUTER_NODE, &lsp_refresh_interval_cmd);
1102 install_element(ROUTER_NODE, &no_lsp_refresh_interval_cmd);
ea120aa0
EDP
1103
1104 install_element(ROUTER_NODE, &max_lsp_lifetime_cmd);
1105 install_element(ROUTER_NODE, &no_max_lsp_lifetime_cmd);
27a45d16
EDP
1106
1107 install_element(ROUTER_NODE, &area_lsp_mtu_cmd);
1108 install_element(ROUTER_NODE, &no_area_lsp_mtu_cmd);
dcb1dcd6
EDP
1109
1110 install_element(ROUTER_NODE, &spf_interval_cmd);
1111 install_element(ROUTER_NODE, &no_spf_interval_cmd);
5336ba30
EDP
1112
1113 install_element(ROUTER_NODE, &spf_delay_ietf_cmd);
1114 install_element(ROUTER_NODE, &no_spf_delay_ietf_cmd);
66e45e10
EDP
1115
1116 install_element(ROUTER_NODE, &area_purge_originator_cmd);
a6a36c41
EDP
1117
1118 install_element(INTERFACE_NODE, &isis_passive_cmd);
1119 install_element(INTERFACE_NODE, &no_isis_passive_cmd);
3e20c83a
EDP
1120
1121 install_element(INTERFACE_NODE, &isis_passwd_cmd);
1122 install_element(INTERFACE_NODE, &no_isis_passwd_cmd);
be49219c
EDP
1123
1124 install_element(INTERFACE_NODE, &isis_metric_cmd);
1125 install_element(INTERFACE_NODE, &no_isis_metric_cmd);
356a2e3c
EDP
1126
1127 install_element(INTERFACE_NODE, &isis_hello_interval_cmd);
1128 install_element(INTERFACE_NODE, &no_isis_hello_interval_cmd);
4e75a67d
EDP
1129
1130 install_element(INTERFACE_NODE, &isis_hello_multiplier_cmd);
1131 install_element(INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
9ce808b9
EDP
1132
1133 install_element(INTERFACE_NODE, &csnp_interval_cmd);
1134 install_element(INTERFACE_NODE, &no_csnp_interval_cmd);
1135
1136 install_element(INTERFACE_NODE, &psnp_interval_cmd);
1137 install_element(INTERFACE_NODE, &no_psnp_interval_cmd);
83d043f6
EDP
1138
1139 install_element(INTERFACE_NODE, &circuit_topology_cmd);
1140 install_element(INTERFACE_NODE, &no_circuit_topology_cmd);
ef020087 1141}