diff options
Diffstat (limited to 'bgpd/bgp_clist.c')
| -rw-r--r-- | bgpd/bgp_clist.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index cf4d44ea22..28b22997ed 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -972,7 +972,7 @@ int community_list_set(struct community_list_handler *ch, const char *name, entry = community_entry_new(); entry->direct = direct; entry->style = style; - entry->any = (str ? 0 : 1); + entry->any = (str ? false : true); entry->u.com = com; entry->reg = regex; entry->seq = seqnum; @@ -1090,26 +1090,34 @@ struct lcommunity *lcommunity_list_match_delete(struct lcommunity *lcom, /* Helper to check if every octet do not exceed UINT_MAX */ static bool lcommunity_list_valid(const char *community) { - int octets = 0; - char **splits; - int num; + int octets; + char **splits, **communities; + int num, num_communities; - frrstr_split(community, ":", &splits, &num); + frrstr_split(community, " ", &communities, &num_communities); - for (int i = 0; i < num; i++) { - if (strtoul(splits[i], NULL, 10) > UINT_MAX) - return false; + for (int j = 0; j < num_communities; j++) { + octets = 0; + frrstr_split(communities[j], ":", &splits, &num); + + for (int i = 0; i < num; i++) { + if (strtoul(splits[i], NULL, 10) > UINT_MAX) + return false; - if (strlen(splits[i]) == 0) + if (strlen(splits[i]) == 0) + return false; + + octets++; + XFREE(MTYPE_TMP, splits[i]); + } + XFREE(MTYPE_TMP, splits); + + if (octets < 3) return false; - octets++; - XFREE(MTYPE_TMP, splits[i]); + XFREE(MTYPE_TMP, communities[j]); } - XFREE(MTYPE_TMP, splits); - - if (octets < 3) - return false; + XFREE(MTYPE_TMP, communities); return true; } @@ -1161,7 +1169,7 @@ int lcommunity_list_set(struct community_list_handler *ch, const char *name, entry = community_entry_new(); entry->direct = direct; entry->style = style; - entry->any = (str ? 0 : 1); + entry->any = (str ? false : true); entry->u.lcom = lcom; entry->reg = regex; entry->seq = seqnum; @@ -1282,7 +1290,7 @@ int extcommunity_list_set(struct community_list_handler *ch, const char *name, entry = community_entry_new(); entry->direct = direct; entry->style = style; - entry->any = 0; + entry->any = false; if (ecom) entry->config = ecommunity_ecom2str( ecom, ECOMMUNITY_FORMAT_COMMUNITY_LIST, 0); |
