From d78b28822e4ea01f17eae875ae3d7cd4bbb2a8cf 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 2ae63d37ac02..8e29e90c7d91 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9708,6 +9708,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;