diff options
| author | Carmine Scarpitta <carmine.scarpitta@uniroma2.it> | 2022-08-24 00:13:25 +0200 |
|---|---|---|
| committer | Carmine Scarpitta <carmine.scarpitta@uniroma2.it> | 2022-08-24 14:22:04 +0200 |
| commit | f8e9c702a17d6b5642078305436ad9b8920a119a (patch) | |
| tree | 5b5d473c2aa6e9e746c4af3d5d32afa4e24cf0c8 /lib/command_py.c | |
| parent | bda15542f425bff67b4f821f2e475f4e330696dd (diff) | |
bgpd: Fix memory leak in SRv6 locator delete
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 locators are removed/unset in bgpd: when
an SRv6 locator is deleted or unset, the memory allocated for the
locator prefix (`tovpn_sid_locator`) is not freed.
This patch adds a `for` loop that iterates over the list of BGP
instances. For each BGP instance using the SRv6 locator to be
removed/unset, we use `XFREE()` to properly free the memory allocated
for `tovpn_sid_locator` after the SRv6 locator is removed or unset.
The memory allocated for `tovpn_sid_locator` cannot be freed before
calling `vpn_leak_postchange_all()`. This is because
after deleting an SRv6 locator, we call `vpn_leak_postchange_all()`
to handle the SRv6 locator deletion and send a BGP Prefix SID withdraw
message. `tovpn_sid_locator` is required to properly build the BGP
Prefix SID withdraw message. After calling `vpn_leak_postchange_all()`
we can safely remove the `tovpn_sid_locator` and free the allocated
memory.
Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
Diffstat (limited to 'lib/command_py.c')
0 files changed, 0 insertions, 0 deletions
