Skip to content

Commit

Permalink
Merge pull request #6166 from volta-networks/fix_isis_lsp_timers
Browse files Browse the repository at this point in the history
isisd, yang: unified lsp-timers command
  • Loading branch information
odd22 authored Apr 8, 2020
2 parents c446af5 + d2c970f commit 63ffd0e
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 171 deletions.
197 changes: 142 additions & 55 deletions isisd/isis_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,8 @@ void cli_show_isis_domain_pwd(struct vty *vty, struct lyd_node *dnode,
}

/*
* XPath: /frr-isisd:isis/instance/lsp/generation-interval
* XPath: /frr-isisd:isis/instance/lsp/timers/level-1/generation-interval
* XPath: /frr-isisd:isis/instance/lsp/timers/level-2/generation-interval
*/
DEFPY(lsp_gen_interval, lsp_gen_interval_cmd,
"lsp-gen-interval [level-1|level-2]$level (1-120)$val",
Expand All @@ -650,11 +651,13 @@ DEFPY(lsp_gen_interval, lsp_gen_interval_cmd,
"Minimum interval in seconds\n")
{
if (!level || strmatch(level, "level-1"))
nb_cli_enqueue_change(vty, "./lsp/generation-interval/level-1",
NB_OP_MODIFY, val_str);
nb_cli_enqueue_change(
vty, "./lsp/timers/level-1/generation-interval",
NB_OP_MODIFY, val_str);
if (!level || strmatch(level, "level-2"))
nb_cli_enqueue_change(vty, "./lsp/generation-interval/level-2",
NB_OP_MODIFY, val_str);
nb_cli_enqueue_change(
vty, "./lsp/timers/level-2/generation-interval",
NB_OP_MODIFY, val_str);

return nb_cli_apply_changes(vty, NULL);
}
Expand All @@ -668,31 +671,20 @@ DEFPY(no_lsp_gen_interval, no_lsp_gen_interval_cmd,
"Minimum interval in seconds\n")
{
if (!level || strmatch(level, "level-1"))
nb_cli_enqueue_change(vty, "./lsp/generation-interval/level-1",
NB_OP_MODIFY, NULL);
nb_cli_enqueue_change(
vty, "./lsp/timers/level-1/generation-interval",
NB_OP_MODIFY, NULL);
if (!level || strmatch(level, "level-2"))
nb_cli_enqueue_change(vty, "./lsp/generation-interval/level-2",
NB_OP_MODIFY, NULL);
nb_cli_enqueue_change(
vty, "./lsp/timers/level-2/generation-interval",
NB_OP_MODIFY, NULL);

return nb_cli_apply_changes(vty, NULL);
}

void cli_show_isis_lsp_gen_interval(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, " lsp-gen-interval %s\n", l1);
else {
vty_out(vty, " lsp-gen-interval level-1 %s\n", l1);
vty_out(vty, " lsp-gen-interval level-2 %s\n", l2);
}
}

