From c46b82460987912eb465187892286922aeaedab4 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Mon, 30 Jan 2023 21:14:39 +0000 Subject: feat(hicn-plugin): handle case of no exact match for mapme IU Ticket: HICN-844 Change-Id: I1f046e6327e4cf507b7fa7a5adae53e63ab491bf Signed-off-by: Mauro Sardara (cherry picked from commit 7cfd91a6c6316fe15186c8cd3acc1c4526db7e25) --- hicn-plugin/includes/vpp_plugins/hicn/error.h | 8 +- hicn-plugin/src/CMakeLists.txt | 1 + hicn-plugin/src/cli.c | 95 +++++++++- hicn-plugin/src/faces/app/face_prod.c | 3 +- hicn-plugin/src/faces/face.h | 12 +- hicn-plugin/src/faces/face_flags.h | 3 +- hicn-plugin/src/hicn.api | 42 +++++ hicn-plugin/src/hicn_api.c | 47 ++++- hicn-plugin/src/hicn_api_test.c | 126 +++++++++++++- hicn-plugin/src/hicn_logging.h | 2 +- hicn-plugin/src/mapme.h | 98 ++++++++--- hicn-plugin/src/mapme_ack.h | 2 + hicn-plugin/src/mapme_ack_node.c | 44 +++-- hicn-plugin/src/mapme_ctrl.h | 5 +- hicn-plugin/src/mapme_ctrl_node.c | 240 +++++++++++++++++++++----- hicn-plugin/src/mapme_eventmgr.c | 23 ++- hicn-plugin/src/pg.c | 3 +- hicn-plugin/src/route.c | 18 +- hicn-plugin/src/route.h | 6 +- 19 files changed, 673 insertions(+), 105 deletions(-) diff --git a/hicn-plugin/includes/vpp_plugins/hicn/error.h b/hicn-plugin/includes/vpp_plugins/hicn/error.h index 717017564..ae5e102e7 100644 --- a/hicn-plugin/includes/vpp_plugins/hicn/error.h +++ b/hicn-plugin/includes/vpp_plugins/hicn/error.h @@ -38,8 +38,8 @@ _ (FACE_NO_GLOBAL_IP, NEXT (FACE_NOMEM), "No global ip address for face") \ _ (FACE_NOT_FOUND_IN_ENTRY, NEXT (FACE_NO_GLOBAL_IP), \ "Face not found in entry") \ - _ (FACE_ALREADY_DELETED, NEXT (FACE_NOT_FOUND_IN_ENTRY), \ - "Face alredy deleted") \ + _ (FACE_NOT_VALID, NEXT (FACE_NOT_FOUND_IN_ENTRY), "Face not valid") \ + _ (FACE_ALREADY_DELETED, NEXT (FACE_NOT_VALID), "Face alredy deleted") \ _ (FACE_ALREADY_CREATED, NEXT (FACE_ALREADY_DELETED), \ "Face alredy created") \ _ (FWD_NOT_ENABLED, NEXT (FACE_ALREADY_CREATED), \ @@ -116,7 +116,9 @@ "Src and dst addresses have different type (ipv4 and ipv6)") \ _ (MAPME_NEXT_HOP_ADDED, NEXT (UDP_TUNNEL_SRC_DST_TYPE), \ "Next hop added to mapme") \ - _ (MAPME_NEXT_HOP_NOT_ADDED, NEXT (MAPME_NEXT_HOP_ADDED), \ + _ (MAPME_WRONG_FACE_CREATED, NEXT (MAPME_NEXT_HOP_ADDED), \ + "Face created does not correspond to the IU input face") \ + _ (MAPME_NEXT_HOP_NOT_ADDED, NEXT (MAPME_WRONG_FACE_CREATED), \ "Next hop added to mapme") \ _ (PCS_NOT_FOUND, NEXT (MAPME_NEXT_HOP_NOT_ADDED), \ "Hash not found in hash table") \ diff --git a/hicn-plugin/src/CMakeLists.txt b/hicn-plugin/src/CMakeLists.txt index 9524b011a..b7fa828f3 100644 --- a/hicn-plugin/src/CMakeLists.txt +++ b/hicn-plugin/src/CMakeLists.txt @@ -179,6 +179,7 @@ set(COMPILER_OPTIONS ############################################################## set(COMPILE_DEFINITIONS "-DHICN_VPP_PLUGIN=1" + "-DHICN_MAPME_ALLOW_NONEXISTING_FIB_ENTRY" ) if (${CMAKE_BUILD_TYPE} MATCHES "Debug") diff --git a/hicn-plugin/src/cli.c b/hicn-plugin/src/cli.c index de1372b10..64ebf61a4 100644 --- a/hicn-plugin/src/cli.c +++ b/hicn-plugin/src/cli.c @@ -36,6 +36,7 @@ #include "error.h" #include "faces/face.h" #include "route.h" +#include "mapme.h" static vl_api_hicn_api_node_params_set_t node_ctl_params = { .pit_max_size = -1, @@ -332,6 +333,83 @@ done: clib_error_return (0, "%s\n", get_error_string (ret)); } +/* + * cli handler for 'mapme' + */ +static clib_error_t * +hicn_cli_mapme_set_command_fn (vlib_main_t *vm, unformat_input_t *main_input, + vlib_cli_command_t *cmd) +{ + clib_error_t *cl_err = 0; + fib_prefix_t prefix; + + /* Get a line of input. */ + unformat_input_t _line_input, *line_input = &_line_input; + if (!unformat_user (main_input, unformat_line_input, line_input)) + { + return (0); + } + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "default-route %U/%d", unformat_ip46_address, + &prefix.fp_addr, IP46_TYPE_ANY, &prefix.fp_len)) + { + ; + } + else + { + return clib_error_return (0, "%s '%U'", + get_error_string (HICN_ERROR_CLI_INVAL), + format_unformat_error, line_input); + } + } + + prefix.fp_proto = ip46_address_is_ip4 (&prefix.fp_addr) ? FIB_PROTOCOL_IP4 : + FIB_PROTOCOL_IP6; + + hicn_mapme_main_t *mapme_main = hicn_mapme_get_main (); + mapme_main->default_route = prefix; + + return (cl_err); +} + +static clib_error_t * +hicn_cli_mapme_get_command_fn (vlib_main_t *vm, unformat_input_t *main_input, + vlib_cli_command_t *cmd) +{ + hicn_mapme_main_t *mm = hicn_mapme_get_main (); + int default_route = 0; + clib_error_t *cl_err = 0; + + /* Get a line of input. */ + unformat_input_t _line_input, *line_input = &_line_input; + if (!unformat_user (main_input, unformat_line_input, line_input)) + { + return (0); + } + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "default-route")) + { + default_route = 1; + } + else + { + return clib_error_return (0, "%s '%U'", + get_error_string (HICN_ERROR_CLI_INVAL), + format_unformat_error, line_input); + } + } + + if (default_route) + { + vlib_cli_output (vm, "Mapme default route: '%U'", format_fib_prefix, + &mm->default_route); + } + + return cl_err; +} + /* * cli handler for 'fib' */ @@ -689,8 +767,10 @@ hicn_enable_command_fn (vlib_main_t *vm, unformat_input_t *main_input, goto done; } } + hicn_face_id_t *vec_faces = NULL; - rv = hicn_route_enable (&pfx, &vec_faces); + fib_node_index_t hicn_fib_index; + rv = hicn_route_enable (&pfx, &hicn_fib_index, &vec_faces); if (vec_faces != NULL) { @@ -756,6 +836,19 @@ done: return cl_err; } +/* cli declaration for 'mapme set default_route' */ +VLIB_CLI_COMMAND (hicn_cli_mapme_set_command, static) = { + .path = "hicn mapme set", + .short_help = "hicn mapme set default-route ", + .function = hicn_cli_mapme_set_command_fn, +}; + +VLIB_CLI_COMMAND (hicn_cli_mapme_get_command, static) = { + .path = "hicn mapme get", + .short_help = "hicn mapme get default-route", + .function = hicn_cli_mapme_get_command_fn, +}; + /* cli declaration for 'control start' */ VLIB_CLI_COMMAND (hicn_cli_node_ctl_start_set_command, static) = { .path = "hicn control start", diff --git a/hicn-plugin/src/faces/app/face_prod.c b/hicn-plugin/src/faces/app/face_prod.c index 4b7a5a2f6..5d0fa727b 100644 --- a/hicn-plugin/src/faces/app/face_prod.c +++ b/hicn-plugin/src/faces/app/face_prod.c @@ -269,7 +269,8 @@ hicn_face_prod_add (fib_prefix_t *prefix, u32 sw_if, u32 *cs_reserved, HICN_DEBUG ("Calling hicn enable for producer face"); hicn_face_id_t *vec_faces = NULL; - hicn_route_enable (prefix, &vec_faces); + fib_node_index_t hicn_fib_node_index; + hicn_route_enable (prefix, &hicn_fib_node_index, &vec_faces); if (vec_faces != NULL) vec_free (vec_faces); diff --git a/hicn-plugin/src/faces/face.h b/hicn-plugin/src/faces/face.h index 2c0a09a28..43900dd4e 100644 --- a/hicn-plugin/src/faces/face.h +++ b/hicn-plugin/src/faces/face.h @@ -574,7 +574,11 @@ hicn_face_ip4_add_and_lock (hicn_face_id_t *index, u8 *hicnb_flags, ip46_address_set_ip4 (&ip_address, nat_addr); hicn_face_id_t idx; - u8 face_flags = 0; + u8 face_flags = *hicnb_flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL ? + HICN_FACE_FLAGS_UDP4 : + *hicnb_flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL ? + HICN_FACE_FLAGS_UDP6 : + 0; hicn_iface_add (&ip_address, sw_if, &idx, adj_index, face_flags); @@ -670,7 +674,11 @@ hicn_face_ip6_add_and_lock (hicn_face_id_t *index, u8 *hicnb_flags, ip46_address_t ip_address = { 0 }; ip46_address_set_ip6 (&ip_address, nat_addr); hicn_face_id_t idx; - u8 face_flags = 0; + u8 face_flags = *hicnb_flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL ? + HICN_FACE_FLAGS_UDP4 : + *hicnb_flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL ? + HICN_FACE_FLAGS_UDP6 : + 0; hicn_iface_add ((const ip46_address_t *) nat_addr, sw_if, &idx, adj_index, face_flags); diff --git a/hicn-plugin/src/faces/face_flags.h b/hicn-plugin/src/faces/face_flags.h index 69598ab1d..880d3b558 100644 --- a/hicn-plugin/src/faces/face_flags.h +++ b/hicn-plugin/src/faces/face_flags.h @@ -26,7 +26,8 @@ _ (2, APPFACE_PROD, "face is producer face") \ _ (3, APPFACE_CONS, "face is consumer face") \ _ (4, DELETED, "face is deleted") \ - _ (5, UDP, "face is udp") + _ (5, UDP4, "face is udp4") \ + _ (6, UDP6, "face is udp6") enum { diff --git a/hicn-plugin/src/hicn.api b/hicn-plugin/src/hicn.api index 2321e6622..d999e0de5 100644 --- a/hicn-plugin/src/hicn.api +++ b/hicn-plugin/src/hicn.api @@ -617,6 +617,48 @@ define hicn_api_udp_tunnel_add_del_reply u32 uei; }; +define hicn_api_mapme_default_route_set +{ + /* Client identifier, set from api_main.my_client_index */ + u32 client_index; + + /* Arbitrary context, so client can match reply to request */ + u32 context; + + /* Fib prefix to be used as default if mapme EPM fails */ + vl_api_prefix_t prefix; +}; + +define hicn_api_mapme_default_route_set_reply +{ + /* From the request */ + u32 context; + + /* Return value, zero means all OK */ + i32 retval; +}; + +define hicn_api_mapme_default_route_get +{ + /* Client identifier, set from api_main.my_client_index */ + u32 client_index; + + /* Arbitrary context, so client can match reply to request */ + u32 context; +}; + +define hicn_api_mapme_default_route_get_reply +{ + /* From the request */ + u32 context; + + /* Return value, zero means all OK */ + i32 retval; + + /* Fib prefix to be used as default if mapme EPM fails */ + vl_api_prefix_t prefix; +}; + /* * fd.io coding-style-patch-verification: ON * diff --git a/hicn-plugin/src/hicn_api.c b/hicn-plugin/src/hicn_api.c index 16e32dd9b..28d993a4a 100644 --- a/hicn-plugin/src/hicn_api.c +++ b/hicn-plugin/src/hicn_api.c @@ -38,6 +38,7 @@ #include "faces/app/face_prod.h" #include "faces/app/face_cons.h" #include "route.h" +#include "mapme.h" /* define message IDs */ #include @@ -494,6 +495,49 @@ vl_api_hicn_api_strategy_get_t_handler (vl_api_hicn_api_strategy_get_t *mp) })); } +/************* MAPME ****************/ + +static void +vl_api_hicn_api_mapme_default_route_set_t_handler ( + vl_api_hicn_api_mapme_default_route_set_t *mp) +{ + vl_api_hicn_api_mapme_default_route_set_reply_t *rmp; + int rv = HICN_ERROR_NONE; + fib_prefix_t prefix; + + hicn_main_t *sm = &hicn_main; + + // Decode prefix + ip_prefix_decode (&mp->prefix, &prefix); + + // Set the the prefix + hicn_mapme_main_t *mm = hicn_mapme_get_main (); + mm->default_route = prefix; + + REPLY_MACRO (VL_API_HICN_API_MAPME_DEFAULT_ROUTE_SET_REPLY); +} + +static void +vl_api_hicn_api_mapme_default_route_get_t_handler ( + vl_api_hicn_api_mapme_default_route_get_t *mp) +{ + vl_api_hicn_api_mapme_default_route_get_reply_t *rmp; + int rv = HICN_ERROR_NONE; + + hicn_main_t *sm = &hicn_main; + + // Get the the prefix + hicn_mapme_main_t *mm = hicn_mapme_get_main (); + + REPLY_MACRO2 ( + VL_API_HICN_API_MAPME_DEFAULT_ROUTE_GET_REPLY /* , rmp, mp, rv */, ({ + if (rv == HICN_ERROR_NONE) + { + ip_prefix_encode (&mm->default_route, &rmp->prefix); + } + })); +} + /************* APP FACE ****************/ static void @@ -590,12 +634,13 @@ vl_api_hicn_api_enable_disable_t_handler (vl_api_hicn_api_enable_disable_t *mp) ip_prefix_decode (&mp->prefix, &prefix); hicn_face_id_t *vec_faces = NULL; + fib_node_index_t hicn_fib_index; switch (clib_net_to_host_u32 (mp->enable_disable)) { case HICN_ENABLE: HICN_DEBUG ("Calling hicn enable from API."); - rv = hicn_route_enable (&prefix, &vec_faces); + rv = hicn_route_enable (&prefix, &hicn_fib_index, &vec_faces); break; case HICN_DISABLE: HICN_DEBUG ("Calling hicn disable from API."); diff --git a/hicn-plugin/src/hicn_api_test.c b/hicn-plugin/src/hicn_api_test.c index cb5da09a4..e3b942b7b 100644 --- a/hicn-plugin/src/hicn_api_test.c +++ b/hicn-plugin/src/hicn_api_test.c @@ -91,7 +91,11 @@ foreach_standard_reply_retval_handler; _ (HICN_API_STRATEGY_SET_REPLY, hicn_api_strategy_set_reply) \ _ (HICN_API_STRATEGY_GET_REPLY, hicn_api_strategy_get_reply) \ _ (HICN_API_ENABLE_DISABLE_REPLY, hicn_api_enable_disable_reply) \ - _ (HICN_API_UDP_TUNNEL_ADD_DEL_REPLY, hicn_api_udp_tunnel_add_del_reply) + _ (HICN_API_UDP_TUNNEL_ADD_DEL_REPLY, hicn_api_udp_tunnel_add_del_reply) \ + _ (HICN_API_MAPME_DEFAULT_ROUTE_SET_REPLY, \ + hicn_api_mapme_default_route_set_reply) \ + _ (HICN_API_MAPME_DEFAULT_ROUTE_GET_REPLY, \ + hicn_api_mapme_default_route_get_reply) static int api_hicn_api_node_params_set (vat_main_t *vam) @@ -788,6 +792,126 @@ api_hicn_api_strategy_set (vat_main_t *vam) return ret; } +static void +vl_api_hicn_api_mapme_default_route_set_reply_t_handler ( + vl_api_hicn_api_mapme_default_route_set_reply_t *mp) +{ + vat_main_t *vam = hicn_test_main.vat_main; + i32 retval = ntohl (mp->retval); + + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + return; + } + + vam->retval = retval; + vam->result_ready = 1; + + if (vam->retval < 0) + { + fformat (vam->ofp, " (API call error: %d)\n", vam->retval); + } +} + +static void +vl_api_hicn_api_mapme_default_route_get_reply_t_handler ( + vl_api_hicn_api_mapme_default_route_get_reply_t *mp) +{ + vat_main_t *vam = hicn_test_main.vat_main; + i32 retval = ntohl (mp->retval); + fib_prefix_t prefix; + u8 *sbuf = 0; + + ip_prefix_decode (&mp->prefix, &prefix); + + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + return; + } + + vam->retval = retval; + vam->result_ready = 1; + + if (vam->retval < 0) + { + fformat (vam->ofp, " (API call error: %d)\n", vam->retval); + return; + } + + sbuf = format (sbuf, "Mapme Default Route: %U", format_fib_prefix, &prefix); + fformat (vam->ofp, "%s\n", sbuf); +} + +static int +api_hicn_api_mapme_default_route_set (vat_main_t *vam) +{ + unformat_input_t *input = vam->input; + vl_api_hicn_api_mapme_default_route_set_t *mp; + int ret; + fib_prefix_t fib_prefix; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "default_route %U/%d", unformat_ip46_address, + &fib_prefix.fp_addr, IP46_TYPE_ANY, &fib_prefix.fp_len)) + { + ; + } + else + { + clib_warning ("Please specify valid route."); + return 1; + } + } + + /* Construct the API message */ + M (HICN_API_MAPME_DEFAULT_ROUTE_SET, mp); + ip_prefix_encode (&fib_prefix, &mp->prefix); + + /* send it... */ + S (mp); + + /* Wait for a reply... */ + W (ret); + + return ret; +} + +static int +api_hicn_api_mapme_default_route_get (vat_main_t *vam) +{ + unformat_input_t *input = vam->input; + vl_api_hicn_api_mapme_default_route_set_t *mp; + int ret; + int default_route = 0; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "default_route")) + { + default_route = 1; + } + else + { + clib_warning ("Invalid option"); + return 1; + } + } + + /* Construct the API message */ + M (HICN_API_MAPME_DEFAULT_ROUTE_GET, mp); + + /* send it... */ + S (mp); + + /* Wait for a reply... */ + W (ret); + + return ret; +} + static int api_hicn_api_strategy_get (vat_main_t *vam) { diff --git a/hicn-plugin/src/hicn_logging.h b/hicn-plugin/src/hicn_logging.h index a960a7212..2e534e546 100644 --- a/hicn-plugin/src/hicn_logging.h +++ b/hicn-plugin/src/hicn_logging.h @@ -27,6 +27,6 @@ #define HICN_DEBUG(...) #endif /* HICN_DEBUG */ -#define HICN_ERROR(...) clib_error_return (0, __VA_ARGS__) +#define HICN_ERROR(...) clib_warning (__VA_ARGS__) #endif /* __HICN_DEBUG_H__ */ \ No newline at end of file diff --git a/hicn-plugin/src/mapme.h b/hicn-plugin/src/mapme.h index 1d46ea9f3..c5567d1d4 100644 --- a/hicn-plugin/src/mapme.h +++ b/hicn-plugin/src/mapme.h @@ -61,10 +61,13 @@ typedef struct hicn_mapme_conf_s { hicn_mapme_conf_t conf; bool remove_dpo; // FIXME used ? + fib_prefix_t default_route; vlib_main_t *vm; } hicn_mapme_main_t; +extern hicn_mapme_main_t *hicn_mapme_get_main (); + /** * @brief List of event to signat to the procesing node (eventmgr) */ @@ -87,6 +90,21 @@ typedef enum typedef hicn_dpo_ctx_t hicn_mapme_tfib_t; +/** + * FIB Lookup Type + */ +#define foreach_hicn_mapme_fib_lookup_type \ + _ (EPM) \ + _ (LPM) \ + _ (LESSPM) + +typedef enum +{ +#define _(a) HICN_MAPME_FIB_LOOKUP_TYPE_##a, + foreach_hicn_mapme_fib_lookup_type +#undef _ +} hicn_mapme_fib_lookup_type_t; + /* * Ideally we might need to care about alignment, but this struct is only * used for casting hicn_dpo_ctx_t. @@ -123,7 +141,17 @@ hicn_mapme_tfib_add (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) // Don't add if it already exists // (eg. an old IU received on a face on which we are retransmitting) if (hicn_mapme_tfib_has (tfib, face_id)) - return 0; + { + HICN_DEBUG ("Found face %d in tfib."); + return 0; + } + + // If local face, do not put in in tfib + if (hicn_face_is_local (face_id)) + { + HICN_DEBUG ("Do not add local face %d to TFIB.", face_id); + return 0; + } u8 pos = HICN_PARAM_FIB_ENTRY_NHOPS_MAX - tfib->tfib_entry_count; @@ -174,9 +202,12 @@ hicn_mapme_tfib_del (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) */ u8 start_pos = HICN_PARAM_FIB_ENTRY_NHOPS_MAX - tfib->tfib_entry_count; u8 pos = ~0; + for (pos = start_pos; pos < HICN_PARAM_FIB_ENTRY_NHOPS_MAX; pos++) if (tfib->next_hops[pos] == face_id) { + HICN_DEBUG ("Deleted the face_id=%d from TFIB as we received an ack.", + face_id); hicn_face_unlock_with_id (tfib->next_hops[pos]); tfib->next_hops[pos] = invalid; break; @@ -196,30 +227,15 @@ hicn_mapme_tfib_del (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) } /** - * @brief Performs an Exact Prefix Match lookup on the FIB + * @brief Retrive DPO from fib entry * @returns the corresponding DPO (hICN or IP LB), or NULL */ static_always_inline dpo_id_t * -fib_epm_lookup (ip46_address_t *addr, u8 plen) +dpo_from_fib_node_index (fib_node_index_t fib_entry_index) { - fib_prefix_t fib_pfx; - fib_node_index_t fib_entry_index; - u32 fib_index; - dpo_id_t *dpo_id; - load_balance_t *lb; - - const dpo_id_t *load_balance_dpo_id; - - /* At this point the face exists in the face table */ - fib_prefix_from_ip46_addr (addr, &fib_pfx); - fib_pfx.fp_len = plen; - - /* Check if the route already exist in the fib : EPM */ - fib_index = fib_table_find (fib_pfx.fp_proto, HICN_FIB_TABLE); - - fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); - if (fib_entry_index == FIB_NODE_INDEX_INVALID) - return NULL; + const dpo_id_t *load_balance_dpo_id = NULL; + load_balance_t *lb = NULL; + dpo_id_t *dpo_id = NULL; load_balance_dpo_id = fib_entry_contribute_ip_forwarding (fib_entry_index); @@ -251,6 +267,46 @@ fib_epm_lookup (ip46_address_t *addr, u8 plen) return (dpo_id_t *) load_balance_dpo_id; } +/** + * @brief Performs an Exact Prefix Match lookup on the FIB + * @returns the corresponding DPO (hICN or IP LB), or NULL + */ +static_always_inline dpo_id_t * +fib_lookup (ip46_address_t *addr, u8 plen, + hicn_mapme_fib_lookup_type_t lookup_type) +{ + fib_prefix_t fib_pfx; + fib_node_index_t fib_entry_index; + u32 fib_index; + + /* At this point the face exists in the face table */ + fib_prefix_from_ip46_addr (addr, &fib_pfx); + fib_pfx.fp_len = plen; + + /* Check if the route already exist in the fib : EPM */ + fib_index = fib_table_find (fib_pfx.fp_proto, HICN_FIB_TABLE); + + switch (lookup_type) + { + case HICN_MAPME_FIB_LOOKUP_TYPE_EPM: + fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); + break; + case HICN_MAPME_FIB_LOOKUP_TYPE_LPM: + fib_entry_index = fib_table_lookup (fib_index, &fib_pfx); + break; + case HICN_MAPME_FIB_LOOKUP_TYPE_LESSPM: + fib_entry_index = fib_table_get_less_specific (fib_index, &fib_pfx); + break; + default: + return NULL; + } + + if (fib_entry_index == FIB_NODE_INDEX_INVALID) + return NULL; + + return dpo_from_fib_node_index (fib_entry_index); +} + /* DPO types */ extern dpo_type_t hicn_face_udp_type; diff --git a/hicn-plugin/src/mapme_ack.h b/hicn-plugin/src/mapme_ack.h index 72ed7a0c4..9f47e9188 100644 --- a/hicn-plugin/src/mapme_ack.h +++ b/hicn-plugin/src/mapme_ack.h @@ -41,6 +41,8 @@ typedef struct u32 next_index; u32 sw_if_index; u8 pkt_type; + u32 seq; + hicn_prefix_t prefix; } hicn_mapme_ack_trace_t; typedef enum diff --git a/hicn-plugin/src/mapme_ack_node.c b/hicn-plugin/src/mapme_ack_node.c index 13ae7ee67..e1f4d3889 100644 --- a/hicn-plugin/src/mapme_ack_node.c +++ b/hicn-plugin/src/mapme_ack_node.c @@ -48,30 +48,30 @@ static char *hicn_mapme_ack_error_strings[] = { */ bool hicn_mapme_process_ack (vlib_main_t *vm, vlib_buffer_t *b, - hicn_face_id_t in_face) + hicn_face_id_t in_face, hicn_prefix_t *prefix, + u32 *seq) { seq_t fib_seq; const dpo_id_t *dpo; - hicn_prefix_t prefix; mapme_params_t params; int rc; /* Parse incoming message */ - rc = hicn_mapme_parse_packet (vlib_buffer_get_current (b), &prefix, ¶ms); + rc = hicn_mapme_parse_packet (vlib_buffer_get_current (b), prefix, ¶ms); if (rc < 0) goto ERR_PARSE; - /* if (params.seq == INVALID_SEQ) */ - /* { */ - /* DEBUG ("Invalid sequence number found in IU"); */ - /* return true; */ - /* } */ + *seq = params.seq; + + HICN_DEBUG ("ACK - type:%d seq:%d prefix:%U len:%d", params.type, params.seq, + format_ip46_address, &prefix->name, IP46_TYPE_ANY, prefix->len); - dpo = fib_epm_lookup (&(prefix.name.as_ip46), prefix.len); + dpo = fib_lookup (&(prefix->name.as_ip46), prefix->len, + HICN_MAPME_FIB_LOOKUP_TYPE_EPM); if (!dpo) { HICN_ERROR ("Ignored ACK for non-existing FIB entry %U. Ignored.", - format_ip_prefix, &prefix); + format_ip_prefix, prefix); return true; } @@ -98,7 +98,14 @@ hicn_mapme_process_ack (vlib_main_t *vm, vlib_buffer_t *b, return true; } - hicn_mapme_tfib_del (tfib, in_face); + rc = hicn_mapme_tfib_del (tfib, in_face) != HICN_ERROR_NONE; + if (rc != HICN_ERROR_NONE) + { + HICN_ERROR ( + "MAPME: Error deleting next hop %d from TFIB for prefix %U/%d", + in_face, format_ip46_address, &prefix->name, IP46_TYPE_ANY, + prefix->len); + } /* * Is the ingress face in TFIB ? if so, remove it, otherwise it might be a @@ -107,7 +114,7 @@ hicn_mapme_process_ack (vlib_main_t *vm, vlib_buffer_t *b, retx_t *retx = vlib_process_signal_event_data ( vm, hicn_mapme_eventmgr_process_node.index, HICN_MAPME_EVENT_FACE_PH_DEL, 1, sizeof (retx_t)); - *retx = (retx_t){ .prefix = prefix, .dpo = *dpo }; + *retx = (retx_t){ .prefix = *prefix, .dpo = *dpo }; return true; @@ -125,6 +132,8 @@ hicn_mapme_ack_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, hicn_mapme_ack_next_t next_index; u32 n_left_from, *from, *to_next; n_left_from = frame->n_vectors; + hicn_prefix_t prefix; + u32 seq; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -152,7 +161,7 @@ hicn_mapme_ack_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_cli_output (vm, "Received IUAck"); hb = hicn_get_buffer (b0); - hicn_mapme_process_ack (vm, b0, hb->face_id); + hicn_mapme_process_ack (vm, b0, hb->face_id, &prefix, &seq); /* Single loop: process 1 packet here */ sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX]; @@ -164,6 +173,8 @@ hicn_mapme_ack_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_add_trace (vm, node, b0, sizeof (*t)); t->sw_if_index = sw_if_index0; t->next_index = next0; + t->prefix = prefix; + t->seq = seq; } /* $$$$$ Done processing 1 packet here $$$$$ */ @@ -186,8 +197,11 @@ hicn_mapme_ack_format_trace (u8 *s, va_list *args) CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); hicn_mapme_ack_trace_t *t = va_arg (*args, hicn_mapme_ack_trace_t *); - s = format (s, "MAPME_ACK: pkt: %d, sw_if_index %d, next index %d", - (int) t->pkt_type, t->sw_if_index, t->next_index); + s = format ( + s, + "MAPME_ACK: pkt: %d, sw_if_index %d, next index %d, prefix %U/%d, seq %u", + (int) t->pkt_type, t->sw_if_index, t->next_index, format_ip46_address, + &t->prefix.name, IP46_TYPE_ANY, t->prefix.len, t->seq); return (s); } diff --git a/hicn-plugin/src/mapme_ctrl.h b/hicn-plugin/src/mapme_ctrl.h index 76382c6d2..d3dfb7b69 100644 --- a/hicn-plugin/src/mapme_ctrl.h +++ b/hicn-plugin/src/mapme_ctrl.h @@ -39,8 +39,9 @@ typedef struct hicn_mapme_ctrl_runtime_s typedef struct { u32 next_index; - u32 sw_if_index; - u8 pkt_type; + u32 seq; + hicn_prefix_t prefix; + hicn_mapme_type_t type; } hicn_mapme_ctrl_trace_t; typedef enum diff --git a/hicn-plugin/src/mapme_ctrl_node.c b/hicn-plugin/src/mapme_ctrl_node.c index e3d340e53..5d4fc5c12 100644 --- a/hicn-plugin/src/mapme_ctrl_node.c +++ b/hicn-plugin/src/mapme_ctrl_node.c @@ -50,7 +50,7 @@ static char *hicn_mapme_ctrl_error_strings[] = { }; static_always_inline int -hicn_mapme_nh_set (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) +hicn_mapme_nh_set (hicn_mapme_tfib_t *tfib, hicn_face_id_t in_face_id) { hicn_dpo_ctx_t *strategy_ctx = (hicn_dpo_ctx_t *) tfib; const fib_prefix_t *prefix = @@ -58,11 +58,13 @@ hicn_mapme_nh_set (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) int ret = 0; - if ((tfib->entry_count == 1) && (tfib->next_hops[0] == face_id)) + if ((tfib->entry_count == 1) && (tfib->next_hops[0] == in_face_id)) return ret; + /* + * Remove all the existing next hops and set the new one + */ u32 n_entries = tfib->entry_count; - /* Remove all the existing next hops and set the new one */ for (int i = 0; i < n_entries; i++) { hicn_face_t *face = hicn_dpoi_get_from_idx (strategy_ctx->next_hops[0]); @@ -73,8 +75,7 @@ hicn_mapme_nh_set (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) &adj->sub_type.nbr.next_hop, face->sw_if, 0); } - else if (face->dpo.dpoi_type == dpo_type_udp_ip4 || - face->dpo.dpoi_type == dpo_type_udp_ip6) + else if (dpo_is_udp_encap (&face->dpo)) { ip_nh_udp_tunnel_add_del_helper (prefix->fp_proto, prefix, face->dpo.dpoi_index, @@ -87,9 +88,8 @@ hicn_mapme_nh_set (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) } ret = HICN_ERROR_MAPME_NEXT_HOP_ADDED; - hicn_face_t *face = hicn_dpoi_get_from_idx (face_id); - if (face->dpo.dpoi_type == dpo_type_udp_ip4 || - face->dpo.dpoi_type == dpo_type_udp_ip6) + hicn_face_t *face = hicn_dpoi_get_from_idx (in_face_id); + if (dpo_is_udp_encap (&face->dpo)) { ip_nh_udp_tunnel_add_del_helper (prefix->fp_proto, prefix, face->dpo.dpoi_index, @@ -137,8 +137,8 @@ hicn_mapme_nh_add (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) const fib_prefix_t *prefix = fib_entry_get_prefix (strategy_ctx->fib_entry_index); hicn_face_t *face = hicn_dpoi_get_from_idx (face_id); - if (face->dpo.dpoi_type == dpo_type_udp_ip4 || - face->dpo.dpoi_type == dpo_type_udp_ip6) + + if (dpo_is_udp_encap (&face->dpo)) { ip_nh_udp_tunnel_add_del_helper ((fib_protocol_t) face->dpo.dpoi_proto, prefix, face->dpo.dpoi_index, @@ -153,6 +153,80 @@ hicn_mapme_nh_add (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) return 0; } +/** + * @brief Add a route to the fib. + * + */ +static_always_inline int +hicn_mapme_add_fib_entry (const fib_prefix_t *prefix, + hicn_face_id_t in_face_id, + fib_node_index_t *hicn_fib_node_index) +{ + int ret = HICN_ERROR_NONE; + dpo_proto_t dpo_proto = DPO_PROTO_NONE; + + hicn_face_t *face = hicn_dpoi_get_from_idx (in_face_id); + + if (face->sw_if == ~0) + { + // UDP encap case + if (face->flags & HICN_FACE_FLAGS_UDP4) + { + dpo_proto = DPO_PROTO_IP4; + } + else if (face->flags & HICN_FACE_FLAGS_UDP6) + { + dpo_proto = DPO_PROTO_IP6; + } + else + { + // Invalid + return HICN_ERROR_FACE_NOT_VALID; + } + + ret = ip_nh_udp_tunnel_add_del_helper ( + prefix->fp_proto, prefix, face->dpo.dpoi_index, dpo_proto, 1); + } + else + { + ret = ip_nh_adj_add_del_helper (prefix->fp_proto, prefix, + &face->nat_addr, face->sw_if, 1); + } + + if (ret != HICN_ERROR_NONE) + { + return ret; + } + + // Now let's trigger the sync the main table with the hicn table + hicn_face_id_t *vec_faces = NULL; + ret = hicn_route_enable (prefix, hicn_fib_node_index, &vec_faces); + + if (vec_faces[0] != in_face_id) + { + HICN_ERROR ("Created new face: new face id: %d, in_face id: %d", + vec_faces[0], in_face_id); + ret = HICN_ERROR_MAPME_WRONG_FACE_CREATED; + } + + return ret; +} + +/** + * Convert hicn prefix to fib prefix + */ +static_always_inline void +hicn_prefix_to_fib_prefix (const hicn_prefix_t *prefix_in, + fib_prefix_t *prefix_out) +{ + clib_memcpy (&prefix_out->fp_addr, &prefix_in->name.as_ip46, + sizeof (prefix_out->fp_addr)); + prefix_out->fp_len = (u16) prefix_in->len; + prefix_out->fp_proto = ip46_address_is_ip4 (&prefix_out->fp_addr) ? + FIB_PROTOCOL_IP4 : + FIB_PROTOCOL_IP6; +} + /* * @brief Process incoming control messages (Interest Update) * @param vm vlib main data structure @@ -167,46 +241,117 @@ hicn_mapme_nh_add (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) */ static_always_inline bool hicn_mapme_process_ctrl (vlib_main_t *vm, vlib_buffer_t *b, - hicn_face_id_t in_face_id) + hicn_face_id_t in_face_id, hicn_prefix_t *prefix, + u32 *seq, hicn_mapme_type_t *type) { seq_t fib_seq; - const dpo_id_t *dpo; - hicn_prefix_t prefix; + const dpo_id_t *dpo, *dpo_mapme_default_route; + fib_prefix_t fib_prefix; mapme_params_t params; + hicn_mapme_tfib_t *tfib; int rc; + hicn_mapme_main_t *mm; +#ifdef HICN_MAPME_ALLOW_NONEXISTING_FIB_ENTRY + fib_node_index_t fib_node_index; + hicn_mapme_tfib_t *tfib_less_specific; +#endif + + mm = hicn_mapme_get_main (); /* Parse incoming message */ - rc = hicn_mapme_parse_packet (vlib_buffer_get_current (b), &prefix, ¶ms); + rc = hicn_mapme_parse_packet (vlib_buffer_get_current (b), prefix, ¶ms); if (rc < 0) goto ERR_PARSE; - vlib_cli_output (vm, "IU - type:%d seq:%d len:%d", params.type, params.seq, - prefix.len); + *seq = params.seq; + *type = params.type; - /* if (params.seq == INVALID_SEQ) */ - /* { */ - /* vlib_log_warn (mapme_main.log_class, */ - /* "Invalid sequence number found in IU"); */ - - /* return true; */ - /* } */ + HICN_DEBUG ("IU - type:%d seq:%d prefix:%U len:%d", params.type, params.seq, + format_ip46_address, &prefix->name, IP46_TYPE_ANY, prefix->len); /* We forge the ACK which we be the packet forwarded by the node */ hicn_mapme_create_ack (vlib_buffer_get_current (b), ¶ms); - dpo = fib_epm_lookup (&prefix.name.as_ip46, prefix.len); + dpo = fib_lookup (&prefix->name.as_ip46, prefix->len, + HICN_MAPME_FIB_LOOKUP_TYPE_EPM); if (!dpo) { #ifdef HICN_MAPME_ALLOW_NONEXISTING_FIB_ENTRY - /* - * This might happen for a node hosting a producer which has moved. - * Destroying the face has led to removing all corresponding FIB - * entries. In that case, we need to correctly restore the FIB entries. - */ - HICN_DEBUG ("Re-creating FIB entry with next hop on connection") -#error "not implemented" + // As the EPM failed (but we received the IU), it means we have another + // prefix that is either more or less specific to which forward + // the IU. We do not update the NHs for this prefix, and we use the + // default mapme route to forward ther IU. + + dpo_mapme_default_route = + fib_lookup (&mm->default_route.fp_addr, mm->default_route.fp_len, + HICN_MAPME_FIB_LOOKUP_TYPE_EPM); + + if (!dpo_mapme_default_route) + { + // No path for mapme default route. + HICN_ERROR ( + "No path for mapme default route (%U). Giving up IU forwarding.", + format_fib_prefix, &mm->default_route); + return false; + } + + hicn_prefix_to_fib_prefix (prefix, &fib_prefix); + HICN_DEBUG ("Re-creating FIB entry with next hop on connection"); + rc = hicn_mapme_add_fib_entry (&fib_prefix, in_face_id, &fib_node_index); + + if (rc != HICN_ERROR_NONE) + { + return false; + } + + // Get the DPO from the fib node index + dpo = dpo_from_fib_node_index (fib_node_index); + + // This cannot fail + ASSERT (dpo); + +// Make sure DPO is hicn +#ifdef HICN_MAPME_ALLOW_LOCATORS + if (!dpo_is_hicn ((dpo))) + { + /* We have an IP DPO */ + HICN_ERROR ("Not implemented yet."); + return false; + } +#endif + + u32 hicn_dpo_ctx_index = dpo->dpoi_index; + u32 hicn_dpo_ctx_index_less_specific_route = + dpo_mapme_default_route->dpoi_index; + + tfib_less_specific = TFIB ( + hicn_strategy_dpo_ctx_get (hicn_dpo_ctx_index_less_specific_route)); + tfib = TFIB (hicn_strategy_dpo_ctx_get (hicn_dpo_ctx_index)); + + for (u8 pos = 0; pos < tfib_less_specific->entry_count; pos++) + { + HICN_DEBUG ( + "Adding nexthop to the tfib, dpo index in_face %d, dpo index " + "tfib %d", + in_face_id, tfib_less_specific->next_hops[pos]); + hicn_mapme_tfib_add (tfib, tfib_less_specific->next_hops[pos]); + } + + // Update sequence number + tfib->seq = params.seq; + + retx_t *retx = vlib_process_signal_event_data ( + vm, hicn_mapme_eventmgr_process_node.index, + HICN_MAPME_EVENT_FACE_NH_SET, 1, sizeof (retx_t)); + *retx = (retx_t){ .prefix = *prefix, + .dpo = { + .dpoi_index = hicn_dpo_ctx_index, + .dpoi_type = DPO_FIRST, + } }; + + return true; #else - // ERROR("Received IU for non-existing FIB entry"); + HICN_ERROR ("Received IU for non-existing FIB entry"); return false; #endif /* HICN_MAPME_ALLOW_NONEXISTING_FIB_ENTRY */ } @@ -221,7 +366,7 @@ hicn_mapme_process_ctrl (vlib_main_t *vm, vlib_buffer_t *b, #endif /* Process the hICN DPO */ - hicn_mapme_tfib_t *tfib = TFIB (hicn_strategy_dpo_ctx_get (dpo->dpoi_index)); + tfib = TFIB (hicn_strategy_dpo_ctx_get (dpo->dpoi_index)); if (tfib == NULL) { @@ -274,7 +419,7 @@ hicn_mapme_process_ctrl (vlib_main_t *vm, vlib_buffer_t *b, retx_t *retx = vlib_process_signal_event_data ( vm, hicn_mapme_eventmgr_process_node.index, HICN_MAPME_EVENT_FACE_NH_SET, 1, sizeof (retx_t)); - *retx = (retx_t){ .prefix = prefix, .dpo = *dpo }; + *retx = (retx_t){ .prefix = *prefix, .dpo = *dpo }; } else if (params.seq == fib_seq) { @@ -298,7 +443,7 @@ hicn_mapme_process_ctrl (vlib_main_t *vm, vlib_buffer_t *b, retx_t *retx = vlib_process_signal_event_data ( vm, hicn_mapme_eventmgr_process_node.index, HICN_MAPME_EVENT_FACE_NH_ADD, 1, sizeof (retx_t)); - *retx = (retx_t){ .prefix = prefix, .dpo = *dpo }; + *retx = (retx_t){ .prefix = *prefix, .dpo = *dpo }; } else // params.seq < fib_seq { @@ -320,7 +465,7 @@ hicn_mapme_process_ctrl (vlib_main_t *vm, vlib_buffer_t *b, retx_t *retx = vlib_process_signal_event_data ( vm, hicn_mapme_eventmgr_process_node.index, HICN_MAPME_EVENT_FACE_PH_ADD, 1, sizeof (retx_t)); - *retx = (retx_t){ .prefix = prefix, .dpo = *dpo }; + *retx = (retx_t){ .prefix = *prefix, .dpo = *dpo }; } /* We just raise events, the event_mgr is in charge of forging packet. */ @@ -343,6 +488,9 @@ hicn_mapme_ctrl_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, u32 n_left_from, *from, *to_next; n_left_from = frame->n_vectors; // hicn_face_id_t in_face; + hicn_prefix_t prefix; + u32 seq; + hicn_mapme_type_t type; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -370,12 +518,23 @@ hicn_mapme_ctrl_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, /* This determines the next node on which the ack will be sent back */ - u32 next0 = hicn_mapme_ctrl_get_iface_node (hb->face_id); + u32 next0 = HICN_MAPME_CTRL_NEXT_IP6_OUTPUT; - hicn_mapme_process_ctrl (vm, b0, hb->face_id); + hicn_mapme_process_ctrl (vm, b0, hb->face_id, &prefix, &seq, &type); vnet_buffer (b0)->ip.adj_index[VLIB_TX] = hb->face_id; + if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && + (b0->flags & VLIB_BUFFER_IS_TRACED))) + { + hicn_mapme_ctrl_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + t->prefix = prefix; + t->next_index = next0; + t->seq = seq; + t->type = type; + } + vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, bi0, next0); } @@ -395,8 +554,9 @@ hicn_mapme_ctrl_format_trace (u8 *s, va_list *args) CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); hicn_mapme_ctrl_trace_t *t = va_arg (*args, hicn_mapme_ctrl_trace_t *); - s = format (s, "MAPME_CTRL: pkt: %d, sw_if_index %d, next index %d", - (int) t->pkt_type, t->sw_if_index, t->next_index); + s = format (s, "MAPME_CTRL: prefix: %U/%d, next_index %u, seq %u, type %u", + format_ip46_address, &t->prefix.name, IP46_TYPE_ANY, + t->prefix.len, t->next_index, t->seq, t->type); return (s); } diff --git a/hicn-plugin/src/mapme_eventmgr.c b/hicn-plugin/src/mapme_eventmgr.c index 5c000a9d8..bb654edf8 100644 --- a/hicn-plugin/src/mapme_eventmgr.c +++ b/hicn-plugin/src/mapme_eventmgr.c @@ -40,6 +40,14 @@ void hicn_mapme_init (vlib_main_t *vm) { mapme_main.vm = vm; + clib_memset_u8 (&mapme_main.default_route, 0, + sizeof (mapme_main.default_route)); +} + +hicn_mapme_main_t * +hicn_mapme_get_main () +{ + return &mapme_main; } /* borrowed from vnet/fib/ip4_fib.c */ @@ -262,8 +270,8 @@ hicn_mapme_send_message (vlib_main_t *vm, const hicn_prefix_t *prefix, mapme_params_t *params, hicn_face_id_t face) { /* This should be retrieved from face information */ - HICN_DEBUG ("Retransmission for prefix %U seq=%d", format_ip46_address, - &prefix->name, IP46_TYPE_ANY, params->seq); + HICN_DEBUG ("Retransmission for prefix %U/%d seq=%d", format_ip46_address, + &prefix->name, IP46_TYPE_ANY, prefix->len, params->seq); char *node_name = hicn_mapme_get_dpo_face_node (face); if (!node_name) @@ -285,7 +293,7 @@ hicn_mapme_send_updates (vlib_main_t *vm, hicn_prefix_t *prefix, dpo_id_t dpo, hicn_mapme_tfib_t *tfib = TFIB (hicn_strategy_dpo_ctx_get (dpo.dpoi_index)); if (!tfib) { - HICN_ERROR ("NULL TFIB entry id=%d", dpo.dpoi_index); + HICN_DEBUG ("NULL TFIB entry id=%d", dpo.dpoi_index); return; } @@ -300,7 +308,8 @@ hicn_mapme_send_updates (vlib_main_t *vm, hicn_prefix_t *prefix, dpo_id_t dpo, if (send_all) { - for (u8 pos = tfib_last_idx; pos < HICN_PARAM_FIB_ENTRY_NHOPS_MAX; pos++) + u8 pos; + for (pos = tfib_last_idx; pos < HICN_PARAM_FIB_ENTRY_NHOPS_MAX; pos++) { hicn_mapme_send_message (vm, prefix, ¶ms, tfib->next_hops[pos]); } @@ -369,6 +378,7 @@ hicn_mapme_eventmgr_process (vlib_main_t *vm, vlib_node_runtime_t *rt, * - For another local face type, we need to advertise local * prefixes and schedule retransmissions */ + HICN_DEBUG ("Mapme Event: HICN_MAPME_EVENT_FACE_ADD"); retx_t *retx_events = event_data; for (u8 i = 0; i < vec_len (retx_events); i++) { @@ -384,6 +394,7 @@ hicn_mapme_eventmgr_process (vlib_main_t *vm, vlib_node_runtime_t *rt, case HICN_MAPME_EVENT_FACE_NH_SET: { + HICN_DEBUG ("Mapme Event: HICN_MAPME_EVENT_FACE_NH_SET"); /* * An hICN FIB entry has been modified. All operations so far * have been procedded in the nodes. Here we need to track @@ -420,6 +431,7 @@ hicn_mapme_eventmgr_process (vlib_main_t *vm, vlib_node_runtime_t *rt, * Transmit IU for all TFIB entries with latest seqno (we have * at least one for sure!) */ + HICN_DEBUG ("Sending mapme message upon NH_SET event"); hicn_mapme_send_updates (vm, &retx->prefix, retx->dpo, true); /* Delete entry_id from retransmissions in the current slot (if @@ -443,6 +455,7 @@ hicn_mapme_eventmgr_process (vlib_main_t *vm, vlib_node_runtime_t *rt, break; case HICN_MAPME_EVENT_FACE_NH_ADD: + HICN_DEBUG ("Mapme Event: HICN_MAPME_EVENT_FACE_NH_ADD"); /* * As per the description of states, this event should add the face * to the list of next hops, and eventually remove it from TFIB. @@ -462,6 +475,7 @@ hicn_mapme_eventmgr_process (vlib_main_t *vm, vlib_node_runtime_t *rt, break; case HICN_MAPME_EVENT_FACE_PH_ADD: + HICN_DEBUG ("Mapme Event: HICN_MAPME_EVENT_FACE_PH_ADD"); /* Back-propagation, interesting even for IN (desync) */ { retx_t *retx_events = event_data; @@ -475,6 +489,7 @@ hicn_mapme_eventmgr_process (vlib_main_t *vm, vlib_node_runtime_t *rt, break; case HICN_MAPME_EVENT_FACE_PH_DEL: + HICN_DEBUG ("Mapme Event: HICN_MAPME_EVENT_FACE_PH_DEL"); /* Ack : remove an element from TFIB */ break; diff --git a/hicn-plugin/src/pg.c b/hicn-plugin/src/pg.c index 78380a804..e3dda0520 100644 --- a/hicn-plugin/src/pg.c +++ b/hicn-plugin/src/pg.c @@ -341,7 +341,8 @@ hicnpg_server_add_and_lock (fib_prefix_t *prefix, u32 *hicnpg_server_index, HICN_DEBUG ("Calling hicn enable for pg-server face"); hicn_face_id_t *vec_faces = NULL; - hicn_route_enable (prefix, &vec_faces); + fib_node_index_t hicn_fib_node_index; + hicn_route_enable (prefix, &hicn_fib_node_index, &vec_faces); if (vec_faces != NULL) vec_free (vec_faces); diff --git a/hicn-plugin/src/route.c b/hicn-plugin/src/route.c index 2509628d9..fa95f7265 100644 --- a/hicn-plugin/src/route.c +++ b/hicn-plugin/src/route.c @@ -370,7 +370,9 @@ disable_data_receiving_rm_fib_entry (vnet_main_t *vnm, vnet_sw_interface_t *si, } int -hicn_route_enable (const fib_prefix_t *prefix, hicn_face_id_t **pvec_faces) +hicn_route_enable (const fib_prefix_t *prefix, + fib_node_index_t *hicn_fib_node_index, + hicn_face_id_t **pvec_faces) { int ret = HICN_ERROR_NONE; @@ -398,10 +400,9 @@ hicn_route_enable (const fib_prefix_t *prefix, hicn_face_id_t **pvec_faces) /* Check if the prefix is already enabled */ u32 fib_hicn_index = fib_table_find (prefix->fp_proto, HICN_FIB_TABLE); - fib_node_index_t fib_hicn_entry_index = - fib_table_lookup_exact_match (fib_hicn_index, prefix); + *hicn_fib_node_index = fib_table_lookup_exact_match (fib_hicn_index, prefix); - if (fib_hicn_entry_index == FIB_NODE_INDEX_INVALID) + if (*hicn_fib_node_index == FIB_NODE_INDEX_INVALID) { HICN_DEBUG ( "No route found for %U. Creating DPO and tracking fib prefix.", @@ -442,10 +443,9 @@ hicn_route_enable (const fib_prefix_t *prefix, hicn_face_id_t **pvec_faces) * to match Neale suggested -- FIB_SOURCE_HICN the client * that is adding them -- no easy explanation at this timeā€¦ */ - CLIB_UNUSED (fib_node_index_t new_fib_node_index) = - fib_table_entry_special_dpo_add ( - fib_hicn_index, prefix, hicn_fib_src, - (FIB_ENTRY_FLAG_EXCLUSIVE | FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT), &dpo); + *hicn_fib_node_index = fib_table_entry_special_dpo_add ( + fib_hicn_index, prefix, hicn_fib_src, + (FIB_ENTRY_FLAG_EXCLUSIVE | FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT), &dpo); HICN_DEBUG ("Calling sync_hicn_fib_entry"); sync_hicn_fib_entry (fib_entry, pvec_faces); @@ -477,7 +477,7 @@ hicn_route_enable (const fib_prefix_t *prefix, hicn_face_id_t **pvec_faces) /* Route already existing. We need to update the dpo. */ load_balance_dpo_id = - fib_entry_contribute_ip_forwarding (fib_hicn_entry_index); + fib_entry_contribute_ip_forwarding (*hicn_fib_node_index); /* The dpo is not a load balance dpo as expected */ if (load_balance_dpo_id->dpoi_type != DPO_LOAD_BALANCE) diff --git a/hicn-plugin/src/route.h b/hicn-plugin/src/route.h index 46204dd4c..4fcb219c8 100644 --- a/hicn-plugin/src/route.h +++ b/hicn-plugin/src/route.h @@ -93,7 +93,7 @@ int ip_nh_adj_add_del_helper (fib_protocol_t fib_proto, * @param fib_proto FIB_PROTOCOL_IP6 or FIB_PROTOCOL_IP4 (mpls not supported) * @param rpfx Prefix for which to add a next hop * @param uei The UDP ENCAP ID - * @param sw_if The + * @param proto The payload proto for this encap */ int ip_nh_udp_tunnel_add_del_helper (fib_protocol_t fib_proto, const fib_prefix_t *rpfx, u32 uei, @@ -109,7 +109,9 @@ int ip_nh_udp_tunnel_add_del_helper (fib_protocol_t fib_proto, * loadbalancer in the vrf HICN already contains a dpo which is not an hICN one * HICN_ERROR_ROUTE_MLT_LD if there are more than a dpo in the vpp loadbalancer */ -int hicn_route_enable (const fib_prefix_t *prefix, hicn_face_id_t **vec_faces); +int hicn_route_enable (const fib_prefix_t *prefix, + fib_node_index_t *hicn_fib_node_index, + hicn_face_id_t **vec_faces); /** * @Brief Disable an hICN for an ip prefix. If hICN wasn't enable on the prefix -- cgit 1.2.3-korg