From 87c3281623fce5f739f450bdff3b7ac793a6ebd5 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 f95769b3362c..253f70cd8708 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9816,6 +9816,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;