mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 13:27:53 +00:00
lib, ripd, ripngd, vtysh: Move distribute list to correct
spot
Allow the `distribute-list...` command in ripd and ripngd to work correctly. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
parent
df19c76a53
commit
458133dbc5
107
lib/distribute.c
107
lib/distribute.c
@ -259,8 +259,8 @@ static enum distribute_type distribute_direction(const char *dir, bool v4)
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
static int distribute_list_parser(bool prefix, bool v4, const char *dir,
|
||||
const char *list, const char *ifname)
|
||||
int distribute_list_parser(bool prefix, bool v4, const char *dir,
|
||||
const char *list, const char *ifname)
|
||||
{
|
||||
enum distribute_type type = distribute_direction(dir, v4);
|
||||
struct distribute_ctx *ctx = listnode_head(dist_ctx_list);
|
||||
@ -274,49 +274,9 @@ static int distribute_list_parser(bool prefix, bool v4, const char *dir,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN (distribute_list,
|
||||
distribute_list_cmd,
|
||||
"distribute-list [prefix] WORD <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(prefix, true, argv[2 + prefix]->arg,
|
||||
argv[1 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
DEFUN (ipv6_distribute_list,
|
||||
ipv6_distribute_list_cmd,
|
||||
"ipv6 distribute-list [prefix] WORD <in|out> [WORD]",
|
||||
"IPv6\n"
|
||||
"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_parser(prefix, false, argv[3 + prefix]->arg,
|
||||
argv[2 + prefix]->arg, ifname);
|
||||
}
|
||||
static int distribute_list_no_parser(struct vty *vty, bool prefix, bool v4,
|
||||
const char *dir, const char *list,
|
||||
const char *ifname)
|
||||
int distribute_list_no_parser(struct vty *vty, bool prefix, bool v4,
|
||||
const char *dir, const char *list,
|
||||
const char *ifname)
|
||||
{
|
||||
enum distribute_type type = distribute_direction(dir, v4);
|
||||
struct distribute_ctx *ctx = listnode_head(dist_ctx_list);
|
||||
@ -336,51 +296,6 @@ static int distribute_list_no_parser(struct vty *vty, bool prefix, bool v4,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN (no_distribute_list,
|
||||
no_distribute_list_cmd,
|
||||
"no distribute-list [prefix] WORD <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(vty, prefix, true,
|
||||
argv[3 + prefix]->arg,
|
||||
argv[2 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
DEFUN (no_ipv6_distribute_list,
|
||||
no_ipv6_distribute_list_cmd,
|
||||
"no ipv6 distribute-list [prefix] WORD <in|out> [WORD]",
|
||||
NO_STR
|
||||
"IPv6\n"
|
||||
"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[3]->type == WORD_TKN) ? 1 : 0;
|
||||
|
||||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_no_parser(vty, prefix, false,
|
||||
argv[4 + prefix]->arg,
|
||||
argv[3 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
static int distribute_print(struct vty *vty, char *tab[], int is_prefix,
|
||||
enum distribute_type type, int has_print)
|
||||
{
|
||||
@ -575,18 +490,6 @@ struct distribute_ctx *distribute_list_ctx_create(struct vrf *vrf)
|
||||
/* Initialize distribute list vty commands */
|
||||
void distribute_list_init(int node)
|
||||
{
|
||||
/* vtysh command-extraction doesn't grok install_element(node, ) */
|
||||
if (node == RIP_NODE) {
|
||||
install_element(RIP_NODE, &distribute_list_cmd);
|
||||
install_element(RIP_NODE, &no_distribute_list_cmd);
|
||||
} else if (node == RIPNG_NODE) {
|
||||
install_element(RIPNG_NODE, &distribute_list_cmd);
|
||||
install_element(RIPNG_NODE, &no_distribute_list_cmd);
|
||||
/* install v6 */
|
||||
install_element(RIPNG_NODE, &ipv6_distribute_list_cmd);
|
||||
install_element(RIPNG_NODE, &no_ipv6_distribute_list_cmd);
|
||||
}
|
||||
|
||||
/* TODO: install v4 syntax command for v6 only protocols. */
|
||||
/* if (node == RIPNG_NODE) {
|
||||
* install_element (node, &ipv6_as_v4_distribute_list_all_cmd);
|
||||
|
@ -85,6 +85,11 @@ extern enum filter_type distribute_apply_in(struct interface *,
|
||||
extern enum filter_type distribute_apply_out(struct interface *,
|
||||
struct prefix *);
|
||||
|
||||
extern int distribute_list_parser(bool prefix, bool v4, const char *dir,
|
||||
const char *list, const char *ifname);
|
||||
extern int distribute_list_no_parser(struct vty *vty, bool prefix, bool v4,
|
||||
const char *dir, const char *list,
|
||||
const char *ifname);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1019,11 +1019,56 @@ DEFPY_YANG (clear_ip_rip,
|
||||
return ret;
|
||||
}
|
||||
|
||||
DEFUN (rip_distribute_list,
|
||||
rip_distribute_list_cmd,
|
||||
"distribute-list [prefix] WORD <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(prefix, true, argv[2 + prefix]->text,
|
||||
argv[1 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
DEFUN (rip_no_distribute_list,
|
||||
rip_no_distribute_list_cmd,
|
||||
"no distribute-list [prefix] WORD <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(vty, prefix, true,
|
||||
argv[3 + prefix]->text,
|
||||
argv[2 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
void rip_cli_init(void)
|
||||
{
|
||||
install_element(CONFIG_NODE, &router_rip_cmd);
|
||||
install_element(CONFIG_NODE, &no_router_rip_cmd);
|
||||
|
||||
install_element(RIP_NODE, &rip_distribute_list_cmd);
|
||||
install_element(RIP_NODE, &rip_no_distribute_list_cmd);
|
||||
|
||||
install_element(RIP_NODE, &rip_allow_ecmp_cmd);
|
||||
install_element(RIP_NODE, &rip_default_information_originate_cmd);
|
||||
install_element(RIP_NODE, &rip_default_metric_cmd);
|
||||
|
@ -3722,9 +3722,6 @@ void rip_init(void)
|
||||
prefix_list_add_hook(rip_distribute_update_all);
|
||||
prefix_list_delete_hook(rip_distribute_update_all);
|
||||
|
||||
/* Distribute list install. */
|
||||
distribute_list_init(RIP_NODE);
|
||||
|
||||
/* Route-map */
|
||||
rip_route_map_init();
|
||||
|
||||
|
@ -503,11 +503,58 @@ DEFPY_YANG (clear_ipv6_rip,
|
||||
return ret;
|
||||
}
|
||||
|
||||
DEFUN (ripng_ipv6_distribute_list,
|
||||
ripng_ipv6_distribute_list_cmd,
|
||||
"ipv6 distribute-list [prefix] WORD <in|out> [WORD]",
|
||||
"IPv6\n"
|
||||
"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_parser(prefix, false, argv[3 + prefix]->text,
|
||||
argv[2 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
DEFUN (ripng_no_ipv6_distribute_list,
|
||||
ripng_no_ipv6_distribute_list_cmd,
|
||||
"no ipv6 distribute-list [prefix] WORD <in|out> [WORD]",
|
||||
NO_STR
|
||||
"IPv6\n"
|
||||
"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[3]->type == WORD_TKN) ? 1 : 0;
|
||||
|
||||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_no_parser(vty, prefix, false,
|
||||
argv[4 + prefix]->text,
|
||||
argv[3 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
void ripng_cli_init(void)
|
||||
{
|
||||
install_element(CONFIG_NODE, &router_ripng_cmd);
|
||||
install_element(CONFIG_NODE, &no_router_ripng_cmd);
|
||||
|
||||
install_element(RIPNG_NODE, &ripng_ipv6_distribute_list_cmd);
|
||||
install_element(RIPNG_NODE, &ripng_no_ipv6_distribute_list_cmd);
|
||||
|
||||
install_element(RIPNG_NODE, &ripng_allow_ecmp_cmd);
|
||||
install_element(RIPNG_NODE, &ripng_default_information_originate_cmd);
|
||||
install_element(RIPNG_NODE, &ripng_default_metric_cmd);
|
||||
|
@ -2723,9 +2723,6 @@ void ripng_init(void)
|
||||
prefix_list_add_hook(ripng_distribute_update_all);
|
||||
prefix_list_delete_hook(ripng_distribute_update_all);
|
||||
|
||||
/* Distribute list install. */
|
||||
distribute_list_init(RIPNG_NODE);
|
||||
|
||||
/* Route-map for interface. */
|
||||
ripng_route_map_init();
|
||||
|
||||
|
@ -119,13 +119,6 @@ sub scan_file {
|
||||
$protocol = "VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD|VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_ISISD|VTYSH_FABRICD";
|
||||
}
|
||||
}
|
||||
elsif ($file =~ /lib\/distribute\.c$/) {
|
||||
if ($defun_array[1] =~ m/ipv6/) {
|
||||
$protocol = "VTYSH_RIPNGD";
|
||||
} else {
|
||||
$protocol = "VTYSH_RIPD";
|
||||
}
|
||||
}
|
||||
elsif ($file =~ /lib\/if_rmap\.c$/) {
|
||||
if ($defun_array[1] =~ m/ipv6/) {
|
||||
$protocol = "VTYSH_RIPNGD";
|
||||
|
Loading…
Reference in New Issue
Block a user