1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Community attribute related functions.
3 * Copyright (C) 1998, 2001 Kunihiro Ishiguro
14 #include "bgpd/bgp_memory.h"
15 #include "bgpd/bgp_community.h"
16 #include "bgpd/bgp_community_alias.h"
18 /* Hash of community attribute. */
19 static struct hash
*comhash
;
21 /* Allocate a new communities value. */
22 static struct community
*community_new(void)
24 return XCALLOC(MTYPE_COMMUNITY
, sizeof(struct community
));
27 /* Free communities value. */
28 void community_free(struct community
**com
)
33 XFREE(MTYPE_COMMUNITY_VAL
, (*com
)->val
);
34 XFREE(MTYPE_COMMUNITY_STR
, (*com
)->str
);
37 json_object_free((*com
)->json
);
41 XFREE(MTYPE_COMMUNITY
, (*com
));
44 /* Add one community value to the community. */
45 void community_add_val(struct community
*com
, uint32_t val
)
48 com
->val
= XREALLOC(MTYPE_COMMUNITY_VAL
, com
->val
, com_length(com
));
51 memcpy(com_lastval(com
), &val
, sizeof(uint32_t));
54 /* Delete one community. */
55 void community_del_val(struct community
*com
, uint32_t *val
)
63 while (i
< com
->size
) {
64 if (memcmp(com
->val
+ i
, val
, sizeof(uint32_t)) == 0) {
65 c
= com
->size
- i
- 1;
68 memmove(com
->val
+ i
, com
->val
+ (i
+ 1),
74 com
->val
= XREALLOC(MTYPE_COMMUNITY_VAL
,
75 com
->val
, com_length(com
));
77 XFREE(MTYPE_COMMUNITY_VAL
, com
->val
);
85 /* Delete all communities listed in com2 from com1 */
86 struct community
*community_delete(struct community
*com1
,
87 struct community
*com2
)
91 while (i
< com2
->size
) {
92 community_del_val(com1
, com2
->val
+ i
);
99 /* Callback function from qsort(). */
100 static int community_compare(const void *a1
, const void *a2
)
105 memcpy(&v1
, a1
, sizeof(uint32_t));
106 memcpy(&v2
, a2
, sizeof(uint32_t));
117 bool community_include(struct community
*com
, uint32_t val
)
123 for (i
= 0; i
< com
->size
; i
++)
124 if (memcmp(&val
, com_nthval(com
, i
), sizeof(uint32_t)) == 0)
129 uint32_t community_val_get(struct community
*com
, int i
)
134 p
= (uint8_t *)com
->val
;
135 p
+= (i
* COMMUNITY_SIZE
);
137 memcpy(&val
, p
, sizeof(uint32_t));
142 /* Sort and uniq given community. */
143 struct community
*community_uniq_sort(struct community
*com
)
146 struct community
*new;
152 new = community_new();
155 for (i
= 0; i
< com
->size
; i
++) {
156 val
= community_val_get(com
, i
);
158 if (!community_include(new, val
))
159 community_add_val(new, val
);
162 qsort(new->val
, new->size
, sizeof(uint32_t), community_compare
);
167 /* Convert communities attribute to string.
169 For Well-known communities value, below keyword is used.
171 0xFFFF0000 "graceful-shutdown"
172 0xFFFF0001 "accept-own"
173 0xFFFF0002 "route-filter-translated-v4"
174 0xFFFF0003 "route-filter-v4"
175 0xFFFF0004 "route-filter-translated-v6"
176 0xFFFF0005 "route-filter-v6"
177 0xFFFF0006 "llgr-stale"
179 0xFFFF0008 "accept-own-nexthop"
180 0xFFFF029A "blackhole"
181 0xFFFFFF01 "no-export"
182 0xFFFFFF02 "no-advertise"
183 0xFFFFFF03 "local-AS"
186 For other values, "AS:VAL" format is used. */
187 static void set_community_string(struct community
*com
, bool make_json
,
188 bool translate_alias
)
197 json_object
*json_community_list
= NULL
;
198 json_object
*json_string
= NULL
;
204 com
->json
= json_object_new_object();
205 json_community_list
= json_object_new_array();
208 /* When communities attribute is empty. */
209 if (com
->size
== 0) {
210 str
= XMALLOC(MTYPE_COMMUNITY_STR
, 1);
214 json_object_string_add(com
->json
, "string", "");
215 json_object_object_add(com
->json
, "list",
216 json_community_list
);
222 /* Memory allocation is time consuming work. So we calculate
223 required string length first. */
226 for (i
= 0; i
< com
->size
; i
++) {
227 memcpy(&comval
, com_nthval(com
, i
), sizeof(uint32_t));
228 comval
= ntohl(comval
);
231 #if CONFDATE > 20230801
232 CPP_NOTICE("Deprecate COMMUNITY_INTERNET BGP community")
234 case COMMUNITY_INTERNET
:
235 len
+= strlen(" internet");
236 zlog_warn("`internet` community is deprecated");
238 case COMMUNITY_GSHUT
:
239 len
+= strlen(" graceful-shutdown");
241 case COMMUNITY_ACCEPT_OWN
:
242 len
+= strlen(" accept-own");
244 case COMMUNITY_ROUTE_FILTER_TRANSLATED_v4
:
245 len
+= strlen(" route-filter-translated-v4");
247 case COMMUNITY_ROUTE_FILTER_v4
:
248 len
+= strlen(" route-filter-v4");
250 case COMMUNITY_ROUTE_FILTER_TRANSLATED_v6
:
251 len
+= strlen(" route-filter-translated-v6");
253 case COMMUNITY_ROUTE_FILTER_v6
:
254 len
+= strlen(" route-filter-v6");
256 case COMMUNITY_LLGR_STALE
:
257 len
+= strlen(" llgr-stale");
259 case COMMUNITY_NO_LLGR
:
260 len
+= strlen(" no-llgr");
262 case COMMUNITY_ACCEPT_OWN_NEXTHOP
:
263 len
+= strlen(" accept-own-nexthop");
265 case COMMUNITY_BLACKHOLE
:
266 len
+= strlen(" blackhole");
268 case COMMUNITY_NO_EXPORT
:
269 len
+= strlen(" no-export");
271 case COMMUNITY_NO_ADVERTISE
:
272 len
+= strlen(" no-advertise");
274 case COMMUNITY_LOCAL_AS
:
275 len
+= strlen(" local-AS");
277 case COMMUNITY_NO_PEER
:
278 len
+= strlen(" no-peer");
286 /* Allocate memory. */
287 str
= XCALLOC(MTYPE_COMMUNITY_STR
, len
);
290 /* Fill in string. */
291 for (i
= 0; i
< com
->size
; i
++) {
292 memcpy(&comval
, com_nthval(com
, i
), sizeof(uint32_t));
293 comval
= ntohl(comval
);
298 strlcat(str
, " ", len
);
301 #if CONFDATE > 20230801
302 CPP_NOTICE("Deprecate COMMUNITY_INTERNET BGP community")
304 case COMMUNITY_INTERNET
:
305 strlcat(str
, "internet", len
);
308 json_object_new_string("internet");
309 json_object_array_add(json_community_list
,
312 zlog_warn("`internet` community is deprecated");
314 case COMMUNITY_GSHUT
:
315 strlcat(str
, "graceful-shutdown", len
);
317 json_string
= json_object_new_string(
319 json_object_array_add(json_community_list
,
323 case COMMUNITY_ACCEPT_OWN
:
324 strlcat(str
, "accept-own", len
);
326 json_string
= json_object_new_string(
328 json_object_array_add(json_community_list
,
332 case COMMUNITY_ROUTE_FILTER_TRANSLATED_v4
:
333 strlcat(str
, "route-filter-translated-v4", len
);
335 json_string
= json_object_new_string(
336 "routeFilterTranslatedV4");
337 json_object_array_add(json_community_list
,
341 case COMMUNITY_ROUTE_FILTER_v4
:
342 strlcat(str
, "route-filter-v4", len
);
344 json_string
= json_object_new_string(
346 json_object_array_add(json_community_list
,
350 case COMMUNITY_ROUTE_FILTER_TRANSLATED_v6
:
351 strlcat(str
, "route-filter-translated-v6", len
);
353 json_string
= json_object_new_string(
354 "routeFilterTranslatedV6");
355 json_object_array_add(json_community_list
,
359 case COMMUNITY_ROUTE_FILTER_v6
:
360 strlcat(str
, "route-filter-v6", len
);
362 json_string
= json_object_new_string(
364 json_object_array_add(json_community_list
,
368 case COMMUNITY_LLGR_STALE
:
369 strlcat(str
, "llgr-stale", len
);
371 json_string
= json_object_new_string(
373 json_object_array_add(json_community_list
,
377 case COMMUNITY_NO_LLGR
:
378 strlcat(str
, "no-llgr", len
);
380 json_string
= json_object_new_string(
382 json_object_array_add(json_community_list
,
386 case COMMUNITY_ACCEPT_OWN_NEXTHOP
:
387 strlcat(str
, "accept-own-nexthop", len
);
389 json_string
= json_object_new_string(
391 json_object_array_add(json_community_list
,
395 case COMMUNITY_BLACKHOLE
:
396 strlcat(str
, "blackhole", len
);
398 json_string
= json_object_new_string(
400 json_object_array_add(json_community_list
,
404 case COMMUNITY_NO_EXPORT
:
405 strlcat(str
, "no-export", len
);
408 json_object_new_string("noExport");
409 json_object_array_add(json_community_list
,
413 case COMMUNITY_NO_ADVERTISE
:
414 strlcat(str
, "no-advertise", len
);
417 json_object_new_string("noAdvertise");
418 json_object_array_add(json_community_list
,
422 case COMMUNITY_LOCAL_AS
:
423 strlcat(str
, "local-AS", len
);
425 json_string
= json_object_new_string("localAs");
426 json_object_array_add(json_community_list
,
430 case COMMUNITY_NO_PEER
:
431 strlcat(str
, "no-peer", len
);
433 json_string
= json_object_new_string("noPeer");
434 json_object_array_add(json_community_list
,
439 as
= (comval
>> 16) & 0xFFFF;
440 val
= comval
& 0xFFFF;
442 snprintf(buf
, sizeof(buf
), "%u:%d", as
, val
);
443 const char *com2alias
=
444 translate_alias
? bgp_community2alias(buf
)
447 strlcat(str
, com2alias
, len
);
449 json_string
= json_object_new_string(com2alias
);
450 json_object_array_add(json_community_list
,
458 json_object_string_add(com
->json
, "string", str
);
459 json_object_object_add(com
->json
, "list", json_community_list
);
464 /* Intern communities attribute. */
465 struct community
*community_intern(struct community
*com
)
467 struct community
*find
;
469 /* Assert this community structure is not interned. */
470 assert(com
->refcnt
== 0);
472 /* Lookup community hash. */
473 find
= (struct community
*)hash_get(comhash
, com
, hash_alloc_intern
);
475 /* Arguemnt com is allocated temporary. So when it is not used in
476 hash, it should be freed. */
478 community_free(&com
);
480 /* Increment refrence counter. */
485 set_community_string(find
, false, true);
490 /* Free community attribute. */
491 void community_unintern(struct community
**com
)
493 struct community
*ret
;
501 /* Pull off from hash. */
502 if ((*com
)->refcnt
== 0) {
503 /* Community value com must exist in hash. */
504 ret
= (struct community
*)hash_release(comhash
, *com
);
511 /* Create new community attribute. */
512 struct community
*community_parse(uint32_t *pnt
, unsigned short length
)
514 struct community tmp
;
515 struct community
*new;
517 /* If length is malformed return NULL. */
518 if (length
% COMMUNITY_SIZE
)
521 /* Make temporary community for hash look up. */
522 tmp
.size
= length
/ COMMUNITY_SIZE
;
525 new = community_uniq_sort(&tmp
);
527 return community_intern(new);
530 struct community
*community_dup(struct community
*com
)
532 struct community
*new;
534 new = XCALLOC(MTYPE_COMMUNITY
, sizeof(struct community
));
535 new->size
= com
->size
;
537 new->val
= XMALLOC(MTYPE_COMMUNITY_VAL
,
538 com
->size
* COMMUNITY_SIZE
);
539 memcpy(new->val
, com
->val
, com
->size
* COMMUNITY_SIZE
);
545 /* Return string representation of communities attribute. */
546 char *community_str(struct community
*com
, bool make_json
, bool translate_alias
)
551 if (make_json
&& !com
->json
&& com
->str
)
552 XFREE(MTYPE_COMMUNITY_STR
, com
->str
);
555 set_community_string(com
, make_json
, translate_alias
);
559 /* Make hash value of community attribute. This function is used by
561 unsigned int community_hash_make(const struct community
*com
)
563 uint32_t *pnt
= com
->val
;
565 return jhash2(pnt
, com
->size
, 0x43ea96c1);
568 bool community_match(const struct community
*com1
, const struct community
*com2
)
573 if (com1
== NULL
&& com2
== NULL
)
576 if (com1
== NULL
|| com2
== NULL
)
579 if (com1
->size
< com2
->size
)
582 /* Every community on com2 needs to be on com1 for this to match */
583 while (i
< com1
->size
&& j
< com2
->size
) {
584 if (memcmp(com1
->val
+ i
, com2
->val
+ j
, sizeof(uint32_t)) == 0)
595 bool community_cmp(const struct community
*com1
, const struct community
*com2
)
597 if (com1
== NULL
&& com2
== NULL
)
599 if (com1
== NULL
|| com2
== NULL
)
602 if (com1
->size
== com2
->size
)
603 if (memcmp(com1
->val
, com2
->val
, com1
->size
* COMMUNITY_SIZE
)
609 /* Add com2 to the end of com1. */
610 struct community
*community_merge(struct community
*com1
,
611 struct community
*com2
)
613 com1
->val
= XREALLOC(MTYPE_COMMUNITY_VAL
, com1
->val
,
614 (com1
->size
+ com2
->size
) * COMMUNITY_SIZE
);
616 memcpy(com1
->val
+ com1
->size
, com2
->val
, com2
->size
* COMMUNITY_SIZE
);
617 com1
->size
+= com2
->size
;
622 /* Community token enum. */
623 enum community_token
{
625 community_token_gshut
,
626 community_token_accept_own
,
627 community_token_route_filter_translated_v4
,
628 community_token_route_filter_v4
,
629 community_token_route_filter_translated_v6
,
630 community_token_route_filter_v6
,
631 community_token_llgr_stale
,
632 community_token_no_llgr
,
633 community_token_accept_own_nexthop
,
634 community_token_blackhole
,
635 community_token_no_export
,
636 community_token_no_advertise
,
637 community_token_local_as
,
638 community_token_no_peer
,
639 community_token_unknown
642 /* Helper to check if a given community is valid */
643 static bool community_valid(const char *community
)
650 frrstr_split(community
, ":", &splits
, &num
);
652 for (int i
= 0; i
< num
; i
++) {
653 if (strtoul(splits
[i
], NULL
, 10) > UINT16_MAX
)
656 if (strlen(splits
[i
]) == 0)
660 XFREE(MTYPE_TMP
, splits
[i
]);
662 XFREE(MTYPE_TMP
, splits
);
664 return (octets
< 2 || invalid
) ? false : true;
667 /* Get next community token from string. */
669 community_gettoken(const char *buf
, enum community_token
*token
, uint32_t *val
)
673 /* Skip white space. */
674 while (isspace((unsigned char)*p
))
677 /* Check the end of the line. */
681 /* Well known community string check. */
682 if (isalpha((unsigned char)*p
)) {
683 #if CONFDATE > 20230801
684 CPP_NOTICE("Deprecate COMMUNITY_INTERNET BGP community")
686 if (strncmp(p
, "internet", strlen("internet")) == 0) {
687 *val
= COMMUNITY_INTERNET
;
688 *token
= community_token_no_export
;
689 p
+= strlen("internet");
690 zlog_warn("`internet` community is deprecated");
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 static void community_hash_free(void *data
)
915 struct community
*com
= data
;
917 community_free(&com
);
920 void community_finish(void)
922 hash_clean(comhash
, community_hash_free
);
927 static struct community
*bgp_aggr_community_lookup(
928 struct bgp_aggregate
*aggregate
,
929 struct community
*community
)
931 return hash_lookup(aggregate
->community_hash
, community
);
934 static void *bgp_aggr_community_hash_alloc(void *p
)
936 struct community
*ref
= (struct community
*)p
;
937 struct community
*community
= NULL
;
939 community
= community_dup(ref
);
943 static void bgp_aggr_community_prepare(struct hash_bucket
*hb
, void *arg
)
945 struct community
*hb_community
= hb
->data
;
946 struct community
**aggr_community
= arg
;
949 *aggr_community
= community_merge(*aggr_community
,
952 *aggr_community
= community_dup(hb_community
);
955 void bgp_aggr_community_remove(void *arg
)
957 struct community
*community
= arg
;
959 community_free(&community
);
962 void bgp_compute_aggregate_community(struct bgp_aggregate
*aggregate
,
963 struct community
*community
)
965 bgp_compute_aggregate_community_hash(aggregate
, community
);
966 bgp_compute_aggregate_community_val(aggregate
);
970 void bgp_compute_aggregate_community_hash(struct bgp_aggregate
*aggregate
,
971 struct community
*community
)
973 struct community
*aggr_community
= NULL
;
975 if ((aggregate
== NULL
) || (community
== NULL
))
978 /* Create hash if not already created.
980 if (aggregate
->community_hash
== NULL
)
981 aggregate
->community_hash
= hash_create(
982 (unsigned int (*)(const void *))community_hash_make
,
983 (bool (*)(const void *, const void *))community_cmp
,
984 "BGP Aggregator community hash");
986 aggr_community
= bgp_aggr_community_lookup(aggregate
, community
);
987 if (aggr_community
== NULL
) {
988 /* Insert community into hash.
990 aggr_community
= hash_get(aggregate
->community_hash
, community
,
991 bgp_aggr_community_hash_alloc
);
994 /* Increment reference counter.
996 aggr_community
->refcnt
++;
999 void bgp_compute_aggregate_community_val(struct bgp_aggregate
*aggregate
)
1001 struct community
*commerge
= NULL
;
1003 if (aggregate
== NULL
)
1006 /* Re-compute aggregate's community.
1008 if (aggregate
->community
)
1009 community_free(&aggregate
->community
);
1010 if (aggregate
->community_hash
&&
1011 aggregate
->community_hash
->count
) {
1012 hash_iterate(aggregate
->community_hash
,
1013 bgp_aggr_community_prepare
,
1014 &aggregate
->community
);
1015 commerge
= aggregate
->community
;
1016 aggregate
->community
= community_uniq_sort(commerge
);
1018 community_free(&commerge
);
1024 void bgp_remove_community_from_aggregate(struct bgp_aggregate
*aggregate
,
1025 struct community
*community
)
1027 struct community
*aggr_community
= NULL
;
1028 struct community
*ret_comm
= NULL
;
1031 || (!aggregate
->community_hash
)
1035 /* Look-up the community in the hash.
1037 aggr_community
= bgp_aggr_community_lookup(aggregate
, community
);
1038 if (aggr_community
) {
1039 aggr_community
->refcnt
--;
1041 if (aggr_community
->refcnt
== 0) {
1042 ret_comm
= hash_release(aggregate
->community_hash
,
1044 community_free(&ret_comm
);
1046 bgp_compute_aggregate_community_val(aggregate
);
1051 void bgp_remove_comm_from_aggregate_hash(struct bgp_aggregate
*aggregate
,
1052 struct community
*community
)
1055 struct community
*aggr_community
= NULL
;
1056 struct community
*ret_comm
= NULL
;
1059 || (!aggregate
->community_hash
)
1063 /* Look-up the community in the hash.
1065 aggr_community
= bgp_aggr_community_lookup(aggregate
, community
);
1066 if (aggr_community
) {
1067 aggr_community
->refcnt
--;
1069 if (aggr_community
->refcnt
== 0) {
1070 ret_comm
= hash_release(aggregate
->community_hash
,
1072 community_free(&ret_comm
);