From d2db218a8ac3f7e1ebb55fee2d37b2b2df00a701 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) # Conflicts: # bgpd/bgp_vty.c --- bgpd/bgp_vty.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 74bbd51c0577..92b1d8ca3a8e 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -8959,6 +8959,13 @@ DEFPY (af_rd_vpn_export, bgp_get_default(), bgp); if (yes) { +<<<<<<< HEAD +======= + 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); +>>>>>>> 0dd96287d (bgpd: fix memory leak when reconfiguring a route distinguisher) bgp->vpn_policy[afi].tovpn_rd = prd; SET_FLAG(bgp->vpn_policy[afi].flags, BGP_VPN_POLICY_TOVPN_RD_SET);