return XCALLOC(MTYPE_BGP_AGGREGATE, sizeof(struct bgp_aggregate));
}
-static void bgp_aggregate_free(struct bgp_aggregate *aggregate)
+void bgp_aggregate_free(struct bgp_aggregate *aggregate)
{
XFREE(MTYPE_ROUTE_MAP_NAME, aggregate->suppress_map_name);
route_map_counter_decrement(aggregate->suppress_map);
}
/* Update an aggregate as routes are added/removed from the BGP table */
-void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
+bool bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
safi_t safi, struct bgp_aggregate *aggregate)
{
struct bgp_table *table;
* then do not create aggregate route
*/
if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS) ||
- (bgp->peer_self == NULL)) {
- bgp_aggregate_free(aggregate);
- return;
- }
+ bgp->peer_self == NULL)
+ return false;
/* Initialize and test routes for MED difference. */
if (aggregate->match_med)
bgp_aggregate_install(bgp, afi, safi, p, origin, aspath, community,
ecommunity, lcommunity, atomic_aggregate,
aggregate);
+
+ return true;
}
void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p, afi_t afi,
bgp_dest_set_bgp_aggregate_info(dest, aggregate);
/* Aggregate address insert into BGP routing table. */
- bgp_aggregate_route(bgp, &p, afi, safi, aggregate);
+ if (!bgp_aggregate_route(bgp, &p, afi, safi, aggregate)) {
+ bgp_aggregate_free(aggregate);
+ bgp_dest_unlock_node(dest);
+ }
return CMD_SUCCESS;
}
extern void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p,
afi_t afi, safi_t safi,
struct bgp_aggregate *aggregate);
-extern void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p,
+extern bool bgp_aggregate_route(struct bgp *bgp, const struct prefix *p,
afi_t afi, safi_t safi,
struct bgp_aggregate *aggregate);
extern void bgp_aggregate_increment(struct bgp *bgp, const struct prefix *p,
extern void bgp_path_info_add_with_caller(const char *caller,
struct bgp_dest *dest,
struct bgp_path_info *pi);
+extern void bgp_aggregate_free(struct bgp_aggregate *aggregate);
#define bgp_path_info_add(A, B) \
bgp_path_info_add_with_caller(__func__, (A), (B))
#define bgp_path_info_free(B) bgp_path_info_free_with_caller(__func__, (B))