diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-04-11 09:20:19 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-04-25 12:39:17 -0400 |
| commit | d39ac3eb76dafb0770e1a1004ae2fb675c09a81e (patch) | |
| tree | 48500c3f5dae0ae8a9f4f489955fd01e49e48c71 | |
| parent | d0fa84c228262e18d14207af4cb7b4e0a8ffdafb (diff) | |
bgpd: Fix memory leak on shutdown
When we remove a bgp instance cleanup the
import_vrf and export_vrf lists.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
| -rw-r--r-- | bgpd/bgpd.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 53ddbf61cc..ccfa90419b 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3380,6 +3380,17 @@ void bgp_free(struct bgp *bgp) rmap = &bgp->table_map[afi][safi]; if (rmap->name) XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name); + + /* + * Yes this is per AFI, but + * the list_delete_and_null nulls the pointer + * and we'll not leak anything on going down + * and the if test will fail on the second safi. + */ + if (bgp->vpn_policy[afi].import_vrf) + list_delete_and_null(&bgp->vpn_policy[afi].import_vrf); + if (bgp->vpn_policy[afi].export_vrf) + list_delete_and_null(&bgp->vpn_policy[afi].export_vrf); } bgp_scan_finish(bgp); |
