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