From 1c225152c0f19d2d52c38e8cdc982750e50f72e0 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 21 Dec 2022 19:26:58 -0500 Subject: [PATCH] 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 --- bgpd/bgp_nexthop.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 25a4a1b521..6bbdbdc1a9 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -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, -- 2.39.5