]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Fix memory leak on shutdown
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 11 Apr 2018 13:20:19 +0000 (09:20 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 25 Apr 2018 16:39:17 +0000 (12:39 -0400)
When we remove a bgp instance cleanup the
import_vrf and export_vrf lists.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgpd.c

index 53ddbf61cce7a553cebd3dc50242d039f5063179..ccfa90419b2ac1c6ceb632bc6264d75f4e6f4906 100644 (file)
@@ -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);