diff options
author | Steven Luong <sluong@cisco.com> | 2021-12-15 13:27:53 -0800 |
---|---|---|
committer | Neale Ranns <neale@graphiant.com> | 2022-01-09 13:43:50 +0000 |
commit | 221be7c03f8daf5b9c00b2509ebbf2c6e7e6232d (patch) | |
tree | 59339ad44acede89b05d3e6d2dc853b0773e9887 | |
parent | 6815bc3d8b966a62e46cd1dac3e357f20019999c (diff) |
fib: multiple memory leaks upon deleting a VRF table
fib_table->ft_locks
name string for parsing the ip table add|del name <tag> command
path list for ip4_specials in mfib
mfib->fib_entry_by_dst_address[0..32]
mfib entry path_ext, msrc->mfes_exts
Type: fix
Signed-off-by: Steven Luong <sluong@cisco.com>
Change-Id: Ia1e0cac577a73608ee1e4b1664b60a66322e81ce
-rw-r--r-- | src/vnet/fib/ip4_fib.c | 1 | ||||
-rw-r--r-- | src/vnet/ip/lookup.c | 1 | ||||
-rw-r--r-- | src/vnet/mfib/ip4_mfib.c | 36 | ||||
-rw-r--r-- | src/vnet/mfib/mfib_entry.c | 2 |
4 files changed, 25 insertions, 15 deletions
diff --git a/src/vnet/fib/ip4_fib.c b/src/vnet/fib/ip4_fib.c index 2fa5d7e00ca..8e580a54716 100644 --- a/src/vnet/fib/ip4_fib.c +++ b/src/vnet/fib/ip4_fib.c @@ -216,6 +216,7 @@ ip4_fib_table_destroy (u32 fib_index) hash_unset (ip4_main.fib_index_by_table_id, fib_table->ft_table_id); } + vec_free (fib_table->ft_locks); vec_free(fib_table->ft_src_route_counts); ip4_fib_table_free(v4_fib); diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c index b678ce330c3..c2c4bae5041 100644 --- a/src/vnet/ip/lookup.c +++ b/src/vnet/ip/lookup.c @@ -410,6 +410,7 @@ vnet_ip_table_cmd (vlib_main_t * vm, } done: + vec_free (name); unformat_free (line_input); return error; } diff --git a/src/vnet/mfib/ip4_mfib.c b/src/vnet/mfib/ip4_mfib.c index e71b7db7e5f..2ad873f82bf 100644 --- a/src/vnet/mfib/ip4_mfib.c +++ b/src/vnet/mfib/ip4_mfib.c @@ -42,6 +42,18 @@ static const mfib_prefix_t ip4_specials[] = .fp_proto = FIB_PROTOCOL_IP4, }, }; +static const fib_route_path_t ip4_special_path = + { + .frp_proto = DPO_PROTO_IP4, + .frp_addr = { + .ip4.data_u32 = 0x0, + }, + .frp_sw_if_index = ~0, + .frp_fib_index = ~0, + .frp_weight = 1, + .frp_flags = FIB_ROUTE_PATH_LOCAL, + .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD, + }; static u32 ip4_create_mfib_with_table_id (u32 table_id, @@ -76,15 +88,6 @@ ip4_create_mfib_with_table_id (u32 table_id, MFIB_RPF_ID_NONE, MFIB_ENTRY_FLAG_DROP); - const fib_route_path_t path = { - .frp_proto = DPO_PROTO_IP4, - .frp_addr = zero_addr, - .frp_sw_if_index = ~0, - .frp_fib_index = ~0, - .frp_weight = 1, - .frp_flags = FIB_ROUTE_PATH_LOCAL, - .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD, - }; int ii; for (ii = 0; ii < ARRAY_LEN(ip4_specials); ii++) @@ -93,7 +96,7 @@ ip4_create_mfib_with_table_id (u32 table_id, &ip4_specials[ii], MFIB_SOURCE_SPECIAL, MFIB_ENTRY_FLAG_NONE, - &path); + &ip4_special_path); } return (mfib_table->mft_index); @@ -113,11 +116,12 @@ ip4_mfib_table_destroy (ip4_mfib_t *mfib) MFIB_SOURCE_DEFAULT_ROUTE); for (ii = 0; ii < ARRAY_LEN(ip4_specials); ii++) - { - mfib_table_entry_delete(mfib_table->mft_index, - &ip4_specials[ii], - MFIB_SOURCE_SPECIAL); - } + { + mfib_table_entry_path_remove(mfib_table->mft_index, + &ip4_specials[ii], + MFIB_SOURCE_SPECIAL, + &ip4_special_path); + } /* * validate no more routes. @@ -125,6 +129,8 @@ ip4_mfib_table_destroy (ip4_mfib_t *mfib) ASSERT(0 == mfib_table->mft_total_route_counts); ASSERT(~0 != mfib_table->mft_table_id); + for (u32 i = 0; i < ARRAY_LEN (mfib->fib_entry_by_dst_address); i++) + hash_free (mfib->fib_entry_by_dst_address[i]); hash_unset (ip4_main.mfib_index_by_table_id, mfib_table->mft_table_id); pool_put(ip4_main.mfibs, mfib_table); } diff --git a/src/vnet/mfib/mfib_entry.c b/src/vnet/mfib/mfib_entry.c index 8050882d436..20945aa6781 100644 --- a/src/vnet/mfib/mfib_entry.c +++ b/src/vnet/mfib/mfib_entry.c @@ -412,6 +412,8 @@ mfib_entry_src_flush (mfib_entry_src_t *msrc) })); hash_free(msrc->mfes_itfs); msrc->mfes_itfs = NULL; + hash_free(msrc->mfes_exts); + msrc->mfes_exts = NULL; fib_path_list_unlock(msrc->mfes_pl); } |