From 2cf6ae9b832f3709209a63778e85ca46d3e1a1ec Mon Sep 17 00:00:00 2001 From: Alberto Compagno Date: Fri, 13 Dec 2019 20:43:30 +0000 Subject: [HICN-457] Adding missing lock to the hash entry in order to avoid memory leak. Signed-off-by: Alberto Compagno Change-Id: I9ee6d6311ca39353f93e6d41b06752b17628b46f --- hicn-plugin/src/data_fwd_node.c | 2 +- hicn-plugin/src/data_push_node.c | 2 +- hicn-plugin/src/strategy.c | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hicn-plugin/src/data_fwd_node.c b/hicn-plugin/src/data_fwd_node.c index ca3baaa0d..1bb064fcf 100644 --- a/hicn-plugin/src/data_fwd_node.c +++ b/hicn-plugin/src/data_fwd_node.c @@ -399,7 +399,7 @@ hicn_satisfy_faces (vlib_main_t * vm, u32 bi0, * Mark the buffer as smaller than TWO_CL. It will be stored as is in the CS, without excluding * the hicn_header. Cloning is not possible, it will be copied. */ - if (b0->current_length < (buffer_advance + (CLIB_CACHE_LINE_BYTES * 2))) + if (b0->current_length <= (buffer_advance + (CLIB_CACHE_LINE_BYTES * 2))) { /* In this case the packet is copied. We don't need to add a reference as no buffer are * chained to it. diff --git a/hicn-plugin/src/data_push_node.c b/hicn-plugin/src/data_push_node.c index ff28b4dea..21ebae16f 100644 --- a/hicn-plugin/src/data_push_node.c +++ b/hicn-plugin/src/data_push_node.c @@ -74,7 +74,7 @@ prep_buffer_for_cs (vlib_main_t * vm, vlib_buffer_t * b0, u8 isv6) * Mark the buffer as smaller than TWO_CL. It will be stored as is in the CS, without excluding * the hicn_header. Cloning is not possible, it will be copied. */ - if (b0->current_length < (buffer_advance + (CLIB_CACHE_LINE_BYTES * 2))) + if (b0->current_length <= (buffer_advance + (CLIB_CACHE_LINE_BYTES * 2))) { /* In this case the packet is copied. We don't need to add a reference as no buffer are * chained to it. diff --git a/hicn-plugin/src/strategy.c b/hicn-plugin/src/strategy.c index 62c2ddc8b..15c0dc720 100644 --- a/hicn-plugin/src/strategy.c +++ b/hicn-plugin/src/strategy.c @@ -117,6 +117,9 @@ hicn_new_interest (hicn_strategy_runtime_t * rt, vlib_buffer_t * b0, hicn_store_internal_state (b0, hicnb0->name_hash, node_id0, dpo_ctx_id0, vft_id0, hash_entry_id, bucket_id, bucket_is_overflow); + // We need to take a lock as the lock is not taken on the hash + // entry because it is a CS entry (hash_insert function). + hash_entry->locks++; *next = is_cs0 ? HICN_STRATEGY_NEXT_INTEREST_HITCS : HICN_STRATEGY_NEXT_INTEREST_HITPIT; -- cgit 1.2.3-korg