Skip to content

Commit

Permalink
Merge pull request FRRouting#13554 from ryndia/fix_leak
Browse files Browse the repository at this point in the history
bgpd: free bgp vpn policy
  • Loading branch information
ton31337 authored Jul 4, 2023
2 parents ae2f167 + cfc5c10 commit c75c96a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bgpd/bgp_mplsvpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ static void sid_register(struct bgp *bgp, const struct in6_addr *sid,
listnode_add(bgp->srv6_functions, func);
}

static void sid_unregister(struct bgp *bgp, const struct in6_addr *sid)
void sid_unregister(struct bgp *bgp, const struct in6_addr *sid)
{
struct listnode *node, *nnode;
struct bgp_srv6_function *func;
Expand Down
1 change: 1 addition & 0 deletions bgpd/bgp_mplsvpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,5 +398,6 @@ struct bgp_mplsvpn_nh_label_bind_cache *bgp_mplsvpn_nh_label_bind_find(
struct bgp_mplsvpn_nh_label_bind_cache_head *tree, struct prefix *p,
mpls_label_t orig_label);
void bgp_mplsvpn_nexthop_init(void);
extern void sid_unregister(struct bgp *bgp, const struct in6_addr *sid);

#endif /* _QUAGGA_BGP_MPLSVPN_H */
15 changes: 13 additions & 2 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3983,7 +3983,6 @@ void bgp_free(struct bgp *bgp)

bgp_evpn_cleanup(bgp);
bgp_pbr_cleanup(bgp);
bgp_srv6_cleanup(bgp);

for (afi = AFI_IP; afi < AFI_MAX; afi++) {
enum vpn_policy_direction dir;
Expand All @@ -4001,8 +4000,20 @@ void bgp_free(struct bgp *bgp)
ecommunity_free(&bgp->vpn_policy[afi].rtlist[dir]);
if (bgp->vpn_policy[afi].tovpn_rd_pretty)
XFREE(MTYPE_BGP, 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);

XFREE(MTYPE_BGP, bgp->as_pretty);
Expand Down

0 comments on commit c75c96a

Please sign in to comment.