ripd: retrofit the 'allow-ecmp' command to the new northbound model

Trivial conversion. The rip->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>
This commit is contained in:
Renato Westphal 2018-05-09 01:34:58 -03:00
parent 8c9226c216
commit edbf59d209
5 changed files with 45 additions and 41 deletions

View File

@ -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);
}

View File

@ -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_ */

View File

@ -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",

View File

@ -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();

View File

@ -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);