]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ripngd: retrofit the 'default-information' command to the new northbound model
authorRenato Westphal <renato@opensourcerouting.org>
Thu, 29 Nov 2018 03:12:29 +0000 (01:12 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 3 Dec 2018 15:47:58 +0000 (13:47 -0200)
Trivial conversion. 'ripng->default_information' was removed because
it was being used only to display the running configuration and
thus is not necessary anymore.

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 8944198c2f1a4368e8c1855b23143a7f51d806c6..04cde899dfa9def4518695f17d8bdcd7585393b4 100644 (file)
@@ -99,10 +99,37 @@ void cli_show_ripng_allow_ecmp(struct vty *vty, struct lyd_node *dnode,
        vty_out(vty, " allow-ecmp\n");
 }
 
+/*
+ * XPath: /frr-ripngd:ripngd/instance/default-information-originate
+ */
+DEFPY (ripng_default_information_originate,
+       ripng_default_information_originate_cmd,
+       "[no] default-information originate",
+       NO_STR
+       "Default route information\n"
+       "Distribute default route\n")
+{
+       nb_cli_enqueue_change(vty, "./default-information-originate",
+                             NB_OP_MODIFY, no ? "false" : "true");
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+void cli_show_ripng_default_information_originate(struct vty *vty,
+                                                 struct lyd_node *dnode,
+                                                 bool show_defaults)
+{
+       if (!yang_dnode_get_bool(dnode, NULL))
+               vty_out(vty, " no");
+
+       vty_out(vty, " default-information originate\n");
+}
+
 void ripng_cli_init(void)
 {
        install_element(CONFIG_NODE, &router_ripng_cmd);
        install_element(CONFIG_NODE, &no_router_ripng_cmd);
 
        install_element(RIPNG_NODE, &ripng_allow_ecmp_cmd);
+       install_element(RIPNG_NODE, &ripng_default_information_originate_cmd);
 }
index e90fb8aaeca324b8990428fbc762a6c7bdc201f3..6ba75c7f40a40add3e00425ac8c2eec37ea1ee03 100644 (file)
@@ -25,5 +25,8 @@ extern void cli_show_router_ripng(struct vty *vty, struct lyd_node *dnode,
                                  bool show_defaults);
 extern void cli_show_ripng_allow_ecmp(struct vty *vty, struct lyd_node *dnode,
                                      bool show_defaults);
+extern void cli_show_ripng_default_information_originate(struct vty *vty,
+                                                        struct lyd_node *dnode,
+                                                        bool show_defaults);
 
 #endif /* _FRR_RIPNG_CLI_H_ */
index f067d048e4027dbb9653ba84ae2e523ad7fc27c3..6d837af3c577ad50142a08aeca20303649a9af8f 100644 (file)
@@ -99,7 +99,22 @@ static int ripngd_instance_default_information_originate_modify(
        enum nb_event event, const struct lyd_node *dnode,
        union nb_resource *resource)
 {
-       /* TODO: implement me. */
+       bool default_information;
+       struct prefix_ipv6 p;
+
+       if (event != NB_EV_APPLY)
+               return NB_OK;
+
+       default_information = yang_dnode_get_bool(dnode, NULL);
+       str2prefix_ipv6("::/0", &p);
+       if (default_information) {
+               ripng_redistribute_add(ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_DEFAULT,
+                                      &p, 0, NULL, 0);
+       } else {
+               ripng_redistribute_delete(ZEBRA_ROUTE_RIPNG,
+                                         RIPNG_ROUTE_DEFAULT, &p, 0);
+       }
+
        return NB_OK;
 }
 
@@ -524,6 +539,7 @@ const struct frr_yang_module_info frr_ripngd_info = {
                {
                        .xpath = "/frr-ripngd:ripngd/instance/default-information-originate",
                        .cbs.modify = ripngd_instance_default_information_originate_modify,
+                       .cbs.cli_show = cli_show_ripng_default_information_originate,
                },
                {
                        .xpath = "/frr-ripngd:ripngd/instance/default-metric",
index 0d5ec507bfe060fec0e53bcaecd06f144caf92f6..e8dc45d1fff78041d606f7549fd97588f7020f36 100644 (file)
@@ -2499,46 +2499,6 @@ DEFUN (show_ipv6_protocols,
 }
 #endif
 
-/* Please be carefull to use this command. */
-DEFUN (ripng_default_information_originate,
-       ripng_default_information_originate_cmd,
-       "default-information originate",
-       "Default route information\n"
-       "Distribute default route\n")
-{
-       struct prefix_ipv6 p;
-
-       if (!ripng->default_information) {
-               ripng->default_information = 1;
-
-               str2prefix_ipv6("::/0", &p);
-               ripng_redistribute_add(ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_DEFAULT,
-                                      &p, 0, NULL, 0);
-       }
-
-       return CMD_SUCCESS;
-}
-
-DEFUN (no_ripng_default_information_originate,
-       no_ripng_default_information_originate_cmd,
-       "no default-information originate",
-       NO_STR
-       "Default route information\n"
-       "Distribute default route\n")
-{
-       struct prefix_ipv6 p;
-
-       if (ripng->default_information) {
-               ripng->default_information = 0;
-
-               str2prefix_ipv6("::/0", &p);
-               ripng_redistribute_delete(ZEBRA_ROUTE_RIPNG,
-                                         RIPNG_ROUTE_DEFAULT, &p, 0);
-       }
-
-       return CMD_SUCCESS;
-}
-
 /* Update ECMP routes to zebra when ECMP is disabled. */
 void ripng_ecmp_disable(void)
 {
@@ -2589,9 +2549,6 @@ static int ripng_config_write(struct vty *vty)
        if (dnode) {
                nb_cli_show_dnode_cmds(vty, dnode, false);
 
-               if (ripng->default_information)
-                       vty_out(vty, " default-information originate\n");
-
                ripng_network_write(vty, 1);
 
                /* RIPng default metric configuration */
@@ -2943,10 +2900,6 @@ void ripng_init()
   install_element (RIPNG_NODE, &no_ripng_garbage_timer_cmd);
 #endif /* 0 */
 
-       install_element(RIPNG_NODE, &ripng_default_information_originate_cmd);
-       install_element(RIPNG_NODE,
-                       &no_ripng_default_information_originate_cmd);
-
        ripng_if_init();
        ripng_debug_init();
 
index 9b5f89076b84c33d58925a531e6c4aa8002008b8..c9bcd8b0e04e1767bb0b8333ec18190d5b6d3bc8 100644 (file)
@@ -106,7 +106,6 @@ struct ripng {
        unsigned long garbage_time;
        int max_mtu;
        int default_metric;
-       int default_information;
 
        /* Input/output buffer of RIPng. */
        struct stream *ibuf;