diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2016-11-17 16:33:09 -0200 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2016-11-25 11:46:06 -0200 |
| commit | d7f966abed5f822e6f90442de5ccbf848be01b64 (patch) | |
| tree | 667ae29fe754bff080b778c655944a083200afdf | |
| parent | 705e86f06eaea9676099f5a32cbed5599ae474c6 (diff) | |
ripngd: implement the "clear ipv6 ripng" vty command
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>
| -rw-r--r-- | ripngd/ripngd.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 96206e2b08..82c4877485 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -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); |
