diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2018-05-09 06:34:58 +0200 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2018-10-27 20:16:12 +0200 |
commit | 0b0609ba35fcf67e17ecc0f44d8bc2979b77b87e (patch) | |
tree | de5ff8d43cf1ee6950919dfc2d911081b70c13ee /ripd | |
parent | ripd: retrofit the 'allow-ecmp' command to the new northbound model (diff) | |
download | frr-0b0609ba35fcf67e17ecc0f44d8bc2979b77b87e.tar.xz frr-0b0609ba35fcf67e17ecc0f44d8bc2979b77b87e.zip |
ripd: retrofit the 'default-information' command to the new northbound model
Trivial conversion.
'rip->default_information_route_map' was removed since it wasn't being
used anywhere.
'rip->default_information' was removed too 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>
Diffstat (limited to 'ripd')
-rw-r--r-- | ripd/rip_cli.c | 32 | ||||
-rw-r--r-- | ripd/rip_cli.h | 3 | ||||
-rw-r--r-- | ripd/rip_northbound.c | 24 | ||||
-rw-r--r-- | ripd/rip_zebra.c | 51 | ||||
-rw-r--r-- | ripd/ripd.c | 15 | ||||
-rw-r--r-- | ripd/ripd.h | 4 |
6 files changed, 58 insertions, 71 deletions
diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c index e3b15047b..9193c089a 100644 --- a/ripd/rip_cli.c +++ b/ripd/rip_cli.c @@ -114,10 +114,42 @@ void cli_show_rip_allow_ecmp(struct vty *vty, struct lyd_node *dnode, vty_out(vty, " allow-ecmp\n"); } +/* + * XPath: /frr-ripd:ripd/instance/default-information-originate + */ +DEFPY (rip_default_information_originate, + rip_default_information_originate_cmd, + "[no] default-information originate", + NO_STR + "Control distribution of default route\n" + "Distribute a default route\n") +{ + struct cli_config_change changes[] = { + { + .xpath = "./default-information-originate", + .operation = NB_OP_MODIFY, + .value = no ? "false" : "true", + }, + }; + + return nb_cli_cfg_change(vty, NULL, changes, array_size(changes)); +} + +void cli_show_rip_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 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); + install_element(RIP_NODE, &rip_default_information_originate_cmd); } diff --git a/ripd/rip_cli.h b/ripd/rip_cli.h index 259a78d8e..d63f02dd9 100644 --- a/ripd/rip_cli.h +++ b/ripd/rip_cli.h @@ -25,5 +25,8 @@ 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); +extern void cli_show_rip_default_information_originate(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 76b154d30..884e2a83d 100644 --- a/ripd/rip_northbound.c +++ b/ripd/rip_northbound.c @@ -99,7 +99,28 @@ ripd_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_ipv4 p; + + if (event != NB_EV_APPLY) + return NB_OK; + + default_information = yang_dnode_get_bool(dnode, NULL); + + memset(&p, 0, sizeof(struct prefix_ipv4)); + p.family = AF_INET; + if (default_information) { + struct nexthop nh; + + memset(&nh, 0, sizeof(nh)); + nh.type = NEXTHOP_TYPE_IPV4; + rip_redistribute_add(ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p, + &nh, 0, 0, 0); + } else { + rip_redistribute_delete(ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p, + 0); + } + return NB_OK; } @@ -733,6 +754,7 @@ const struct frr_yang_module_info frr_ripd_info = { { .xpath = "/frr-ripd:ripd/instance/default-information-originate", .cbs.modify = ripd_instance_default_information_originate_modify, + .cbs.cli_show = cli_show_rip_default_information_originate, }, { .xpath = "/frr-ripd:ripd/instance/default-metric", diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index 29b2f8817..1d0290daf 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -493,55 +493,6 @@ DEFUN (no_rip_redistribute_type_metric_routemap, return CMD_WARNING_CONFIG_FAILED; } -/* Default information originate. */ - -DEFUN (rip_default_information_originate, - rip_default_information_originate_cmd, - "default-information originate", - "Control distribution of default route\n" - "Distribute a default route\n") -{ - struct prefix_ipv4 p; - struct nexthop nh; - - if (!rip->default_information) { - memset(&p, 0, sizeof(struct prefix_ipv4)); - memset(&nh, 0, sizeof(nh)); - - p.family = AF_INET; - nh.type = NEXTHOP_TYPE_IPV4; - - rip->default_information = 1; - - rip_redistribute_add(ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p, - &nh, 0, 0, 0); - } - - return CMD_SUCCESS; -} - -DEFUN (no_rip_default_information_originate, - no_rip_default_information_originate_cmd, - "no default-information originate", - NO_STR - "Control distribution of default route\n" - "Distribute a default route\n") -{ - struct prefix_ipv4 p; - - if (rip->default_information) { - memset(&p, 0, sizeof(struct prefix_ipv4)); - p.family = AF_INET; - - rip->default_information = 0; - - rip_redistribute_delete(ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p, - 0); - } - - return CMD_SUCCESS; -} - int config_write_rip_redistribute(struct vty *vty, int config_mode) { int i; @@ -612,8 +563,6 @@ void rip_zclient_init(struct thread_master *master) install_element(RIP_NODE, &no_rip_redistribute_type_metric_cmd); install_element(RIP_NODE, &no_rip_redistribute_type_metric_routemap_cmd); - install_element(RIP_NODE, &rip_default_information_originate_cmd); - install_element(RIP_NODE, &no_rip_default_information_originate_cmd); } void rip_zclient_stop(void) diff --git a/ripd/ripd.c b/ripd/ripd.c index ca2bad6de..7dfabc623 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -3605,17 +3605,6 @@ static int config_write_rip(struct vty *vty) rip->update_time, rip->timeout_time, rip->garbage_time); - /* Default information configuration. */ - if (rip->default_information) { - if (rip->default_information_route_map) - vty_out(vty, - " default-information originate route-map %s\n", - rip->default_information_route_map); - else - vty_out(vty, - " default-information originate\n"); - } - /* Redistribute configuration. */ config_write_rip_redistribute(vty, 1); @@ -3807,10 +3796,6 @@ void rip_clean(void) route_unlock_node(rp); } - /* Redistribute related clear. */ - if (rip->default_information_route_map) - free(rip->default_information_route_map); - for (i = 0; i < ZEBRA_ROUTE_MAX; i++) if (rip->route_map[i].name) free(rip->route_map[i].name); diff --git a/ripd/ripd.h b/ripd/ripd.h index 68b302e87..c2e39f1a7 100644 --- a/ripd/ripd.h +++ b/ripd/ripd.h @@ -142,10 +142,6 @@ struct rip { /* RIP default metric. */ int default_metric; - /* RIP default-information originate. */ - uint8_t default_information; - char *default_information_route_map; - /* RIP default distance. */ uint8_t distance; struct route_table *distance_table; |