aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/interest_pcslookup_node.c
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2023-01-19 20:39:23 +0000
committerMauro Sardara <msardara@cisco.com>2023-01-20 10:26:11 +0000
commit0771b15a15b84be06c8cc80dc8311e035444c596 (patch)
tree19fbf26a65015faa29d168727dd79275a145114e /hicn-plugin/src/interest_pcslookup_node.c
parent6e41f3a43bccd768a4a633706f9028114ab58b83 (diff)
fix: interest aggregation
Interests processed in the same vector were not aggregated properly. Ticket: HICN-827 Change-Id: I9aa83e8689ec11642525fd3406972f1b2dea4d8f Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'hicn-plugin/src/interest_pcslookup_node.c')
-rw-r--r--hicn-plugin/src/interest_pcslookup_node.c53
1 files changed, 52 insertions, 1 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?