]> git.proxmox.com Git - mirror_frr.git/commitdiff
ripngd: implement the 'clear-ripng-route' YANG RPC
authorRenato Westphal <renato@opensourcerouting.org>
Thu, 29 Nov 2018 15:24:26 +0000 (13:24 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 3 Dec 2018 15:47:58 +0000 (13:47 -0200)
The "clear ipv6 ripng" command was turned into a YANG RPC so that
other northbound plugins can execute it as well. This RPC closely
matches the 'clear-rip-route' RPC from the ietf-rip module.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ripngd/ripng_cli.c
ripngd/ripng_northbound.c
ripngd/ripngd.c
ripngd/ripngd.h

index 431c1ee3248585d52c203140727417dcf3d2a50e..a187e80fd7a4691a79e507ad6ada5a1c6900f766 100644 (file)
@@ -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);
 }
index 040bbf5d70daccf97ae0d2bc4e5cb2ee1fad61ab..6ec80982be26d41d555b9afb3cec0a226aafe6e3 100644 (file)
@@ -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;
 }
 
index 1ac6a4d6b9672ae97b7f2f6951180f447103e2c4..58d83febfb40ce2296582f97644ce58d72446c14 100644 (file)
@@ -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
index 8319cf9c1e81239040a608f67b2f593c823400c9..fc29b9d0d944a2dae36a6f2566bc46c98687d086 100644 (file)
@@ -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);