diff options
-rw-r--r-- | bgpd/ChangeLog | 5 | ||||
-rw-r--r-- | bgpd/bgp_clist.c | 323 | ||||
-rw-r--r-- | bgpd/bgp_clist.h | 10 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 28 | ||||
-rw-r--r-- | bgpd/bgp_routemap.c | 24 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 268 |
6 files changed, 272 insertions, 386 deletions
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog index 0e2d5282..c1ca177c 100644 --- a/bgpd/ChangeLog +++ b/bgpd/ChangeLog @@ -1,5 +1,10 @@ 2005-02-02 Akihiro Mizutani <mizutani@net-chef.net> + * bgp_clist.[ch], bgp_route.c, bgp_routemap.c, bgp_vty.c: + community-list cleanup. + +2005-02-02 Akihiro Mizutani <mizutani@net-chef.net> + * bgp_route.c, bgp_vty.c, bgp_zebra.c, bgpd.[ch]: "enforce-multihop" -> "disable-connected-check". diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index 572d11c9..b36f2341 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -34,20 +34,16 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA /* Lookup master structure for community-list or extcommunity-list. */ struct community_list_master * -community_list_master_lookup (struct community_list_handler *ch, int style) +community_list_master_lookup (struct community_list_handler *ch, int master) { if (ch) - switch (style) + switch (master) { - case COMMUNITY_LIST_STANDARD: - case COMMUNITY_LIST_EXPANDED: - case COMMUNITY_LIST_AUTO: - return &ch->community_list; - break; - case EXTCOMMUNITY_LIST_STANDARD: - case EXTCOMMUNITY_LIST_EXPANDED: - case EXTCOMMUNITY_LIST_AUTO: - return &ch->extcommunity_list; + case COMMUNITY_LIST_MASTER: + return &ch->community_list; + break; + case EXTCOMMUNITY_LIST_MASTER: + return &ch->extcommunity_list; } return NULL; } @@ -115,7 +111,7 @@ community_list_free (struct community_list *list) struct community_list * community_list_insert (struct community_list_handler *ch, - const char *name, int style) + const char *name, int master) { size_t i; long number; @@ -125,7 +121,7 @@ community_list_insert (struct community_list_handler *ch, struct community_list_master *cm; /* Lookup community-list master. */ - cm = community_list_master_lookup (ch, style); + cm = community_list_master_lookup (ch, master); if (!cm) return NULL; @@ -209,7 +205,7 @@ community_list_insert (struct community_list_handler *ch, struct community_list * community_list_lookup (struct community_list_handler *ch, - const char *name, int style) + const char *name, int master) { struct community_list *list; struct community_list_master *cm; @@ -217,7 +213,7 @@ community_list_lookup (struct community_list_handler *ch, if (!name) return NULL; - cm = community_list_master_lookup (ch, style); + cm = community_list_master_lookup (ch, master); if (!cm) return NULL; @@ -232,14 +228,14 @@ community_list_lookup (struct community_list_handler *ch, } struct community_list * -community_list_get (struct community_list_handler *ch, - const char *name, int style) +community_list_get (struct community_list_handler *ch, + const char *name, int master) { struct community_list *list; - list = community_list_lookup (ch, name, style); + list = community_list_lookup (ch, name, master); if (!list) - list = community_list_insert (ch, name, style); + list = community_list_insert (ch, name, master); return list; } @@ -609,15 +605,13 @@ int community_list_set (struct community_list_handler *ch, const char *name, const char *str, int direct, int style) { - struct community_entry *entry; + struct community_entry *entry = NULL; struct community_list *list; - struct community *com; - regex_t *regex; - - entry = NULL; + struct community *com = NULL; + regex_t *regex = NULL; /* Get community list. */ - list = community_list_get (ch, name, style); + list = community_list_get (ch, name, COMMUNITY_LIST_MASTER); /* When community-list already has entry, new entry should have same style. If you want to have mixed style community-list, you can @@ -628,68 +622,33 @@ community_list_set (struct community_list_handler *ch, first = list->head; - if (style == COMMUNITY_LIST_AUTO) - style = first->style; - else if (style != first->style) - { - return (first->style == COMMUNITY_LIST_STANDARD - ? COMMUNITY_LIST_ERR_STANDARD_CONFLICT - : COMMUNITY_LIST_ERR_EXPANDED_CONFLICT); - } + if (style != first->style) + { + return (first->style == COMMUNITY_LIST_STANDARD + ? COMMUNITY_LIST_ERR_STANDARD_CONFLICT + : COMMUNITY_LIST_ERR_EXPANDED_CONFLICT); + } } - /* When str is NULL, it is matches any. */ - if (!str) + if (str) { - entry = community_entry_new (); - entry->direct = direct; - entry->any = 1; - if (style == COMMUNITY_LIST_AUTO) - entry->style = COMMUNITY_LIST_STANDARD; + if (style == COMMUNITY_LIST_STANDARD) + com = community_str2com (str); else - entry->style = style; - } - else - { - /* Standard community-list parse. String must be converted into - community structure without problem. */ - if (style == COMMUNITY_LIST_STANDARD || style == COMMUNITY_LIST_AUTO) - { - com = community_str2com (str); - if (com) - { - entry = community_entry_new (); - entry->u.com = com; - entry->direct = direct; - entry->style = COMMUNITY_LIST_STANDARD; - } - else if (style == COMMUNITY_LIST_STANDARD) - return COMMUNITY_LIST_ERR_MALFORMED_VAL; + regex = bgp_regcomp (str); - /* We can't convert string into communities value. When - community-list type is auto, fall dawn to regular expression - match. */ - } - - /* Expanded community-list parse. String may include regular - expression. */ - if (!entry && (style == COMMUNITY_LIST_EXPANDED - || style == COMMUNITY_LIST_AUTO)) - { - regex = bgp_regcomp (str); - if (regex) - { - entry = community_entry_new (); - entry->reg = regex; - entry->config = XSTRDUP (MTYPE_COMMUNITY_LIST_CONFIG, str); - entry->direct = direct; - entry->style = COMMUNITY_LIST_EXPANDED; - } - else - return COMMUNITY_LIST_ERR_MALFORMED_VAL; - } + if (! com && ! regex) + return COMMUNITY_LIST_ERR_MALFORMED_VAL; } + entry = community_entry_new (); + entry->direct = direct; + entry->style = style; + entry->any = (str ? 0 : 1); + entry->u.com = com; + entry->reg = regex; + entry->config = (regex ? XSTRDUP (MTYPE_COMMUNITY_LIST_CONFIG, str) : NULL); + /* Do not put duplicated community entry. */ if (community_list_dup_check (list, entry)) community_entry_free (entry); @@ -706,15 +665,13 @@ community_list_unset (struct community_list_handler *ch, const char *name, const char *str, int direct, int style) { - struct community_entry *entry; + struct community_entry *entry = NULL; struct community_list *list; - struct community *com; - regex_t *regex; - - entry = NULL; + struct community *com = NULL; + regex_t *regex = NULL; /* Lookup community list. */ - list = community_list_lookup (ch, name, style); + list = community_list_lookup (ch, name, COMMUNITY_LIST_MASTER); if (list == NULL) return COMMUNITY_LIST_ERR_CANT_FIND_LIST; @@ -725,37 +682,23 @@ community_list_unset (struct community_list_handler *ch, return 0; } - /* Community list string is specified. Lookup entry from community - list. */ - if (style == COMMUNITY_LIST_STANDARD || style == COMMUNITY_LIST_AUTO) - { - com = community_str2com (str); - if (com) - { - entry = community_list_entry_lookup (list, com, direct); - community_free (com); - } - else if (style == COMMUNITY_LIST_STANDARD) - return COMMUNITY_LIST_ERR_MALFORMED_VAL; + if (style == COMMUNITY_LIST_STANDARD) + com = community_str2com (str); + else + regex = bgp_regcomp (str); - /* If we can't convert string into community and community-list - type is auto, fall dawn to expanded community-list. */ - } + if (! com && ! regex) + return COMMUNITY_LIST_ERR_MALFORMED_VAL; - /* Expanded community-list parse. String may include regular - expression. */ - if (!entry - && (style == COMMUNITY_LIST_EXPANDED || style == COMMUNITY_LIST_AUTO)) - { - regex = bgp_regcomp (str); - if (regex) - { - entry = community_list_entry_lookup (list, str, direct); - bgp_regex_free (regex); - } - else - return COMMUNITY_LIST_ERR_MALFORMED_VAL; - } + if (com) + entry = community_list_entry_lookup (list, com, direct); + else + entry = community_list_entry_lookup (list, str, direct); + + if (com) + community_free (com); + if (regex) + bgp_regex_free (regex); if (!entry) return COMMUNITY_LIST_ERR_CANT_FIND_LIST; @@ -771,15 +714,15 @@ extcommunity_list_set (struct community_list_handler *ch, const char *name, const char *str, int direct, int style) { - struct community_entry *entry; + struct community_entry *entry = NULL; struct community_list *list; - struct ecommunity *ecom; - regex_t *regex; + struct ecommunity *ecom = NULL; + regex_t *regex = NULL; entry = NULL; /* Get community list. */ - list = community_list_get (ch, name, style); + list = community_list_get (ch, name, EXTCOMMUNITY_LIST_MASTER); /* When community-list already has entry, new entry should have same style. If you want to have mixed style community-list, you can @@ -790,75 +733,41 @@ extcommunity_list_set (struct community_list_handler *ch, first = list->head; - if (style == EXTCOMMUNITY_LIST_AUTO) - style = first->style; - else if (style != first->style) - { - return (first->style == EXTCOMMUNITY_LIST_STANDARD - ? COMMUNITY_LIST_ERR_STANDARD_CONFLICT - : COMMUNITY_LIST_ERR_EXPANDED_CONFLICT); - } + if (style != first->style) + { + return (first->style == EXTCOMMUNITY_LIST_STANDARD + ? COMMUNITY_LIST_ERR_STANDARD_CONFLICT + : COMMUNITY_LIST_ERR_EXPANDED_CONFLICT); + } } - /* When str is NULL, it is matches any. */ - if (!str) + if (str) { - entry = community_entry_new (); - entry->direct = direct; - entry->any = 1; - if (style == EXTCOMMUNITY_LIST_AUTO) - entry->style = EXTCOMMUNITY_LIST_STANDARD; + if (style == EXTCOMMUNITY_LIST_STANDARD) + ecom = ecommunity_str2com (str, 0, 1); else - entry->style = style; - } - else - { - /* Standard extcommunity-list parse. String is converted into - ecommunity structure. */ - if (style == EXTCOMMUNITY_LIST_STANDARD - || style == EXTCOMMUNITY_LIST_AUTO) - { - /* Type is unknown. String includes keyword. */ - ecom = ecommunity_str2com (str, 0, 1); - if (ecom) - { - entry = community_entry_new (); - entry->config - = - ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_COMMUNITY_LIST); - ecom->str = - ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_DISPLAY); - entry->u.ecom = ecom; - entry->direct = direct; - entry->style = EXTCOMMUNITY_LIST_STANDARD; - } - else if (style == EXTCOMMUNITY_LIST_STANDARD) - return COMMUNITY_LIST_ERR_MALFORMED_VAL; + regex = bgp_regcomp (str); - /* We can't convert string into communities value. When - community-list type is auto, fall dawn to regular expression - match. */ - } - - /* Expanded extcommunity-list parse. String may include regular - expression. */ - if (!entry && (style == EXTCOMMUNITY_LIST_EXPANDED - || style == EXTCOMMUNITY_LIST_AUTO)) - { - regex = bgp_regcomp (str); - if (regex) - { - entry = community_entry_new (); - entry->reg = regex; - entry->config = XSTRDUP (MTYPE_COMMUNITY_LIST_CONFIG, str); - entry->direct = direct; - entry->style = EXTCOMMUNITY_LIST_EXPANDED; - } - else - return COMMUNITY_LIST_ERR_MALFORMED_VAL; - } + if (! ecom && ! regex) + return COMMUNITY_LIST_ERR_MALFORMED_VAL; } + if (ecom) + ecom->str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_DISPLAY); + + entry = community_entry_new (); + entry->direct = direct; + entry->style = style; + entry->any = (str ? 0 : 1); + if (ecom) + entry->config = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_COMMUNITY_LIST); + else if (regex) + entry->config = XSTRDUP (MTYPE_COMMUNITY_LIST_CONFIG, str); + else + entry->config = NULL; + entry->u.ecom = ecom; + entry->reg = regex; + /* Do not put duplicated community entry. */ if (community_list_dup_check (list, entry)) community_entry_free (entry); @@ -875,15 +784,13 @@ extcommunity_list_unset (struct community_list_handler *ch, const char *name, const char *str, int direct, int style) { - struct community_entry *entry; + struct community_entry *entry = NULL; struct community_list *list; struct ecommunity *ecom = NULL; - regex_t *regex; - - entry = NULL; + regex_t *regex = NULL; /* Lookup extcommunity list. */ - list = community_list_lookup (ch, name, style); + list = community_list_lookup (ch, name, EXTCOMMUNITY_LIST_MASTER); if (list == NULL) return COMMUNITY_LIST_ERR_CANT_FIND_LIST; @@ -894,37 +801,23 @@ extcommunity_list_unset (struct community_list_handler *ch, return 0; } - /* Community list string is specified. Lookup entry from community - list. */ - if (style == EXTCOMMUNITY_LIST_STANDARD || style == EXTCOMMUNITY_LIST_AUTO) - { - ecom = ecommunity_str2com (str, 0, 1); - if (ecom) - { - entry = community_list_entry_lookup (list, ecom, direct); - ecommunity_free (ecom); - } - else if (style == COMMUNITY_LIST_STANDARD) - return COMMUNITY_LIST_ERR_MALFORMED_VAL; + if (style == EXTCOMMUNITY_LIST_STANDARD) + ecom = ecommunity_str2com (str, 0, 1); + else + regex = bgp_regcomp (str); - /* If we can't convert string into community and community-list - type is auto, fall dawn to expanded community-list. */ - } + if (! ecom && ! regex) + return COMMUNITY_LIST_ERR_MALFORMED_VAL; - /* Expanded community-list parse. String may include regular - expression. */ - if (!entry - && (style == COMMUNITY_LIST_EXPANDED || style == COMMUNITY_LIST_AUTO)) - { - regex = bgp_regcomp (str); - if (regex) - { - entry = community_list_entry_lookup (list, str, direct); - bgp_regex_free (regex); - } - else - return COMMUNITY_LIST_ERR_MALFORMED_VAL; - } + if (ecom) + entry = community_list_entry_lookup (list, ecom, direct); + else + entry = community_list_entry_lookup (list, str, direct); + + if (ecom) + ecommunity_free (ecom); + if (regex) + bgp_regex_free (regex); if (!entry) return COMMUNITY_LIST_ERR_CANT_FIND_LIST; diff --git a/bgpd/bgp_clist.h b/bgpd/bgp_clist.h index 11db2d71..6f1faf0b 100644 --- a/bgpd/bgp_clist.h +++ b/bgpd/bgp_clist.h @@ -18,6 +18,10 @@ along with GNU Zebra; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Master Community-list. */ +#define COMMUNITY_LIST_MASTER 0 +#define EXTCOMMUNITY_LIST_MASTER 1 + /* Community-list deny and permit. */ #define COMMUNITY_DENY 0 #define COMMUNITY_PERMIT 1 @@ -29,10 +33,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA /* Community-list entry types. */ #define COMMUNITY_LIST_STANDARD 0 /* Standard community-list. */ #define COMMUNITY_LIST_EXPANDED 1 /* Expanded community-list. */ -#define COMMUNITY_LIST_AUTO 2 /* Automatically detected. */ -#define EXTCOMMUNITY_LIST_STANDARD 3 /* Standard extcommunity-list. */ -#define EXTCOMMUNITY_LIST_EXPANDED 4 /* Expanded extcommunity-list. */ -#define EXTCOMMUNITY_LIST_AUTO 5 /* Automatically detected. */ +#define EXTCOMMUNITY_LIST_STANDARD 2 /* Standard extcommunity-list. */ +#define EXTCOMMUNITY_LIST_EXPANDED 3 /* Expanded extcommunity-list. */ /* Community-list. */ struct community_list diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index a3be9f0d..156120b8 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7767,7 +7767,7 @@ bgp_show_community_list (struct vty *vty, const char *com, int exact, { struct community_list *list; - list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_AUTO); + list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); if (list == NULL) { vty_out (vty, "%% %s is not a valid community-list name%s", com, @@ -7782,11 +7782,12 @@ bgp_show_community_list (struct vty *vty, const char *com, int exact, DEFUN (show_ip_bgp_community_list, show_ip_bgp_community_list_cmd, - "show ip bgp community-list WORD", + "show ip bgp community-list (<1-500>|WORD)", SHOW_STR IP_STR BGP_STR "Display routes matching the community-list\n" + "community-list number\n" "community-list name\n") { return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); @@ -7794,7 +7795,7 @@ DEFUN (show_ip_bgp_community_list, DEFUN (show_ip_bgp_ipv4_community_list, show_ip_bgp_ipv4_community_list_cmd, - "show ip bgp ipv4 (unicast|multicast) community-list WORD", + "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", SHOW_STR IP_STR BGP_STR @@ -7802,6 +7803,7 @@ DEFUN (show_ip_bgp_ipv4_community_list, "Address Family modifier\n" "Address Family modifier\n" "Display routes matching the community-list\n" + "community-list number\n" "community-list name\n") { if (strncmp (argv[0], "m", 1) == 0) @@ -7812,11 +7814,12 @@ DEFUN (show_ip_bgp_ipv4_community_list, DEFUN (show_ip_bgp_community_list_exact, show_ip_bgp_community_list_exact_cmd, - "show ip bgp community-list WORD exact-match", + "show ip bgp community-list (<1-500>|WORD) exact-match", SHOW_STR IP_STR BGP_STR "Display routes matching the community-list\n" + "community-list number\n" "community-list name\n" "Exact match of the communities\n") { @@ -7825,7 +7828,7 @@ DEFUN (show_ip_bgp_community_list_exact, DEFUN (show_ip_bgp_ipv4_community_list_exact, show_ip_bgp_ipv4_community_list_exact_cmd, - "show ip bgp ipv4 (unicast|multicast) community-list WORD exact-match", + "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", SHOW_STR IP_STR BGP_STR @@ -7833,6 +7836,7 @@ DEFUN (show_ip_bgp_ipv4_community_list_exact, "Address Family modifier\n" "Address Family modifier\n" "Display routes matching the community-list\n" + "community-list number\n" "community-list name\n" "Exact match of the communities\n") { @@ -7845,10 +7849,11 @@ DEFUN (show_ip_bgp_ipv4_community_list_exact, #ifdef HAVE_IPV6 DEFUN (show_bgp_community_list, show_bgp_community_list_cmd, - "show bgp community-list WORD", + "show bgp community-list (<1-500>|WORD)", SHOW_STR BGP_STR "Display routes matching the community-list\n" + "community-list number\n" "community-list name\n") { return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); @@ -7856,12 +7861,13 @@ DEFUN (show_bgp_community_list, ALIAS (show_bgp_community_list, show_bgp_ipv6_community_list_cmd, - "show bgp ipv6 community-list WORD", + "show bgp ipv6 community-list (<1-500>|WORD)", SHOW_STR BGP_STR "Address family\n" "Display routes matching the community-list\n" - "community-list name\n") + "community-list number\n" + "community-list name\n"); /* old command */ DEFUN (show_ipv6_bgp_community_list, @@ -7891,10 +7897,11 @@ DEFUN (show_ipv6_mbgp_community_list, DEFUN (show_bgp_community_list_exact, show_bgp_community_list_exact_cmd, - "show bgp community-list WORD exact-match", + "show bgp community-list (<1-500>|WORD) exact-match", SHOW_STR BGP_STR "Display routes matching the community-list\n" + "community-list number\n" "community-list name\n" "Exact match of the communities\n") { @@ -7903,11 +7910,12 @@ DEFUN (show_bgp_community_list_exact, ALIAS (show_bgp_community_list_exact, show_bgp_ipv6_community_list_exact_cmd, - "show bgp ipv6 community-list WORD exact-match", + "show bgp ipv6 community-list (<1-500>|WORD) exact-match", SHOW_STR BGP_STR "Address family\n" "Display routes matching the community-list\n" + "community-list number\n" "community-list name\n" "Exact match of the communities\n") diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 76740056..73165d35 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -556,7 +556,7 @@ route_match_community (void *rule, struct prefix *prefix, bgp_info = object; rcom = rule; - list = community_list_lookup (bgp_clist, rcom->name, COMMUNITY_LIST_AUTO); + list = community_list_lookup (bgp_clist, rcom->name, COMMUNITY_LIST_MASTER); if (! list) return RMAP_NOMATCH; @@ -632,7 +632,7 @@ route_match_ecommunity (void *rule, struct prefix *prefix, bgp_info = object; list = community_list_lookup (bgp_clist, (char *) rule, - EXTCOMMUNITY_LIST_AUTO); + EXTCOMMUNITY_LIST_MASTER); if (! list) return RMAP_NOMATCH; @@ -1225,7 +1225,7 @@ struct route_map_rule_cmd route_set_community_cmd = route_set_community_free, }; -/* `set comm-list (<1-99>|<100-199>|WORD) delete' */ +/* `set comm-list (<1-99>|<100-500>|WORD) delete' */ /* For community set mechanism. */ route_map_result_t @@ -1244,7 +1244,7 @@ route_set_community_delete (void *rule, struct prefix *prefix, return RMAP_OKAY; binfo = object; - list = community_list_lookup (bgp_clist, rule, COMMUNITY_LIST_AUTO); + list = community_list_lookup (bgp_clist, rule, COMMUNITY_LIST_MASTER); old = binfo->attr->community; if (list && old) @@ -2412,7 +2412,7 @@ ALIAS (no_match_metric, DEFUN (match_community, match_community_cmd, - "match community (<1-99>|<100-199>|WORD)", + "match community (<1-99>|<100-500>|WORD)", MATCH_STR "Match BGP community list\n" "Community-list number (standard)\n" @@ -2424,7 +2424,7 @@ DEFUN (match_community, DEFUN (match_community_exact, match_community_exact_cmd, - "match community (<1-99>|<100-199>|WORD) exact-match", + "match community (<1-99>|<100-500>|WORD) exact-match", MATCH_STR "Match BGP community list\n" "Community-list number (standard)\n" @@ -2459,7 +2459,7 @@ DEFUN (no_match_community, ALIAS (no_match_community, no_match_community_val_cmd, - "no match community (<1-99>|<100-199>|WORD)", + "no match community (<1-99>|<100-500>|WORD)", NO_STR MATCH_STR "Match BGP community list\n" @@ -2469,7 +2469,7 @@ ALIAS (no_match_community, ALIAS (no_match_community, no_match_community_exact_cmd, - "no match community (<1-99>|<100-199>|WORD) exact-match", + "no match community (<1-99>|<100-500>|WORD) exact-match", NO_STR MATCH_STR "Match BGP community list\n" @@ -2480,7 +2480,7 @@ ALIAS (no_match_community, DEFUN (match_ecommunity, match_ecommunity_cmd, - "match extcommunity (<1-99>|<100-199>|WORD)", + "match extcommunity (<1-99>|<100-500>|WORD)", MATCH_STR "Match BGP/VPN extended community list\n" "Extended community-list number (standard)\n" @@ -2502,7 +2502,7 @@ DEFUN (no_match_ecommunity, ALIAS (no_match_ecommunity, no_match_ecommunity_val_cmd, - "no match extcommunity (<1-99>|<100-199>|WORD)", + "no match extcommunity (<1-99>|<100-500>|WORD)", NO_STR MATCH_STR "Match BGP/VPN extended community list\n" @@ -2913,7 +2913,7 @@ ALIAS (no_set_community, DEFUN (set_community_delete, set_community_delete_cmd, - "set comm-list (<1-99>|<100-199>|WORD) delete", + "set comm-list (<1-99>|<100-500>|WORD) delete", SET_STR "set BGP community list (for deletion)\n" "Community-list number (standard)\n" @@ -2945,7 +2945,7 @@ DEFUN (no_set_community_delete, ALIAS (no_set_community_delete, no_set_community_delete_val_cmd, - "no set comm-list (<1-99>|<100-199>|WORD) delete", + "no set comm-list (<1-99>|<100-500>|WORD) delete", NO_STR SET_STR "set BGP community list (for deletion)\n" diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 58aec8ed..412b91d7 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9597,52 +9597,40 @@ community_list_set_vty (struct vty *vty, int argc, const char **argv, return CMD_SUCCESS; } -/* Community-list delete with name. */ -int -community_list_unset_all_vty (struct vty *vty, const char *name) -{ - int ret; - - ret = community_list_unset (bgp_clist, name, NULL, 0, COMMUNITY_LIST_AUTO); - - if (ret < 0) - { - community_list_perror (vty, ret); - return CMD_WARNING; - } - return CMD_SUCCESS; -} - /* Communiyt-list entry delete. */ int -community_list_unset_vty (struct vty *vty, int argc, const char **argv, - int style) +community_list_unset_vty (struct vty *vty, int argc, const char **argv, + int style) { int ret; - int direct; - char *str; + int direct = 0; + char *str = NULL; - /* Check the list direct. */ - if (strncmp (argv[1], "p", 1) == 0) - direct = COMMUNITY_PERMIT; - else if (strncmp (argv[1], "d", 1) == 0) - direct = COMMUNITY_DENY; - else + if (argc > 1) { - vty_out (vty, "%% Matching condition must be permit or deny%s", - VTY_NEWLINE); - return CMD_WARNING; - } + /* Check the list direct. */ + if (strncmp (argv[1], "p", 1) == 0) + direct = COMMUNITY_PERMIT; + else if (strncmp (argv[1], "d", 1) == 0) + direct = COMMUNITY_DENY; + else + { + vty_out (vty, "%% Matching condition must be permit or deny%s", + VTY_NEWLINE); + return CMD_WARNING; + } - /* Concat community string argument. */ - str = argv_concat (argv, argc, 2); + /* Concat community string argument. */ + str = argv_concat (argv, argc, 2); + } /* Unset community list. */ ret = community_list_unset (bgp_clist, argv[0], str, direct, style); /* Free temporary community list string allocated by argv_concat(). */ - XFREE (MTYPE_TMP, str); + if (str) + XFREE (MTYPE_TMP, str); if (ret < 0) { @@ -9657,19 +9645,6 @@ community_list_unset_vty (struct vty *vty, int argc, const char **argv, #define COMMUNITY_LIST_STR "Add a community list entry\n" #define COMMUNITY_VAL_STR "Community number in aa:nn format or internet|local-AS|no-advertise|no-export\n" -DEFUN (ip_community_list, - ip_community_list_cmd, - "ip community-list WORD (deny|permit) .AA:NN", - IP_STR - COMMUNITY_LIST_STR - "Community list name\n" - "Specify community to reject\n" - "Specify community to accept\n" - COMMUNITY_VAL_STR) -{ - return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_AUTO, 1); -} - DEFUN (ip_community_list_standard, ip_community_list_standard_cmd, "ip community-list <1-99> (deny|permit) .AA:NN", @@ -9694,7 +9669,7 @@ ALIAS (ip_community_list_standard, DEFUN (ip_community_list_expanded, ip_community_list_expanded_cmd, - "ip community-list <100-199> (deny|permit) .LINE", + "ip community-list <100-500> (deny|permit) .LINE", IP_STR COMMUNITY_LIST_STR "Community list number (expanded)\n" @@ -9743,44 +9718,50 @@ DEFUN (ip_community_list_name_expanded, return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1); } -DEFUN (no_ip_community_list_all, - no_ip_community_list_all_cmd, - "no ip community-list (WORD|<1-99>|<100-199>)", +DEFUN (no_ip_community_list_standard_all, + no_ip_community_list_standard_all_cmd, + "no ip community-list <1-99>", + NO_STR + IP_STR + COMMUNITY_LIST_STR + "Community list number (standard)\n") +{ + return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD); +} + +DEFUN (no_ip_community_list_expanded_all, + no_ip_community_list_expanded_all_cmd, + "no ip community-list <100-500>", NO_STR IP_STR COMMUNITY_LIST_STR - "Community list name\n" - "Community list number (standard)\n" "Community list number (expanded)\n") { - return community_list_unset_all_vty (vty, argv[0]); + return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED); } -DEFUN (no_ip_community_list_name_all, - no_ip_community_list_name_all_cmd, - "no ip community-list (standard|expanded) WORD", +DEFUN (no_ip_community_list_name_standard_all, + no_ip_community_list_name_standard_all_cmd, + "no ip community-list standard WORD", NO_STR IP_STR COMMUNITY_LIST_STR "Add a standard community-list entry\n" - "Add an expanded community-list entry\n" "Community list name\n") { - return community_list_unset_all_vty (vty, argv[1]); + return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD); } -DEFUN (no_ip_community_list, - no_ip_community_list_cmd, - "no ip community-list WORD (deny|permit) .AA:NN", +DEFUN (no_ip_community_list_name_expanded_all, + no_ip_community_list_name_expanded_all_cmd, + "no ip community-list expanded WORD", NO_STR IP_STR COMMUNITY_LIST_STR - "Community list name\n" - "Specify community to reject\n" - "Specify community to accept\n" - COMMUNITY_VAL_STR) + "Add an expanded community-list entry\n" + "Community list name\n") { - return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_AUTO); + return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED); } DEFUN (no_ip_community_list_standard, @@ -9799,7 +9780,7 @@ DEFUN (no_ip_community_list_standard, DEFUN (no_ip_community_list_expanded, no_ip_community_list_expanded_cmd, - "no ip community-list <100-199> (deny|permit) .LINE", + "no ip community-list <100-500> (deny|permit) .LINE", NO_STR IP_STR COMMUNITY_LIST_STR @@ -9883,7 +9864,7 @@ DEFUN (show_ip_community_list, struct community_list *list; struct community_list_master *cm; - cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_AUTO); + cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); if (! cm) return CMD_SUCCESS; @@ -9898,7 +9879,7 @@ DEFUN (show_ip_community_list, DEFUN (show_ip_community_list_arg, show_ip_community_list_arg_cmd, - "show ip community-list (<1-199>|WORD)", + "show ip community-list (<1-500>|WORD)", SHOW_STR IP_STR "List community-list\n" @@ -9907,7 +9888,7 @@ DEFUN (show_ip_community_list_arg, { struct community_list *list; - list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_AUTO); + list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER); if (! list) { vty_out (vty, "%% Can't find communit-list%s", VTY_NEWLINE); @@ -9968,49 +9949,38 @@ extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv, } int -extcommunity_list_unset_all_vty (struct vty *vty, const char *name) +extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv, + int style) { int ret; + int direct = 0; + char *str = NULL; - ret = extcommunity_list_unset (bgp_clist, name, NULL, 0, EXTCOMMUNITY_LIST_AUTO); - - if (ret < 0) + if (argc > 1) { - community_list_perror (vty, ret); - return CMD_WARNING; - } - return CMD_SUCCESS; -} - -int -extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv, - int style) -{ - int ret; - int direct; - char *str; + /* Check the list direct. */ + if (strncmp (argv[1], "p", 1) == 0) + direct = COMMUNITY_PERMIT; + else if (strncmp (argv[1], "d", 1) == 0) + direct = COMMUNITY_DENY; + else + { + vty_out (vty, "%% Matching condition must be permit or deny%s", + VTY_NEWLINE); + return CMD_WARNING; + } - /* Check the list direct. */ - if (strncmp (argv[1], "p", 1) == 0) - direct = COMMUNITY_PERMIT; - else if (strncmp (argv[1], "d", 1) == 0) - direct = COMMUNITY_DENY; - else - { - vty_out (vty, "%% Matching condition must be permit or deny%s", - VTY_NEWLINE); - return CMD_WARNING; + /* Concat community string argument. */ + str = argv_concat (argv, argc, 2); } - /* Concat community string argument. */ - str = argv_concat (argv, argc, 2); - /* Unset community list. */ ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style); /* Free temporary community list string allocated by argv_concat(). */ - XFREE (MTYPE_TMP, str); + if (str) + XFREE (MTYPE_TMP, str); if (ret < 0) { @@ -10049,7 +10019,7 @@ ALIAS (ip_extcommunity_list_standard, DEFUN (ip_extcommunity_list_expanded, ip_extcommunity_list_expanded_cmd, - "ip extcommunity-list <100-199> (deny|permit) .LINE", + "ip extcommunity-list <100-500> (deny|permit) .LINE", IP_STR EXTCOMMUNITY_LIST_STR "Extended Community list number (expanded)\n" @@ -10098,29 +10068,50 @@ DEFUN (ip_extcommunity_list_name_expanded, return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1); } -DEFUN (no_ip_extcommunity_list_all, - no_ip_extcommunity_list_all_cmd, - "no ip extcommunity-list (<1-99>|<100-199>)", +DEFUN (no_ip_extcommunity_list_standard_all, + no_ip_extcommunity_list_standard_all_cmd, + "no ip extcommunity-list <1-99>", + NO_STR + IP_STR + EXTCOMMUNITY_LIST_STR + "Extended Community list number (standard)\n") +{ + return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD); +} + +DEFUN (no_ip_extcommunity_list_expanded_all, + no_ip_extcommunity_list_expanded_all_cmd, + "no ip extcommunity-list <100-500>", NO_STR IP_STR EXTCOMMUNITY_LIST_STR - "Extended Community list number (standard)\n" "Extended Community list number (expanded)\n") { - return extcommunity_list_unset_all_vty (vty, argv[0]); + return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED); } -DEFUN (no_ip_extcommunity_list_name_all, - no_ip_extcommunity_list_name_all_cmd, - "no ip extcommunity-list (standard|expanded) WORD", +DEFUN (no_ip_extcommunity_list_name_standard_all, + no_ip_extcommunity_list_name_standard_all_cmd, + "no ip extcommunity-list standard WORD", NO_STR IP_STR EXTCOMMUNITY_LIST_STR "Specify standard extcommunity-list\n" + "Extended Community list name\n") +{ + return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD); +} + +DEFUN (no_ip_extcommunity_list_name_expanded_all, + no_ip_extcommunity_list_name_expanded_all_cmd, + "no ip extcommunity-list expanded WORD", + NO_STR + IP_STR + EXTCOMMUNITY_LIST_STR "Specify expanded extcommunity-list\n" "Extended Community list name\n") { - return extcommunity_list_unset_all_vty (vty, argv[1]); + return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED); } DEFUN (no_ip_extcommunity_list_standard, @@ -10139,7 +10130,7 @@ DEFUN (no_ip_extcommunity_list_standard, DEFUN (no_ip_extcommunity_list_expanded, no_ip_extcommunity_list_expanded_cmd, - "no ip extcommunity-list <100-199> (deny|permit) .LINE", + "no ip extcommunity-list <100-500> (deny|permit) .LINE", NO_STR IP_STR EXTCOMMUNITY_LIST_STR @@ -10223,7 +10214,7 @@ DEFUN (show_ip_extcommunity_list, struct community_list *list; struct community_list_master *cm; - cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_AUTO); + cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); if (! cm) return CMD_SUCCESS; @@ -10238,7 +10229,7 @@ DEFUN (show_ip_extcommunity_list, DEFUN (show_ip_extcommunity_list_arg, show_ip_extcommunity_list_arg_cmd, - "show ip extcommunity-list (<1-199>|WORD)", + "show ip extcommunity-list (<1-500>|WORD)", SHOW_STR IP_STR "List extended-community list\n" @@ -10247,7 +10238,7 @@ DEFUN (show_ip_extcommunity_list_arg, { struct community_list *list; - list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_AUTO); + list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER); if (! list) { vty_out (vty, "%% Can't find extcommunit-list%s", VTY_NEWLINE); @@ -10287,23 +10278,15 @@ community_list_config_write (struct vty *vty) int write = 0; /* Community-list. */ - cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_AUTO); + cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); for (list = cm->num.head; list; list = list->next) for (entry = list->head; entry; entry = entry->next) { - if (atol (list->name) < 200) - vty_out (vty, "ip community-list %s %s %s%s", - list->name, community_direct_str (entry->direct), - community_list_config_str (entry), - VTY_NEWLINE); - else - vty_out (vty, "ip community-list %s %s %s %s%s", - entry->style == COMMUNITY_LIST_STANDARD - ? "standard" : "expanded", - list->name, community_direct_str (entry->direct), - community_list_config_str (entry), - VTY_NEWLINE); + vty_out (vty, "ip community-list %s %s %s%s", + list->name, community_direct_str (entry->direct), + community_list_config_str (entry), + VTY_NEWLINE); write++; } for (list = cm->str.head; list; list = list->next) @@ -10319,21 +10302,14 @@ community_list_config_write (struct vty *vty) } /* Extcommunity-list. */ - cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_AUTO); + cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); for (list = cm->num.head; list; list = list->next) for (entry = list->head; entry; entry = entry->next) { - if (atol (list->name) < 200) - vty_out (vty, "ip extcommunity-list %s %s %s%s", - list->name, community_direct_str (entry->direct), - community_list_config_str (entry), VTY_NEWLINE); - else - vty_out (vty, "ip extcommunity-list %s %s %s %s%s", - entry->style == EXTCOMMUNITY_LIST_STANDARD - ? "standard" : "expanded", - list->name, community_direct_str (entry->direct), - community_list_config_str (entry), VTY_NEWLINE); + vty_out (vty, "ip extcommunity-list %s %s %s%s", + list->name, community_direct_str (entry->direct), + community_list_config_str (entry), VTY_NEWLINE); write++; } for (list = cm->str.head; list; list = list->next) @@ -10362,16 +10338,16 @@ community_list_vty () install_node (&community_list_node, community_list_config_write); /* Community-list. */ - install_element (CONFIG_NODE, &ip_community_list_cmd); install_element (CONFIG_NODE, &ip_community_list_standard_cmd); install_element (CONFIG_NODE, &ip_community_list_standard2_cmd); install_element (CONFIG_NODE, &ip_community_list_expanded_cmd); install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd); install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd); install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd); - install_element (CONFIG_NODE, &no_ip_community_list_all_cmd); - install_element (CONFIG_NODE, &no_ip_community_list_name_all_cmd); - install_element (CONFIG_NODE, &no_ip_community_list_cmd); + install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd); + install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); + install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd); + install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd); install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd); install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd); install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd); @@ -10388,8 +10364,10 @@ community_list_vty () install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd); install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd); install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); - install_element (CONFIG_NODE, &no_ip_extcommunity_list_all_cmd); - install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_all_cmd); + install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); + install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); + install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd); + install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd); install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd); install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd); install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd); |