]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_route.c
bgpd : aggregate-address memory leak fix
[mirror_frr.git] / bgpd / bgp_route.c
index 4441e86fbbf8fbdc3f4f4f4eb6b1de930081a5e7..12c959a2985eab98db97431bb1948f3dbf245667 100644 (file)
@@ -8338,30 +8338,7 @@ static int bgp_aggregate_unset(struct vty *vty, const char *prefix_str,
        /* Unlock aggregate address configuration. */
        bgp_dest_set_bgp_aggregate_info(dest, NULL);
 
-       if (aggregate->community)
-               community_free(&aggregate->community);
-
-       hash_clean_and_free(&aggregate->community_hash,
-                           bgp_aggr_community_remove);
-
-       if (aggregate->ecommunity)
-               ecommunity_free(&aggregate->ecommunity);
-
-       hash_clean_and_free(&aggregate->ecommunity_hash,
-                           bgp_aggr_ecommunity_remove);
-
-       if (aggregate->lcommunity)
-               lcommunity_free(&aggregate->lcommunity);
-
-       hash_clean_and_free(&aggregate->lcommunity_hash,
-                           bgp_aggr_lcommunity_remove);
-
-       if (aggregate->aspath)
-               aspath_free(aggregate->aspath);
-
-       hash_clean_and_free(&aggregate->aspath_hash, bgp_aggr_aspath_remove);
-
-       bgp_aggregate_free(aggregate);
+       bgp_free_aggregate_info(aggregate);
        bgp_dest_unlock_node(dest);
        bgp_dest_unlock_node(dest);
 
@@ -8545,6 +8522,34 @@ DEFPY(aggregate_addressv4, aggregate_addressv4_cmd,
                                 match_med != NULL, suppress_map);
 }
 
+void bgp_free_aggregate_info(struct bgp_aggregate *aggregate)
+{
+       if (aggregate->community)
+               community_free(&aggregate->community);
+
+       hash_clean_and_free(&aggregate->community_hash,
+                           bgp_aggr_community_remove);
+
+       if (aggregate->ecommunity)
+               ecommunity_free(&aggregate->ecommunity);
+
+       hash_clean_and_free(&aggregate->ecommunity_hash,
+                           bgp_aggr_ecommunity_remove);
+
+       if (aggregate->lcommunity)
+               lcommunity_free(&aggregate->lcommunity);
+
+       hash_clean_and_free(&aggregate->lcommunity_hash,
+                           bgp_aggr_lcommunity_remove);
+
+       if (aggregate->aspath)
+               aspath_free(aggregate->aspath);
+
+       hash_clean_and_free(&aggregate->aspath_hash, bgp_aggr_aspath_remove);
+
+       bgp_aggregate_free(aggregate);
+}
+
 DEFPY(aggregate_addressv6, aggregate_addressv6_cmd,
       "[no] aggregate-address X:X::X:X/M$prefix [{"
       "as-set$as_set_s"