]> git.puffer.fish Git - mirror/frr.git/commitdiff
isisd: retrofit the 'isis hello-multiplier' command
authorEmanuele Di Pascale <emanuele@voltanet.io>
Wed, 14 Nov 2018 12:05:47 +0000 (13:05 +0100)
committerEmanuele Di Pascale <emanuele@voltanet.io>
Tue, 18 Dec 2018 14:23:49 +0000 (15:23 +0100)
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
isisd/isis_cli.c
isisd/isis_cli.h
isisd/isis_northbound.c
isisd/isis_vty_common.c
isisd/isis_vty_fabricd.c
isisd/isis_vty_isisd.c

index 9c25484980f394439c01fe0f668019a3ac66c1ef..f39a83e0efa88b08716915c404c73568970f0984 100644 (file)
@@ -1391,6 +1391,64 @@ void cli_show_ip_isis_hello_interval(struct vty *vty, struct lyd_node *dnode,
        }
 }
 
+/*
+ * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/multiplier
+ */
+DEFPY(isis_hello_multiplier, isis_hello_multiplier_cmd,
+      "isis hello-multiplier [level-1|level-2]$level (2-100)$mult",
+      "IS-IS routing protocol\n"
+      "Set multiplier for Hello holding time\n"
+      "Specify hello multiplier for level-1 IIHs\n"
+      "Specify hello multiplier for level-2 IIHs\n"
+      "Hello multiplier value\n")
+{
+       if (!level || strmatch(level, "level-1"))
+               nb_cli_enqueue_change(
+                       vty, "./frr-isisd:isis/hello/multiplier/level-1",
+                       NB_OP_MODIFY, mult_str);
+       if (!level || strmatch(level, "level-2"))
+               nb_cli_enqueue_change(
+                       vty, "./frr-isisd:isis/hello/multiplier/level-2",
+                       NB_OP_MODIFY, mult_str);
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFPY(no_isis_hello_multiplier, no_isis_hello_multiplier_cmd,
+      "no isis hello-multiplier [level-1|level-2]$level [(2-100)]",
+      NO_STR
+      "IS-IS routing protocol\n"
+      "Set multiplier for Hello holding time\n"
+      "Specify hello multiplier for level-1 IIHs\n"
+      "Specify hello multiplier for level-2 IIHs\n"
+      "Hello multiplier value\n")
+{
+       if (!level || strmatch(level, "level-1"))
+               nb_cli_enqueue_change(
+                       vty, "./frr-isisd:isis/hello/multiplier/level-1",
+                       NB_OP_MODIFY, NULL);
+       if (!level || strmatch(level, "level-2"))
+               nb_cli_enqueue_change(
+                       vty, "./frr-isisd:isis/hello/multiplier/level-2",
+                       NB_OP_MODIFY, NULL);
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+void cli_show_ip_isis_hello_multi(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-multiplier %s\n", l1);
+       else {
+               vty_out(vty, " isis hello-multiplier %s level-1\n", l1);
+               vty_out(vty, " isis hello-multiplier %s level-2\n", l2);
+       }
+}
+
 void isis_cli_init(void)
 {
        install_element(CONFIG_NODE, &router_isis_cmd);
@@ -1453,6 +1511,9 @@ void isis_cli_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);
 }
 
 #endif /* ifndef FABRICD */
index 056144cac0ff7947cfd2a5507df6ae4ba7f16267..987da20212f4456eb643bcf8724832495faa03aa 100644 (file)
@@ -89,5 +89,7 @@ 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);
+void cli_show_ip_isis_hello_multi(struct vty *vty, struct lyd_node *dnode,
+                                 bool show_defaults);
 
 #endif /* ISISD_ISIS_CLI_H_ */
index fc81fe39f69a206aa59216cd487ba294972aa120..677950185061d1e242e984746734289e44178a25 100644 (file)
@@ -1950,7 +1950,16 @@ lib_interface_isis_hello_multiplier_level_1_modify(enum nb_event event,
                                                   const struct lyd_node *dnode,
                                                   union nb_resource *resource)
 {
-       /* TODO: implement me. */
+       struct isis_circuit *circuit;
+       uint16_t multi;
+
+       if (event != NB_EV_APPLY)
+               return NB_OK;
+
+       circuit = yang_dnode_get_entry(dnode, true);
+       multi = yang_dnode_get_uint16(dnode, NULL);
+       circuit->hello_multiplier[0] = multi;
+
        return NB_OK;
 }
 
@@ -1962,7 +1971,16 @@ lib_interface_isis_hello_multiplier_level_2_modify(enum nb_event event,
                                                   const struct lyd_node *dnode,
                                                   union nb_resource *resource)
 {
-       /* TODO: implement me. */
+       struct isis_circuit *circuit;
+       uint16_t multi;
+
+       if (event != NB_EV_APPLY)
+               return NB_OK;
+
+       circuit = yang_dnode_get_entry(dnode, true);
+       multi = yang_dnode_get_uint16(dnode, NULL);
+       circuit->hello_multiplier[1] = multi;
+
        return NB_OK;
 }
 
@@ -2671,6 +2689,10 @@ const struct frr_yang_module_info frr_isisd_info = {
                        .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-2",
                        .cbs.modify = lib_interface_isis_hello_interval_level_2_modify,
                },
+               {
+                       .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier",
+                       .cbs.cli_show = cli_show_ip_isis_hello_multi,
+               },
                {
                        .xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-1",
                        .cbs.modify = lib_interface_isis_hello_multiplier_level_1_modify,
index 773c26f3b8accb06b1314d4c9f897842bef98354..78e6f0eec0870c554654394b0ee0e54417e6aaf5 100644 (file)
@@ -56,42 +56,6 @@ struct isis_circuit *isis_circuit_lookup(struct vty *vty)
        return circuit;
 }
 
