aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hicn-plugin/src/interest_pcslookup_node.c53
-rw-r--r--hicn-plugin/src/strategy_node.c53
2 files changed, 66 insertions, 40 deletions
diff --git a/hicn-plugin/src/interest_pcslookup_node.c b/hicn-plugin/src/interest_pcslookup_node.c
index e3668c565..a0b2ee3f0 100644
--- a/hicn-plugin/src/interest_pcslookup_node.c
+++ b/hicn-plugin/src/interest_pcslookup_node.c
@@ -47,6 +47,20 @@ static char *hicn_interest_pcslookup_error_strings[] = {
vlib_node_registration_t hicn_interest_pcslookup_node;
+always_inline void
+drop_packet (vlib_main_t *vm, u32 bi0, u32 *n_left_to_next, u32 *next0,
+ u32 **to_next, u32 *next_index, vlib_node_runtime_t *node)
+{
+ *next0 = HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP;
+
+ (*to_next)[0] = bi0;
+ *to_next += 1;
+ *n_left_to_next -= 1;
+
+ vlib_validate_buffer_enqueue_x1 (vm, node, *next_index, *to_next,
+ *n_left_to_next, bi0, *next0);
+}
+
/*
* ICN forwarder node for interests.
*/
@@ -64,6 +78,8 @@ hicn_interest_pcslookup_node_inline (vlib_main_t *vm,
u32 bi0;
u32 next0 = HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP;
hicn_pcs_entry_t *pcs_entry = NULL;
+ f64 tnow;
+ hicn_buffer_t *hicnb0;
rt = vlib_node_get_runtime_data (vm, hicn_interest_pcslookup_node.index);
@@ -75,6 +91,8 @@ hicn_interest_pcslookup_node_inline (vlib_main_t *vm,
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
+ tnow = vlib_time_now (vm);
+
while (n_left_from > 0)
{
u32 n_left_to_next;
@@ -105,9 +123,11 @@ hicn_interest_pcslookup_node_inline (vlib_main_t *vm,
// Update stats
stats.pkts_processed++;
+ hicnb0 = hicn_get_buffer (b0);
+
// Check if the interest is in the PCS already
hicn_name_t name;
- hicn_packet_get_name (&hicn_get_buffer (b0)->pkbuf, &name);
+ hicn_packet_get_name (&hicnb0->pkbuf, &name);
ret = hicn_pcs_lookup_one (rt->pitcs, &name, &pcs_entry);
if (ret == HICN_ERROR_NONE)
@@ -124,7 +144,38 @@ hicn_interest_pcslookup_node_inline (vlib_main_t *vm,
if (PREDICT_FALSE (ret != HICN_ERROR_NONE))
next0 = HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP;
}
+ else
+ {
+ // No entry in PCS. Let's create one now
+ pcs_entry = hicn_pcs_entry_pit_get (
+ rt->pitcs, tnow, hicn_buffer_get_lifetime (b0));
+
+ ret = hicn_pcs_pit_insert (rt->pitcs, pcs_entry, &name);
+
+ if (PREDICT_FALSE (ret != HICN_ERROR_NONE))
+ {
+ next0 = HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP;
+ goto end;
+ }
+
+ // Store internal state
+ ret = hicn_store_internal_state (
+ b0, hicn_pcs_entry_get_index (rt->pitcs, pcs_entry),
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX]);
+
+ if (PREDICT_FALSE (ret != HICN_ERROR_NONE))
+ {
+ hicn_pcs_entry_remove_lock (rt->pitcs, pcs_entry);
+ drop_packet (vm, bi0, &n_left_from, &next0, &to_next,
+ &next_index, node);
+ continue;
+ }
+
+ // Add face
+ hicn_pcs_entry_pit_add_face (pcs_entry, hicnb0->face_id);
+ }
+ end:
stats.pkts_interest_count++;
// Interest manifest?
diff --git a/hicn-plugin/src/strategy_node.c b/hicn-plugin/src/strategy_node.c
index 67ac1c140..6c98f3b06 100644
--- a/hicn-plugin/src/strategy_node.c
+++ b/hicn-plugin/src/strategy_node.c
@@ -64,12 +64,26 @@ always_inline void
drop_packet (vlib_main_t *vm, u32 bi0, u32 *n_left_to_next, u32 *next0,
u32 **to_next, u32 *next_index, vlib_node_runtime_t *node)
{
+ vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0);
+
*next0 = HICN_STRATEGY_NEXT_ERROR_DROP;
(*to_next)[0] = bi0;
*to_next += 1;
*n_left_to_next -= 1;
+ // Maybe trace
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (b0->flags & VLIB_BUFFER_IS_TRACED)))
+ {
+ hicn_strategy_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
+ t->pkt_type = HICN_PACKET_TYPE_INTEREST;
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX];
+ t->next_index = *next0;
+ t->dpo_type = hicn_get_buffer (b0)->vft_id;
+ t->out_face = -1;
+ }
+
vlib_validate_buffer_enqueue_x1 (vm, node, *next_index, *to_next,
*n_left_to_next, bi0, *next0);
}
@@ -95,10 +109,8 @@ hicn_strategy_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
u32 clones[MAX_OUT_FACES];
u16 outfaces_len;
u32 next0;
- const hicn_dpo_ctx_t *dpo_ctx;
const hicn_strategy_vft_t *strategy;
hicn_buffer_t *hicnb0;
- hicn_pcs_entry_t *pcs_entry = NULL;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -111,7 +123,6 @@ hicn_strategy_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
while (n_left_from > 0)
{
-
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
while (n_left_from > 0 && n_left_to_next > 0)
{
@@ -138,11 +149,7 @@ hicn_strategy_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
hicnb0 = hicn_get_buffer (b0);
// Get the strategy VFT
- hicnb0->dpo_ctx_id = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
- dpo_ctx = hicn_strategy_dpo_ctx_get (hicnb0->dpo_ctx_id);
- hicnb0->vft_id = dpo_ctx->dpo_type;
strategy = hicn_dpo_get_strategy_vft (hicnb0->vft_id);
- strategy->hicn_add_interest (hicnb0->dpo_ctx_id);
// Check we have at least one next hop for the packet
ret = strategy->hicn_select_next_hop (
@@ -155,38 +162,6 @@ hicn_strategy_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
continue;
}
- // Create a new PIT entry
- pcs_entry = hicn_pcs_entry_pit_get (rt->pitcs, tnow,
- hicn_buffer_get_lifetime (b0));
-
- // Add entry to PIT table
- hicn_name_t name;
- hicn_packet_get_name (&hicnb0->pkbuf, &name);
- ret = hicn_pcs_pit_insert (rt->pitcs, pcs_entry, &name);
-
- if (PREDICT_FALSE (ret != HICN_ERROR_NONE))
- {
- drop_packet (vm, bi0, &n_left_from, &next0, &to_next,
- &next_index, node);
- continue;
- }
-
- // Store internal state
- ret = hicn_store_internal_state (
- b0, hicn_pcs_entry_get_index (rt->pitcs, pcs_entry),
- vnet_buffer (b0)->ip.adj_index[VLIB_TX]);
-
- if (PREDICT_FALSE (ret != HICN_ERROR_NONE))
- {
- hicn_pcs_entry_remove_lock (rt->pitcs, pcs_entry);
- drop_packet (vm, bi0, &n_left_from, &next0, &to_next,
- &next_index, node);
- continue;
- }
-
- // Add face
- hicn_pcs_entry_pit_add_face (pcs_entry, hicnb0->face_id);
-
// Set next node
next0 = hicn_buffer_is_v6 (b0) ? HICN_STRATEGY_NEXT_INTEREST_FACE6 :
HICN_STRATEGY_NEXT_INTEREST_FACE4;