vpp-swan: fix memory leaks

This patch fix the memory leaks discovered in the current
implementation, inlcuding expired data, spd dump, and host names.

Type: fix
Signed-off-by: Gabriel Oginski <gabrielx.oginski@intel.com>
Change-Id: I3794f5db3c58d1e78df25f242c91e7a67363de53
This commit is contained in:
Gabriel Oginski
2023-02-14 08:46:36 +00:00
committed by Fan Zhang
parent 9ad423fceb
commit 2da99e5072
2 changed files with 216 additions and 68 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -545,6 +545,7 @@ update_addrs (private_kernel_vpp_net_t *this, iface_t *entry)
vl_api_ip_address_details_t *rmp, *tmp;
linked_list_t *addrs;
host_t *host;
enumerator_t *enumerator;
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
@@ -591,6 +592,13 @@ update_addrs (private_kernel_vpp_net_t *this, iface_t *entry)
vl_msg_api_free (mp);
free (out);
/* clean-up */
enumerator = entry->addrs->create_enumerator (entry->addrs);
while (enumerator->enumerate (enumerator, &host))
{
host->destroy (host);
}
enumerator->destroy (enumerator);
entry->addrs->destroy (entry->addrs);
entry->addrs =
linked_list_create_from_enumerator (addrs->create_enumerator (addrs));