summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ripngd/ripng_cli.c15
-rw-r--r--ripngd/ripng_northbound.c36
-rw-r--r--ripngd/ripngd.c48
-rw-r--r--ripngd/ripngd.h1
4 files changed, 52 insertions, 48 deletions
diff --git a/ripngd/ripng_cli.c b/ripngd/ripng_cli.c
index 431c1ee324..a187e80fd7 100644
--- a/ripngd/ripng_cli.c
+++ b/ripngd/ripng_cli.c
@@ -451,6 +451,19 @@ void cli_show_ipv6_ripng_split_horizon(struct vty *vty, struct lyd_node *dnode,
}
}
+/*
+ * XPath: /frr-ripngd:clear-ripng-route
+ */
+DEFPY (clear_ipv6_rip,
+ clear_ipv6_rip_cmd,
+ "clear ipv6 ripng",
+ CLEAR_STR
+ IPV6_STR
+ "Clear IPv6 RIP database\n")
+{
+ return nb_cli_rpc("/frr-ripngd:clear-ripng-route", NULL, NULL);
+}
+
void ripng_cli_init(void)
{
install_element(CONFIG_NODE, &router_ripng_cmd);
@@ -471,4 +484,6 @@ void ripng_cli_init(void)
install_element(RIPNG_NODE, &no_ripng_timers_cmd);
install_element(INTERFACE_NODE, &ipv6_ripng_split_horizon_cmd);
+
+ install_element(ENABLE_NODE, &clear_ipv6_rip_cmd);
}
diff --git a/ripngd/ripng_northbound.c b/ripngd/ripng_northbound.c
index 040bbf5d70..6ec80982be 100644
--- a/ripngd/ripng_northbound.c
+++ b/ripngd/ripng_northbound.c
@@ -27,6 +27,7 @@
#include "table.h"
#include "command.h"
#include "routemap.h"
+#include "agg_table.h"
#include "northbound.h"
#include "libfrr.h"
@@ -717,7 +718,40 @@ ripngd_state_routes_route_metric_get_elem(const char *xpath,
static int clear_ripng_route_rpc(const char *xpath, const struct list *input,
struct list *output)
{
- /* TODO: implement me. */
+ struct agg_node *rp;
+ struct ripng_info *rinfo;
+ struct list *list;
+ struct listnode *listnode;
+
+ /* Clear received RIPng routes */
+ for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp)) {
+ list = rp->info;
+ if (list == NULL)
+ continue;
+
+ for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
+ if (!ripng_route_rte(rinfo))
+ continue;
+
+ if (CHECK_FLAG(rinfo->flags, RIPNG_RTF_FIB))
+ ripng_zebra_ipv6_delete(rp);
+ break;
+ }
+
+ if (rinfo) {
+ RIPNG_TIMER_OFF(rinfo->t_timeout);
+ RIPNG_TIMER_OFF(rinfo->t_garbage_collect);
+ listnode_delete(list, rinfo);
+ ripng_info_free(rinfo);
+ }
+
+ if (list_isempty(list)) {
+ list_delete(&list);
+ rp->info = NULL;
+ agg_unlock_node(rp);
+ }
+ }
+
return NB_OK;
}
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index 1ac6a4d6b9..58d83febfb 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -66,7 +66,7 @@ struct ripng_nexthop {
struct in6_addr address;
};
-static int ripng_route_rte(struct ripng_info *rinfo)
+int ripng_route_rte(struct ripng_info *rinfo)
{
return (rinfo->type == ZEBRA_ROUTE_RIPNG
&& rinfo->sub_type == RIPNG_ROUTE_RTE);
@@ -2111,50 +2111,6 @@ DEFUN (show_ipv6_ripng_status,
return CMD_SUCCESS;
}
-DEFUN (clear_ipv6_rip,
- clear_ipv6_rip_cmd,
- "clear ipv6 ripng",
- CLEAR_STR
- IPV6_STR
- "Clear IPv6 RIP database\n")
-{
- struct agg_node *rp;
- struct ripng_info *rinfo;
- struct list *list;
- struct listnode *listnode;
-
- /* Clear received RIPng routes */
- for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp)) {
- list = rp->info;
- if (list == NULL)
- continue;
-
- for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
- if (!ripng_route_rte(rinfo))
- continue;
-
- if (CHECK_FLAG(rinfo->flags, RIPNG_RTF_FIB))
- ripng_zebra_ipv6_delete(rp);
- break;
- }
-
- if (rinfo) {
- RIPNG_TIMER_OFF(rinfo->t_timeout);
- RIPNG_TIMER_OFF(rinfo->t_garbage_collect);
- listnode_delete(list, rinfo);
- ripng_info_free(rinfo);
- }
-
- if (list_isempty(list)) {
- list_delete(&list);
- rp->info = NULL;
- agg_unlock_node(rp);
- }
- }
-
- return CMD_SUCCESS;
-}
-
#if 0
/* RIPng update timer setup. */
DEFUN (ripng_update_timer,
@@ -2580,8 +2536,6 @@ void ripng_init()
install_element(VIEW_NODE, &show_ipv6_ripng_cmd);
install_element(VIEW_NODE, &show_ipv6_ripng_status_cmd);
- install_element(ENABLE_NODE, &clear_ipv6_rip_cmd);
-
install_default(RIPNG_NODE);
#if 0
diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h
index 8319cf9c1e..fc29b9d0d9 100644
--- a/ripngd/ripngd.h
+++ b/ripngd/ripngd.h
@@ -372,6 +372,7 @@ extern int ripng_offset_list_apply_out(struct prefix_ipv6 *, struct interface *,
extern void ripng_offset_init(void);
extern void ripng_offset_clean(void);
+extern int ripng_route_rte(struct ripng_info *rinfo);
extern struct ripng_info *ripng_info_new(void);
extern void ripng_info_free(struct ripng_info *rinfo);
extern void ripng_event(enum ripng_event, int);