summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorCarmine Scarpitta <cscarpit@cisco.com>2024-05-08 09:48:55 +0200
committerCarmine Scarpitta <cscarpit@cisco.com>2024-05-09 08:14:34 +0200
commit165caaeea8b04b6ac59c9016f1d5240238200a27 (patch)
treefe311d522633b39dae49129ba397dae36525eecc /bgpd
parentbgpd: Fix SRv6 memory leaks spotted by ASAN (diff)
downloadfrr-165caaeea8b04b6ac59c9016f1d5240238200a27.tar.xz
frr-165caaeea8b04b6ac59c9016f1d5240238200a27.zip
bgpd: Move SRv6 cleanup functions
Move SRv6 cleanup operations to `bgp_srv6_cleanup` function. Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgpd.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index c133e02c7..76014d4eb 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -1473,6 +1473,20 @@ static void bgp_srv6_init(struct bgp *bgp)
static void bgp_srv6_cleanup(struct bgp *bgp)
{
+ for (afi_t afi = AFI_IP; afi < AFI_MAX; afi++) {
+ if (bgp->vpn_policy[afi].tovpn_sid_locator != NULL)
+ srv6_locator_chunk_free(
+ &bgp->vpn_policy[afi].tovpn_sid_locator);
+ if (bgp->vpn_policy[afi].tovpn_zebra_vrf_sid_last_sent != NULL)
+ XFREE(MTYPE_BGP_SRV6_SID,
+ bgp->vpn_policy[afi].tovpn_zebra_vrf_sid_last_sent);
+ if (bgp->vpn_policy[afi].tovpn_sid != NULL) {
+ sid_unregister(bgp, bgp->vpn_policy[afi].tovpn_sid);
+ XFREE(MTYPE_BGP_SRV6_SID,
+ bgp->vpn_policy[afi].tovpn_sid);
+ }
+ }
+
if (bgp->tovpn_sid_locator != NULL)
srv6_locator_chunk_free(&bgp->tovpn_sid_locator);
if (bgp->tovpn_zebra_vrf_sid_last_sent != NULL)
@@ -4145,18 +4159,6 @@ void bgp_free(struct bgp *bgp)
if (bgp->vpn_policy[afi].tovpn_rd_pretty)
XFREE(MTYPE_BGP_NAME,
bgp->vpn_policy[afi].tovpn_rd_pretty);
- if (bgp->vpn_policy[afi].tovpn_sid_locator != NULL)
- srv6_locator_chunk_free(
- &bgp->vpn_policy[afi].tovpn_sid_locator);
- if (bgp->vpn_policy[afi].tovpn_zebra_vrf_sid_last_sent != NULL)
- XFREE(MTYPE_BGP_SRV6_SID,
- bgp->vpn_policy[afi]
- .tovpn_zebra_vrf_sid_last_sent);
- if (bgp->vpn_policy[afi].tovpn_sid != NULL) {
- sid_unregister(bgp, bgp->vpn_policy[afi].tovpn_sid);
- XFREE(MTYPE_BGP_SRV6_SID,
- bgp->vpn_policy[afi].tovpn_sid);
- }
}
bgp_srv6_cleanup(bgp);
bgp_confederation_id_unset(bgp);