summaryrefslogtreecommitdiffstats
path: root/ripngd
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2018-11-29 04:12:29 +0100
committerRenato Westphal <renato@opensourcerouting.org>2018-12-03 16:47:58 +0100
commit54b565627ac5dbd48bc7aa48b0c7dd5836967ef4 (patch)
tree39bdbe7b63cc24f8158199ba9f297b79f064b401 /ripngd
parentripngd: retrofit the 'allow-ecmp' command to the new northbound model (diff)
downloadfrr-54b565627ac5dbd48bc7aa48b0c7dd5836967ef4.tar.xz
frr-54b565627ac5dbd48bc7aa48b0c7dd5836967ef4.zip
ripngd: retrofit the 'default-information' command to the new northbound model
Trivial conversion. 'ripng->default_information' was removed 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 'ripngd')
-rw-r--r--ripngd/ripng_cli.c27
-rw-r--r--ripngd/ripng_cli.h3
-rw-r--r--ripngd/ripng_northbound.c18
-rw-r--r--ripngd/ripngd.c47
-rw-r--r--ripngd/ripngd.h1
5 files changed, 47 insertions, 49 deletions
diff --git a/ripngd/ripng_cli.c b/ripngd/ripng_cli.c
index 8944198c2..04cde899d 100644
--- a/ripngd/ripng_cli.c
+++ b/ripngd/ripng_cli.c
@@ -99,10 +99,37 @@ void cli_show_ripng_allow_ecmp(struct vty *vty, struct lyd_node *dnode,
vty_out(vty, " allow-ecmp\n");
}
+/*
+ * XPath: /frr-ripngd:ripngd/instance/default-information-originate
+ */
+DEFPY (ripng_default_information_originate,
+ ripng_default_information_originate_cmd,
+ "[no] default-information originate",
+ NO_STR
+ "Default route information\n"
+ "Distribute default route\n")
+{
+ nb_cli_enqueue_change(vty, "./default-information-originate",
+ NB_OP_MODIFY, no ? "false" : "true");
+
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+void cli_show_ripng_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 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);
+ install_element(RIPNG_NODE, &ripng_default_information_originate_cmd);
}
diff --git a/ripngd/ripng_cli.h b/ripngd/ripng_cli.h
index e90fb8aae..6ba75c7f4 100644
--- a/ripngd/ripng_cli.h
+++ b/ripngd/ripng_cli.h
@@ -25,5 +25,8 @@ 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);
+extern void cli_show_ripng_default_information_originate(struct vty *vty,
+ struct lyd_node *dnode,
+ bool show_defaults);
#endif /* _FRR_RIPNG_CLI_H_ */
diff --git a/ripngd/ripng_northbound.c b/ripngd/ripng_northbound.c
index f067d048e..6d837af3c 100644
--- a/ripngd/ripng_northbound.c
+++ b/ripngd/ripng_northbound.c
@@ -99,7 +99,22 @@ static int ripngd_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_ipv6 p;
+
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ default_information = yang_dnode_get_bool(dnode, NULL);
+ str2prefix_ipv6("::/0", &p);
+ if (default_information) {
+ ripng_redistribute_add(ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_DEFAULT,
+ &p, 0, NULL, 0);
+ } else {
+ ripng_redistribute_delete(ZEBRA_ROUTE_RIPNG,
+ RIPNG_ROUTE_DEFAULT, &p, 0);
+ }
+
return NB_OK;
}
@@ -524,6 +539,7 @@ const struct frr_yang_module_info frr_ripngd_info = {
{
.xpath = "/frr-ripngd:ripngd/instance/default-information-originate",
.cbs.modify = ripngd_instance_default_information_originate_modify,
+ .cbs.cli_show = cli_show_ripng_default_information_originate,
},
{
.xpath = "/frr-ripngd:ripngd/instance/default-metric",
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index 0d5ec507b..e8dc45d1f 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -2499,46 +2499,6 @@ DEFUN (show_ipv6_protocols,
}
#endif
-/* Please be carefull to use this command. */
-DEFUN (ripng_default_information_originate,
- ripng_default_information_originate_cmd,
- "default-information originate",
- "Default route information\n"
- "Distribute default route\n")
-{
- struct prefix_ipv6 p;
-
- if (!ripng->default_information) {
- ripng->default_information = 1;
-
- str2prefix_ipv6("::/0", &p);
- ripng_redistribute_add(ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_DEFAULT,
- &p, 0, NULL, 0);
- }
-
- return CMD_SUCCESS;
-}
-
-DEFUN (no_ripng_default_information_originate,
- no_ripng_default_information_originate_cmd,
- "no default-information originate",
- NO_STR
- "Default route information\n"
- "Distribute default route\n")
-{
- struct prefix_ipv6 p;
-
- if (ripng->default_information) {
- ripng->default_information = 0;
-
- str2prefix_ipv6("::/0", &p);
- ripng_redistribute_delete(ZEBRA_ROUTE_RIPNG,
- RIPNG_ROUTE_DEFAULT, &p, 0);
- }
-
- return CMD_SUCCESS;
-}
-
/* Update ECMP routes to zebra when ECMP is disabled. */
void ripng_ecmp_disable(void)
{
@@ -2589,9 +2549,6 @@ static int ripng_config_write(struct vty *vty)
if (dnode) {
nb_cli_show_dnode_cmds(vty, dnode, false);
- if (ripng->default_information)
- vty_out(vty, " default-information originate\n");
-
ripng_network_write(vty, 1);
/* RIPng default metric configuration */
@@ -2943,10 +2900,6 @@ void ripng_init()
install_element (RIPNG_NODE, &no_ripng_garbage_timer_cmd);
#endif /* 0 */
- install_element(RIPNG_NODE, &ripng_default_information_originate_cmd);
- install_element(RIPNG_NODE,
- &no_ripng_default_information_originate_cmd);
-
ripng_if_init();
ripng_debug_init();
diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h
index 9b5f89076..c9bcd8b0e 100644
--- a/ripngd/ripngd.h
+++ b/ripngd/ripngd.h
@@ -106,7 +106,6 @@ struct ripng {
unsigned long garbage_time;
int max_mtu;
int default_metric;
- int default_information;
/* Input/output buffer of RIPng. */
struct stream *ibuf;