]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ripngd: add vrf input parameter to the "clear-ripng-route" RPC
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 4 Jan 2019 21:08:10 +0000 (19:08 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Fri, 18 Jan 2019 18:15:41 +0000 (16:15 -0200)
Description of the new parameter (adapted from the ietf-rip module):

  "VRF name identifying a specific RIPng instance.
   This leaf is optional for the rpc.
   If it is specified, the rpc will clear all routes in the
   specified RIPng instance;
   if it is not specified, the rpc will clear all routes in
   all RIPng instances.";

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

index c89832d51d30c1ba027f13d7e68d27e12110b01e..804fa8dea670a441d88e1f57dde23120c4118935 100644 (file)
@@ -478,12 +478,24 @@ void cli_show_ipv6_ripng_split_horizon(struct vty *vty, struct lyd_node *dnode,
  */
 DEFPY (clear_ipv6_rip,
        clear_ipv6_rip_cmd,
-       "clear ipv6 ripng",
+       "clear ipv6 ripng [vrf WORD]",
        CLEAR_STR
        IPV6_STR
-       "Clear IPv6 RIP database\n")
+       "Clear IPv6 RIP database\n"
+       VRF_CMD_HELP_STR)
 {
-       return nb_cli_rpc("/frr-ripngd:clear-ripng-route", NULL, NULL);
+       struct list *input;
+
+       input = list_new();
+       if (vrf) {
+               struct yang_data *yang_vrf;
+
+               yang_vrf = yang_data_new(
+                       "/frr-ripngd:clear-ripng-route/input/vrf", vrf);
+               listnode_add(input, yang_vrf);
+       }
+
+       return nb_cli_rpc("/frr-ripngd:clear-ripng-route", input, NULL);
 }
 
 void ripng_cli_init(void)
index 3a1d52837524d2516da6e0a7de6b00f35f0e29ed..4b15a3aef7f8ca37dd9ccc557d44417283c105b9 100644 (file)
@@ -32,6 +32,7 @@
 #include "libfrr.h"
 
 #include "ripngd/ripngd.h"
+#include "ripngd/ripng_debug.h"
 #include "ripngd/ripng_route.h"
 #include "ripngd/ripng_cli.h"
 
@@ -894,21 +895,20 @@ ripngd_instance_state_routes_route_metric_get_elem(const char *xpath,
 /*
  * XPath: /frr-ripngd:clear-ripng-route
  */
-static int clear_ripng_route_rpc(const char *xpath, const struct list *input,
-                                struct list *output)
+static void clear_ripng_route(struct ripng *ripng)
 {
-       struct ripng *ripng;
        struct agg_node *rp;
-       struct ripng_info *rinfo;
-       struct list *list;
-       struct listnode *listnode;
 
-       ripng = ripng_lookup_by_vrf_id(VRF_DEFAULT);
-       if (!ripng)
-               return NB_OK;
+       if (IS_RIPNG_DEBUG_EVENT)
+               zlog_debug("Clearing all RIPng routes (VRF %s)",
+                          ripng->vrf_name);
 
        /* Clear received RIPng routes */
        for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp)) {
+               struct list *list;
+               struct listnode *listnode;
+               struct ripng_info *rinfo;
+
                list = rp->info;
                if (list == NULL)
                        continue;
@@ -935,6 +935,30 @@ static int clear_ripng_route_rpc(const char *xpath, const struct list *input,
                        agg_unlock_node(rp);
                }
        }
+}
+
+static int clear_ripng_route_rpc(const char *xpath, const struct list *input,
+                                struct list *output)
+{
+       struct ripng *ripng;
+       struct yang_data *yang_vrf;
+
+       yang_vrf = yang_data_list_find(input, "%s/%s", xpath, "input/vrf");
+       if (yang_vrf) {
+               ripng = ripng_lookup_by_vrf_name(yang_vrf->value);
+               if (ripng)
+                       clear_ripng_route(ripng);
+       } else {
+               struct vrf *vrf;
+
+               RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
+                       ripng = vrf->info;
+                       if (!ripng)
+                               continue;
+
+                       clear_ripng_route(ripng);
+               }
+       }
 
        return NB_OK;
 }
index 6f7773f8bafb6dc0030574e0813de5df5a708a91..b341b438a4d5a95cbb278cfb1ce04f4e81377bb4 100644 (file)
@@ -322,5 +322,18 @@ module frr-ripngd {
     description
       "Clears RIPng routes from the IPv6 routing table and routes
        redistributed into the RIPng protocol.";
+
+    input {
+      leaf vrf {
+        type string;
+        description
+          "VRF name identifying a specific RIPng instance.
+           This leaf is optional for the rpc.
+           If it is specified, the rpc will clear all routes in the
+           specified RIPng instance;
+           if it is not specified, the rpc will clear all routes in
+           all RIPng instances.";
+      }
+    }
   }
 }