-DEFUN (isis_hello_multiplier,
-       isis_hello_multiplier_cmd,
-       PROTO_NAME " hello-multiplier (2-100)",
-       PROTO_HELP
-       "Set multiplier for Hello holding time\n"
-       "Hello multiplier value\n")
-{
-       uint16_t mult = atoi(argv[2]->arg);
-       struct isis_circuit *circuit = isis_circuit_lookup(vty);
-       if (!circuit)
-               return CMD_ERR_NO_MATCH;
-
-       circuit->hello_multiplier[0] = mult;
-       circuit->hello_multiplier[1] = mult;
-
-       return CMD_SUCCESS;
-}
-
-DEFUN (no_isis_hello_multiplier,
-       no_isis_hello_multiplier_cmd,
-       "no " PROTO_NAME " hello-multiplier [(2-100)]",
-       NO_STR
-       PROTO_HELP
-       "Set multiplier for Hello holding time\n"
-       "Hello multiplier value\n")
-{
-       struct isis_circuit *circuit = isis_circuit_lookup(vty);
-       if (!circuit)
-               return CMD_ERR_NO_MATCH;
-
-       circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER;
-       circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER;
-
-       return CMD_SUCCESS;
-}
-
 DEFUN (csnp_interval,
        csnp_interval_cmd,
        PROTO_NAME " csnp-interval (1-600)",
@@ -264,9 +228,6 @@ DEFUN (no_isis_bfd,
 
 void isis_vty_init(void)
 {
-       install_element(INTERFACE_NODE, &isis_hello_multiplier_cmd);
-       install_element(INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
-
        install_element(INTERFACE_NODE, &csnp_interval_cmd);
        install_element(INTERFACE_NODE, &no_csnp_interval_cmd);
 
index 2c86e91603de55e3f4c12187eaa0a30c67d6387d..aad2ab95e316e932f37fbdc30ca7ef87fb4b5f5a 100644 (file)
@@ -869,6 +869,42 @@ DEFUN (no_isis_hello_interval,
        return CMD_SUCCESS;
 }
 
+DEFUN (isis_hello_multiplier,
+       isis_hello_multiplier_cmd,
+       PROTO_NAME " hello-multiplier (2-100)",
+       PROTO_HELP
+       "Set multiplier for Hello holding time\n"
+       "Hello multiplier value\n")
+{
+       uint16_t mult = atoi(argv[2]->arg);
+       struct isis_circuit *circuit = isis_circuit_lookup(vty);
+       if (!circuit)
+               return CMD_ERR_NO_MATCH;
+
+       circuit->hello_multiplier[0] = mult;
+       circuit->hello_multiplier[1] = mult;
+
+       return CMD_SUCCESS;
+}
+
+DEFUN (no_isis_hello_multiplier,
+       no_isis_hello_multiplier_cmd,
+       "no " PROTO_NAME " hello-multiplier [(2-100)]",
+       NO_STR
+       PROTO_HELP
+       "Set multiplier for Hello holding time\n"
+       "Hello multiplier value\n")
+{
+       struct isis_circuit *circuit = isis_circuit_lookup(vty);
+       if (!circuit)
+               return CMD_ERR_NO_MATCH;
+
+       circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER;
+       circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER;
+
+       return CMD_SUCCESS;
+}
+
 void isis_vty_daemon_init(void)
 {
        install_element(ROUTER_NODE, &fabric_tier_cmd);
@@ -919,4 +955,7 @@ void isis_vty_daemon_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);
 }
index 2465154647d5e5b029578dbf6aec733f6273b248..a011bf7a62bdcd34c8fe3fce4b738aed809af162 100644 (file)
@@ -219,45 +219,6 @@ DEFUN (no_isis_priority_level,
        return CMD_SUCCESS;
 }
 
-DEFUN (isis_hello_multiplier_level,
-       isis_hello_multiplier_level_cmd,
-       "isis hello-multiplier (2-100) <level-1|level-2>",
-       "IS-IS routing protocol\n"
-       "Set multiplier for Hello holding time\n"
-       "Hello multiplier value\n"
-       "Specify hello multiplier for level-1 IIHs\n"
-       "Specify hello multiplier for level-2 IIHs\n")
-{
-       uint16_t mult = atoi(argv[2]->arg);
-       struct isis_circuit *circuit = isis_circuit_lookup(vty);
-       if (!circuit)
-               return CMD_ERR_NO_MATCH;
-
-       circuit->hello_multiplier[level_for_arg(argv[3]->text)] = mult;
-
-       return CMD_SUCCESS;
-}
-
-DEFUN (no_isis_hello_multiplier_level,
-       no_isis_hello_multiplier_level_cmd,
-       "no isis hello-multiplier [(2-100)] <level-1|level-2>",
-       NO_STR
-       "IS-IS routing protocol\n"
-       "Set multiplier for Hello holding time\n"
-       "Hello multiplier value\n"
-       "Specify hello multiplier for level-1 IIHs\n"
-       "Specify hello multiplier 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_multiplier[level] = DEFAULT_HELLO_MULTIPLIER;
-
-       return CMD_SUCCESS;
-}
-
 DEFUN (isis_threeway_adj,
        isis_threeway_adj_cmd,
        "[no] isis three-way-handshake",
@@ -397,9 +358,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_multiplier_level_cmd);
-       install_element(INTERFACE_NODE, &no_isis_hello_multiplier_level_cmd);
-
        install_element(INTERFACE_NODE, &isis_threeway_adj_cmd);
 
        install_element(INTERFACE_NODE, &isis_hello_padding_cmd);