Skip to content

Commit

Permalink
Merge pull request #12558 from donaldsharp/bgp_static_route_mem_leak
Browse files Browse the repository at this point in the history
bgpd: static routes are leaked on shutdown
  • Loading branch information
riw777 authored Dec 27, 2022
2 parents 962ae98 + 1c22515 commit 7430278
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
7 changes: 2 additions & 5 deletions bgpd/bgp_nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,8 @@ static void bgp_connected_cleanup(struct route_table *table,
if (!bc)
return;

bc->refcnt--;
if (bc->refcnt == 0) {
XFREE(MTYPE_BGP_CONN, bc);
bgp_dest_set_bgp_connected_ref_info(bn, NULL);
}
XFREE(MTYPE_BGP_CONN, bc);
bgp_dest_set_bgp_connected_ref_info(bn, NULL);
}

bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
Expand Down
6 changes: 5 additions & 1 deletion bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -8917,7 +8917,11 @@ void bgp_redistribute_withdraw(struct bgp *bgp, afi_t afi, int type,
bgp_aggregate_decrement(bgp, bgp_dest_get_prefix(dest),
pi, afi, SAFI_UNICAST);
bgp_path_info_delete(dest, pi);
bgp_process(bgp, dest, afi, SAFI_UNICAST);
if (!CHECK_FLAG(bgp->flags,
BGP_FLAG_DELETE_IN_PROGRESS))
bgp_process(bgp, dest, afi, SAFI_UNICAST);
else
bgp_path_info_reap(dest, pi);
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions bgpd/rfapi/bgp_rfapi_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -3847,6 +3847,13 @@ struct rfapi_cfg *bgp_rfapi_cfg_new(struct rfapi_rfp_cfg *cfg)
return h;
}

static void bgp_rfapi_rfgn_list_delete(void *data)
{
struct rfapi_rfg_name *rfgn = data;
free(rfgn->name);
rfgn_free(rfgn);
}

void bgp_rfapi_cfg_destroy(struct bgp *bgp, struct rfapi_cfg *h)
{
afi_t afi;
Expand All @@ -3858,8 +3865,13 @@ void bgp_rfapi_cfg_destroy(struct bgp *bgp, struct rfapi_cfg *h)
if (h->l2_groups != NULL)
list_delete(&h->l2_groups);
list_delete(&h->nve_groups_sequential);

h->rfg_export_direct_bgp_l->del = bgp_rfapi_rfgn_list_delete;
list_delete(&h->rfg_export_direct_bgp_l);

h->rfg_export_zebra_l->del = bgp_rfapi_rfgn_list_delete;
list_delete(&h->rfg_export_zebra_l);

if (h->default_rt_export_list)
ecommunity_free(&h->default_rt_export_list);
if (h->default_rt_import_list)
Expand Down

0 comments on commit 7430278

Please sign in to comment.