]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ripngd: retrofit the 'allow-ecmp' command to the new northbound model
authorRenato Westphal <renato@opensourcerouting.org>
Thu, 29 Nov 2018 02:57:39 +0000 (00:57 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 3 Dec 2018 15:47:58 +0000 (13:47 -0200)
Trivial conversion. The ripng->ecmp variable was converted to a boolean
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 7bdc7422070157763291f8369ed6a630f2ac091e..8944198c2f1a4368e8c1855b23143a7f51d806c6 100644 (file)
@@ -75,8 +75,34 @@ void cli_show_router_ripng(struct vty *vty, struct lyd_node *dnode,
        vty_out(vty, "router ripng\n");
 }
 
+/*
+ * XPath: /frr-ripngd:ripngd/instance/allow-ecmp
+ */
+DEFPY (ripng_allow_ecmp,
+       ripng_allow_ecmp_cmd,
+       "[no] allow-ecmp",
+       NO_STR
+       "Allow Equal Cost MultiPath\n")
+{
+       nb_cli_enqueue_change(vty, "./allow-ecmp", NB_OP_MODIFY,
+                             no ? "false" : "true");
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+void cli_show_ripng_allow_ecmp(struct vty *vty, struct lyd_node *dnode,
+                              bool show_defaults)
+{
+       if (!yang_dnode_get_bool(dnode, NULL))
+               vty_out(vty, " no");
+
+       vty_out(vty, " allow-ecmp\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);
 }
index f0ef046f6a72c0ae21a2234d50e79d43913f1343..e90fb8aaeca324b8990428fbc762a6c7bdc201f3 100644 (file)
@@ -23,5 +23,7 @@
 
 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);
 
 #endif /* _FRR_RIPNG_CLI_H_ */
index 219d8d1db7244f0bf2de604f3446d85e74f488c4..f067d048e4027dbb9653ba84ae2e523ad7fc27c3 100644 (file)
@@ -82,7 +82,13 @@ static int ripngd_instance_allow_ecmp_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->ecmp = yang_dnode_get_bool(dnode, NULL);
+       if (!ripng->ecmp)
+               ripng_ecmp_disable();
+
        return NB_OK;
 }
 
@@ -513,6 +519,7 @@ const struct frr_yang_module_info frr_ripngd_info = {
                {
                        .xpath = "/frr-ripngd:ripngd/instance/allow-ecmp",
                        .cbs.modify = ripngd_instance_allow_ecmp_modify,
+                       .cbs.cli_show = cli_show_ripng_allow_ecmp,
                },
                {
                        .xpath = "/frr-ripngd:ripngd/instance/default-information-originate",
index 634596719c592fc9ed13b85c954819611c1d8a76..0d5ec507bfe060fec0e53bcaecd06f144caf92f6 100644 (file)
@@ -2540,7 +2540,7 @@ DEFUN (no_ripng_default_information_originate,
 }
 
 /* Update ECMP routes to zebra when ECMP is disabled. */
-static void ripng_ecmp_disable(void)
+void ripng_ecmp_disable(void)
 {
        struct agg_node *rp;
        struct ripng_info *rinfo, *tmp_rinfo;
@@ -2577,38 +2577,6 @@ static void ripng_ecmp_disable(void)
                }
 }
 
-DEFUN (ripng_allow_ecmp,
-       ripng_allow_ecmp_cmd,
-       "allow-ecmp",
-       "Allow Equal Cost MultiPath\n")
-{
-       if (ripng->ecmp) {
-               vty_out(vty, "ECMP is already enabled.\n");
-               return CMD_WARNING;
-       }
-
-       ripng->ecmp = 1;
-       zlog_info("ECMP is enabled.");
-       return CMD_SUCCESS;
-}
-
-DEFUN (no_ripng_allow_ecmp,
-       no_ripng_allow_ecmp_cmd,
-       "no allow-ecmp",
-       NO_STR
-       "Allow Equal Cost MultiPath\n")
-{
-       if (!ripng->ecmp) {
-               vty_out(vty, "ECMP is already disabled.\n");
-               return CMD_WARNING;
-       }
-
-       ripng->ecmp = 0;
-       zlog_info("ECMP is disabled.");
-       ripng_ecmp_disable();
-       return CMD_SUCCESS;
-}
-
 /* RIPng configuration write function. */
 static int ripng_config_write(struct vty *vty)
 {
@@ -2644,10 +2612,6 @@ static int ripng_config_write(struct vty *vty)
                                        inet6_ntoa(rp->p.u.prefix6),
                                        rp->p.prefixlen);
 
-               /* ECMP configuration. */
-               if (ripng->ecmp)
-                       vty_out(vty, " allow-ecmp\n");
-
                /* RIPng static routes. */
                for (rp = agg_route_top(ripng->route); rp;
                     rp = agg_route_next(rp))
@@ -2983,9 +2947,6 @@ void ripng_init()
        install_element(RIPNG_NODE,
                        &no_ripng_default_information_originate_cmd);
 
-       install_element(RIPNG_NODE, &ripng_allow_ecmp_cmd);
-       install_element(RIPNG_NODE, &no_ripng_allow_ecmp_cmd);
-
        ripng_if_init();
        ripng_debug_init();
 
index de3b2e194735b570f6fd285fe045031593f01154..9b5f89076b84c33d58925a531e6c4aa8002008b8 100644 (file)
@@ -134,7 +134,7 @@ struct ripng {
        struct thread *t_triggered_interval;
 
        /* RIPng ECMP flag */
-       unsigned int ecmp;
+       bool ecmp;
 
        /* For redistribute route map. */
        struct {
@@ -378,6 +378,7 @@ extern void ripng_redistribute_delete(int, int, struct prefix_ipv6 *,
                                      ifindex_t);
 extern void ripng_redistribute_withdraw(int type);
 
+extern void ripng_ecmp_disable(void);
 extern void ripng_distribute_update_interface(struct interface *);
 extern void ripng_if_rmap_update_interface(struct interface *);