From d77630adaf48f05766c33ec60ef19ed50acae161 Mon Sep 17 00:00:00 2001 From: John Lo Date: Fri, 28 Apr 2017 00:33:36 -0400 Subject: Fix memory leak on deletion of BD (bridge domain) On BD deletion, free memory used by members vector and mac_by_ip4 and mac_by_ip6 hash tables. Change-Id: Ied467e79bb6636fd8788bdeddee660c66391bb7e Signed-off-by: John Lo --- src/vnet/l2/l2_bd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/vnet/l2/l2_bd.c') diff --git a/src/vnet/l2/l2_bd.c b/src/vnet/l2/l2_bd.c index cfaf4c994f5..7c55789bb32 100644 --- a/src/vnet/l2/l2_bd.c +++ b/src/vnet/l2/l2_bd.c @@ -92,15 +92,21 @@ bd_add_bd_index (bd_main_t * bdm, u32 bd_id) static int bd_delete (bd_main_t * bdm, u32 bd_index) { - u32 bd_id = l2input_main.bd_configs[bd_index].bd_id; + l2_bridge_domain_t *bd = &l2input_main.bd_configs[bd_index]; + u32 bd_id = bd->bd_id; hash_unset (bdm->bd_index_by_bd_id, bd_id); /* mark this index clear */ bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap, bd_index, 0); - l2input_main.bd_configs[bd_index].bd_id = ~0; - l2input_main.bd_configs[bd_index].feature_bitmap = 0; + /* clear BD config for reuse: bd_id to -1 and clear feature_bitmap */ + bd->bd_id = ~0; + bd->feature_bitmap = 0; + /* free memory used by BD and flush non-static MACs in BD */ + vec_free (bd->members); + hash_free (bd->mac_by_ip4); + hash_free (bd->mac_by_ip6); l2fib_flush_bd_mac (vlib_get_main (), bd_index); return 0; -- cgit 1.2.3-korg