aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/l2/l2_bd.c
diff options
context:
space:
mode:
authorJohn Lo <loj@cisco.com>2017-04-28 00:33:36 -0400
committerDamjan Marion <dmarion.lists@gmail.com>2017-04-28 07:59:53 +0000
commitd77630adaf48f05766c33ec60ef19ed50acae161 (patch)
treea78e08759dfa53139dfbc5b1dd0e9310e491c2f9 /src/vnet/l2/l2_bd.c
parent5445f5fd9b9d020b285d48e571c86528932ac071 (diff)
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 <loj@cisco.com>
Diffstat (limited to 'src/vnet/l2/l2_bd.c')
-rw-r--r--src/vnet/l2/l2_bd.c12
1 files changed, 9 insertions, 3 deletions
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;