/*
* XPath: /frr-isisd:isis/instance/lsp/refresh-interval
* XPath: /frr-isisd:isis/instance/lsp/timers/level-1/refresh-interval
* XPath: /frr-isisd:isis/instance/lsp/timers/level-2/refresh-interval
*/
DEFPY(lsp_refresh_interval, lsp_refresh_interval_cmd,
"lsp-refresh-interval [level-1|level-2]$level (1-65235)$val",
Expand All @@ -702,10 +694,12 @@ DEFPY(lsp_refresh_interval, lsp_refresh_interval_cmd,
"LSP refresh interval in seconds\n")
{
if (!level || strmatch(level, "level-1"))
nb_cli_enqueue_change(vty, "./lsp/refresh-interval/level-1",
nb_cli_enqueue_change(vty,
"./lsp/timers/level-1/refresh-interval",
NB_OP_MODIFY, val_str);
if (!level || strmatch(level, "level-2"))
nb_cli_enqueue_change(vty, "./lsp/refresh-interval/level-2",
nb_cli_enqueue_change(vty,
"./lsp/timers/level-2/refresh-interval",
NB_OP_MODIFY, val_str);

return nb_cli_apply_changes(vty, NULL);
Expand All @@ -720,32 +714,22 @@ DEFPY(no_lsp_refresh_interval, no_lsp_refresh_interval_cmd,
"LSP refresh interval in seconds\n")
{
if (!level || strmatch(level, "level-1"))
nb_cli_enqueue_change(vty, "./lsp/refresh-interval/level-1",
nb_cli_enqueue_change(vty,
"./lsp/timers/level-1/refresh-interval",
NB_OP_MODIFY, NULL);
if (!level || strmatch(level, "level-2"))
nb_cli_enqueue_change(vty, "./lsp/refresh-interval/level-2",
nb_cli_enqueue_change(vty,
"./lsp/timers/level-2/refresh-interval",
NB_OP_MODIFY, NULL);

return nb_cli_apply_changes(vty, NULL);
}

void cli_show_isis_lsp_ref_interval(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, " lsp-refresh-interval %s\n", l1);
else {
vty_out(vty, " lsp-refresh-interval level-1 %s\n", l1);
vty_out(vty, " lsp-refresh-interval level-2 %s\n", l2);
}
}

/*
* XPath: /frr-isisd:isis/instance/lsp/maximum-lifetime
* XPath: /frr-isisd:isis/instance/lsp/timers/level-1/maximum-lifetime
* XPath: /frr-isisd:isis/instance/lsp/timers/level-1/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"
Expand All @@ -754,10 +738,12 @@ DEFPY(max_lsp_lifetime, max_lsp_lifetime_cmd,
"LSP lifetime in seconds\n")
{
if (!level || strmatch(level, "level-1"))
nb_cli_enqueue_change(vty, "./lsp/maximum-lifetime/level-1",
nb_cli_enqueue_change(vty,
"./lsp/timers/level-1/maximum-lifetime",
NB_OP_MODIFY, val_str);
if (!level || strmatch(level, "level-2"))
nb_cli_enqueue_change(vty, "./lsp/maximum-lifetime/level-2",
nb_cli_enqueue_change(vty,
"./lsp/timers/level-2/maximum-lifetime",
NB_OP_MODIFY, val_str);

return nb_cli_apply_changes(vty, NULL);
Expand All @@ -772,26 +758,125 @@ DEFPY(no_max_lsp_lifetime, no_max_lsp_lifetime_cmd,
"LSP lifetime in seconds\n")
{
if (!level || strmatch(level, "level-1"))
nb_cli_enqueue_change(vty, "./lsp/maximum-lifetime/level-1",
nb_cli_enqueue_change(vty,
"./lsp/timers/level-1/maximum-lifetime",
NB_OP_MODIFY, NULL);
if (!level || strmatch(level, "level-2"))
nb_cli_enqueue_change(vty, "./lsp/maximum-lifetime/level-2",
nb_cli_enqueue_change(vty,
"./lsp/timers/level-2/maximum-lifetime",
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)
/* unified LSP timers command
* XPath: /frr-isisd:isis/instance/lsp/timers
*/

DEFPY(lsp_timers, lsp_timers_cmd,
"lsp-timers [level-1|level-2]$level gen-interval (1-120)$gen refresh-interval (1-65235)$refresh max-lifetime (350-65535)$lifetime",
"LSP-related timers\n"
"LSP-related timers for Level 1 only\n"
"LSP-related timers for Level 2 only\n"
"Minimum interval between regenerating same LSP\n"
"Generation interval in seconds\n"
"LSP refresh interval\n"
"LSP refresh interval in seconds\n"
"Maximum LSP lifetime\n"
"Maximum LSP lifetime in seconds\n")
{
const char *l1 = yang_dnode_get_string(dnode, "./level-1");
const char *l2 = yang_dnode_get_string(dnode, "./level-2");
if (!level || strmatch(level, "level-1")) {
nb_cli_enqueue_change(
vty, "./lsp/timers/level-1/generation-interval",
NB_OP_MODIFY, gen_str);
nb_cli_enqueue_change(vty,
"./lsp/timers/level-1/refresh-interval",
NB_OP_MODIFY, refresh_str);
nb_cli_enqueue_change(vty,
"./lsp/timers/level-1/maximum-lifetime",
NB_OP_MODIFY, lifetime_str);
}
if (!level || strmatch(level, "level-2")) {
nb_cli_enqueue_change(
vty, "./lsp/timers/level-2/generation-interval",
NB_OP_MODIFY, gen_str);
nb_cli_enqueue_change(vty,
"./lsp/timers/level-2/refresh-interval",
NB_OP_MODIFY, refresh_str);
nb_cli_enqueue_change(vty,
"./lsp/timers/level-2/maximum-lifetime",
NB_OP_MODIFY, lifetime_str);
}

if (strmatch(l1, l2))
vty_out(vty, " max-lsp-lifetime %s\n", l1);
return nb_cli_apply_changes(vty, NULL);
}

DEFPY(no_lsp_timers, no_lsp_timers_cmd,
"no lsp-timers [level-1|level-2]$level [gen-interval (1-120) refresh-interval (1-65235) max-lifetime (350-65535)]",
NO_STR
"LSP-related timers\n"
"LSP-related timers for Level 1 only\n"
"LSP-related timers for Level 2 only\n"
"Minimum interval between regenerating same LSP\n"
"Generation interval in seconds\n"
"LSP refresh interval\n"
"LSP refresh interval in seconds\n"
"Maximum LSP lifetime\n"
"Maximum LSP lifetime in seconds\n")
{
if (!level || strmatch(level, "level-1")) {
nb_cli_enqueue_change(
vty, "./lsp/timers/level-1/generation-interval",
NB_OP_MODIFY, NULL);
nb_cli_enqueue_change(vty,
"./lsp/timers/level-1/refresh-interval",
NB_OP_MODIFY, NULL);
nb_cli_enqueue_change(vty,
"./lsp/timers/level-1/maximum-lifetime",
NB_OP_MODIFY, NULL);
}
if (!level || strmatch(level, "level-2")) {
nb_cli_enqueue_change(
vty, "./lsp/timers/level-2/generation-interval",
NB_OP_MODIFY, NULL);
nb_cli_enqueue_change(vty,
"./lsp/timers/level-2/refresh-interval",
NB_OP_MODIFY, NULL);
nb_cli_enqueue_change(vty,
"./lsp/timers/level-2/maximum-lifetime",
NB_OP_MODIFY, NULL);
}

return nb_cli_apply_changes(vty, NULL);
}

void cli_show_isis_lsp_timers(struct vty *vty, struct lyd_node *dnode,
bool show_defaults)
{
const char *l1_refresh =
yang_dnode_get_string(dnode, "./level-1/refresh-interval");
const char *l2_refresh =
yang_dnode_get_string(dnode, "./level-2/refresh-interval");
const char *l1_lifetime =
yang_dnode_get_string(dnode, "./level-1/maximum-lifetime");
const char *l2_lifetime =
yang_dnode_get_string(dnode, "./level-2/maximum-lifetime");
const char *l1_gen =
yang_dnode_get_string(dnode, "./level-1/generation-interval");
const char *l2_gen =
yang_dnode_get_string(dnode, "./level-2/generation-interval");
if (strmatch(l1_refresh, l2_refresh)
&& strmatch(l1_lifetime, l2_lifetime) && strmatch(l1_gen, l2_gen))
vty_out(vty,
" lsp-timers gen-interval %s refresh-interval %s max-lifetime %s\n",
l1_gen, l1_refresh, l1_lifetime);
else {
vty_out(vty, " max-lsp-lifetime level-1 %s\n", l1);
vty_out(vty, " max-lsp-lifetime level-2 %s\n", l2);
vty_out(vty,
" lsp-timers level-1 gen-interval %s refresh-interval %s max-lifetime %s\n",
l1_gen, l1_refresh, l1_lifetime);
vty_out(vty,
" lsp-timers level-2 gen-interval %s refresh-interval %s max-lifetime %s\n",
l2_gen, l2_refresh, l2_lifetime);
}
}

Expand Down Expand Up @@ -2001,6 +2086,8 @@ void isis_cli_init(void)
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);
install_element(ISIS_NODE, &lsp_timers_cmd);
install_element(ISIS_NODE, &no_lsp_timers_cmd);
install_element(ISIS_NODE, &area_lsp_mtu_cmd);
install_element(ISIS_NODE, &no_area_lsp_mtu_cmd);

Expand Down
34 changes: 11 additions & 23 deletions isisd/isis_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,55 +95,43 @@ const struct frr_yang_module_info frr_isisd_info = {
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/refresh-interval",
.xpath = "/frr-isisd:isis/instance/lsp/timers",
.cbs = {
.cli_show = cli_show_isis_lsp_ref_interval,
.cli_show = cli_show_isis_lsp_timers,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/refresh-interval/level-1",
.xpath = "/frr-isisd:isis/instance/lsp/timers/level-1/refresh-interval",
.cbs = {
.modify = isis_instance_lsp_refresh_interval_level_1_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/refresh-interval/level-2",
.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",
.xpath = "/frr-isisd:isis/instance/lsp/timers/level-1/maximum-lifetime",
.cbs = {
.modify = isis_instance_lsp_maximum_lifetime_level_1_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/maximum-lifetime/level-2",
.xpath = "/frr-isisd:isis/instance/lsp/timers/level-1/generation-interval",
.cbs = {
.modify = isis_instance_lsp_maximum_lifetime_level_2_modify,
.modify = isis_instance_lsp_generation_interval_level_1_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/generation-interval",
.xpath = "/frr-isisd:isis/instance/lsp/timers/level-2/refresh-interval",
.cbs = {
.cli_show = cli_show_isis_lsp_gen_interval,
.modify = isis_instance_lsp_refresh_interval_level_2_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/generation-interval/level-1",
.xpath = "/frr-isisd:isis/instance/lsp/timers/level-2/maximum-lifetime",
.cbs = {
.modify = isis_instance_lsp_generation_interval_level_1_modify,
.modify = isis_instance_lsp_maximum_lifetime_level_2_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/generation-interval/level-2",
.xpath = "/frr-isisd:isis/instance/lsp/timers/level-2/generation-interval",
.cbs = {
.modify = isis_instance_lsp_generation_interval_level_2_modify,
},
Expand Down
8 changes: 2 additions & 6 deletions isisd/isis_nb.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,8 @@ void cli_show_isis_area_pwd(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_domain_pwd(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
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);
void cli_show_isis_lsp_timers(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_lsp_mtu(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_spf_min_interval(struct vty *vty, struct lyd_node *dnode,
Expand Down
Loading

0 comments on commit 63ffd0e

Please sign in to comment.