]> git.puffer.fish Git - mirror/frr.git/commitdiff
ripngd: implement the "clear ipv6 ripng" vty command
authorRenato Westphal <renato@opensourcerouting.org>
Thu, 17 Nov 2016 18:33:09 +0000 (16:33 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Fri, 25 Nov 2016 13:46:06 +0000 (11:46 -0200)
This command deletes all received routes from the RIPng routing table. It
should be used with caution as it can create black holes in the network
(until it reconverges). Very useful to make automated testing (e.g. ANVL)
more predictable.

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

index 96206e2b086cbd4ba9d03e56e814d1a44621697c..82c4877485215fa0f69d966960fedc8874d4c089 100644 (file)
@@ -2170,6 +2170,54 @@ 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")
+{
+  struct route_node *rp;
+  struct ripng_info *rinfo;
+  struct list *list;
+  struct listnode *listnode;
+
+  /* Clear received RIPng routes */
+  for (rp = route_top (ripng->table); rp; rp = 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_free (list);
+         rp->info = NULL;
+         route_unlock_node (rp);
+       }
+    }
+
+  return CMD_SUCCESS;
+}
+
 DEFUN (router_ripng,
        router_ripng_cmd,
        "router ripng",
@@ -3047,6 +3095,8 @@ 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_element (CONFIG_NODE, &router_ripng_cmd);
   install_element (CONFIG_NODE, &no_router_ripng_cmd);