From d4455c897530483f4684c2c5583c48ecbe476fc6 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 19 Nov 2018 13:03:34 +0200 Subject: [PATCH] bgpd: Remove extcommunity-list by name without typing full rule Signed-off-by: Donatas Abraitis --- bgpd/bgp_vty.c | 80 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 8 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 85b6414e48..61769a5763 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -14984,6 +14984,7 @@ DEFUN (no_extcommunity_list_standard_all, int style = EXTCOMMUNITY_LIST_STANDARD; int direct = 0; char *cl_number_or_name = NULL; + char *str = NULL; int idx = 0; if (argv_find(argv, argc, "ip", &idx)) { @@ -14992,13 +14993,25 @@ DEFUN (no_extcommunity_list_standard_all, vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> '\n"); zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> ' being used"); } + + idx = 0; + argv_find(argv, argc, "permit", &idx); + argv_find(argv, argc, "deny", &idx); + + if (idx) { + direct = argv_find(argv, argc, "permit", &idx) + ? COMMUNITY_PERMIT + : COMMUNITY_DENY; + + idx = 0; + argv_find(argv, argc, "AA:NN", &idx); + str = argv_concat(argv, argc, idx); + } + + idx = 0; argv_find(argv, argc, "(1-99)", &idx); argv_find(argv, argc, "WORD", &idx); cl_number_or_name = argv[idx]->arg; - direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT - : COMMUNITY_DENY; - argv_find(argv, argc, "AA:NN", &idx); - char *str = argv_concat(argv, argc, idx); int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, direct, style); @@ -15026,6 +15039,22 @@ ALIAS (no_extcommunity_list_standard_all, "Specify community to accept\n" EXTCOMMUNITY_VAL_STR) +ALIAS(no_extcommunity_list_standard_all, + no_bgp_extcommunity_list_standard_all_list_cmd, + "no bgp extcommunity-list <(1-99)|standard WORD>", + NO_STR IP_STR EXTCOMMUNITY_LIST_STR + "Extended Community list number (standard)\n" + "Specify standard extcommunity-list\n" + "Community list name\n") + +ALIAS(no_extcommunity_list_standard_all, + no_ip_extcommunity_list_standard_all_list_cmd, + "no ip extcommunity-list <(1-99)|standard WORD>", + NO_STR IP_STR EXTCOMMUNITY_LIST_STR + "Extended Community list number (standard)\n" + "Specify standard extcommunity-list\n" + "Community list name\n") + DEFUN (no_extcommunity_list_expanded_all, no_bgp_extcommunity_list_expanded_all_cmd, "no bgp extcommunity-list <(100-500)|expanded WORD> LINE...", @@ -15042,6 +15071,7 @@ DEFUN (no_extcommunity_list_expanded_all, int style = EXTCOMMUNITY_LIST_EXPANDED; int direct = 0; char *cl_number_or_name = NULL; + char *str = NULL; int idx = 0; if (argv_find(argv, argc, "ip", &idx)) { @@ -15050,13 +15080,25 @@ DEFUN (no_extcommunity_list_expanded_all, vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> '\n"); zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> ' being used"); } + + idx = 0; + argv_find(argv, argc, "permit", &idx); + argv_find(argv, argc, "deny", &idx); + + if (idx) { + direct = argv_find(argv, argc, "permit", &idx) + ? COMMUNITY_PERMIT + : COMMUNITY_DENY; + + idx = 0; + argv_find(argv, argc, "LINE", &idx); + str = argv_concat(argv, argc, idx); + } + + idx = 0; argv_find(argv, argc, "(100-500)", &idx); argv_find(argv, argc, "WORD", &idx); cl_number_or_name = argv[idx]->arg; - direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT - : COMMUNITY_DENY; - argv_find(argv, argc, "LINE", &idx); - char *str = argv_concat(argv, argc, idx); int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, direct, style); @@ -15084,6 +15126,22 @@ ALIAS (no_extcommunity_list_expanded_all, "Specify community to accept\n" "An ordered list as a regular-expression\n") +ALIAS(no_extcommunity_list_expanded_all, + no_ip_extcommunity_list_expanded_all_list_cmd, + "no ip extcommunity-list <(100-500)|expanded WORD>", + NO_STR IP_STR EXTCOMMUNITY_LIST_STR + "Extended Community list number (expanded)\n" + "Specify expanded extcommunity-list\n" + "Extended Community list name\n") + +ALIAS(no_extcommunity_list_expanded_all, + no_bgp_extcommunity_list_expanded_all_list_cmd, + "no bgp extcommunity-list <(100-500)|expanded WORD>", + NO_STR IP_STR EXTCOMMUNITY_LIST_STR + "Extended Community list number (expanded)\n" + "Specify expanded extcommunity-list\n" + "Extended Community list name\n") + static void extcommunity_list_show(struct vty *vty, struct community_list *list) { struct community_entry *entry; @@ -15297,13 +15355,19 @@ static void community_list_vty(void) install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); + install_element(CONFIG_NODE, + &no_bgp_extcommunity_list_standard_all_list_cmd); install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); + install_element(CONFIG_NODE, + &no_bgp_extcommunity_list_expanded_all_list_cmd); install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); + install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_list_cmd); install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); + install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_list_cmd); install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); -- 2.39.5