Skip to content
Permalink
Browse files

bgpd: Remove community-list by name without typing full rule

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
  • Loading branch information...
ton31337 committed Nov 15, 2018
1 parent d482ae5 commit 174b5cb932006a0713fe5bf7e32c19c4130ee96f
Showing with 65 additions and 10 deletions.
  1. +65 −10 bgpd/bgp_vty.c
@@ -13986,6 +13986,7 @@ DEFUN (no_community_list_standard_all,
COMMUNITY_VAL_STR)
{
char *cl_name_or_number = NULL;
char *str = NULL;
int direct = 0;
int style = COMMUNITY_LIST_STANDARD;

@@ -13998,13 +13999,23 @@ DEFUN (no_community_list_standard_all,
zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
}

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_name_or_number = 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 = community_list_unset(bgp_clist, cl_name_or_number, str,
direct, style);
@@ -14031,6 +14042,20 @@ ALIAS (no_community_list_standard_all,
"Specify community to accept\n"
COMMUNITY_VAL_STR)

ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd,
"no bgp community-list <(1-99)|standard WORD>",
NO_STR BGP_STR COMMUNITY_LIST_STR
"Community list number (standard)\n"
"Add an standard community-list entry\n"
"Community list name\n")

ALIAS(no_community_list_standard_all, no_ip_community_list_standard_all_list_cmd,
"no ip community-list <(1-99)|standard WORD>",
NO_STR BGP_STR COMMUNITY_LIST_STR
"Community list number (standard)\n"
"Add an standard community-list entry\n"
"Community list name\n")

/*community-list expanded */
DEFUN (community_list_expanded_all,
bgp_community_list_expanded_all_cmd,
@@ -14103,23 +14128,35 @@ DEFUN (no_community_list_expanded_all,
COMMUNITY_VAL_STR)
{
char *cl_name_or_number = NULL;
char *str = NULL;
int direct = 0;
int style = COMMUNITY_LIST_EXPANDED;

int idx = 0;
if (argv_find(argv, argc, "ip", &idx)) {
vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n");
vty_out(vty, "if you are using this please migrate to the below command.\n");
vty_out(vty, "'no community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
zlog_warn("Deprecated option: 'no community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
}

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, "(100-500)", &idx);
argv_find(argv, argc, "WORD", &idx);
cl_name_or_number = 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 = community_list_unset(bgp_clist, cl_name_or_number, str,
direct, style);
@@ -14147,6 +14184,20 @@ ALIAS (no_community_list_expanded_all,
"Specify community to accept\n"
COMMUNITY_VAL_STR)

ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd,
"no bgp community-list <(100-500)|expanded WORD>",
NO_STR IP_STR COMMUNITY_LIST_STR
"Community list number (expanded)\n"
"Add an expanded community-list entry\n"
"Community list name\n")

ALIAS(no_community_list_expanded_all, no_ip_community_list_expanded_all_list_cmd,
"no ip community-list <(100-500)|expanded WORD>",
NO_STR IP_STR COMMUNITY_LIST_STR
"Community list number (expanded)\n"
"Add an expanded community-list entry\n"
"Community list name\n")

/* Return configuration string of community-list entry. */
static const char *community_list_config_str(struct community_entry *entry)
{
@@ -15227,13 +15278,17 @@ static void community_list_vty(void)
install_element(CONFIG_NODE, &bgp_community_list_standard_cmd);
install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd);
install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd);
install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd);
install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd);
install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd);
install_element(VIEW_NODE, &show_bgp_community_list_cmd);
install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd);
install_element(CONFIG_NODE, &ip_community_list_standard_cmd);
install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd);
install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
install_element(CONFIG_NODE, &no_ip_community_list_standard_all_list_cmd);
install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_list_cmd);
install_element(VIEW_NODE, &show_ip_community_list_cmd);
install_element(VIEW_NODE, &show_ip_community_list_arg_cmd);

0 comments on commit 174b5cb

Please sign in to comment.
You can’t perform that action at this time.