aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/data_fwd_node.c
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-02-22 10:06:58 +0100
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-02-22 10:06:58 +0100
commit6570a746680fb9f99718183157909acfd2c85cad (patch)
tree90f8ad8a3da1385979db5b231053aa2bbdd76be8 /hicn-plugin/src/data_fwd_node.c
parent1e2e32c281ddb053d03efd74eea660dfb0b6316f (diff)
[HICN-74] Data with lifetime 0 are never cached in the CS. When such data is received the PIT entry is removed.
If the data comes from the push node the data is dropped. Change-Id: I8780e16cca30ad8298f1a494f1138f8b35ae0fab Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'hicn-plugin/src/data_fwd_node.c')
-rw-r--r--hicn-plugin/src/data_fwd_node.c80
1 files changed, 60 insertions, 20 deletions
diff --git a/hicn-plugin/src/data_fwd_node.c b/hicn-plugin/src/data_fwd_node.c
index b25c9e0ac..19181ac03 100644
--- a/hicn-plugin/src/data_fwd_node.c
+++ b/hicn-plugin/src/data_fwd_node.c
@@ -50,7 +50,7 @@ clone_data_to_cs (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
hicn_hash_node_t * nodep, vlib_buffer_t * b0,
hicn_hash_entry_t * hash_entry, u64 name_hash,
hicn_buffer_t * hicnb, const hicn_dpo_vft_t * dpo_vft,
- dpo_id_t * hicn_dpo_id);
+ dpo_id_t * hicn_dpo_id, hicn_lifetime_t dmsg_lifetime);
/* packet trace format function */
@@ -221,24 +221,69 @@ hicn_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
pitp->u.pit.pe_txnh);
#if HICN_FEATURE_CS
- /*
- * Clone data packet in the content store and
- * convert the PIT entry into a CS entry
- */
- clone_data_to_cs (vm, pitcs, pitp, hicn0, tnow, node0,
- b0, hash_entry0, hicnb0->name_hash, hicnb0,
- dpo_vft0, &hicn_dpo_id0);
+ hicn_lifetime_t dmsg_lifetime;
- hicn_pcs_remove_lock (pitcs, &pitp, &node0, vm,
- hash_entry0, NULL, NULL);
+ hicn_type_t type = hicnb0->type;
+ hicn_ops_vft[type.l1]->get_lifetime (type, &hicn0->protocol,
+ &dmsg_lifetime);
+
+ if (dmsg_lifetime)
+ {
+ /*
+ * Clone data packet in the content store and
+ * convert the PIT entry into a CS entry
+ */
+ clone_data_to_cs (vm, pitcs, pitp, hicn0, tnow, node0,
+ b0, hash_entry0, hicnb0->name_hash,
+ hicnb0, dpo_vft0, &hicn_dpo_id0,
+ dmsg_lifetime);
+
+ hicn_pcs_remove_lock (pitcs, &pitp, &node0, vm,
+ hash_entry0, NULL, NULL);
+ }
+ else
+ {
+ /*
+ * If the packet is copied and not cloned, we need to free the vlib_buffer
+ */
+ if (hicnb0->flags & HICN_BUFFER_FLAGS_PKT_LESS_TWO_CL)
+ {
+ vlib_buffer_free_one (vm, bi0);
+ }
+ else
+ {
+ /*
+ * Remove one reference as the buffer is no
+ * longer in any frame. The vlib_buffer will be freed when
+ * all its cloned vlib_buffer will be freed.
+ */
+ b0->n_add_refs--;
+ }
+
+ /* Delete the PIT entry */
+ hicn_pcs_pit_delete (pitcs, &pitp, &node0, vm,
+ hash_entry0, dpo_vft0, &hicn_dpo_id0);
+ }
#else
ASSERT (pitp == hicn_pit_get_data (node0));
/*
- * Remove one reference as the buffer is no
- * longer in any frame
+ * If the packet is copied and not cloned, we need to free the vlib_buffer
*/
- b0->n_add_refs--;
- /* If not enabled, delete the PIT entry */
+ if (hicnb0->flags & HICN_BUFFER_FLAGS_PKT_LESS_TWO_CL)
+ {
+ vlib_buffer_free_one (vm, bi0);
+ }
+ else
+ {
+ /*
+ * Remove one reference as the buffer is no
+ * longer in any frame. The vlib_buffer will be freed when
+ * all its cloned vlib_buffer will be freed.
+ */
+ b0->n_add_refs--;
+ }
+
+ /* Delete the PIT entry */
hicn_pcs_pit_delete (pitcs, &pitp, &node0, vm,
hash_entry0, dpo_vft0, &hicn_dpo_id0);
#endif
@@ -490,9 +535,8 @@ clone_data_to_cs (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
hicn_hash_node_t * nodep, vlib_buffer_t * b0,
hicn_hash_entry_t * hash_entry, u64 name_hash,
hicn_buffer_t * hicnb, const hicn_dpo_vft_t * dpo_vft,
- dpo_id_t * hicn_dpo_id)
+ dpo_id_t * hicn_dpo_id, hicn_lifetime_t dmsg_lifetime)
{
- hicn_lifetime_t dmsg_lifetime;
/*
* At this point we think we're safe to proceed. Store the CS buf in
* the PIT/CS hashtable entry
@@ -510,10 +554,6 @@ clone_data_to_cs (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
pitp->shared.create_time = tnow;
- hicn_type_t type = hicnb0->type;
- hicn_ops_vft[type.l1]->get_lifetime (type, &hicn0->protocol,
- &dmsg_lifetime);
-
if (dmsg_lifetime < HICN_PARAM_CS_LIFETIME_MIN
|| dmsg_lifetime > HICN_PARAM_CS_LIFETIME_MAX)
{