diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2018-05-09 06:35:01 +0200 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2018-10-27 20:16:12 +0200 |
commit | 908f0020923f77545ae467837d78b7eaa91f048e (patch) | |
tree | c11a91f0fb93c83fb7301e6c5324be8497c6a5a4 /ripd/rip_cli.c | |
parent | ripd: retrofit the 'passive-interface' command to the new northbound model (diff) | |
download | frr-908f0020923f77545ae467837d78b7eaa91f048e.tar.xz frr-908f0020923f77545ae467837d78b7eaa91f048e.zip |
ripd: retrofit the 'redistribute' commands to the new northbound model
Trivial conversion. As usual, combine multiple DEFUNs into a single
DEFPY for simplicity.
As a bonus of the northbound conversion, this commit fixes the
redistribution of certain protocols into ripd. The 'redist_type' array
used by the "redistribute" commands was terribly outdated, which was
preventing the CLI to parse correctly certain protocols like isis
and babel.
Remove the route_map hooks installed by rip_route_map_init() since they
were redundant (rip_init() already takes care of that).
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripd/rip_cli.c')
-rw-r--r-- | ripd/rip_cli.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c index ae7e05cc1..4bbec64f1 100644 --- a/ripd/rip_cli.c +++ b/ripd/rip_cli.c @@ -536,6 +536,82 @@ void cli_show_rip_non_passive_interface(struct vty *vty, struct lyd_node *dnode, yang_dnode_get_string(dnode, NULL)); } +/* + * XPath: /frr-ripd:ripd/instance/redistribute + */ +DEFPY (rip_redistribute, + rip_redistribute_cmd, + "redistribute " FRR_REDIST_STR_RIPD "$protocol [{metric (0-16)|route-map WORD}]", + REDIST_STR + FRR_REDIST_HELP_STR_RIPD + "Metric\n" + "Metric value\n" + "Route map reference\n" + "Pointer to route-map entries\n") +{ + char xpath_list[XPATH_MAXLEN]; + struct cli_config_change changes[] = { + { + .xpath = ".", + .operation = NB_OP_CREATE, + }, + { + .xpath = "./route-map", + .operation = route_map ? NB_OP_MODIFY : NB_OP_DELETE, + .value = route_map, + }, + { + .xpath = "./metric", + .operation = metric_str ? NB_OP_MODIFY : NB_OP_DELETE, + .value = metric_str, + }, + }; + + snprintf(xpath_list, sizeof(xpath_list), + "./redistribute[protocol='%s']", protocol); + + return nb_cli_cfg_change(vty, xpath_list, changes, array_size(changes)); +} + +DEFPY (no_rip_redistribute, + no_rip_redistribute_cmd, + "no redistribute " FRR_REDIST_STR_RIPD "$protocol [{metric (0-16)|route-map WORD}]", + NO_STR + REDIST_STR + FRR_REDIST_HELP_STR_RIPD + "Metric\n" + "Metric value\n" + "Route map reference\n" + "Pointer to route-map entries\n") +{ + char xpath_list[XPATH_MAXLEN]; + struct cli_config_change changes[] = { + { + .xpath = ".", + .operation = NB_OP_DELETE, + }, + }; + + snprintf(xpath_list, sizeof(xpath_list), + "./redistribute[protocol='%s']", protocol); + + return nb_cli_cfg_change(vty, xpath_list, changes, array_size(changes)); +} + +void cli_show_rip_redistribute(struct vty *vty, struct lyd_node *dnode, + bool show_defaults) +{ + vty_out(vty, " redistribute %s", + yang_dnode_get_string(dnode, "./protocol")); + if (yang_dnode_exists(dnode, "./metric")) + vty_out(vty, " metric %s", + yang_dnode_get_string(dnode, "./metric")); + if (yang_dnode_exists(dnode, "./route-map")) + vty_out(vty, " route-map %s", + yang_dnode_get_string(dnode, "./route-map")); + vty_out(vty, "\n"); +} + void rip_cli_init(void) { install_element(CONFIG_NODE, &router_rip_cmd); @@ -556,4 +632,6 @@ void rip_cli_init(void) install_element(RIP_NODE, &no_rip_offset_list_cmd); install_element(RIP_NODE, &rip_passive_default_cmd); install_element(RIP_NODE, &rip_passive_interface_cmd); + install_element(RIP_NODE, &rip_redistribute_cmd); + install_element(RIP_NODE, &no_rip_redistribute_cmd); } |