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
28 #include "bgpd/bgp_memory.h"
29 #include "bgpd/bgp_community.h"
31 /* Hash of community attribute. */
32 static struct hash
*comhash
;
34 /* Allocate a new communities value. */
35 static struct community
*community_new(void)
37 return XCALLOC(MTYPE_COMMUNITY
, sizeof(struct community
));
40 /* Free communities value. */
41 void community_free(struct community
**com
)
43 XFREE(MTYPE_COMMUNITY_VAL
, (*com
)->val
);
44 XFREE(MTYPE_COMMUNITY_STR
, (*com
)->str
);
47 json_object_free((*com
)->json
);
51 XFREE(MTYPE_COMMUNITY
, (*com
));
54 /* Add one community value to the community. */
55 static void community_add_val(struct community
*com
, uint32_t val
)
59 com
->val
= XREALLOC(MTYPE_COMMUNITY_VAL
, com
->val
,
62 com
->val
= XMALLOC(MTYPE_COMMUNITY_VAL
, com_length(com
));
65 memcpy(com_lastval(com
), &val
, sizeof(uint32_t));
68 /* Delete one community. */
69 void community_del_val(struct community
*com
, uint32_t *val
)
77 while (i
< com
->size
) {
78 if (memcmp(com
->val
+ i
, val
, sizeof(uint32_t)) == 0) {
79 c
= com
->size
- i
- 1;
82 memmove(com
->val
+ i
, com
->val
+ (i
+ 1),
88 com
->val
= XREALLOC(MTYPE_COMMUNITY_VAL
,
89 com
->val
, com_length(com
));
91 XFREE(MTYPE_COMMUNITY_VAL
, com
->val
);
99 /* Delete all communities listed in com2 from com1 */
100 struct community
*community_delete(struct community
*com1
,
101 struct community
*com2
)
105 while (i
< com2
->size
) {
106 community_del_val(com1
, com2
->val
+ i
);
113 /* Callback function from qsort(). */
114 static int community_compare(const void *a1
, const void *a2
)
119 memcpy(&v1
, a1
, sizeof(uint32_t));
120 memcpy(&v2
, a2
, sizeof(uint32_t));
131 int community_include(struct community
*com
, uint32_t val
)
137 for (i
= 0; i
< com
->size
; i
++)
138 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
;
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");
292 len
+= strlen(" 65536:65535");
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 strlcat(str
, buf
, len
);
452 json_string
= json_object_new_string(buf
);
453 json_object_array_add(json_community_list
,
461 json_object_string_add(com
->json
, "string", str
);
462 json_object_object_add(com
->json
, "list", json_community_list
);
467 /* Intern communities attribute. */
468 struct community
*community_intern(struct community
*com
)
470 struct community
*find
;
472 /* Assert this community structure is not interned. */
473 assert(com
->refcnt
== 0);
475 /* Lookup community hash. */
476 find
= (struct community
*)hash_get(comhash
, com
, hash_alloc_intern
);
478 /* Arguemnt com is allocated temporary. So when it is not used in
479 hash, it should be freed. */
481 community_free(&com
);
483 /* Increment refrence counter. */
488 set_community_string(find
, false);
493 /* Free community attribute. */
494 void community_unintern(struct community
**com
)
496 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. */
521 /* Make temporary community for hash look up. */
522 tmp
.size
= length
/ 4;
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
, com
->size
* 4);
538 memcpy(new->val
, com
->val
, com
->size
* 4);
544 /* Retrun string representation of communities attribute. */
545 char *community_str(struct community
*com
, bool make_json
)
550 if (make_json
&& !com
->json
&& com
->str
)
551 XFREE(MTYPE_COMMUNITY_STR
, com
->str
);
554 set_community_string(com
, make_json
);
558 /* Make hash value of community attribute. This function is used by
560 unsigned int community_hash_make(const struct community
*com
)
562 uint32_t *pnt
= (uint32_t *)com
->val
;
564 return jhash2(pnt
, com
->size
, 0x43ea96c1);
567 int community_match(const struct community
*com1
, const struct community
*com2
)
572 if (com1
== NULL
&& com2
== NULL
)
575 if (com1
== NULL
|| com2
== NULL
)
578 if (com1
->size
< com2
->size
)
581 /* Every community on com2 needs to be on com1 for this to match */
582 while (i
< com1
->size
&& j
< com2
->size
) {
583 if (memcmp(com1
->val
+ i
, com2
->val
+ j
, sizeof(uint32_t)) == 0)
594 /* If two aspath have same value then return 1 else return 0. This
595 function is used by hash package. */
596 bool community_cmp(const struct community
*com1
, const struct community
*com2
)
598 if (com1
== NULL
&& com2
== NULL
)
600 if (com1
== NULL
|| com2
== NULL
)
603 if (com1
->size
== com2
->size
)
604 if (memcmp(com1
->val
, com2
->val
, com1
->size
* 4) == 0)
609 /* Add com2 to the end of com1. */
610 struct community
*community_merge(struct community
*com1
,
611 struct community
*com2
)
614 com1
->val
= XREALLOC(MTYPE_COMMUNITY_VAL
, com1
->val
,
615 (com1
->size
+ com2
->size
) * 4);
617 com1
->val
= XMALLOC(MTYPE_COMMUNITY_VAL
,
618 (com1
->size
+ com2
->size
) * 4);
620 memcpy(com1
->val
+ com1
->size
, com2
->val
, com2
->size
* 4);
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 /* Get next community token from string. */
648 community_gettoken(const char *buf
, enum community_token
*token
, uint32_t *val
)
652 /* Skip white space. */
653 while (isspace((unsigned char)*p
))
656 /* Check the end of the line. */
660 /* Well known community string check. */
661 if (isalpha((unsigned char)*p
)) {
662 if (strncmp(p
, "internet", strlen("internet")) == 0) {
663 *val
= COMMUNITY_INTERNET
;
664 *token
= community_token_no_export
;
665 p
+= strlen("internet");
668 if (strncmp(p
, "graceful-shutdown", strlen("graceful-shutdown"))
670 *val
= COMMUNITY_GSHUT
;
671 *token
= community_token_gshut
;
672 p
+= strlen("graceful-shutdown");
675 if (strncmp(p
, "accept-own", strlen("accept-own"))
677 *val
= COMMUNITY_ACCEPT_OWN
;
678 *token
= community_token_accept_own
;
679 p
+= strlen("accept-own");
682 if (strncmp(p
, "route-filter-translated-v4",
683 strlen("route-filter-translated-v4"))
685 *val
= COMMUNITY_ROUTE_FILTER_TRANSLATED_v4
;
686 *token
= community_token_route_filter_translated_v4
;
687 p
+= strlen("route-filter-translated-v4");
690 if (strncmp(p
, "route-filter-v4", strlen("route-filter-v4"))
692 *val
= COMMUNITY_ROUTE_FILTER_v4
;
693 *token
= community_token_route_filter_v4
;
694 p
+= strlen("route-filter-v4");
697 if (strncmp(p
, "route-filter-translated-v6",
698 strlen("route-filter-translated-v6"))
700 *val
= COMMUNITY_ROUTE_FILTER_TRANSLATED_v6
;
701 *token
= community_token_route_filter_translated_v6
;
702 p
+= strlen("route-filter-translated-v6");
705 if (strncmp(p
, "route-filter-v6", strlen("route-filter-v6"))
707 *val
= COMMUNITY_ROUTE_FILTER_v6
;
708 *token
= community_token_route_filter_v6
;
709 p
+= strlen("route-filter-v6");
712 if (strncmp(p
, "llgr-stale", strlen("llgr-stale"))
714 *val
= COMMUNITY_LLGR_STALE
;
715 *token
= community_token_llgr_stale
;
716 p
+= strlen("llgr-stale");
719 if (strncmp(p
, "no-llgr", strlen("no-llgr"))
721 *val
= COMMUNITY_NO_LLGR
;
722 *token
= community_token_no_llgr
;
723 p
+= strlen("no-llgr");
726 if (strncmp(p
, "accept-own-nexthop",
727 strlen("accept-own-nexthop"))
729 *val
= COMMUNITY_ACCEPT_OWN_NEXTHOP
;
730 *token
= community_token_accept_own_nexthop
;
731 p
+= strlen("accept-own-nexthop");
734 if (strncmp(p
, "blackhole", strlen("blackhole"))
736 *val
= COMMUNITY_BLACKHOLE
;
737 *token
= community_token_blackhole
;
738 p
+= strlen("blackhole");
741 if (strncmp(p
, "no-export", strlen("no-export")) == 0) {
742 *val
= COMMUNITY_NO_EXPORT
;
743 *token
= community_token_no_export
;
744 p
+= strlen("no-export");
747 if (strncmp(p
, "no-advertise", strlen("no-advertise")) == 0) {
748 *val
= COMMUNITY_NO_ADVERTISE
;
749 *token
= community_token_no_advertise
;
750 p
+= strlen("no-advertise");
753 if (strncmp(p
, "local-AS", strlen("local-AS")) == 0) {
754 *val
= COMMUNITY_LOCAL_AS
;
755 *token
= community_token_local_as
;
756 p
+= strlen("local-AS");
759 if (strncmp(p
, "no-peer", strlen("no-peer")) == 0) {
760 *val
= COMMUNITY_NO_PEER
;
761 *token
= community_token_no_peer
;
762 p
+= strlen("no-peer");
766 /* Unknown string. */
767 *token
= community_token_unknown
;
771 /* Community value. */
772 if (isdigit((unsigned char)*p
)) {
775 uint32_t community_low
= 0;
776 uint32_t community_high
= 0;
778 while (isdigit((unsigned char)*p
) || *p
== ':') {
781 *token
= community_token_unknown
;
787 if (community_low
> UINT16_MAX
) {
789 community_token_unknown
;
793 community_high
= community_low
<< 16;
799 community_low
+= (*p
- '0');
804 *token
= community_token_unknown
;
808 if (community_low
> UINT16_MAX
) {
809 *token
= community_token_unknown
;
813 *val
= community_high
+ community_low
;
814 *token
= community_token_val
;
817 *token
= community_token_unknown
;
821 /* convert string to community structure */
822 struct community
*community_str2com(const char *str
)
824 struct community
*com
= NULL
;
825 struct community
*com_sort
= NULL
;
827 enum community_token token
= community_token_unknown
;
830 str
= community_gettoken(str
, &token
, &val
);
833 case community_token_val
:
834 case community_token_gshut
:
835 case community_token_accept_own
:
836 case community_token_route_filter_translated_v4
:
837 case community_token_route_filter_v4
:
838 case community_token_route_filter_translated_v6
:
839 case community_token_route_filter_v6
:
840 case community_token_llgr_stale
:
841 case community_token_no_llgr
:
842 case community_token_accept_own_nexthop
:
843 case community_token_blackhole
:
844 case community_token_no_export
:
845 case community_token_no_advertise
:
846 case community_token_local_as
:
847 case community_token_no_peer
:
849 com
= community_new();
852 community_add_val(com
, val
);
854 case community_token_unknown
:
856 community_free(&com
);
861 com_sort
= community_uniq_sort(com
);
862 community_free(&com
);
867 /* Return communities hash entry count. */
868 unsigned long community_count(void)
870 return comhash
->count
;
873 /* Return communities hash. */
874 struct hash
*community_hash(void)
879 /* Initialize comminity related hash. */
880 void community_init(void)
883 hash_create((unsigned int (*)(const void *))community_hash_make
,
884 (bool (*)(const void *, const void *))community_cmp
,
885 "BGP Community Hash");
888 void community_finish(void)
894 static struct community
*bgp_aggr_community_lookup(
895 struct bgp_aggregate
*aggregate
,
896 struct community
*community
)
898 return hash_lookup(aggregate
->community_hash
, community
);
901 static void *bgp_aggr_communty_hash_alloc(void *p
)
903 struct community
*ref
= (struct community
*)p
;
904 struct community
*community
= NULL
;
906 community
= community_dup(ref
);
910 static void bgp_aggr_community_prepare(struct hash_bucket
*hb
, void *arg
)
912 struct community
*hb_community
= hb
->data
;
913 struct community
**aggr_community
= arg
;
916 *aggr_community
= community_merge(*aggr_community
,
919 *aggr_community
= community_dup(hb_community
);
922 void bgp_aggr_community_remove(void *arg
)
924 struct community
*community
= arg
;
926 community_free(&community
);
929 void bgp_compute_aggregate_community(struct bgp_aggregate
*aggregate
,
930 struct community
*community
)
932 bgp_compute_aggregate_community_hash(aggregate
, community
);
933 bgp_compute_aggregate_community_val(aggregate
);
937 void bgp_compute_aggregate_community_hash(struct bgp_aggregate
*aggregate
,
938 struct community
*community
)
940 struct community
*aggr_community
= NULL
;
942 if ((aggregate
== NULL
) || (community
== NULL
))
945 /* Create hash if not already created.
947 if (aggregate
->community_hash
== NULL
)
948 aggregate
->community_hash
= hash_create(
949 (unsigned int (*)(const void *))community_hash_make
,
950 (bool (*)(const void *, const void *))community_cmp
,
951 "BGP Aggregator community hash");
953 aggr_community
= bgp_aggr_community_lookup(aggregate
, community
);
954 if (aggr_community
== NULL
) {
955 /* Insert community into hash.
957 aggr_community
= hash_get(aggregate
->community_hash
, community
,
958 bgp_aggr_communty_hash_alloc
);
961 /* Increment reference counter.
963 aggr_community
->refcnt
++;
966 void bgp_compute_aggregate_community_val(struct bgp_aggregate
*aggregate
)
968 struct community
*commerge
= NULL
;
970 if (aggregate
== NULL
)
973 /* Re-compute aggregate's community.
975 if (aggregate
->community
)
976 community_free(&aggregate
->community
);
977 if (aggregate
->community_hash
&&
978 aggregate
->community_hash
->count
) {
979 hash_iterate(aggregate
->community_hash
,
980 bgp_aggr_community_prepare
,
981 &aggregate
->community
);
982 commerge
= aggregate
->community
;
983 aggregate
->community
= community_uniq_sort(commerge
);
985 community_free(&commerge
);
991 void bgp_remove_community_from_aggregate(struct bgp_aggregate
*aggregate
,
992 struct community
*community
)
994 struct community
*aggr_community
= NULL
;
995 struct community
*ret_comm
= NULL
;
998 || (!aggregate
->community_hash
)
1002 /* Look-up the community in the hash.
1004 aggr_community
= bgp_aggr_community_lookup(aggregate
, community
);
1005 if (aggr_community
) {
1006 aggr_community
->refcnt
--;
1008 if (aggr_community
->refcnt
== 0) {
1009 ret_comm
= hash_release(aggregate
->community_hash
,
1011 community_free(&ret_comm
);
1013 bgp_compute_aggregate_community_val(aggregate
);
1018 void bgp_remove_comm_from_aggregate_hash(struct bgp_aggregate
*aggregate
,
1019 struct community
*community
)
1022 struct community
*aggr_community
= NULL
;
1023 struct community
*ret_comm
= NULL
;
1026 || (!aggregate
->community_hash
)
1030 /* Look-up the community in the hash.
1032 aggr_community
= bgp_aggr_community_lookup(aggregate
, community
);
1033 if (aggr_community
) {
1034 aggr_community
->refcnt
--;
1036 if (aggr_community
->refcnt
== 0) {
1037 ret_comm
= hash_release(aggregate
->community_hash
,
1039 community_free(&ret_comm
);