summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ripd/rip_cli.c31
-rw-r--r--ripd/rip_cli.h2
-rw-r--r--ripd/rip_northbound.c9
-rw-r--r--ripd/ripd.c40
-rw-r--r--ripd/ripd.h4
5 files changed, 45 insertions, 41 deletions
diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c
index 684fbd300..e3b15047b 100644
--- a/ripd/rip_cli.c
+++ b/ripd/rip_cli.c
@@ -85,8 +85,39 @@ void cli_show_router_rip(struct vty *vty, struct lyd_node *dnode,
vty_out(vty, "router rip\n");
}
+/*
+ * XPath: /frr-ripd:ripd/instance/allow-ecmp
+ */
+DEFPY (rip_allow_ecmp,
+ rip_allow_ecmp_cmd,
+ "[no] allow-ecmp",
+ NO_STR
+ "Allow Equal Cost MultiPath\n")
+{
+ struct cli_config_change changes[] = {
+ {
+ .xpath = "./allow-ecmp",
+ .operation = NB_OP_MODIFY,
+ .value = no ? "false" : "true",
+ },
+ };
+
+ return nb_cli_cfg_change(vty, NULL, changes, array_size(changes));
+}
+
+void cli_show_rip_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 rip_cli_init(void)
{
install_element(CONFIG_NODE, &router_rip_cmd);
install_element(CONFIG_NODE, &no_router_rip_cmd);
+
+ install_element(RIP_NODE, &rip_allow_ecmp_cmd);
}
diff --git a/ripd/rip_cli.h b/ripd/rip_cli.h
index b8997e880..259a78d8e 100644
--- a/ripd/rip_cli.h
+++ b/ripd/rip_cli.h
@@ -23,5 +23,7 @@
extern void cli_show_router_rip(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
+extern void cli_show_rip_allow_ecmp(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults);
#endif /* _FRR_RIP_CLI_H_ */
diff --git a/ripd/rip_northbound.c b/ripd/rip_northbound.c
index e780bc5e1..76b154d30 100644
--- a/ripd/rip_northbound.c
+++ b/ripd/rip_northbound.c
@@ -81,7 +81,13 @@ static int ripd_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;
+
+ rip->ecmp = yang_dnode_get_bool(dnode, NULL);
+ if (!rip->ecmp)
+ rip_ecmp_disable();
+
return NB_OK;
}
@@ -722,6 +728,7 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/allow-ecmp",
.cbs.modify = ripd_instance_allow_ecmp_modify,
+ .cbs.cli_show = cli_show_rip_allow_ecmp,
},
{
.xpath = "/frr-ripd:ripd/instance/default-information-originate",
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 9cb1ae8cf..ca2bad6de 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -3290,7 +3290,7 @@ DEFUN (no_rip_distance_source_access_list,
}
/* Update ECMP routes to zebra when ECMP is disabled. */
-static void rip_ecmp_disable(void)
+void rip_ecmp_disable(void)
{
struct route_node *rp;
struct rip_info *rinfo, *tmp_rinfo;
@@ -3327,38 +3327,6 @@ static void rip_ecmp_disable(void)
}
}
-DEFUN (rip_allow_ecmp,
- rip_allow_ecmp_cmd,
- "allow-ecmp",
- "Allow Equal Cost MultiPath\n")
-{
- if (rip->ecmp) {
- vty_out(vty, "ECMP is already enabled.\n");
- return CMD_WARNING;
- }
-
- rip->ecmp = 1;
- zlog_info("ECMP is enabled.");
- return CMD_SUCCESS;
-}
-
-DEFUN (no_rip_allow_ecmp,
- no_rip_allow_ecmp_cmd,
- "no allow-ecmp",
- NO_STR
- "Allow Equal Cost MultiPath\n")
-{
- if (!rip->ecmp) {
- vty_out(vty, "ECMP is already disabled.\n");
- return CMD_WARNING;
- }
-
- rip->ecmp = 0;
- zlog_info("ECMP is disabled.");
- rip_ecmp_disable();
- return CMD_SUCCESS;
-}
-
/* Print out routes update time. */
static void rip_vty_out_uptime(struct vty *vty, struct rip_info *rinfo)
{
@@ -3684,10 +3652,6 @@ static int config_write_rip(struct vty *vty)
? rdistance->access_list
: "");
- /* ECMP configuration. */
- if (rip->ecmp)
- vty_out(vty, " allow-ecmp\n");
-
/* RIP static route configuration. */
for (rn = route_top(rip->route); rn; rn = route_next(rn))
if (rn->info)
@@ -3982,8 +3946,6 @@ void rip_init(void)
install_element(RIP_NODE, &no_rip_distance_source_cmd);
install_element(RIP_NODE, &rip_distance_source_access_list_cmd);
install_element(RIP_NODE, &no_rip_distance_source_access_list_cmd);
- install_element(RIP_NODE, &rip_allow_ecmp_cmd);
- install_element(RIP_NODE, &no_rip_allow_ecmp_cmd);
/* Debug related init. */
rip_debug_init();
diff --git a/ripd/ripd.h b/ripd/ripd.h
index 8e34939f2..68b302e87 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -151,7 +151,7 @@ struct rip {
struct route_table *distance_table;
/* RIP ECMP flag */
- unsigned int ecmp;
+ bool ecmp;
/* For redistribute route map. */
struct {
@@ -389,6 +389,8 @@ extern int rip_request_send(struct sockaddr_in *, struct interface *, uint8_t,
struct connected *);
extern int rip_neighbor_lookup(struct sockaddr_in *);
+extern void rip_ecmp_disable(void);
+
extern int rip_create_socket(void);
extern int rip_redistribute_check(int);