mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 09:00:55 +00:00
ripd: add vrf input parameter to the "clear-rip-route" RPC
Description of the new parameter (adapted from the ietf-rip module): "VRF name identifying a specific RIP instance. This leaf is optional for the rpc. If it is specified, the rpc will clear all routes in the specified RIP instance; if it is not specified, the rpc will clear all routes in all RIP instances."; Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
32600a9807
commit
14f17e6362
@ -983,12 +983,24 @@ void cli_show_ip_rip_authentication_key_chain(struct vty *vty,
|
||||
*/
|
||||
DEFPY (clear_ip_rip,
|
||||
clear_ip_rip_cmd,
|
||||
"clear ip rip",
|
||||
"clear ip rip [vrf WORD]",
|
||||
CLEAR_STR
|
||||
IP_STR
|
||||
"Clear IP RIP database\n")
|
||||
"Clear IP RIP database\n"
|
||||
VRF_CMD_HELP_STR)
|
||||
{
|
||||
return nb_cli_rpc("/frr-ripd:clear-rip-route", NULL, NULL);
|
||||
struct list *input;
|
||||
|
||||
input = list_new();
|
||||
if (vrf) {
|
||||
struct yang_data *yang_vrf;
|
||||
|
||||
yang_vrf = yang_data_new("/frr-ripd:clear-rip-route/input/vrf",
|
||||
vrf);
|
||||
listnode_add(input, yang_vrf);
|
||||
}
|
||||
|
||||
return nb_cli_rpc("/frr-ripd:clear-rip-route", input, NULL);
|
||||
}
|
||||
|
||||
void rip_cli_init(void)
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "libfrr.h"
|
||||
|
||||
#include "ripd/ripd.h"
|
||||
#include "ripd/rip_debug.h"
|
||||
#include "ripd/rip_cli.h"
|
||||
|
||||
/*
|
||||
@ -1351,21 +1352,19 @@ ripd_instance_state_routes_route_metric_get_elem(const char *xpath,
|
||||
/*
|
||||
* XPath: /frr-ripd:clear-rip-route
|
||||
*/
|
||||
static int clear_rip_route_rpc(const char *xpath, const struct list *input,
|
||||
struct list *output)
|
||||
static void clear_rip_route(struct rip *rip)
|
||||
{
|
||||
struct rip *rip;
|
||||
struct route_node *rp;
|
||||
struct rip_info *rinfo;
|
||||
struct list *list;
|
||||
struct listnode *listnode;
|
||||
|
||||
rip = rip_lookup_by_vrf_id(VRF_DEFAULT);
|
||||
if (!rip)
|
||||
return NB_OK;
|
||||
if (IS_RIP_DEBUG_EVENT)
|
||||
zlog_debug("Clearing all RIP routes (VRF %s)", rip->vrf_name);
|
||||
|
||||
/* Clear received RIP routes */
|
||||
for (rp = route_top(rip->table); rp; rp = route_next(rp)) {
|
||||
struct list *list;
|
||||
struct listnode *listnode;
|
||||
struct rip_info *rinfo;
|
||||
|
||||
list = rp->info;
|
||||
if (!list)
|
||||
continue;
|
||||
@ -1392,6 +1391,30 @@ static int clear_rip_route_rpc(const char *xpath, const struct list *input,
|
||||
route_unlock_node(rp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int clear_rip_route_rpc(const char *xpath, const struct list *input,
|
||||
struct list *output)
|
||||
{
|
||||
struct rip *rip;
|
||||
struct yang_data *yang_vrf;
|
||||
|
||||
yang_vrf = yang_data_list_find(input, "%s/%s", xpath, "input/vrf");
|
||||
if (yang_vrf) {
|
||||
rip = rip_lookup_by_vrf_name(yang_vrf->value);
|
||||
if (rip)
|
||||
clear_rip_route(rip);
|
||||
} else {
|
||||
struct vrf *vrf;
|
||||
|
||||
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
||||
rip = vrf->info;
|
||||
if (!rip)
|
||||
continue;
|
||||
|
||||
clear_rip_route(rip);
|
||||
}
|
||||
}
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
@ -552,6 +552,19 @@ module frr-ripd {
|
||||
description
|
||||
"Clears RIP routes from the IP routing table and routes
|
||||
redistributed into the RIP protocol.";
|
||||
|
||||
input {
|
||||
leaf vrf {
|
||||
type string;
|
||||
description
|
||||
"VRF name identifying a specific RIP instance.
|
||||
This leaf is optional for the rpc.
|
||||
If it is specified, the rpc will clear all routes in the
|
||||
specified RIP instance;
|
||||
if it is not specified, the rpc will clear all routes in
|
||||
all RIP instances.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user