From fee57833d7870912e5c3b32cb787ec7ca9301ed8 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 18 Dec 2024 16:53:48 +0100 Subject: [PATCH] bgpd: fix memory leak when reconfiguring a route distinguisher A memory leak happens when reconfiguring an already configured route distinguisher on an L3VPN BGP instance. Fix this by freeing the previous route distinguisher. Signed-off-by: Philippe Guibert (cherry picked from commit 0dd96287dda22b79ef6d7424f4e1a8dc92959f92) --- bgpd/bgp_vty.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index fdf84395e2..97ca5622b9 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9482,6 +9482,8 @@ DEFPY (af_rd_vpn_export, bgp_get_default(), bgp); if (yes) { + if (bgp->vpn_policy[afi].tovpn_rd_pretty) + XFREE(MTYPE_BGP_NAME, bgp->vpn_policy[afi].tovpn_rd_pretty); bgp->vpn_policy[afi].tovpn_rd_pretty = XSTRDUP(MTYPE_BGP_NAME, rd_str); bgp->vpn_policy[afi].tovpn_rd = prd; -- 2.39.5