diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2019-01-04 22:08:10 +0100 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2019-01-18 19:15:41 +0100 |
commit | c5b2b5f65cd76c76f9d1ed1a219b33469f1e8524 (patch) | |
tree | c2f64a3b4854f36aab5afd0b389f9e7692780e82 | |
parent | ripngd: make YANG operational-data VRF aware too (diff) | |
download | frr-c5b2b5f65cd76c76f9d1ed1a219b33469f1e8524.tar.xz frr-c5b2b5f65cd76c76f9d1ed1a219b33469f1e8524.zip |
ripngd: add vrf input parameter to the "clear-ripng-route" RPC
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>
-rw-r--r-- | ripngd/ripng_cli.c | 18 | ||||
-rw-r--r-- | ripngd/ripng_northbound.c | 42 | ||||
-rw-r--r-- | yang/frr-ripngd.yang | 13 |
3 files changed, 61 insertions, 12 deletions
diff --git a/ripngd/ripng_cli.c b/ripngd/ripng_cli.c index c89832d51..804fa8dea 100644 --- a/ripngd/ripng_cli.c +++ b/ripngd/ripng_cli.c @@ -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) diff --git a/ripngd/ripng_northbound.c b/ripngd/ripng_northbound.c index 3a1d52837..4b15a3aef 100644 --- a/ripngd/ripng_northbound.c +++ b/ripngd/ripng_northbound.c @@ -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; } diff --git a/yang/frr-ripngd.yang b/yang/frr-ripngd.yang index 6f7773f8b..b341b438a 100644 --- a/yang/frr-ripngd.yang +++ b/yang/frr-ripngd.yang @@ -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."; + } + } } } |