bgpd: bgp_connected_add memory was being leaked in some cases

On shutdown, bgp calls an unlock for the bnc connected table,
via the bgp_connected_cleanup function.  This function is
only ever called on shutdown, so we know that bgp is going
away.  The refcount for the connected data can be more than
1.  Let's not worry about the refcount on shutdown and
just delete the nodes instead of leaving them around.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2022-12-21 19:26:58 -05:00
parent c560f0698f
commit 1c225152c0

View File

@ -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,