forked from Mirror/frr
bgpd: Fix memory leak when an SRv6 SID is removed
Running `bgp_srv6l3vpn_to_bgp_vrf` and `bgp_srv6l3vpn_to_bgp_vrf2` topotests with `--valgrind-memleaks` gives several memory leak errors. This is due to the way SRv6 SIDs are removed in bgpd: when an SRv6 locator is deleted/unset, all the SIDs allocated from that locator are removed from the SRv6 functions list (`bgp->srv6_functions`),but the memory allocated for the SIDs is not freed. This patch adds a call to `XFREE()` to properly free the allocated memory when an SRv6 SID is removed. Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
This commit is contained in:
parent
03852f673b
commit
bda15542f4
|
@ -312,8 +312,10 @@ static int bgp_srv6_locator_unset(struct bgp *bgp)
|
|||
}
|
||||
|
||||
/* refresh functions */
|
||||
for (ALL_LIST_ELEMENTS(bgp->srv6_functions, node, nnode, func))
|
||||
for (ALL_LIST_ELEMENTS(bgp->srv6_functions, node, nnode, func)) {
|
||||
listnode_delete(bgp->srv6_functions, func);
|
||||
XFREE(MTYPE_BGP_SRV6_FUNCTION, func);
|
||||
}
|
||||
|
||||
/* refresh tovpn_sid */
|
||||
for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) {
|
||||
|
|
|
@ -3229,8 +3229,10 @@ static int bgp_zebra_process_srv6_locator_delete(ZAPI_CALLBACK_ARGS)
|
|||
tmp_prefi.prefixlen = 128;
|
||||
tmp_prefi.prefix = func->sid;
|
||||
if (prefix_match((struct prefix *)&loc.prefix,
|
||||
(struct prefix *)&tmp_prefi))
|
||||
(struct prefix *)&tmp_prefi)) {
|
||||
listnode_delete(bgp->srv6_functions, func);
|
||||
XFREE(MTYPE_BGP_SRV6_FUNCTION, func);
|
||||
}
|
||||
}
|
||||
|
||||
// refresh tovpn_sid
|
||||
|
|
Loading…
Reference in a new issue