forked from Mirror/frr
eigrpd: convert distribute-list configuration to northbound
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
parent
22d1ad786f
commit
5a759f8a69
|
@ -401,6 +401,64 @@ void eigrp_cli_show_neighbor(struct vty *vty, const struct lyd_node *dnode,
|
|||
vty_out(vty, " neighbor %s\n", prefix);
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-eigrpd:eigrpd/instance/distribute-list
|
||||
*/
|
||||
DEFPY_YANG (eigrp_distribute_list,
|
||||
eigrp_distribute_list_cmd,
|
||||
"distribute-list [prefix]$prefix ACCESSLIST_NAME$name <in|out>$dir [WORD$ifname]",
|
||||
"Filter networks in routing updates\n"
|
||||
"Specify a prefix\n"
|
||||
"Access-list name\n"
|
||||
"Filter incoming routing updates\n"
|
||||
"Filter outgoing routing updates\n"
|
||||
"Interface name\n")
|
||||
{
|
||||
char xpath[XPATH_MAXLEN];
|
||||
|
||||
snprintf(xpath, sizeof(xpath),
|
||||
"./distribute-list[interface='%s']/%s/%s-list",
|
||||
ifname ? ifname : "", dir, prefix ? "prefix" : "access");
|
||||
/* nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); */
|
||||
nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, name);
|
||||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
DEFPY_YANG (eigrp_no_distribute_list,
|
||||
eigrp_no_distribute_list_cmd,
|
||||
"no distribute-list [prefix]$prefix ACCESSLIST_NAME$name <in|out>$dir [WORD$ifname]",
|
||||
NO_STR
|
||||
"Filter networks in routing updates\n"
|
||||
"Specify a prefix\n"
|
||||
"Access-list name\n"
|
||||
"Filter incoming routing updates\n"
|
||||
"Filter outgoing routing updates\n"
|
||||
"Interface name\n")
|
||||
{
|
||||
const struct lyd_node *value_node;
|
||||
char xpath[XPATH_MAXLEN];
|
||||
|
||||
snprintf(xpath, sizeof(xpath),
|
||||
"./distribute-list[interface='%s']/%s/%s-list",
|
||||
ifname ? ifname : "", dir, prefix ? "prefix" : "access");
|
||||
/*
|
||||
* See if the user has specified specific list so check it exists.
|
||||
*
|
||||
* NOTE: Other FRR CLI commands do not do this sort of verification and
|
||||
* there may be an official decision not to.
|
||||
*/
|
||||
if (name) {
|
||||
value_node = yang_dnode_getf(vty->candidate_config->dnode, "%s/%s",
|
||||
VTY_CURR_XPATH, xpath);
|
||||
if (!value_node || strcmp(name, lyd_get_value(value_node))) {
|
||||
vty_out(vty, "distribute list doesn't exist\n");
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
}
|
||||
}
|
||||
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
|
||||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-eigrpd:eigrpd/instance/redistribute
|
||||
* XPath: /frr-eigrpd:eigrpd/instance/redistribute/route-map
|
||||
|
@ -875,6 +933,8 @@ eigrp_cli_init(void)
|
|||
install_element(EIGRP_NODE, &no_eigrp_metric_weights_cmd);
|
||||
install_element(EIGRP_NODE, &eigrp_network_cmd);
|
||||
install_element(EIGRP_NODE, &eigrp_neighbor_cmd);
|
||||
install_element(EIGRP_NODE, &eigrp_distribute_list_cmd);
|
||||
install_element(EIGRP_NODE, &eigrp_no_distribute_list_cmd);
|
||||
install_element(EIGRP_NODE, &eigrp_redistribute_source_metric_cmd);
|
||||
|
||||
vrf_cmd_init(NULL);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "lib/table.h"
|
||||
#include "lib/vrf.h"
|
||||
#include "lib/zclient.h"
|
||||
#include "lib/distribute.h"
|
||||
|
||||
#include "eigrp_structs.h"
|
||||
#include "eigrpd.h"
|
||||
|
@ -701,6 +702,22 @@ static int eigrpd_instance_neighbor_destroy(struct nb_cb_destroy_args *args)
|
|||
return NB_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-eigrpd:eigrpd/instance/distribute-list
|
||||
*/
|
||||
static int eigrpd_instance_distribute_list_create(struct nb_cb_create_args *args)
|
||||
{
|
||||
struct eigrp *eigrp;
|
||||
|
||||
if (args->event != NB_EV_APPLY)
|
||||
return NB_OK;
|
||||
|
||||
eigrp = nb_running_get_entry(args->dnode, NULL, true);
|
||||
group_distribute_list_create_helper(args, eigrp->distribute_ctx);
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-eigrpd:eigrpd/instance/redistribute
|
||||
*/
|
||||
|
@ -1402,6 +1419,45 @@ const struct frr_yang_module_info frr_eigrpd_info = {
|
|||
.cli_show = eigrp_cli_show_neighbor,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-eigrpd:eigrpd/instance/distribute-list",
|
||||
.cbs = {
|
||||
.create = eigrpd_instance_distribute_list_create,
|
||||
.destroy = group_distribute_list_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-eigrpd:eigrpd/instance/distribute-list/in/access-list",
|
||||
.cbs = {
|
||||
.modify = group_distribute_list_ipv4_modify,
|
||||
.destroy = group_distribute_list_ipv4_destroy,
|
||||
.cli_show = group_distribute_list_ipv4_cli_show,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-eigrpd:eigrpd/instance/distribute-list/out/access-list",
|
||||
.cbs = {
|
||||
.modify = group_distribute_list_ipv4_modify,
|
||||
.destroy = group_distribute_list_ipv4_destroy,
|
||||
.cli_show = group_distribute_list_ipv4_cli_show,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-eigrpd:eigrpd/instance/distribute-list/in/prefix-list",
|
||||
.cbs = {
|
||||
.modify = group_distribute_list_ipv4_modify,
|
||||
.destroy = group_distribute_list_ipv4_destroy,
|
||||
.cli_show = group_distribute_list_ipv4_cli_show,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-eigrpd:eigrpd/instance/distribute-list/out/prefix-list",
|
||||
.cbs = {
|
||||
.modify = group_distribute_list_ipv4_modify,
|
||||
.destroy = group_distribute_list_ipv4_destroy,
|
||||
.cli_show = group_distribute_list_ipv4_cli_show,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-eigrpd:eigrpd/instance/redistribute",
|
||||
.cbs = {
|
||||
|
|
|
@ -1107,49 +1107,6 @@ ALIAS(no_set_tag, no_set_tag_val_cmd, "no set tag (0-65535)", NO_STR SET_STR
|
|||
"Tag value for routing protocol\n"
|
||||
"Tag value\n")
|
||||
|
||||
DEFUN (eigrp_distribute_list,
|
||||
eigrp_distribute_list_cmd,
|
||||
"distribute-list [prefix] ACCESSLIST_NAME <in|out> [WORD]",
|
||||
"Filter networks in routing updates\n"
|
||||
"Specify a prefix\n"
|
||||
"Access-list name\n"
|
||||
"Filter incoming routing updates\n"
|
||||
"Filter outgoing routing updates\n"
|
||||
"Interface name\n")
|
||||
{
|
||||
const char *ifname = NULL;
|
||||
int prefix = (argv[1]->type == WORD_TKN) ? 1 : 0;
|
||||
|
||||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_parser(NULL, prefix, true, argv[2 + prefix]->text,
|
||||
argv[1 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
DEFUN (eigrp_no_distribute_list,
|
||||
eigrp_no_distribute_list_cmd,
|
||||
"no distribute-list [prefix] ACCESSLIST_NAME <in|out> [WORD]",
|
||||
NO_STR
|
||||
"Filter networks in routing updates\n"
|
||||
"Specify a prefix\n"
|
||||
"Access-list name\n"
|
||||
"Filter incoming routing updates\n"
|
||||
"Filter outgoing routing updates\n"
|
||||
"Interface name\n")
|
||||
{
|
||||
const char *ifname = NULL;
|
||||
int prefix = (argv[2]->type == WORD_TKN) ? 1 : 0;
|
||||
|
||||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_no_parser(NULL, vty, prefix, true,
|
||||
argv[3 + prefix]->text,
|
||||
argv[2 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
|
||||
/* Route-map init */
|
||||
void eigrp_route_map_init(void)
|
||||
{
|
||||
|
@ -1158,9 +1115,6 @@ void eigrp_route_map_init(void)
|
|||
route_map_add_hook(eigrp_route_map_update);
|
||||
route_map_delete_hook(eigrp_route_map_update);
|
||||
|
||||
install_element(EIGRP_NODE, &eigrp_distribute_list_cmd);
|
||||
install_element(EIGRP_NODE, &eigrp_no_distribute_list_cmd);
|
||||
|
||||
/*route_map_install_match (&route_match_metric_cmd);
|
||||
route_map_install_match (&route_match_interface_cmd);*/
|
||||
/*route_map_install_match (&route_match_ip_next_hop_cmd);
|
||||
|
|
|
@ -22,6 +22,9 @@ module frr-eigrpd {
|
|||
import frr-route-types {
|
||||
prefix frr-route-types;
|
||||
}
|
||||
import frr-filter {
|
||||
prefix frr-filter;
|
||||
}
|
||||
|
||||
organization "FRRouting";
|
||||
contact
|
||||
|
@ -224,6 +227,8 @@ module frr-eigrpd {
|
|||
type inet:ipv4-address;
|
||||
}
|
||||
|
||||
uses frr-filter:distribute-list-group;
|
||||
|
||||
list redistribute {
|
||||
description "Redistribute routes learned from other routing protocols";
|
||||
|
||||
|
|
Loading…
Reference in a new issue