From 356a2e3c0cc48ebb54b49c1b912c8080b9abad68 Mon Sep 17 00:00:00 2001 From: Emanuele Di Pascale Date: Wed, 14 Nov 2018 13:03:03 +0100 Subject: [PATCH] isisd: retrofit the 'isis hello-interval' command Signed-off-by: Emanuele Di Pascale --- isisd/isis_cli.c | 61 ++++++++++++++++++++++++++++++++++++++++ isisd/isis_cli.h | 2 ++ isisd/isis_northbound.c | 26 +++++++++++++++-- isisd/isis_vty_common.c | 39 ------------------------- isisd/isis_vty_fabricd.c | 39 +++++++++++++++++++++++++ isisd/isis_vty_isisd.c | 42 --------------------------- 6 files changed, 126 insertions(+), 83 deletions(-) diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c index e89f76a97f..9c25484980 100644 --- a/isisd/isis_cli.c +++ b/isisd/isis_cli.c @@ -1333,6 +1333,64 @@ void cli_show_ip_isis_metric(struct vty *vty, struct lyd_node *dnode, } } +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/interval + */ +DEFPY(isis_hello_interval, isis_hello_interval_cmd, + "isis hello-interval [level-1|level-2]$level (1-600)$intv", + "IS-IS routing protocol\n" + "Set Hello interval\n" + "Specify hello-interval for level-1 IIHs\n" + "Specify hello-interval for level-2 IIHs\n" + "Holdtime 1 seconds, interval depends on multiplier\n") +{ + if (!level || strmatch(level, "level-1")) + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/hello/interval/level-1", + NB_OP_MODIFY, intv_str); + if (!level || strmatch(level, "level-2")) + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/hello/interval/level-2", + NB_OP_MODIFY, intv_str); + + return nb_cli_apply_changes(vty, NULL); +} + +DEFPY(no_isis_hello_interval, no_isis_hello_interval_cmd, + "no isis hello-interval [level-1|level-2]$level [(1-600)]", + NO_STR + "IS-IS routing protocol\n" + "Set Hello interval\n" + "Specify hello-interval for level-1 IIHs\n" + "Specify hello-interval for level-2 IIHs\n" + "Holdtime 1 second, interval depends on multiplier\n") +{ + if (!level || strmatch(level, "level-1")) + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/hello/interval/level-1", + NB_OP_MODIFY, NULL); + if (!level || strmatch(level, "level-2")) + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/hello/interval/level-2", + NB_OP_MODIFY, NULL); + + return nb_cli_apply_changes(vty, NULL); +} + +void cli_show_ip_isis_hello_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, " isis hello-interval %s\n", l1); + else { + vty_out(vty, " isis hello-interval %s level-1\n", l1); + vty_out(vty, " isis hello-interval %s level-2\n", l2); + } +} + void isis_cli_init(void) { install_element(CONFIG_NODE, &router_isis_cmd); @@ -1392,6 +1450,9 @@ void isis_cli_init(void) install_element(INTERFACE_NODE, &isis_metric_cmd); install_element(INTERFACE_NODE, &no_isis_metric_cmd); + + install_element(INTERFACE_NODE, &isis_hello_interval_cmd); + install_element(INTERFACE_NODE, &no_isis_hello_interval_cmd); } #endif /* ifndef FABRICD */ diff --git a/isisd/isis_cli.h b/isisd/isis_cli.h index 70fa47f88d..056144cac0 100644 --- a/isisd/isis_cli.h +++ b/isisd/isis_cli.h @@ -87,5 +87,7 @@ void cli_show_ip_isis_password(struct vty *vty, struct lyd_node *dnode, bool show_defaults); void cli_show_ip_isis_metric(struct vty *vty, struct lyd_node *dnode, bool show_defaults); +void cli_show_ip_isis_hello_interval(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 0f1305f6b2..fc81fe39f6 100644 --- a/isisd/isis_northbound.c +++ b/isisd/isis_northbound.c @@ -1908,7 +1908,16 @@ lib_interface_isis_hello_interval_level_1_modify(enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource) { - /* TODO: implement me. */ + struct isis_circuit *circuit; + uint32_t interval; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = yang_dnode_get_entry(dnode, true); + interval = yang_dnode_get_uint32(dnode, NULL); + circuit->hello_interval[0] = interval; + return NB_OK; } @@ -1920,7 +1929,16 @@ lib_interface_isis_hello_interval_level_2_modify(enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource) { - /* TODO: implement me. */ + struct isis_circuit *circuit; + uint32_t interval; + + if (event != NB_EV_APPLY) + return NB_OK; + + circuit = yang_dnode_get_entry(dnode, true); + interval = yang_dnode_get_uint32(dnode, NULL); + circuit->hello_interval[1] = interval; + return NB_OK; } @@ -2641,6 +2659,10 @@ const struct frr_yang_module_info frr_isisd_info = { .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/padding", .cbs.modify = lib_interface_isis_hello_padding_modify, }, + { + .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/interval", + .cbs.cli_show = cli_show_ip_isis_hello_interval, + }, { .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-1", .cbs.modify = lib_interface_isis_hello_interval_level_1_modify, diff --git a/isisd/isis_vty_common.c b/isisd/isis_vty_common.c index 4b21e909b5..773c26f3b8 100644 --- a/isisd/isis_vty_common.c +++ b/isisd/isis_vty_common.c @@ -56,42 +56,6 @@ struct isis_circuit *isis_circuit_lookup(struct vty *vty) return circuit; } -DEFUN (isis_hello_interval, - isis_hello_interval_cmd, - PROTO_NAME " hello-interval (1-600)", - PROTO_HELP - "Set Hello interval\n" - "Holdtime 1 seconds, interval depends on multiplier\n") -{ - uint32_t interval = atoi(argv[2]->arg); - struct isis_circuit *circuit = isis_circuit_lookup(vty); - if (!circuit) - return CMD_ERR_NO_MATCH; - - circuit->hello_interval[0] = interval; - circuit->hello_interval[1] = interval; - - return CMD_SUCCESS; -} - -DEFUN (no_isis_hello_interval, - no_isis_hello_interval_cmd, - "no " PROTO_NAME " hello-interval [(1-600)]", - NO_STR - PROTO_HELP - "Set Hello interval\n" - "Holdtime 1 second, interval depends on multiplier\n") -{ - struct isis_circuit *circuit = isis_circuit_lookup(vty); - if (!circuit) - return CMD_ERR_NO_MATCH; - - circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL; - circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL; - - return CMD_SUCCESS; -} - DEFUN (isis_hello_multiplier, isis_hello_multiplier_cmd, PROTO_NAME " hello-multiplier (2-100)", @@ -300,9 +264,6 @@ DEFUN (no_isis_bfd, void isis_vty_init(void) { - install_element(INTERFACE_NODE, &isis_hello_interval_cmd); - install_element(INTERFACE_NODE, &no_isis_hello_interval_cmd); - install_element(INTERFACE_NODE, &isis_hello_multiplier_cmd); install_element(INTERFACE_NODE, &no_isis_hello_multiplier_cmd); diff --git a/isisd/isis_vty_fabricd.c b/isisd/isis_vty_fabricd.c index 63dd646cb4..2c86e91603 100644 --- a/isisd/isis_vty_fabricd.c +++ b/isisd/isis_vty_fabricd.c @@ -833,6 +833,42 @@ DEFUN (no_isis_metric, return CMD_SUCCESS; } +DEFUN (isis_hello_interval, + isis_hello_interval_cmd, + PROTO_NAME " hello-interval (1-600)", + PROTO_HELP + "Set Hello interval\n" + "Holdtime 1 seconds, interval depends on multiplier\n") +{ + uint32_t interval = atoi(argv[2]->arg); + struct isis_circuit *circuit = isis_circuit_lookup(vty); + if (!circuit) + return CMD_ERR_NO_MATCH; + + circuit->hello_interval[0] = interval; + circuit->hello_interval[1] = interval; + + return CMD_SUCCESS; +} + +DEFUN (no_isis_hello_interval, + no_isis_hello_interval_cmd, + "no " PROTO_NAME " hello-interval [(1-600)]", + NO_STR + PROTO_HELP + "Set Hello interval\n" + "Holdtime 1 second, interval depends on multiplier\n") +{ + struct isis_circuit *circuit = isis_circuit_lookup(vty); + if (!circuit) + return CMD_ERR_NO_MATCH; + + circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL; + circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL; + + return CMD_SUCCESS; +} + void isis_vty_daemon_init(void) { install_element(ROUTER_NODE, &fabric_tier_cmd); @@ -880,4 +916,7 @@ void isis_vty_daemon_init(void) install_element(INTERFACE_NODE, &isis_metric_cmd); install_element(INTERFACE_NODE, &no_isis_metric_cmd); + + install_element(INTERFACE_NODE, &isis_hello_interval_cmd); + install_element(INTERFACE_NODE, &no_isis_hello_interval_cmd); } diff --git a/isisd/isis_vty_isisd.c b/isisd/isis_vty_isisd.c index d284fc44c8..2465154647 100644 --- a/isisd/isis_vty_isisd.c +++ b/isisd/isis_vty_isisd.c @@ -219,45 +219,6 @@ DEFUN (no_isis_priority_level, return CMD_SUCCESS; } -DEFUN (isis_hello_interval_level, - isis_hello_interval_level_cmd, - "isis hello-interval (1-600) ", - "IS-IS routing protocol\n" - "Set Hello interval\n" - "Holdtime 1 second, interval depends on multiplier\n" - "Specify hello-interval for level-1 IIHs\n" - "Specify hello-interval for level-2 IIHs\n") -{ - uint32_t interval = atoi(argv[2]->arg); - struct isis_circuit *circuit = isis_circuit_lookup(vty); - if (!circuit) - return CMD_ERR_NO_MATCH; - - circuit->hello_interval[level_for_arg(argv[3]->text)] = interval; - - return CMD_SUCCESS; -} - -DEFUN (no_isis_hello_interval_level, - no_isis_hello_interval_level_cmd, - "no isis hello-interval [(1-600)] ", - NO_STR - "IS-IS routing protocol\n" - "Set Hello interval\n" - "Holdtime 1 second, interval depends on multiplier\n" - "Specify hello-interval for level-1 IIHs\n" - "Specify hello-interval for level-2 IIHs\n") -{ - struct isis_circuit *circuit = isis_circuit_lookup(vty); - int level = level_for_arg(argv[argc - 1]->text); - if (!circuit) - return CMD_ERR_NO_MATCH; - - circuit->hello_interval[level] = DEFAULT_HELLO_INTERVAL; - - return CMD_SUCCESS; -} - DEFUN (isis_hello_multiplier_level, isis_hello_multiplier_level_cmd, "isis hello-multiplier (2-100) ", @@ -436,9 +397,6 @@ void isis_vty_daemon_init(void) install_element(INTERFACE_NODE, &isis_priority_level_cmd); install_element(INTERFACE_NODE, &no_isis_priority_level_cmd); - install_element(INTERFACE_NODE, &isis_hello_interval_level_cmd); - install_element(INTERFACE_NODE, &no_isis_hello_interval_level_cmd); - install_element(INTERFACE_NODE, &isis_hello_multiplier_level_cmd); install_element(INTERFACE_NODE, &no_isis_hello_multiplier_level_cmd); -- 2.39.5