Skip to content

Commit

Permalink
Merge pull request #3344 from ton31337/fix/optional_args_for_communit…
Browse files Browse the repository at this point in the history
…y-lists

bgpd: Remove community-list by name without typing full rule
  • Loading branch information
qlyoung committed Nov 16, 2018
2 parents 6b2ddd6 + 174b5cb commit 01defa9
Showing 1 changed file with 65 additions and 10 deletions.
75 changes: 65 additions & 10 deletions bgpd/bgp_vty.c
Expand Up @@ -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;

Expand All @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 01defa9

Please sign in to comment.