diff options
-rw-r--r-- | isisd/isis_cli.c | 54 | ||||
-rw-r--r-- | isisd/isis_cli.h | 2 | ||||
-rw-r--r-- | isisd/isis_northbound.c | 26 | ||||
-rw-r--r-- | isisd/isis_vty_common.c | 71 | ||||
-rw-r--r-- | isisd/isis_vty_common.h | 2 | ||||
-rw-r--r-- | isisd/isis_vty_fabricd.c | 72 | ||||
-rw-r--r-- | isisd/isis_vty_isisd.c | 30 |
7 files changed, 152 insertions, 105 deletions
diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c index 48f944e83..d28af98a0 100644 --- a/isisd/isis_cli.c +++ b/isisd/isis_cli.c @@ -683,6 +683,58 @@ void cli_show_isis_lsp_ref_interval(struct vty *vty, struct lyd_node *dnode, } } +/* + * XPath: /frr-isisd:isis/instance/lsp/maximum-lifetime + */ +DEFPY(max_lsp_lifetime, max_lsp_lifetime_cmd, + "max-lsp-lifetime [level-1|level-2]$level (350-65535)$val", + "Maximum LSP lifetime\n" + "Maximum LSP lifetime for Level 1 only\n" + "Maximum LSP lifetime for Level 2 only\n" + "LSP lifetime in seconds\n") +{ + if (!level || strmatch(level, "level-1")) + nb_cli_enqueue_change(vty, "./lsp/maximum-lifetime/level-1", + NB_OP_MODIFY, val_str); + if (!level || strmatch(level, "level-2")) + nb_cli_enqueue_change(vty, "./lsp/maximum-lifetime/level-2", + NB_OP_MODIFY, val_str); + + return nb_cli_apply_changes(vty, NULL); +} + +DEFPY(no_max_lsp_lifetime, no_max_lsp_lifetime_cmd, + "no max-lsp-lifetime [level-1|level-2]$level [(350-65535)]", + NO_STR + "Maximum LSP lifetime\n" + "Maximum LSP lifetime for Level 1 only\n" + "Maximum LSP lifetime for Level 2 only\n" + "LSP lifetime in seconds\n") +{ + if (!level || strmatch(level, "level-1")) + nb_cli_enqueue_change(vty, "./lsp/maximum-lifetime/level-1", + NB_OP_MODIFY, NULL); + if (!level || strmatch(level, "level-2")) + nb_cli_enqueue_change(vty, "./lsp/maximum-lifetime/level-2", + NB_OP_MODIFY, NULL); + + return nb_cli_apply_changes(vty, NULL); +} + +void cli_show_isis_lsp_max_lifetime(struct vty *vty, struct lyd_node *dnode, + bool show_defaults) +{ + const char *l1 = yang_dnode_get_string(dnode, "./level-1"); + const char *l2 = yang_dnode_get_string(dnode, "./level-2"); + + if (strmatch(l1, l2)) + vty_out(vty, " max-lsp-lifetime %s\n", l1); + else { + vty_out(vty, " max-lsp-lifetime level-1 %s\n", l1); + vty_out(vty, " max-lsp-lifetime level-2 %s\n", l2); + } +} + void isis_cli_init(void) { install_element(CONFIG_NODE, &router_isis_cmd); @@ -713,6 +765,8 @@ void isis_cli_init(void) install_element(ISIS_NODE, &no_lsp_gen_interval_cmd); install_element(ISIS_NODE, &lsp_refresh_interval_cmd); install_element(ISIS_NODE, &no_lsp_refresh_interval_cmd); + install_element(ISIS_NODE, &max_lsp_lifetime_cmd); + install_element(ISIS_NODE, &no_max_lsp_lifetime_cmd); } #endif /* ifndef FABRICD */ diff --git a/isisd/isis_cli.h b/isisd/isis_cli.h index ee0f17bf9..a8fc7f1ce 100644 --- a/isisd/isis_cli.h +++ b/isisd/isis_cli.h @@ -47,5 +47,7 @@ void cli_show_isis_lsp_gen_interval(struct vty *vty, struct lyd_node *dnode, bool show_defaults); void cli_show_isis_lsp_ref_interval(struct vty *vty, struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_lsp_max_lifetime(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); #endif /* ISISD_ISIS_CLI_H_ */ diff --git a/isisd/isis_northbound.c b/isisd/isis_northbound.c index e08711909..11cc9c230 100644 --- a/isisd/isis_northbound.c +++ b/isisd/isis_northbound.c @@ -415,7 +415,16 @@ isis_instance_lsp_maximum_lifetime_level_1_modify(enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource) { - /* TODO: implement me. */ + struct isis_area *area; + uint16_t max_lt; + + if (event != NB_EV_APPLY) + return NB_OK; + + max_lt = yang_dnode_get_uint16(dnode, NULL); + area = yang_dnode_get_entry(dnode, true); + isis_area_max_lsp_lifetime_set(area, IS_LEVEL_1, max_lt); + return NB_OK; } @@ -427,7 +436,16 @@ isis_instance_lsp_maximum_lifetime_level_2_modify(enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource) { - /* TODO: implement me. */ + struct isis_area *area; + uint16_t max_lt; + + if (event != NB_EV_APPLY) + return NB_OK; + + max_lt = yang_dnode_get_uint16(dnode, NULL); + area = yang_dnode_get_entry(dnode, true); + isis_area_max_lsp_lifetime_set(area, IS_LEVEL_2, max_lt); + return NB_OK; } @@ -1894,6 +1912,10 @@ const struct frr_yang_module_info frr_isisd_info = { .cbs.modify = isis_instance_lsp_refresh_interval_level_2_modify, }, { + .xpath = "/frr-isisd:isis/instance/lsp/maximum-lifetime", + .cbs.cli_show = cli_show_isis_lsp_max_lifetime, + }, + { .xpath = "/frr-isisd:isis/instance/lsp/maximum-lifetime/level-1", .cbs.modify = isis_instance_lsp_maximum_lifetime_level_1_modify, }, diff --git a/isisd/isis_vty_common.c b/isisd/isis_vty_common.c index 4068a87f7..03432df4c 100644 --- a/isisd/isis_vty_common.c +++ b/isisd/isis_vty_common.c @@ -587,74 +587,6 @@ DEFUN (spf_delay_ietf, return CMD_SUCCESS; } -int isis_vty_max_lsp_lifetime_set(struct vty *vty, int level, uint16_t interval) -{ - VTY_DECLVAR_CONTEXT(isis_area, area); - int lvl; - uint16_t refresh_interval = interval - 300; - int set_refresh_interval[ISIS_LEVELS] = {0, 0}; - - for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++) { - if (!(lvl & level)) - continue; - - if (refresh_interval < area->lsp_refresh[lvl - 1]) { - vty_out(vty, - "Level %d Max LSP lifetime %us must be 300s greater than " - "the configured LSP refresh interval %us\n", - lvl, interval, area->lsp_refresh[lvl - 1]); - vty_out(vty, - "Automatically reducing level %d LSP refresh interval " - "to %us\n", - lvl, refresh_interval); - set_refresh_interval[lvl - 1] = 1; - - if (refresh_interval - <= area->lsp_gen_interval[lvl - 1]) { - vty_out(vty, - "LSP refresh interval %us must be greater than " - "the configured LSP gen interval %us\n", - refresh_interval, - area->lsp_gen_interval[lvl - 1]); - return CMD_WARNING_CONFIG_FAILED; - } - } - } - - for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++) { - if (!(lvl & level)) - continue; - isis_area_max_lsp_lifetime_set(area, lvl, interval); - if (set_refresh_interval[lvl - 1]) - isis_area_lsp_refresh_set(area, lvl, refresh_interval); - } - - return CMD_SUCCESS; -} - -DEFUN (max_lsp_lifetime, - max_lsp_lifetime_cmd, - "max-lsp-lifetime (350-65535)", - "Maximum LSP lifetime\n" - "LSP lifetime in seconds\n") -{ - int lifetime = atoi(argv[1]->arg); - - return isis_vty_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2, lifetime); -} - - -DEFUN (no_max_lsp_lifetime, - no_max_lsp_lifetime_cmd, - "no max-lsp-lifetime [(350-65535)]", - NO_STR - "Maximum LSP lifetime\n" - "LSP lifetime in seconds\n") -{ - return isis_vty_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2, - DEFAULT_LSP_LIFETIME); -} - void isis_vty_init(void) { install_element(INTERFACE_NODE, &isis_passive_cmd); @@ -692,9 +624,6 @@ void isis_vty_init(void) install_element(ROUTER_NODE, &spf_interval_cmd); install_element(ROUTER_NODE, &no_spf_interval_cmd); - install_element(ROUTER_NODE, &max_lsp_lifetime_cmd); - install_element(ROUTER_NODE, &no_max_lsp_lifetime_cmd); - install_element(ROUTER_NODE, &spf_delay_ietf_cmd); install_element(ROUTER_NODE, &no_spf_delay_ietf_cmd); diff --git a/isisd/isis_vty_common.h b/isisd/isis_vty_common.h index b2c4316ac..297da0e2c 100644 --- a/isisd/isis_vty_common.h +++ b/isisd/isis_vty_common.h @@ -26,8 +26,6 @@ struct isis_circuit *isis_circuit_lookup(struct vty *vty); -int isis_vty_max_lsp_lifetime_set(struct vty *vty, int level, uint16_t interval); - void isis_vty_daemon_init(void); void isis_vty_init(void); diff --git a/isisd/isis_vty_fabricd.c b/isisd/isis_vty_fabricd.c index 13fd41937..a507c0d24 100644 --- a/isisd/isis_vty_fabricd.c +++ b/isisd/isis_vty_fabricd.c @@ -475,6 +475,75 @@ DEFUN (no_lsp_refresh_interval, DEFAULT_MAX_LSP_GEN_INTERVAL); } +static int +isis_vty_max_lsp_lifetime_set(struct vty *vty, int level, uint16_t interval) +{ + VTY_DECLVAR_CONTEXT(isis_area, area); + int lvl; + uint16_t refresh_interval = interval - 300; + int set_refresh_interval[ISIS_LEVELS] = {0, 0}; + + for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++) { + if (!(lvl & level)) + continue; + + if (refresh_interval < area->lsp_refresh[lvl - 1]) { + vty_out(vty, + "Level %d Max LSP lifetime %us must be 300s greater than " + "the configured LSP refresh interval %us\n", + lvl, interval, area->lsp_refresh[lvl - 1]); + vty_out(vty, + "Automatically reducing level %d LSP refresh interval " + "to %us\n", + lvl, refresh_interval); + set_refresh_interval[lvl - 1] = 1; + + if (refresh_interval + <= area->lsp_gen_interval[lvl - 1]) { + vty_out(vty, + "LSP refresh interval %us must be greater than " + "the configured LSP gen interval %us\n", + refresh_interval, + area->lsp_gen_interval[lvl - 1]); + return CMD_WARNING_CONFIG_FAILED; + } + } + } + + for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++) { + if (!(lvl & level)) + continue; + isis_area_max_lsp_lifetime_set(area, lvl, interval); + if (set_refresh_interval[lvl - 1]) + isis_area_lsp_refresh_set(area, lvl, refresh_interval); + } + + return CMD_SUCCESS; +} + +DEFUN (max_lsp_lifetime, + max_lsp_lifetime_cmd, + "max-lsp-lifetime (350-65535)", + "Maximum LSP lifetime\n" + "LSP lifetime in seconds\n") +{ + int lifetime = atoi(argv[1]->arg); + + return isis_vty_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2, lifetime); +} + + +DEFUN (no_max_lsp_lifetime, + no_max_lsp_lifetime_cmd, + "no max-lsp-lifetime [(350-65535)]", + NO_STR + "Maximum LSP lifetime\n" + "LSP lifetime in seconds\n") +{ + return isis_vty_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2, + DEFAULT_LSP_LIFETIME); +} + void isis_vty_daemon_init(void) { install_element(ROUTER_NODE, &fabric_tier_cmd); @@ -499,4 +568,7 @@ void isis_vty_daemon_init(void) install_element(ROUTER_NODE, &lsp_refresh_interval_cmd); install_element(ROUTER_NODE, &no_lsp_refresh_interval_cmd); + + install_element(ROUTER_NODE, &max_lsp_lifetime_cmd); + install_element(ROUTER_NODE, &no_max_lsp_lifetime_cmd); } diff --git a/isisd/isis_vty_isisd.c b/isisd/isis_vty_isisd.c index fe7e72ba5..65248c34e 100644 --- a/isisd/isis_vty_isisd.c +++ b/isisd/isis_vty_isisd.c @@ -465,33 +465,6 @@ DEFUN (no_psnp_interval_level, return CMD_SUCCESS; } -DEFUN (max_lsp_lifetime_level, - max_lsp_lifetime_level_cmd, - "max-lsp-lifetime <level-1|level-2> (350-65535)", - "Maximum LSP lifetime\n" - "Maximum LSP lifetime for Level 1 only\n" - "Maximum LSP lifetime for Level 2 only\n" - "LSP lifetime in seconds\n") -{ - uint16_t lifetime = atoi(argv[2]->arg); - - return isis_vty_max_lsp_lifetime_set(vty, level_for_arg(argv[1]->text), - lifetime); -} - -DEFUN (no_max_lsp_lifetime_level, - no_max_lsp_lifetime_level_cmd, - "no max-lsp-lifetime <level-1|level-2> [(350-65535)]", - NO_STR - "Maximum LSP lifetime\n" - "Maximum LSP lifetime for Level 1 only\n" - "Maximum LSP lifetime for Level 2 only\n" - "LSP lifetime in seconds\n") -{ - return isis_vty_max_lsp_lifetime_set(vty, level_for_arg(argv[1]->text), - DEFAULT_LSP_LIFETIME); -} - DEFUN (spf_interval_level, spf_interval_level_cmd, "spf-interval <level-1|level-2> (1-120)", @@ -558,9 +531,6 @@ void isis_vty_daemon_init(void) install_element(INTERFACE_NODE, &psnp_interval_level_cmd); install_element(INTERFACE_NODE, &no_psnp_interval_level_cmd); - install_element(ROUTER_NODE, &max_lsp_lifetime_level_cmd); - install_element(ROUTER_NODE, &no_max_lsp_lifetime_level_cmd); - install_element(ROUTER_NODE, &spf_interval_level_cmd); install_element(ROUTER_NODE, &no_spf_interval_level_cmd); } |