1 /* Community attribute related functions.
2 * Copyright (C) 1998, 2001 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #include "bgpd/bgp_memory.h"
30 #include "bgpd/bgp_community.h"
31 #include "bgpd/bgp_community_alias.h"
33 /* Hash of community attribute. */
34 static struct hash
*comhash
;
36 /* Allocate a new communities value. */
37 static struct community
*community_new(void)
39 return XCALLOC(MTYPE_COMMUNITY
, sizeof(struct community
));
42 /* Free communities value. */
43 void community_free(struct community
**com
)
48 XFREE(MTYPE_COMMUNITY_VAL
, (*com
)->val
);
49 XFREE(MTYPE_COMMUNITY_STR
, (*com
)->str
);
52 json_object_free((*com
)->json
);
56 XFREE(MTYPE_COMMUNITY
, (*com
));
59 /* Add one community value to the community. */
60 void community_add_val(struct community
*com
, uint32_t val
)
63 com
->val
= XREALLOC(MTYPE_COMMUNITY_VAL
, com
->val
, com_length(com
));
66 memcpy(com_lastval(com
), &val
, sizeof(uint32_t));
69 /* Delete one community. */
70 void community_del_val(struct community
*com
, uint32_t *val
)
78 while (i
< com
->size
) {
79 if (memcmp(com
->val
+ i
, val
, sizeof(uint32_t)) == 0) {
80 c
= com
->size
- i
- 1;
83 memmove(com
->val
+ i
, com
->val
+ (i
+ 1),
89 com
->val
= XREALLOC(MTYPE_COMMUNITY_VAL
,
90 com
->val
, com_length(com
));
92 XFREE(MTYPE_COMMUNITY_VAL
, com
->val
);
100 /* Delete all communities listed in com2 from com1 */
101 struct community
*community_delete(struct community
*com1
,
102 struct community
*com2
)
106 while (i
< com2
->size
) {
107 community_del_val(com1
, com2
->val
+ i
);
114 /* Callback function from qsort(). */
115 static int community_compare(const void *a1
, const void *a2
)
120 memcpy(&v1
, a1
, sizeof(uint32_t));
121 memcpy(&v2
, a2
, sizeof(uint32_t));
132 bool community_include(struct community
*com
, uint32_t val
)
138 for (i
= 0; i
< com
->size
; i
++)
139 if (memcmp(&val
, com_nthval(com
, i
), sizeof(uint32_t)) == 0)
144 uint32_t community_val_get(struct community
*com
, int i
)
149 p
= (uint8_t *)com
->val
;
150 p
+= (i
* COMMUNITY_SIZE
);
152 memcpy(&val
, p
, sizeof(uint32_t));
157 /* Sort and uniq given community. */
158 struct community
*community_uniq_sort(struct community
*com
)
161 struct community
*new;
167 new = community_new();
170 for (i
= 0; i
< com
->size
; i
++) {
171 val
= community_val_get(com
, i
);
173 if (!community_include(new, val
))
174 community_add_val(new, val
);
177 qsort(new->val
, new->size
, sizeof(uint32_t), community_compare
);
182 /* Convert communities attribute to string.
184 For Well-known communities value, below keyword is used.
187 0xFFFF0000 "graceful-shutdown"
188 0xFFFF0001 "accept-own"
189 0xFFFF0002 "route-filter-translated-v4"
190 0xFFFF0003 "route-filter-v4"
191 0xFFFF0004 "route-filter-translated-v6"
192 0xFFFF0005 "route-filter-v6"
193 0xFFFF0006 "llgr-stale"
195 0xFFFF0008 "accept-own-nexthop"
196 0xFFFF029A "blackhole"
197 0xFFFFFF01 "no-export"
198 0xFFFFFF02 "no-advertise"
199 0xFFFFFF03 "local-AS"
202 For other values, "AS:VAL" format is used. */
203 static void set_community_string(struct community
*com
, bool make_json
)
212 json_object
*json_community_list
= NULL
;
213 json_object
*json_string
= NULL
;
219 com
->json
= json_object_new_object();
220 json_community_list
= json_object_new_array();
223 /* When communities attribute is empty. */
224 if (com
->size
== 0) {
225 str
= XMALLOC(MTYPE_COMMUNITY_STR
, 1);
229 json_object_string_add(com
->json
, "string", "");
230 json_object_object_add(com
->json
, "list",
231 json_community_list
);
237 /* Memory allocation is time consuming work. So we calculate
238 required string length first. */
241 for (i
= 0; i
< com
->size
; i
++) {
242 memcpy(&comval
, com_nthval(com
, i
), sizeof(uint32_t));
243 comval
= ntohl(comval
);
246 case COMMUNITY_INTERNET
:
247 len
+= strlen(" internet");
249 case COMMUNITY_GSHUT
:
250 len
+= strlen(" graceful-shutdown");
252 case COMMUNITY_ACCEPT_OWN
:
253 len
+= strlen(" accept-own");
255 case COMMUNITY_ROUTE_FILTER_TRANSLATED_v4
:
256 len
+= strlen(" route-filter-translated-v4");
258 case COMMUNITY_ROUTE_FILTER_v4
:
259 len
+= strlen(" route-filter-v4");
261 case COMMUNITY_ROUTE_FILTER_TRANSLATED_v6
:
262 len
+= strlen(" route-filter-translated-v6");
264 case COMMUNITY_ROUTE_FILTER_v6
:
265 len
+= strlen(" route-filter-v6");
267 case COMMUNITY_LLGR_STALE
:
268 len
+= strlen(" llgr-stale");
270 case COMMUNITY_NO_LLGR
:
271 len
+= strlen(" no-llgr");
273 case COMMUNITY_ACCEPT_OWN_NEXTHOP
:
274 len
+= strlen(" accept-own-nexthop");
276 case COMMUNITY_BLACKHOLE
:
277 len
+= strlen(" blackhole");
279 case COMMUNITY_NO_EXPORT
:
280 len
+= strlen(" no-export");
282 case COMMUNITY_NO_ADVERTISE
:
283 len
+= strlen(" no-advertise");
285 case COMMUNITY_LOCAL_AS
:
286 len
+= strlen(" local-AS");
288 case COMMUNITY_NO_PEER
:
289 len
+= strlen(" no-peer");
297 /* Allocate memory. */
298 str
= XCALLOC(MTYPE_COMMUNITY_STR
, len
);
301 /* Fill in string. */
302 for (i
= 0; i
< com
->size
; i
++) {
303 memcpy(&comval
, com_nthval(com
, i
), sizeof(uint32_t));
304 comval
= ntohl(comval
);
309 strlcat(str
, " ", len
);
312 case COMMUNITY_INTERNET
:
313 strlcat(str
, "internet", len
);
316 json_object_new_string("internet");
317 json_object_array_add(json_community_list
,
321 case COMMUNITY_GSHUT
:
322 strlcat(str
, "graceful-shutdown", len
);
324 json_string
= json_object_new_string(
326 json_object_array_add(json_community_list
,
330 case COMMUNITY_ACCEPT_OWN
:
331 strlcat(str
, "accept-own", len
);
333 json_string
= json_object_new_string(
335 json_object_array_add(json_community_list
,
339 case COMMUNITY_ROUTE_FILTER_TRANSLATED_v4
:
340 strlcat(str
, "route-filter-translated-v4", len
);
342 json_string
= json_object_new_string(
343 "routeFilterTranslatedV4");
344 json_object_array_add(json_community_list
,
348 case COMMUNITY_ROUTE_FILTER_v4
:
349 strlcat(str
, "route-filter-v4", len
);
351 json_string
= json_object_new_string(
353 json_object_array_add(json_community_list
,
357 case COMMUNITY_ROUTE_FILTER_TRANSLATED_v6
:
358 strlcat(str
, "route-filter-translated-v6", len
);
360 json_string
= json_object_new_string(
361 "routeFilterTranslatedV6");
362 json_object_array_add(json_community_list
,
366 case COMMUNITY_ROUTE_FILTER_v6
:
367 strlcat(str
, "route-filter-v6", len
);
369 json_string
= json_object_new_string(
371 json_object_array_add(json_community_list
,
375 case COMMUNITY_LLGR_STALE
:
376 strlcat(str
, "llgr-stale", len
);
378 json_string
= json_object_new_string(
380 json_object_array_add(json_community_list
,
384 case COMMUNITY_NO_LLGR
:
385 strlcat(str
, "no-llgr", len
);
387 json_string
= json_object_new_string(
389 json_object_array_add(json_community_list
,
393 case COMMUNITY_ACCEPT_OWN_NEXTHOP
:
394 strlcat(str
, "accept-own-nexthop", len
);
396 json_string
= json_object_new_string(
398 json_object_array_add(json_community_list
,
402 case COMMUNITY_BLACKHOLE
:
403 strlcat(str
, "blackhole", len
);
405 json_string
= json_object_new_string(
407 json_object_array_add(json_community_list
,
411 case COMMUNITY_NO_EXPORT
:
412 strlcat(str
, "no-export", len
);
415 json_object_new_string("noExport");
416 json_object_array_add(json_community_list
,
420 case COMMUNITY_NO_ADVERTISE
:
421 strlcat(str
, "no-advertise", len
);
424 json_object_new_string("noAdvertise");
425 json_object_array_add(json_community_list
,
429 case COMMUNITY_LOCAL_AS
:
430 strlcat(str
, "local-AS", len
);
432 json_string
= json_object_new_string("localAs");
433 json_object_array_add(json_community_list
,
437 case COMMUNITY_NO_PEER
:
438 strlcat(str
, "no-peer", len
);
440 json_string
= json_object_new_string("noPeer");
441 json_object_array_add(json_community_list
,
446 as
= (comval
>> 16) & 0xFFFF;
447 val
= comval
& 0xFFFF;
449 snprintf(buf
, sizeof(buf
), "%u:%d", as
, val
);
450 const char *com2alias
= bgp_community2alias(buf
);
452 strlcat(str
, com2alias
, len
);
454 json_string
= json_object_new_string(com2alias
);
455 json_object_array_add(json_community_list
,
463 json_object_string_add(com
->json
, "string", str
);
464 json_object_object_add(com
->json
, "list", json_community_list
);
469 /* Intern communities attribute. */
470 struct community
*community_intern(struct community
*com
)
472 struct community
*find
;
474 /* Assert this community structure is not interned. */
475 assert(com
->refcnt
== 0);
477 /* Lookup community hash. */
478 find
= (struct community
*)hash_get(comhash
, com
, hash_alloc_intern
);
480 /* Arguemnt com is allocated temporary. So when it is not used in
481 hash, it should be freed. */
483 community_free(&com
);
485 /* Increment refrence counter. */
490 set_community_string(find
, false);
495 /* Free community attribute. */
496 void community_unintern(struct community
**com
)
498 struct community
*ret
;
503 /* Pull off from hash. */
504 if ((*com
)->refcnt
== 0) {
505 /* Community value com must exist in hash. */
506 ret
= (struct community
*)hash_release(comhash
, *com
);
513 /* Create new community attribute. */
514 struct community
*community_parse(uint32_t *pnt
, unsigned short length
)
516 struct community tmp
;
517 struct community
*new;
519 /* If length is malformed return NULL. */
520 if (length
% COMMUNITY_SIZE
)
523 /* Make temporary community for hash look up. */
524 tmp
.size
= length
/ COMMUNITY_SIZE
;
527 new = community_uniq_sort(&tmp
);
529 return community_intern(new);
532 struct community
*community_dup(struct community
*com
)
534 struct community
*new;
536 new = XCALLOC(MTYPE_COMMUNITY
, sizeof(struct community
));
537 new->size
= com
->size
;
539 new->val
= XMALLOC(MTYPE_COMMUNITY_VAL
,
540 com
->size
* COMMUNITY_SIZE
);
541 memcpy(new->val
, com
->val
, com
->size
* COMMUNITY_SIZE
);
547 /* Retrun string representation of communities attribute. */
548 char *community_str(struct community
*com
, bool make_json
)
553 if (make_json
&& !com
->json
&& com
->str
)
554 XFREE(MTYPE_COMMUNITY_STR
, com
->str
);
557 set_community_string(com
, make_json
);
561 /* Make hash value of community attribute. This function is used by
563 unsigned int community_hash_make(const struct community
*com
)
565 uint32_t *pnt
= com
->val
;
567 return jhash2(pnt
, com
->size
, 0x43ea96c1);
570 bool community_match(const struct community
*com1
, const struct community
*com2
)
575 if (com1
== NULL
&& com2
== NULL
)
578 if (com1
== NULL
|| com2
== NULL
)
581 if (com1
->size
< com2
->size
)
584 /* Every community on com2 needs to be on com1 for this to match */
585 while (i
< com1
->size
&& j
< com2
->size
) {
586 if (memcmp(com1
->val
+ i
, com2
->val
+ j
, sizeof(uint32_t)) == 0)
597 /* If two aspath have same value then return 1 else return 0. This
598 function is used by hash package. */
599 bool community_cmp(const struct community
*com1
, const struct community
*com2
)
601 if (com1
== NULL
&& com2
== NULL
)
603 if (com1
== NULL
|| com2
== NULL
)
606 if (com1
->size
== com2
->size
)
607 if (memcmp(com1
->val
, com2
->val
, com1
->size
* COMMUNITY_SIZE
)
613 /* Add com2 to the end of com1. */
614 struct community
*community_merge(struct community
*com1
,
615 struct community
*com2
)
617 com1
->val
= XREALLOC(MTYPE_COMMUNITY_VAL
, com1
->val
,
618 (com1
->size
+ com2
->size
) * COMMUNITY_SIZE
);
620 memcpy(com1
->val
+ com1
->size
, com2
->val
, com2
->size
* COMMUNITY_SIZE
);
621 com1
->size
+= com2
->size
;
626 /* Community token enum. */
627 enum community_token
{
629 community_token_gshut
,
630 community_token_accept_own
,
631 community_token_route_filter_translated_v4
,
632 community_token_route_filter_v4
,
633 community_token_route_filter_translated_v6
,
634 community_token_route_filter_v6
,
635 community_token_llgr_stale
,
636 community_token_no_llgr
,
637 community_token_accept_own_nexthop
,
638 community_token_blackhole
,
639 community_token_no_export
,
640 community_token_no_advertise
,
641 community_token_local_as
,
642 community_token_no_peer
,
643 community_token_unknown
646 /* Helper to check if a given community is valid */
647 static bool community_valid(const char *community
)
654 frrstr_split(community
, ":", &splits
, &num
);
656 for (int i
= 0; i
< num
; i
++) {
657 if (strtoul(splits
[i
], NULL
, 10) > UINT16_MAX
)
660 if (strlen(splits
[i
]) == 0)
664 XFREE(MTYPE_TMP
, splits
[i
]);
666 XFREE(MTYPE_TMP
, splits
);
668 return (octets
< 2 || invalid
) ? false : true;
671 /* Get next community token from string. */
673 community_gettoken(const char *buf
, enum community_token
*token
, uint32_t *val
)
677 /* Skip white space. */
678 while (isspace((unsigned char)*p
))
681 /* Check the end of the line. */
685 /* Well known community string check. */
686 if (isalpha((unsigned char)*p
)) {
687 if (strncmp(p
, "internet", strlen("internet")) == 0) {
688 *val
= COMMUNITY_INTERNET
;
689 *token
= community_token_no_export
;
690 p
+= strlen("internet");
693 if (strncmp(p
, "graceful-shutdown", strlen("graceful-shutdown"))
695 *val
= COMMUNITY_GSHUT
;
696 *token
= community_token_gshut
;
697 p
+= strlen("graceful-shutdown");
700 if (strncmp(p
, "accept-own-nexthop",
701 strlen("accept-own-nexthop"))
703 *val
= COMMUNITY_ACCEPT_OWN_NEXTHOP
;
704 *token
= community_token_accept_own_nexthop
;
705 p
+= strlen("accept-own-nexthop");
708 if (strncmp(p
, "accept-own", strlen("accept-own"))
710 *val
= COMMUNITY_ACCEPT_OWN
;
711 *token
= community_token_accept_own
;
712 p
+= strlen("accept-own");
715 if (strncmp(p
, "route-filter-translated-v4",
716 strlen("route-filter-translated-v4"))
718 *val
= COMMUNITY_ROUTE_FILTER_TRANSLATED_v4
;
719 *token
= community_token_route_filter_translated_v4
;
720 p
+= strlen("route-filter-translated-v4");
723 if (strncmp(p
, "route-filter-v4", strlen("route-filter-v4"))
725 *val
= COMMUNITY_ROUTE_FILTER_v4
;
726 *token
= community_token_route_filter_v4
;
727 p
+= strlen("route-filter-v4");
730 if (strncmp(p
, "route-filter-translated-v6",
731 strlen("route-filter-translated-v6"))
733 *val
= COMMUNITY_ROUTE_FILTER_TRANSLATED_v6
;
734 *token
= community_token_route_filter_translated_v6
;
735 p
+= strlen("route-filter-translated-v6");
738 if (strncmp(p
, "route-filter-v6", strlen("route-filter-v6"))
740 *val
= COMMUNITY_ROUTE_FILTER_v6
;
741 *token
= community_token_route_filter_v6
;
742 p
+= strlen("route-filter-v6");
745 if (strncmp(p
, "llgr-stale", strlen("llgr-stale"))
747 *val
= COMMUNITY_LLGR_STALE
;
748 *token
= community_token_llgr_stale
;
749 p
+= strlen("llgr-stale");
752 if (strncmp(p
, "no-llgr", strlen("no-llgr"))
754 *val
= COMMUNITY_NO_LLGR
;
755 *token
= community_token_no_llgr
;
756 p
+= strlen("no-llgr");
759 if (strncmp(p
, "blackhole", strlen("blackhole"))
761 *val
= COMMUNITY_BLACKHOLE
;
762 *token
= community_token_blackhole
;
763 p
+= strlen("blackhole");
766 if (strncmp(p
, "no-export", strlen("no-export")) == 0) {
767 *val
= COMMUNITY_NO_EXPORT
;
768 *token
= community_token_no_export
;
769 p
+= strlen("no-export");
772 if (strncmp(p
, "no-advertise", strlen("no-advertise")) == 0) {
773 *val
= COMMUNITY_NO_ADVERTISE
;
774 *token
= community_token_no_advertise
;
775 p
+= strlen("no-advertise");
778 if (strncmp(p
, "local-AS", strlen("local-AS")) == 0) {
779 *val
= COMMUNITY_LOCAL_AS
;
780 *token
= community_token_local_as
;
781 p
+= strlen("local-AS");
784 if (strncmp(p
, "no-peer", strlen("no-peer")) == 0) {
785 *val
= COMMUNITY_NO_PEER
;
786 *token
= community_token_no_peer
;
787 p
+= strlen("no-peer");
791 /* Unknown string. */
792 *token
= community_token_unknown
;
796 /* Community value. */
797 if (isdigit((unsigned char)*p
)) {
800 uint32_t community_low
= 0;
801 uint32_t community_high
= 0;
803 if (!community_valid(p
)) {
804 *token
= community_token_unknown
;
808 while (isdigit((unsigned char)*p
) || *p
== ':') {
811 *token
= community_token_unknown
;
817 if (community_low
> UINT16_MAX
) {
819 community_token_unknown
;
823 community_high
= community_low
<< 16;
829 community_low
+= (*p
- '0');
834 *token
= community_token_unknown
;
838 *val
= community_high
+ community_low
;
839 *token
= community_token_val
;
842 *token
= community_token_unknown
;
846 /* convert string to community structure */
847 struct community
*community_str2com(const char *str
)
849 struct community
*com
= NULL
;
850 struct community
*com_sort
= NULL
;
852 enum community_token token
= community_token_unknown
;
855 str
= community_gettoken(str
, &token
, &val
);
858 case community_token_val
:
859 case community_token_gshut
:
860 case community_token_accept_own
:
861 case community_token_route_filter_translated_v4
:
862 case community_token_route_filter_v4
:
863 case community_token_route_filter_translated_v6
:
864 case community_token_route_filter_v6
:
865 case community_token_llgr_stale
:
866 case community_token_no_llgr
:
867 case community_token_accept_own_nexthop
:
868 case community_token_blackhole
:
869 case community_token_no_export
:
870 case community_token_no_advertise
:
871 case community_token_local_as
:
872 case community_token_no_peer
:
874 com
= community_new();
877 community_add_val(com
, val
);
879 case community_token_unknown
:
881 community_free(&com
);
886 com_sort
= community_uniq_sort(com
);
887 community_free(&com
);
892 /* Return communities hash entry count. */
893 unsigned long community_count(void)
895 return comhash
->count
;
898 /* Return communities hash. */
899 struct hash
*community_hash(void)
904 /* Initialize comminity related hash. */
905 void community_init(void)
908 hash_create((unsigned int (*)(const void *))community_hash_make
,
909 (bool (*)(const void *, const void *))community_cmp
,
910 "BGP Community Hash");
913 void community_finish(void)
919 static struct community
*bgp_aggr_community_lookup(
920 struct bgp_aggregate
*aggregate
,
921 struct community
*community
)
923 return hash_lookup(aggregate
->community_hash
, community
);
926 static void *bgp_aggr_communty_hash_alloc(void *p
)
928 struct community
*ref
= (struct community
*)p
;
929 struct community
*community
= NULL
;
931 community
= community_dup(ref
);
935 static void bgp_aggr_community_prepare(struct hash_bucket
*hb
, void *arg
)
937 struct community
*hb_community
= hb
->data
;
938 struct community
**aggr_community
= arg
;
941 *aggr_community
= community_merge(*aggr_community
,
944 *aggr_community
= community_dup(hb_community
);
947 void bgp_aggr_community_remove(void *arg
)
949 struct community
*community
= arg
;
951 community_free(&community
);
954 void bgp_compute_aggregate_community(struct bgp_aggregate
*aggregate
,
955 struct community
*community
)
957 bgp_compute_aggregate_community_hash(aggregate
, community
);
958 bgp_compute_aggregate_community_val(aggregate
);
962 void bgp_compute_aggregate_community_hash(struct bgp_aggregate
*aggregate
,
963 struct community
*community
)
965 struct community
*aggr_community
= NULL
;
967 if ((aggregate
== NULL
) || (community
== NULL
))
970 /* Create hash if not already created.
972 if (aggregate
->community_hash
== NULL
)
973 aggregate
->community_hash
= hash_create(
974 (unsigned int (*)(const void *))community_hash_make
,
975 (bool (*)(const void *, const void *))community_cmp
,
976 "BGP Aggregator community hash");
978 aggr_community
= bgp_aggr_community_lookup(aggregate
, community
);
979 if (aggr_community
== NULL
) {
980 /* Insert community into hash.
982 aggr_community
= hash_get(aggregate
->community_hash
, community
,
983 bgp_aggr_communty_hash_alloc
);
986 /* Increment reference counter.
988 aggr_community
->refcnt
++;
991 void bgp_compute_aggregate_community_val(struct bgp_aggregate
*aggregate
)
993 struct community
*commerge
= NULL
;
995 if (aggregate
== NULL
)
998 /* Re-compute aggregate's community.
1000 if (aggregate
->community
)
1001 community_free(&aggregate
->community
);
1002 if (aggregate
->community_hash
&&
1003 aggregate
->community_hash
->count
) {
1004 hash_iterate(aggregate
->community_hash
,
1005 bgp_aggr_community_prepare
,
1006 &aggregate
->community
);
1007 commerge
= aggregate
->community
;
1008 aggregate
->community
= community_uniq_sort(commerge
);
1010 community_free(&commerge
);
1016 void bgp_remove_community_from_aggregate(struct bgp_aggregate
*aggregate
,
1017 struct community
*community
)
1019 struct community
*aggr_community
= NULL
;
1020 struct community
*ret_comm
= NULL
;
1023 || (!aggregate
->community_hash
)
1027 /* Look-up the community in the hash.
1029 aggr_community
= bgp_aggr_community_lookup(aggregate
, community
);
1030 if (aggr_community
) {
1031 aggr_community
->refcnt
--;
1033 if (aggr_community
->refcnt
== 0) {
1034 ret_comm
= hash_release(aggregate
->community_hash
,
1036 community_free(&ret_comm
);
1038 bgp_compute_aggregate_community_val(aggregate
);
1043 void bgp_remove_comm_from_aggregate_hash(struct bgp_aggregate
*aggregate
,
1044 struct community
*community
)
1047 struct community
*aggr_community
= NULL
;
1048 struct community
*ret_comm
= NULL
;
1051 || (!aggregate
->community_hash
)
1055 /* Look-up the community in the hash.
1057 aggr_community
= bgp_aggr_community_lookup(aggregate
, community
);
1058 if (aggr_community
) {
1059 aggr_community
->refcnt
--;
1061 if (aggr_community
->refcnt
== 0) {
1062 ret_comm
= hash_release(aggregate
->community_hash
,
1064 community_free(&ret_comm
);