diff options
author | Donald Sharp <sharpd@nvidia.com> | 2021-02-08 17:36:05 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2021-05-04 22:23:37 +0200 |
commit | 458133dbc5fa60f6b5c30e850d0232df37049240 (patch) | |
tree | 8f86f26338f4023b3bf038b447e2dd705b3d2c50 | |
parent | lib: Abstract parsing of distribute lists (diff) | |
download | frr-458133dbc5fa60f6b5c30e850d0232df37049240.tar.xz frr-458133dbc5fa60f6b5c30e850d0232df37049240.zip |
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>
-rw-r--r-- | lib/distribute.c | 107 | ||||
-rw-r--r-- | lib/distribute.h | 5 | ||||
-rw-r--r-- | ripd/rip_cli.c | 45 | ||||
-rw-r--r-- | ripd/ripd.c | 3 | ||||
-rw-r--r-- | ripngd/ripng_cli.c | 47 | ||||
-rw-r--r-- | ripngd/ripngd.c | 3 | ||||
-rwxr-xr-x | vtysh/extract.pl.in | 7 |
7 files changed, 102 insertions, 115 deletions
diff --git a/lib/distribute.c b/lib/distribute.c index bc402798d..6fe2c4a07 100644 --- a/lib/distribute.c +++ b/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); diff --git a/lib/distribute.h b/lib/distribute.h index 4016d3b13..8582e754d 100644 --- a/lib/distribute.h +++ b/lib/distribute.h @@ -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 diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c index 87098ece6..43e5b21fa 100644 --- a/ripd/rip_cli.c +++ b/ripd/rip_cli.c @@ -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); diff --git a/ripd/ripd.c b/ripd/ripd.c index 1c23575bf..9832c7c52 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -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(); diff --git a/ripngd/ripng_cli.c b/ripngd/ripng_cli.c index 365082f80..7e0d01408 100644 --- a/ripngd/ripng_cli.c +++ b/ripngd/ripng_cli.c @@ -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); diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 0e8314014..5a71928fb 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -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(); diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in index af974771c..37ae0ab18 100755 --- a/vtysh/extract.pl.in +++ b/vtysh/extract.pl.in @@ -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"; |