aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-10-21 18:03:16 +0200
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-10-22 18:01:19 +0200
commit0afc64ba6ca5a522202c948fc56ae42344a51e76 (patch)
treeafe1b99d0ffc97122b3fcb1b6e7efbd247cc49c4
parenta9a7f4c36804d0a5acc5788cf2ef9f39954cccb4 (diff)
[HICN-342] No need to take a lock on the hash entry if the lookup for
a data hit the CS. Data packets coming from the network are dropped, data packets coming from an application face are either dropped or sent to the push node (which does not require a lock on the hash entry) Change-Id: Icf662dffa33b9dda2e2a69fc2104a69a82ef19fd Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
-rw-r--r--hicn-plugin/src/data_pcslookup_node.c52
-rw-r--r--hicn-plugin/src/pcs.h28
-rw-r--r--libtransport/src/hicn/transport/interfaces/callbacks.cc2
-rw-r--r--libtransport/src/hicn/transport/interfaces/callbacks.h2
-rw-r--r--libtransport/src/hicn/transport/interfaces/socket_consumer.cc4
-rw-r--r--libtransport/src/hicn/transport/interfaces/socket_producer.cc4
6 files changed, 51 insertions, 41 deletions
diff --git a/hicn-plugin/src/data_pcslookup_node.c b/hicn-plugin/src/data_pcslookup_node.c
index fdf855e57..1ae36202f 100644
--- a/hicn-plugin/src/data_pcslookup_node.c
+++ b/hicn-plugin/src/data_pcslookup_node.c
@@ -14,12 +14,12 @@
*/
#include "data_pcslookup.h"
+#include "infra.h"
#include "mgmt.h"
#include "parser.h"
-#include "infra.h"
+#include "state.h"
#include "strategy.h"
#include "strategy_dpo_manager.h"
-#include "state.h"
/* Stats string values */
static char *hicn_data_pcslookup_error_strings[] = {
@@ -37,10 +37,9 @@ vlib_node_registration_t hicn_data_pcslookup_node;
* hICN node for handling data. It performs a lookup in the PIT.
*/
static uword
-hicn_data_pcslookup_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn_data_pcslookup_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
-
u32 n_left_from, *from, *to_next;
hicn_data_pcslookup_next_t next_index;
hicn_data_pcslookup_runtime_t *rt;
@@ -87,7 +86,8 @@ hicn_data_pcslookup_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
{
vlib_buffer_t *b1;
b1 = vlib_get_buffer (vm, from[1]);
- //Prefetch two cache lines-- 128 byte-- so that we load the hicn_buffer_t as well
+ // Prefetch two cache lines-- 128 byte-- so that we load the
+ // hicn_buffer_t as well
CLIB_PREFETCH (b1, 2 * CLIB_CACHE_LINE_BYTES, STORE);
CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES, LOAD);
}
@@ -99,10 +99,9 @@ hicn_data_pcslookup_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
to_next += 1;
n_left_to_next -= 1;
-
b0 = vlib_get_buffer (vm, bi0);
hb0 = hicn_get_buffer (b0);
- next0 = HICN_DATA_PCSLOOKUP_NEXT_ERROR_DROP;
+ next0 = HICN_DATA_PCSLOOKUP_NEXT_ERROR_DROP;
/* Incr packet counter */
stats.pkts_processed += 1;
@@ -111,26 +110,24 @@ hicn_data_pcslookup_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
nameptr = (u8 *) (&name);
if (PREDICT_TRUE (ret0 == HICN_ERROR_NONE &&
- hicn_hashtb_fullhash (nameptr, namelen,
- &name_hash) == HICN_ERROR_NONE))
+ hicn_hashtb_fullhash (nameptr, namelen,
+ &name_hash) ==
+ HICN_ERROR_NONE))
{
int res =
hicn_hashtb_lookup_node (rt->pitcs->pcs_table, nameptr,
namelen, name_hash,
- !(hb0->flags &
- HICN_BUFFER_FLAGS_FACE_IS_APP)
- /* take lock */ ,
+ 1 /*is_data. Do not take lock if hit CS */ ,
&node_id0, &dpo_ctx_id0, &vft_id0,
- &is_cs0,
- &hash_entry_id, &bucket_id,
+ &is_cs0, &hash_entry_id, &bucket_id,
&bucket_is_overflown);
stats.pkts_data_count += 1;
#if HICN_FEATURE_CS
- if ((res == HICN_ERROR_HASHTB_HASH_NOT_FOUND
- || (res == HICN_ERROR_NONE && is_cs0))
- && ((hb0->flags & HICN_BUFFER_FLAGS_FACE_IS_APP)))
+ if ((res == HICN_ERROR_HASHTB_HASH_NOT_FOUND ||
+ (res == HICN_ERROR_NONE && is_cs0)) &&
+ ((hb0->flags & HICN_BUFFER_FLAGS_FACE_IS_APP)))
{
next0 = HICN_DATA_PCSLOOKUP_NEXT_STORE_DATA;
}
@@ -169,9 +166,8 @@ hicn_data_pcslookup_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
* Fix in case of a wrong speculation. Needed to
* clone the data in the right frame
*/
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, next0);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
/* Maybe trace */
if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
@@ -217,24 +213,22 @@ hicn_data_pcslookup_format_trace (u8 * s, va_list * args)
return (s);
}
-
/*
* Node registration for the data forwarder node
*/
/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn_data_pcslookup_node) =
+VLIB_REGISTER_NODE(hicn_data_pcslookup_node) =
{
.function = hicn_data_pcslookup_node_fn,
.name = "hicn-data-pcslookup",
- .vector_size = sizeof (u32),
- .runtime_data_bytes = sizeof (hicn_data_pcslookup_runtime_t),
+ .vector_size = sizeof(u32),
+ .runtime_data_bytes = sizeof(hicn_data_pcslookup_runtime_t),
.format_trace = hicn_data_pcslookup_format_trace,
- .type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN (hicn_data_pcslookup_error_strings),
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN(hicn_data_pcslookup_error_strings),
.error_strings = hicn_data_pcslookup_error_strings,
.n_next_nodes = HICN_DATA_PCSLOOKUP_N_NEXT,
- .next_nodes =
- {
+ .next_nodes = {
[HICN_DATA_PCSLOOKUP_NEXT_V4_LOOKUP] = "ip4-lookup",
[HICN_DATA_PCSLOOKUP_NEXT_V6_LOOKUP] = "ip6-lookup",
[HICN_DATA_PCSLOOKUP_NEXT_STORE_DATA] = "hicn-data-push",
diff --git a/hicn-plugin/src/pcs.h b/hicn-plugin/src/pcs.h
index c7e8a4b59..d9c48954e 100644
--- a/hicn-plugin/src/pcs.h
+++ b/hicn-plugin/src/pcs.h
@@ -499,8 +499,16 @@ hicn_pcs_cs_update (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
policy_vft->hicn_cs_delete_get (pitcs, policy_state,
&node, &pcs_entry, &hash_entry);
- hicn_pcs_cs_delete (vm, pitcs, &pcs_entry, &node, hash_entry, NULL,
- NULL);
+ /*
+ * We don't have to decrease the lock (therefore we cannot
+ * use hicn_pcs_cs_delete function)
+ */
+ policy_vft->hicn_cs_dequeue (pitcs, node, pcs_entry, policy_state);
+
+ hicn_cs_delete_trimmed (pitcs, &pcs_entry, hash_entry, &node, vm);
+
+ /* Update the global CS counter */
+ pitcs->pcs_cs_count--;
}
}
else
@@ -541,14 +549,14 @@ hicn_pcs_cs_delete (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
}
/* A data could have been inserted in the CS through a push. In this case locks == 0 */
- if (hash_entry->locks == 0 || hash_entry->locks == 1)
+ hash_entry->locks--;
+ if (hash_entry->locks == 0)
{
hicn_pcs_delete_internal
(pitcs, pcs_entryp, hash_entry, nodep, vm, dpo_vft, hicn_dpo_id);
}
else
{
- hash_entry->locks--;
hash_entry->he_flags |= HICN_HASH_ENTRY_FLAG_DELETED;
}
}
@@ -603,8 +611,16 @@ hicn_pcs_cs_insert (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
policy_vft->hicn_cs_delete_get (pitcs, policy_state,
&node, &pcs_entry, &hash_entry);
- hicn_pcs_cs_delete (vm, pitcs, &pcs_entry, &node, hash_entry, NULL,
- NULL);
+ /*
+ * We don't have to decrease the lock (therefore we cannot
+ * use hicn_pcs_cs_delete function)
+ */
+ policy_vft->hicn_cs_dequeue (pitcs, node, pcs_entry, policy_state);
+
+ hicn_cs_delete_trimmed (pitcs, &pcs_entry, hash_entry, &node, vm);
+
+ /* Update the global CS counter */
+ pitcs->pcs_cs_count--;
}
}
return ret;
diff --git a/libtransport/src/hicn/transport/interfaces/callbacks.cc b/libtransport/src/hicn/transport/interfaces/callbacks.cc
index af470898c..2574e7720 100644
--- a/libtransport/src/hicn/transport/interfaces/callbacks.cc
+++ b/libtransport/src/hicn/transport/interfaces/callbacks.cc
@@ -19,7 +19,7 @@ namespace transport {
namespace interface {
-nullptr_t VOID_HANDLER = nullptr;
+std::nullptr_t VOID_HANDLER = nullptr;
} // namespace interface
diff --git a/libtransport/src/hicn/transport/interfaces/callbacks.h b/libtransport/src/hicn/transport/interfaces/callbacks.h
index 41b6213fe..7194cca42 100644
--- a/libtransport/src/hicn/transport/interfaces/callbacks.h
+++ b/libtransport/src/hicn/transport/interfaces/callbacks.h
@@ -107,7 +107,7 @@ using ProducerContentObjectCallback =
using ProducerInterestCallback =
std::function<void(ProducerSocket &, core::Interest &)>;
-extern nullptr_t VOID_HANDLER;
+extern std::nullptr_t VOID_HANDLER;
} // namespace interface
diff --git a/libtransport/src/hicn/transport/interfaces/socket_consumer.cc b/libtransport/src/hicn/transport/interfaces/socket_consumer.cc
index 6eae23c85..14cd27b6b 100644
--- a/libtransport/src/hicn/transport/interfaces/socket_consumer.cc
+++ b/libtransport/src/hicn/transport/interfaces/socket_consumer.cc
@@ -135,8 +135,8 @@ int ConsumerSocket::rescheduleOnIOService(int socket_option_key,
/* Condition variable for the wait */
std::condition_variable cv;
bool done = false;
- io_service_.dispatch([this, &socket_option_key, &socket_option_value, &mtx,
- &cv, &result, &done, &func]() {
+ io_service_.dispatch([&socket_option_key, &socket_option_value, &mtx,
+ &result, &done, &func]() {
std::unique_lock<std::mutex> lck(mtx);
done = true;
result = func(socket_option_key, socket_option_value);
diff --git a/libtransport/src/hicn/transport/interfaces/socket_producer.cc b/libtransport/src/hicn/transport/interfaces/socket_producer.cc
index bc93e77c6..f90197490 100644
--- a/libtransport/src/hicn/transport/interfaces/socket_producer.cc
+++ b/libtransport/src/hicn/transport/interfaces/socket_producer.cc
@@ -406,8 +406,8 @@ int ProducerSocket::rescheduleOnIOService(int socket_option_key,
/* Condition variable for the wait */
std::condition_variable cv;
bool done = false;
- io_service_.dispatch([this, &socket_option_key, &socket_option_value, &mtx,
- &cv, &result, &done, &func]() {
+ io_service_.dispatch([&socket_option_key, &socket_option_value, &mtx,
+ &result, &done, &func]() {
std::unique_lock<std::mutex> lck(mtx);
done = true;
result = func(socket_option_key, socket_option_value);