summaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/route.c
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-plugin/src/route.c')
-rw-r--r--hicn-plugin/src/route.c232
1 files changed, 0 insertions, 232 deletions
diff --git a/hicn-plugin/src/route.c b/hicn-plugin/src/route.c
index 0096edb2b..b569d431e 100644
--- a/hicn-plugin/src/route.c
+++ b/hicn-plugin/src/route.c
@@ -103,238 +103,6 @@ hicn_route_get_dpo (const fib_prefix_t * prefix,
}
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;
- hicn_face_id_t faces_id_tmp[HICN_PARAM_FIB_ENTRY_NHOPS_MAX];
- int n_face_id = 0;
- const hicn_dpo_vft_t *dpo_vft;
- u32 fib_index;
- vlib_main_t *vm = vlib_get_main ();
-
- 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_safe (face_id[i]);
-
- if (face == NULL)
- {
- vlib_cli_output (vm, "Face %d not found, skip...\n", face_id[i]);
- return ret;
- }
- else
- {
- faces_id_tmp[n_face_id++] = face_id[i];
- }
- }
-
- ret = hicn_route_get_dpo (prefix, &hicn_dpo_id, &fib_index);
-
- if (ret == HICN_ERROR_NONE)
- {
- for (int i = 0; i < n_face_id && (ret == HICN_ERROR_NONE); i++)
- {
- u32 vft_id = hicn_dpo_get_vft_id (hicn_dpo_id);
- dpo_vft = hicn_dpo_get_vft (vft_id);
-
- hicn_face_t *face =
- hicn_dpoi_get_from_idx (faces_id_tmp[i]);
- //Disable feature on the interface
- if (prefix->fp_proto == FIB_PROTOCOL_IP4)
- vnet_feature_enable_disable ("ip4-local", "hicn-data-input-ip4",
- face->sw_if, 1, 0, 0);
- else if (prefix->fp_proto == FIB_PROTOCOL_IP6)
- vnet_feature_enable_disable ("ip6-local", "hicn-data-input-ip6",
- face->sw_if, 1, 0, 0);
-
- ret = dpo_vft->hicn_dpo_add_update_nh (faces_id_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,
- const fib_prefix_t * prefix)
-{
- dpo_id_t dpo = DPO_INVALID;
- const dpo_id_t *hicn_dpo_id;
- int ret = HICN_ERROR_NONE;
- hicn_face_id_t face_id_tmp[HICN_PARAM_FIB_ENTRY_NHOPS_MAX];
- int n_face_id = 0;
- index_t dpo_idx;
- u32 fib_index;
- vlib_main_t *vm = vlib_get_main ();
-
- if (face_id == NULL || !hicn_dpoi_idx_is_valid (*face_id))
- {
- 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]);
-
- if (face == NULL)
- {
- vlib_cli_output (vm, "Face %d not found, skip...\n", face_id[i]);
- return ret;
- }
- else
- {
- face_id_tmp[n_face_id++] = face_id[i];
- }
- }
-
- ret = hicn_route_get_dpo (prefix, &hicn_dpo_id, &fib_index);
-
- if (ret == HICN_ERROR_ROUTE_NOT_FOUND)
- {
- hicn_face_id_t nhops[HICN_PARAM_FIB_ENTRY_NHOPS_MAX];
- for (int i = 0; i < n_face_id; i++)
- {
- nhops[i] = face_id_tmp[i];
- hicn_face_t *face =
- hicn_dpoi_get_from_idx (face_id_tmp[i]);
- //Disable feature on the interface
- if (prefix->fp_proto == FIB_PROTOCOL_IP4)
- vnet_feature_enable_disable ("ip4-local", "hicn-data-input-ip4",
- face->sw_if, 1, 0, 0);
- else if (prefix->fp_proto == FIB_PROTOCOL_IP6)
- vnet_feature_enable_disable ("ip6-local", "hicn-data-input-ip6",
- face->sw_if, 1, 0, 0);
- }
-
- default_dpo.hicn_dpo_create (prefix->fp_proto, nhops, n_face_id,
- &dpo_idx);
-
- /* the value we got when we registered */
- /*
- * This should be taken from the name?!? the index of the
- * object
- */
- dpo_set (&dpo,
- default_dpo.hicn_dpo_get_type (),
- (ip46_address_is_ip4 (&prefix->fp_addr) ? DPO_PROTO_IP4 :
- DPO_PROTO_IP6), dpo_idx);
-
- /* Here is where we create the "via" like route */
- /*
- * For the moment we use the global one the prefix you want
- * to match Neale suggested -- FIB_SOURCE_HICN the client
- * that is adding them -- no easy explanation at this timeā€¦
- */
- fib_node_index_t new_fib_node_index =
- fib_table_entry_special_dpo_add (fib_index,
- prefix,
- hicn_fib_src,
- (FIB_ENTRY_FLAG_EXCLUSIVE |
- FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT),
- &dpo);
-
- /* We added a route, therefore add one lock to the table */
- fib_table_lock (fib_index, prefix->fp_proto, hicn_fib_src);
-
- dpo_unlock (&dpo);
- ret =
- (new_fib_node_index !=
- FIB_NODE_INDEX_INVALID) ? HICN_ERROR_NONE :
- HICN_ERROR_ROUTE_NO_INSERT;
-
- /*
- * TODO: we might want to store the fib index in the face.
- * This will help to update the fib entries when a face is
- * deleted. Fib_index_t is returned from
- * fib_table_entry_special_dpo_add.
- */
- }
- else if (ret == HICN_ERROR_NONE)
- {
- ret = hicn_route_add_nhops (face_id, len, prefix);
- }
- return ret;
-}
-
-int
-hicn_route_del (fib_prefix_t * prefix)
-{
- const dpo_id_t *hicn_dpo_id;
- int ret = HICN_ERROR_NONE;
- u32 fib_index;
-
- /* Remove the fib entry only if the dpo is of type hicn */
- ret = hicn_route_get_dpo (prefix, &hicn_dpo_id, &fib_index);
-
- if (ret == HICN_ERROR_NONE)
- {
- fib_table_entry_special_remove (HICN_FIB_TABLE, prefix, hicn_fib_src);
-
- /*
- * Remove the lock from the table. We keep one lock per route
- */
- fib_table_unlock (fib_index, prefix->fp_proto, hicn_fib_src);
- }
- //Remember to remove the lock from the table when removing the entry
- return ret;
-}
-
-int
-hicn_route_del_nhop (fib_prefix_t * prefix, hicn_face_id_t face_id)
-{
- const dpo_id_t *hicn_dpo_id;
- int ret;
- u32 vft_id;
- const hicn_dpo_vft_t *dpo_vft;
- u32 fib_index;
-
-
- ret = hicn_route_get_dpo (prefix, &hicn_dpo_id, &fib_index);
-
- /* Check if the dpo is an hicn_dpo_t */
- if (ret == HICN_ERROR_NONE)
- {
- vft_id = hicn_dpo_get_vft_id (hicn_dpo_id);
- dpo_vft = hicn_dpo_get_vft (vft_id);
-
- hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
- //Disable feature on the interface
- if (prefix->fp_proto == FIB_PROTOCOL_IP4)
- vnet_feature_enable_disable ("ip4-local", "hicn-data-input-ip4",
- face->sw_if, 0, 0, 0);
- else if (prefix->fp_proto == FIB_PROTOCOL_IP6)
- vnet_feature_enable_disable ("ip6-local", "hicn-data-input-ip6",
- face->sw_if, 0, 0, 0);
-
- ret = dpo_vft->hicn_dpo_del_nh (face_id, hicn_dpo_id->dpoi_index);
-
- hicn_dpo_ctx_t *dpo_ctx =
- hicn_strategy_dpo_ctx_get (hicn_dpo_id->dpoi_index);
-
-
- if (ret == HICN_ERROR_NONE && !dpo_ctx->entry_count)
- ret = hicn_route_del (prefix);
- }
- //Remember to remove the lock from the table when removing the entry
- return ret;
-}
-
-int
hicn_route_set_strategy (fib_prefix_t * prefix, u8 strategy_id)
{
const dpo_id_t *hicn_dpo_id;