]> git.proxmox.com Git - mirror_frr.git/commitdiff
ripngd: retrofit the 'default-metric' command to the new northbound model
authorRenato Westphal <renato@opensourcerouting.org>
Thu, 29 Nov 2018 03:20:28 +0000 (01:20 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 3 Dec 2018 15:47:58 +0000 (13:47 -0200)
Trivial conversion. ripng->default_metric was converted to an
uint8_t to match the way it's defined in the YANG module.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ripngd/ripng_cli.c
ripngd/ripng_cli.h
ripngd/ripng_northbound.c
ripngd/ripngd.c
ripngd/ripngd.h

index 04cde899dfa9def4518695f17d8bdcd7585393b4..5a1c9bdca28a1f2fbe7f0b12b68a74acb52dba95 100644 (file)
@@ -125,6 +125,40 @@ void cli_show_ripng_default_information_originate(struct vty *vty,
        vty_out(vty, " default-information originate\n");
 }
 
+/*
+ * XPath: /frr-ripngd:ripngd/instance/default-metric
+ */
+DEFPY (ripng_default_metric,
+       ripng_default_metric_cmd,
+       "default-metric (1-16)",
+       "Set a metric of redistribute routes\n"
+       "Default metric\n")
+{
+       nb_cli_enqueue_change(vty, "./default-metric", NB_OP_MODIFY,
+                             default_metric_str);
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFPY (no_ripng_default_metric,
+       no_ripng_default_metric_cmd,
+       "no default-metric [(1-16)]",
+       NO_STR
+       "Set a metric of redistribute routes\n"
+       "Default metric\n")
+{
+       nb_cli_enqueue_change(vty, "./default-metric", NB_OP_MODIFY, NULL);
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+void cli_show_ripng_default_metric(struct vty *vty, struct lyd_node *dnode,
+                                  bool show_defaults)
+{
+       vty_out(vty, " default-metric %s\n",
+               yang_dnode_get_string(dnode, NULL));
+}
+
 void ripng_cli_init(void)
 {
        install_element(CONFIG_NODE, &router_ripng_cmd);
@@ -132,4 +166,6 @@ void ripng_cli_init(void)
 
        install_element(RIPNG_NODE, &ripng_allow_ecmp_cmd);
        install_element(RIPNG_NODE, &ripng_default_information_originate_cmd);
+       install_element(RIPNG_NODE, &ripng_default_metric_cmd);
+       install_element(RIPNG_NODE, &no_ripng_default_metric_cmd);
 }
index 6ba75c7f40a40add3e00425ac8c2eec37ea1ee03..0cdbc2d6a1967c862baadab63855364c45eb7276 100644 (file)
@@ -28,5 +28,8 @@ extern void cli_show_ripng_allow_ecmp(struct vty *vty, struct lyd_node *dnode,
 extern void cli_show_ripng_default_information_originate(struct vty *vty,
                                                         struct lyd_node *dnode,
                                                         bool show_defaults);
+extern void cli_show_ripng_default_metric(struct vty *vty,
+                                         struct lyd_node *dnode,
+                                         bool show_defaults);
 
 #endif /* _FRR_RIPNG_CLI_H_ */
index 6d837af3c577ad50142a08aeca20303649a9af8f..7a7c14cebca4570035a77ca018d3d1b591bd1802 100644 (file)
@@ -125,7 +125,11 @@ static int ripngd_instance_default_metric_modify(enum nb_event event,
                                                 const struct lyd_node *dnode,
                                                 union nb_resource *resource)
 {
-       /* TODO: implement me. */
+       if (event != NB_EV_APPLY)
+               return NB_OK;
+
+       ripng->default_metric = yang_dnode_get_uint8(dnode, NULL);
+
        return NB_OK;
 }
 
@@ -544,6 +548,7 @@ const struct frr_yang_module_info frr_ripngd_info = {
                {
                        .xpath = "/frr-ripngd:ripngd/instance/default-metric",
                        .cbs.modify = ripngd_instance_default_metric_modify,
+                       .cbs.cli_show = cli_show_ripng_default_metric,
                },
                {
                        .xpath = "/frr-ripngd:ripngd/instance/network",
index e8dc45d1fff78041d606f7549fd97588f7020f36..4d67aa2f680e9603eea23c23ec2aa29828a7d8c3 100644 (file)
@@ -2290,33 +2290,6 @@ DEFUN (no_ripng_aggregate_address,
        return CMD_SUCCESS;
 }
 
-DEFUN (ripng_default_metric,
-       ripng_default_metric_cmd,
-       "default-metric (1-16)",
-       "Set a metric of redistribute routes\n"
-       "Default metric\n")
-{
-       int idx_number = 1;
-       if (ripng) {
-               ripng->default_metric = atoi(argv[idx_number]->arg);
-       }
-       return CMD_SUCCESS;
-}
-
-DEFUN (no_ripng_default_metric,
-       no_ripng_default_metric_cmd,
-       "no default-metric [(1-16)]",
-       NO_STR
-       "Set a metric of redistribute routes\n"
-       "Default metric\n")
-{
-       if (ripng) {
-               ripng->default_metric = RIPNG_DEFAULT_METRIC_DEFAULT;
-       }
-       return CMD_SUCCESS;
-}
-
-
 #if 0
 /* RIPng update timer setup. */
 DEFUN (ripng_update_timer,
@@ -2551,11 +2524,6 @@ static int ripng_config_write(struct vty *vty)
 
                ripng_network_write(vty, 1);
 
-               /* RIPng default metric configuration */
-               if (ripng->default_metric != RIPNG_DEFAULT_METRIC_DEFAULT)
-                       vty_out(vty, " default-metric %d\n",
-                               ripng->default_metric);
-
                ripng_redistribute_write(vty, 1);
 
                /* RIP offset-list configuration. */
@@ -2885,9 +2853,6 @@ void ripng_init()
        install_element(RIPNG_NODE, &ripng_aggregate_address_cmd);
        install_element(RIPNG_NODE, &no_ripng_aggregate_address_cmd);
 
-       install_element(RIPNG_NODE, &ripng_default_metric_cmd);
-       install_element(RIPNG_NODE, &no_ripng_default_metric_cmd);
-
        install_element(RIPNG_NODE, &ripng_timers_cmd);
        install_element(RIPNG_NODE, &no_ripng_timers_cmd);
 #if 0
index c9bcd8b0e04e1767bb0b8333ec18190d5b6d3bc8..6ebc72dae5b70887387995ed2227281034caac68 100644 (file)
@@ -77,9 +77,6 @@
 #define RIPNG_DEFAULT_ACCEPT_NONE        1
 #define RIPNG_DEFAULT_ACCEPT             2
 
-/* Default value for "default-metric" command. */
-#define RIPNG_DEFAULT_METRIC_DEFAULT     1
-
 /* For max RTE calculation. */
 #ifndef IPV6_HDRLEN
 #define IPV6_HDRLEN 40
@@ -105,7 +102,7 @@ struct ripng {
        unsigned long timeout_time;
        unsigned long garbage_time;
        int max_mtu;
-       int default_metric;
+       uint8_t default_metric;
 
        /* Input/output buffer of RIPng. */
        struct stream *ibuf;