summaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/route.c
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-11-21 11:59:54 +0000
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-11-22 12:47:14 +0000
commit62f7b46d4c49d6e5bfb5b3b537bfcaf6503e7bac (patch)
tree35e206900cf6a1535df2b3439a55e0fdd9091a7f /hicn-plugin/src/route.c
parentae6f3b8e1f55fc4bb7807c293850d3cb46cab1fd (diff)
[HICN-405] Added application face delete
Added two new messages in the binary api: - hicn_api_face_cons_del to delete a consumer face - hicn_api_face_prod_del to delete a producer face Added the corresponding commands in the vpp_api_test for debugging and testing Reworked the cache policy structure to add a new function that flash the content store from the content coming from the destroyed producer face. This is required since the CS while each producer face has its own lru list. Removing only the producer face without flushing the CS from the content coming from the producer face will lead to a segfault in case there is a hit in the CS as the lru no longer exists and it won't be possible to update the head of the lru. Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com> Change-Id: I8776c86952d50900aa504dd22aec521ed25c1dae
Diffstat (limited to 'hicn-plugin/src/route.c')
-rw-r--r--hicn-plugin/src/route.c116
1 files changed, 58 insertions, 58 deletions
diff --git a/hicn-plugin/src/route.c b/hicn-plugin/src/route.c
index 3581fe490..321f11940 100644
--- a/hicn-plugin/src/route.c
+++ b/hicn-plugin/src/route.c
@@ -86,6 +86,61 @@ hicn_route_get_dpo (const fib_prefix_t * prefix,
return ret;
}
+int
+hicn_route_add_nhops (hicn_face_id_t * face_id, u32 len,
+ const fib_prefix_t * prefix)
+{
+ const dpo_id_t *hicn_dpo_id;
+ int ret = HICN_ERROR_NONE;
+ dpo_id_t faces_dpo_tmp[HICN_PARAM_FIB_ENTRY_NHOPS_MAX];
+ int n_face_dpo = 0;
+ const hicn_dpo_vft_t *dpo_vft;
+ u32 fib_index;
+ vlib_main_t *vm = vlib_get_main ();
+ hicn_face_vft_t *face_vft = NULL;
+
+ if (face_id == NULL)
+ {
+ return HICN_ERROR_ROUTE_INVAL;
+ }
+ /*
+ * Check is the faces are available, otherwise skip the face
+ * id_adjacency existance is not checked. It should be checked before
+ * sending a packet out
+ */
+ for (int i = 0; i < clib_min (HICN_PARAM_FIB_ENTRY_NHOPS_MAX, len); i++)
+ {
+ hicn_face_t *face = hicn_dpoi_get_from_idx (face_id[i]);
+ face_vft = hicn_face_get_vft (face->shared.face_type);
+ dpo_id_t face_dpo = DPO_INVALID;
+ face_vft->hicn_face_get_dpo (face, &face_dpo);
+
+ if (!dpo_id_is_valid (&face_dpo))
+ {
+ vlib_cli_output (vm, "Face %d not found, skip...\n", face_id[i]);
+ return ret;
+ }
+ else
+ {
+ faces_dpo_tmp[n_face_dpo++] = face_dpo;
+ }
+ }
+
+ ret = hicn_route_get_dpo (prefix, &hicn_dpo_id, &fib_index);
+
+ if (ret == HICN_ERROR_NONE)
+ {
+ for (int i = 0; i < n_face_dpo && (ret == HICN_ERROR_NONE); i++)
+ {
+ u32 vft_id = hicn_dpo_get_vft_id (hicn_dpo_id);
+ dpo_vft = hicn_dpo_get_vft (vft_id);
+ ret = dpo_vft->hicn_dpo_add_update_nh (&faces_dpo_tmp[i],
+ hicn_dpo_id->dpoi_index);
+ }
+ }
+ return ret;
+}
+
/* Add a new route for a name prefix */
int
hicn_route_add (hicn_face_id_t * face_id, u32 len,
@@ -153,8 +208,8 @@ hicn_route_add (hicn_face_id_t * face_id, u32 len,
*/
dpo_set (&dpo,
default_dpo.hicn_dpo_get_type (),
- (ip46_address_is_ip4 (&prefix->fp_addr) ? DPO_PROTO_IP4 : DPO_PROTO_IP6),
- dpo_idx);
+ (ip46_address_is_ip4 (&prefix->fp_addr) ? DPO_PROTO_IP4 :
+ DPO_PROTO_IP6), dpo_idx);
/* Here is where we create the "via" like route */
/*
@@ -187,62 +242,7 @@ hicn_route_add (hicn_face_id_t * face_id, u32 len,
}
else if (ret == HICN_ERROR_NONE)
{
- ret = HICN_ERROR_ROUTE_ALREADY_EXISTS;
- }
- return ret;
-}
-
-int
-hicn_route_add_nhops (hicn_face_id_t * face_id, u32 len,
- const fib_prefix_t * prefix)
-{
- const dpo_id_t *hicn_dpo_id;
- int ret = HICN_ERROR_NONE;
- dpo_id_t faces_dpo_tmp[HICN_PARAM_FIB_ENTRY_NHOPS_MAX];
- int n_face_dpo = 0;
- const hicn_dpo_vft_t *dpo_vft;
- u32 fib_index;
- vlib_main_t *vm = vlib_get_main ();
- hicn_face_vft_t *face_vft = NULL;
-
- if (face_id == NULL)
- {
- return HICN_ERROR_ROUTE_INVAL;
- }
- /*
- * Check is the faces are available, otherwise skip the face
- * id_adjacency existance is not checked. It should be checked before
- * sending a packet out
- */
- for (int i = 0; i < clib_min (HICN_PARAM_FIB_ENTRY_NHOPS_MAX, len); i++)
- {
- hicn_face_t *face = hicn_dpoi_get_from_idx (face_id[i]);
- face_vft = hicn_face_get_vft (face->shared.face_type);
- dpo_id_t face_dpo = DPO_INVALID;
- face_vft->hicn_face_get_dpo (face, &face_dpo);
-
- if (!dpo_id_is_valid (&face_dpo))
- {
- vlib_cli_output (vm, "Face %d not found, skip...\n", face_id[i]);
- return ret;
- }
- else
- {
- faces_dpo_tmp[n_face_dpo++] = face_dpo;
- }
- }
-
- ret = hicn_route_get_dpo (prefix, &hicn_dpo_id, &fib_index);
-
- if (ret == HICN_ERROR_NONE)
- {
- for (int i = 0; i < n_face_dpo && (ret == HICN_ERROR_NONE); i++)
- {
- u32 vft_id = hicn_dpo_get_vft_id (hicn_dpo_id);
- dpo_vft = hicn_dpo_get_vft (vft_id);
- ret = dpo_vft->hicn_dpo_add_update_nh (&faces_dpo_tmp[i],
- hicn_dpo_id->dpoi_index);
- }
+ ret = hicn_route_add_nhops (face_id, len, prefix);
}
return ret;
}