diff options
Diffstat (limited to 'hicn-plugin')
-rw-r--r-- | hicn-plugin/src/data_input_node.c | 10 | ||||
-rw-r--r-- | hicn-plugin/src/faces/face.c | 11 | ||||
-rw-r--r-- | hicn-plugin/src/faces/face.h | 19 | ||||
-rw-r--r-- | hicn-plugin/src/faces/face_node.c | 63 | ||||
-rw-r--r-- | hicn-plugin/src/faces/iface_node.c | 33 | ||||
-rw-r--r-- | hicn-plugin/src/mapme_eventmgr.c | 41 | ||||
-rw-r--r-- | hicn-plugin/src/route.c | 16 | ||||
-rw-r--r-- | hicn-plugin/src/route.h | 2 |
8 files changed, 112 insertions, 83 deletions
diff --git a/hicn-plugin/src/data_input_node.c b/hicn-plugin/src/data_input_node.c index dbf49de54..a91f9156d 100644 --- a/hicn-plugin/src/data_input_node.c +++ b/hicn-plugin/src/data_input_node.c @@ -81,13 +81,21 @@ hicn_data_input_set_adj_index (vlib_buffer_t *b, const hicn_dpo_ctx_t *dpo_ctx) { CLIB_UNUSED (u8 set) = 0; + u32 *adj_index = &vnet_buffer (b)->ip.adj_index[VLIB_RX]; + + if (*adj_index != ADJ_INDEX_INVALID) + { + return; + } + for (u8 pos = 0; pos < dpo_ctx->entry_count; pos++) { hicn_face_t *face = hicn_dpoi_get_from_idx (dpo_ctx->next_hops[pos]); assert (face); + if (ip46_address_cmp (&(face->nat_addr), dst_addr) == 0) { - vnet_buffer (b)->ip.adj_index[VLIB_RX] = face->dpo.dpoi_index; + *adj_index = face->dpo.dpoi_index; set = 1; break; } diff --git a/hicn-plugin/src/faces/face.c b/hicn-plugin/src/faces/face.c index 84fd5e6ee..ce3001ac7 100644 --- a/hicn-plugin/src/faces/face.c +++ b/hicn-plugin/src/faces/face.c @@ -266,10 +266,12 @@ hicn_face_del (hicn_face_id_t face_id) } static void -hicn_iface_to_face (hicn_face_t *face, const dpo_id_t *dpo) +hicn_iface_to_face (hicn_face_t *face, const dpo_id_t *dpo, + dpo_proto_t dpo_proto) { - dpo_stack (hicn_face_type, dpo->dpoi_proto, &face->dpo, dpo); + dpo_stack (hicn_face_type, dpo_proto, &face->dpo, dpo); + face->dpo.dpoi_proto = dpo_proto; face->flags &= ~HICN_FACE_FLAGS_IFACE; face->flags |= HICN_FACE_FLAGS_FACE; @@ -305,7 +307,7 @@ hicn_iface_to_face (hicn_face_t *face, const dpo_id_t *dpo) */ int hicn_face_add (const dpo_id_t *dpo_nh, ip46_address_t *nat_address, int sw_if, - hicn_face_id_t *pfaceid) + hicn_face_id_t *pfaceid, dpo_proto_t dpo_proto) { hicn_face_t *face; @@ -329,7 +331,6 @@ hicn_face_add (const dpo_id_t *dpo_nh, ip46_address_t *nat_address, int sw_if, if (face == NULL) { - hicn_iface_add (nat_address, sw_if, pfaceid, dpo_nh->dpoi_index, 0); face = hicn_dpoi_get_from_idx (*pfaceid); @@ -345,7 +346,7 @@ hicn_face_add (const dpo_id_t *dpo_nh, ip46_address_t *nat_address, int sw_if, mhash_set_mem (&hicn_face_hashtb, &key, (uword *) pfaceid, 0); } - hicn_iface_to_face (face, dpo_nh); + hicn_iface_to_face (face, dpo_nh, dpo_proto); temp_dpo.dpoi_index = ~0; diff --git a/hicn-plugin/src/faces/face.h b/hicn-plugin/src/faces/face.h index b23cb9b12..2c0a09a28 100644 --- a/hicn-plugin/src/faces/face.h +++ b/hicn-plugin/src/faces/face.h @@ -453,7 +453,7 @@ hicn_face_get_with_dpo (const ip46_address_t *addr, u32 sw_if, * reachable ip address, otherwise HICN_ERROR_NONE */ int hicn_face_add (const dpo_id_t *dpo_nh, ip46_address_t *nat_address, - int sw_if, hicn_face_id_t *pfaceid); + int sw_if, hicn_face_id_t *pfaceid, dpo_proto_t dpo_proto); /** * @brief Create a new incomplete face ip. (Meant to be used by the data plane) @@ -524,6 +524,7 @@ hicn_face_ip4_find (hicn_face_id_t *index, u8 *hicnb_flags, u32 node_index) { int ret = HICN_ERROR_FACE_NOT_FOUND; + hicn_face_id_t face_id; /*All (complete) faces are indexed by remote addess as well */ /* if the face exists, it adds a lock */ @@ -533,11 +534,13 @@ hicn_face_ip4_find (hicn_face_id_t *index, u8 *hicnb_flags, if (face != NULL) { /* unlock the face. We don't take a lock on each interest we receive */ - hicn_face_id_t face_id = hicn_dpoi_get_index (face); + face_id = hicn_dpoi_get_index (face); hicn_face_unlock_with_id (face_id); - ret = HICN_ERROR_FACE_ALREADY_CREATED; + *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; - *index = hicn_dpoi_get_index (face); + *index = face_id; + + ret = HICN_ERROR_FACE_ALREADY_CREATED; } return ret; @@ -621,6 +624,7 @@ hicn_face_ip6_find (hicn_face_id_t *index, u8 *hicnb_flags, u32 node_index) { int ret = HICN_ERROR_FACE_NOT_FOUND; + hicn_face_id_t face_id; hicn_face_t *face = hicn_face_get ((const ip46_address_t *) nat_addr, sw_if, &hicn_face_hashtb, adj_index); @@ -628,11 +632,12 @@ hicn_face_ip6_find (hicn_face_id_t *index, u8 *hicnb_flags, if (face != NULL) { /* unlock the face. We don't take a lock on each interest we receive */ - hicn_face_id_t face_id = hicn_dpoi_get_index (face); + face_id = hicn_dpoi_get_index (face); hicn_face_unlock_with_id (face_id); - ret = HICN_ERROR_FACE_ALREADY_CREATED; *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; - *index = hicn_dpoi_get_index (face); + *index = face_id; + + ret = HICN_ERROR_FACE_ALREADY_CREATED; } return ret; diff --git a/hicn-plugin/src/faces/face_node.c b/hicn-plugin/src/faces/face_node.c index ab51293b3..2cfb9c7dc 100644 --- a/hicn-plugin/src/faces/face_node.c +++ b/hicn-plugin/src/faces/face_node.c @@ -117,7 +117,7 @@ typedef enum vlib_buffer_t *b0; \ u32 bi0, sw_if0; \ u32 next0 = NEXT_ERROR_DROP_IP##ipv; \ - u8 is_icmp0; \ + u8 is_mapme0; \ IP_HEADER_##ipv *ip_hdr = NULL; \ hicn_buffer_t *hicnb0; \ int from_tunnel0; \ @@ -144,7 +144,9 @@ typedef enum \ /* Parse packet and cache useful info in opaque2 */ \ ret0 = hicn_data_parse_pkt (b0, vlib_buffer_length_in_chain (vm, b0)); \ - is_icmp0 = ret0 == HICN_ERROR_PARSER_MAPME_PACKET; \ + is_mapme0 = hicn_packet_get_type (&hicn_get_buffer (b0)->pkbuf) == \ + HICN_PACKET_TYPE_MAPME; \ + \ ret0 = (ret0 == HICN_ERROR_NONE) || \ (ret0 == HICN_ERROR_PARSER_MAPME_PACKET); \ \ @@ -155,15 +157,14 @@ typedef enum } \ else \ { \ - next0 = is_icmp0 * NEXT_MAPME_IP##ipv + \ - (1 - is_icmp0) * NEXT_DATA_IP##ipv; \ + next0 = is_mapme0 * NEXT_MAPME_IP##ipv + \ + (1 - is_mapme0) * NEXT_DATA_IP##ipv; \ from_tunnel0 = \ (hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL || \ hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL) > 0; \ sw_if0 = \ (from_tunnel0) * ~0 + \ (1 - from_tunnel0) * vnet_buffer (b0)->sw_if_index[VLIB_RX]; \ - \ ret0 = hicn_face_ip##ipv##_find ( \ &hicnb0->face_id, &hicnb0->flags, &ip_hdr->dst_address, sw_if0, \ vnet_buffer (b0)->ip.adj_index[VLIB_RX], \ @@ -206,7 +207,7 @@ typedef enum u32 bi0, bi1, sw_if0, sw_if1; \ u32 next0 = NEXT_ERROR_DROP_IP##ipv; \ u32 next1 = NEXT_ERROR_DROP_IP##ipv; \ - u8 is_icmp0, is_icmp1; \ + u8 is_mapme0, is_mapme1; \ IP_HEADER_##ipv *ip_hdr0 = NULL; \ IP_HEADER_##ipv *ip_hdr1 = NULL; \ hicn_buffer_t *hicnb0; \ @@ -243,19 +244,21 @@ typedef enum /* Parse packet and cache useful info in opaque2 */ \ ret0 = hicn_data_parse_pkt (b0, vlib_buffer_length_in_chain (vm, b0)); \ ret1 = hicn_data_parse_pkt (b1, vlib_buffer_length_in_chain (vm, b1)); \ - is_icmp0 = ret0 == HICN_ERROR_PARSER_MAPME_PACKET; \ - is_icmp1 = ret1 == HICN_ERROR_PARSER_MAPME_PACKET; \ + is_mapme0 = hicn_packet_get_type (&hicn_get_buffer (b0)->pkbuf) == \ + HICN_PACKET_TYPE_MAPME; \ + is_mapme1 = hicn_packet_get_type (&hicn_get_buffer (b1)->pkbuf) == \ + HICN_PACKET_TYPE_MAPME; \ ret0 = (ret0 == HICN_ERROR_NONE) || \ (ret0 == HICN_ERROR_PARSER_MAPME_PACKET); \ ret1 = (ret1 == HICN_ERROR_NONE) || \ (ret1 == HICN_ERROR_PARSER_MAPME_PACKET); \ if (PREDICT_TRUE (ret0 && ret1)) \ { \ - next0 = is_icmp0 * NEXT_MAPME_IP##ipv + \ - (1 - is_icmp0) * NEXT_DATA_IP##ipv; \ + next0 = is_mapme0 * NEXT_MAPME_IP##ipv + \ + (1 - is_mapme0) * NEXT_DATA_IP##ipv; \ \ - next1 = is_icmp1 * NEXT_MAPME_IP##ipv + \ - (1 - is_icmp1) * NEXT_DATA_IP##ipv; \ + next1 = is_mapme1 * NEXT_MAPME_IP##ipv + \ + (1 - is_mapme1) * NEXT_DATA_IP##ipv; \ \ from_tunnel0 = \ (hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL || \ @@ -263,7 +266,6 @@ typedef enum sw_if0 = \ (from_tunnel0) * ~0 + \ (1 - from_tunnel0) * vnet_buffer (b0)->sw_if_index[VLIB_RX]; \ - \ ret0 = hicn_face_ip##ipv##_find ( \ &hicnb0->face_id, &hicnb0->flags, &ip_hdr0->dst_address, sw_if0, \ vnet_buffer (b0)->ip.adj_index[VLIB_RX], \ @@ -280,7 +282,6 @@ typedef enum sw_if1 = \ (from_tunnel1) * ~0 + \ (1 - from_tunnel1) * vnet_buffer (b1)->sw_if_index[VLIB_RX]; \ - \ ret1 = hicn_face_ip##ipv##_find ( \ &hicnb1->face_id, &hicnb1->flags, &ip_hdr1->dst_address, sw_if1, \ vnet_buffer (b1)->ip.adj_index[VLIB_RX], \ @@ -300,7 +301,6 @@ typedef enum sw_if0 = \ (from_tunnel0) * ~0 + \ (1 - from_tunnel0) * vnet_buffer (b0)->sw_if_index[VLIB_RX]; \ - \ ret0 = hicn_face_ip##ipv##_find ( \ &hicnb0->face_id, &hicnb0->flags, &ip_hdr0->dst_address, sw_if0, \ vnet_buffer (b0)->ip.adj_index[VLIB_RX], \ @@ -312,8 +312,8 @@ typedef enum } \ else \ { \ - next0 = is_icmp0 * NEXT_MAPME_IP##ipv + \ - (1 - is_icmp0) * NEXT_DATA_IP##ipv; \ + next0 = is_mapme0 * NEXT_MAPME_IP##ipv + \ + (1 - is_mapme0) * NEXT_DATA_IP##ipv; \ } \ } \ else if (!ret0 && ret1) \ @@ -325,7 +325,6 @@ typedef enum sw_if1 = \ (from_tunnel1) * ~0 + \ (1 - from_tunnel1) * vnet_buffer (b1)->sw_if_index[VLIB_RX]; \ - \ ret1 = hicn_face_ip##ipv##_find ( \ &hicnb1->face_id, &hicnb1->flags, &ip_hdr1->dst_address, sw_if1, \ vnet_buffer (b1)->ip.adj_index[VLIB_RX], \ @@ -337,8 +336,8 @@ typedef enum } \ else \ { \ - next1 = is_icmp1 * NEXT_MAPME_IP##ipv + \ - (1 - is_icmp1) * NEXT_DATA_IP##ipv; \ + next1 = is_mapme1 * NEXT_MAPME_IP##ipv + \ + (1 - is_mapme1) * NEXT_DATA_IP##ipv; \ } \ } \ else \ @@ -607,6 +606,7 @@ static char *hicn6_face_output_error_strings[] = { typedef struct { u32 next_index; + u32 next_node; u32 sw_if_index; u8 pkt_type; u8 packet_data[60]; @@ -616,6 +616,7 @@ typedef struct typedef struct { u32 next_index; + u32 next_node; u32 sw_if_index; u8 pkt_type; u8 packet_data[60]; @@ -671,7 +672,8 @@ typedef struct vlib_add_trace (vm, node, b0, sizeof (*t)); \ t->pkt_type = HICN_PACKET_TYPE_INTEREST; \ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \ - t->next_index = next0; \ + t->next_index = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \ + t->next_node = next0; \ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b0), \ sizeof (t->packet_data)); \ } \ @@ -750,7 +752,8 @@ typedef struct vlib_add_trace (vm, node, b0, sizeof (*t)); \ t->pkt_type = HICN_PACKET_TYPE_INTEREST; \ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \ - t->next_index = next0; \ + t->next_index = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \ + t->next_node = next0; \ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b0), \ sizeof (t->packet_data)); \ } \ @@ -762,11 +765,11 @@ typedef struct vlib_add_trace (vm, node, b1, sizeof (*t)); \ t->pkt_type = HICN_PACKET_TYPE_INTEREST; \ t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \ - t->next_index = next1; \ + t->next_index = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; \ + t->next_node = next1; \ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b1), \ sizeof (t->packet_data)); \ } \ - \ /* Verify speculative enqueue, maybe switch current next frame */ \ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next, \ n_left_to_next, bi0, bi1, next0, \ @@ -819,8 +822,10 @@ hicn4_face_output_format_trace (u8 *s, va_list *args) CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); hicn4_face_output_trace_t *t = va_arg (*args, hicn4_face_output_trace_t *); - s = format (s, "FACE_IP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U", - (int) t->pkt_type, t->sw_if_index, t->next_index, + s = format (s, + "FACE_IP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d, next " + "node: %d\n%U", + (int) t->pkt_type, t->sw_if_index, t->next_index, t->next_node, format_ip4_header, t->packet_data, sizeof (t->packet_data)); return (s); } @@ -884,8 +889,10 @@ hicn6_face_output_format_trace (u8 *s, va_list *args) CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); hicn6_face_output_trace_t *t = va_arg (*args, hicn6_face_output_trace_t *); - s = format (s, "FACE_IP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U", - (int) t->pkt_type, t->sw_if_index, t->next_index, + s = format (s, + "FACE_IP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d, next " + "node: %d\n%U", + (int) t->pkt_type, t->sw_if_index, t->next_index, t->next_node, format_ip6_header, t->packet_data, sizeof (t->packet_data)); return (s); } diff --git a/hicn-plugin/src/faces/iface_node.c b/hicn-plugin/src/faces/iface_node.c index fba7e97e6..8b74c6c25 100644 --- a/hicn-plugin/src/faces/iface_node.c +++ b/hicn-plugin/src/faces/iface_node.c @@ -164,7 +164,7 @@ typedef struct IP_HEADER_##ipv *ip_hdr = NULL; \ hicn_buffer_t *hicnb0; \ int ret0 = HICN_ERROR_NONE; \ - u8 is_icmp0, is_manifest0; \ + u8 is_mapme0, is_manifest0; \ /* Prefetch for next iteration. */ \ if (n_left_from > 1) \ { \ @@ -188,7 +188,8 @@ typedef struct /* Parse packet and cache useful info in opaque2 */ \ ret0 = \ hicn_interest_parse_pkt (b0, vlib_buffer_length_in_chain (vm, b0)); \ - is_icmp0 = (ret0 == HICN_ERROR_PARSER_MAPME_PACKET); \ + is_mapme0 = hicn_packet_get_type (&hicn_get_buffer (b0)->pkbuf) == \ + HICN_PACKET_TYPE_MAPME; \ is_manifest0 = hicnb0->payload_type == HPT_MANIFEST; \ ret0 = (ret0 == HICN_ERROR_NONE) || \ (ret0 == HICN_ERROR_PARSER_MAPME_PACKET); \ @@ -198,8 +199,8 @@ typedef struct } \ else \ { \ - next0 = is_icmp0 * NEXT_MAPME_IP##ipv + \ - (1 - is_icmp0) * (NEXT_INTEREST_IP##ipv + is_manifest0); \ + next0 = is_mapme0 * NEXT_MAPME_IP##ipv + \ + (1 - is_mapme0) * (NEXT_INTEREST_IP##ipv + is_manifest0); \ \ next_iface0 = NEXT_DATA_LOOKUP_IP##ipv; \ sw_if0 = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \ @@ -257,7 +258,7 @@ typedef struct vlib_buffer_t *b0, *b1; \ u32 bi0, bi1, next0, next1; \ u32 next_iface0, next_iface1, sw_if0 = ~0, sw_if1 = ~0; \ - u8 is_icmp0, is_icmp1, is_manifest0, is_manifest1; \ + u8 is_mapme0, is_mapme1, is_manifest0, is_manifest1; \ IP_HEADER_##ipv *ip_hdr0 = NULL; \ IP_HEADER_##ipv *ip_hdr1 = NULL; \ int ret0 = HICN_ERROR_NONE, ret1 = HICN_ERROR_NONE; \ @@ -296,8 +297,10 @@ typedef struct hicn_interest_parse_pkt (b0, vlib_buffer_length_in_chain (vm, b0)); \ ret1 = \ hicn_interest_parse_pkt (b1, vlib_buffer_length_in_chain (vm, b1)); \ - is_icmp0 = ret0 == HICN_ERROR_PARSER_MAPME_PACKET; \ - is_icmp1 = ret1 == HICN_ERROR_PARSER_MAPME_PACKET; \ + is_mapme0 = hicn_packet_get_type (&hicn_get_buffer (b0)->pkbuf) == \ + HICN_PACKET_TYPE_MAPME; \ + is_mapme1 = hicn_packet_get_type (&hicn_get_buffer (b1)->pkbuf) == \ + HICN_PACKET_TYPE_MAPME; \ is_manifest0 = hicnb0->payload_type == HPT_MANIFEST; \ is_manifest1 = hicnb1->payload_type == HPT_MANIFEST; \ ret0 = (ret0 == HICN_ERROR_NONE) || \ @@ -307,11 +310,11 @@ typedef struct \ if (PREDICT_TRUE (ret0 && ret1)) \ { \ - next0 = is_icmp0 * NEXT_MAPME_IP##ipv + \ - (1 - is_icmp0) * (NEXT_INTEREST_IP##ipv + is_manifest0); \ + next0 = is_mapme0 * NEXT_MAPME_IP##ipv + \ + (1 - is_mapme0) * (NEXT_INTEREST_IP##ipv + is_manifest0); \ \ - next1 = is_icmp1 * NEXT_MAPME_IP##ipv + \ - (1 - is_icmp1) * (NEXT_INTEREST_IP##ipv + is_manifest1); \ + next1 = is_mapme1 * NEXT_MAPME_IP##ipv + \ + (1 - is_mapme1) * (NEXT_INTEREST_IP##ipv + is_manifest1); \ \ next_iface0 = NEXT_DATA_LOOKUP_IP##ipv; \ sw_if0 = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \ @@ -366,8 +369,8 @@ typedef struct else if (ret0 && !ret1) \ { \ next1 = HICN##ipv##_IFACE_INPUT_NEXT_ERROR_DROP; \ - next0 = is_icmp0 * NEXT_MAPME_IP##ipv + \ - (1 - is_icmp0) * NEXT_INTEREST_IP##ipv; \ + next0 = is_mapme0 * NEXT_MAPME_IP##ipv + \ + (1 - is_mapme0) * NEXT_INTEREST_IP##ipv; \ next_iface0 = NEXT_DATA_LOOKUP_IP##ipv; \ sw_if0 = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \ \ @@ -398,8 +401,8 @@ typedef struct next0 = HICN##ipv##_IFACE_INPUT_NEXT_ERROR_DROP; \ next_iface1 = NEXT_DATA_LOOKUP_IP##ipv; \ sw_if1 = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \ - next1 = is_icmp1 * NEXT_MAPME_IP##ipv + \ - (1 - is_icmp1) * NEXT_INTEREST_IP##ipv; \ + next1 = is_mapme1 * NEXT_MAPME_IP##ipv + \ + (1 - is_mapme1) * NEXT_INTEREST_IP##ipv; \ \ if (hicnb1->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL && \ vnet_buffer (b1)->ip.adj_index[VLIB_RX] != ADJ_INDEX_INVALID) \ diff --git a/hicn-plugin/src/mapme_eventmgr.c b/hicn-plugin/src/mapme_eventmgr.c index 866ac9a85..5c000a9d8 100644 --- a/hicn-plugin/src/mapme_eventmgr.c +++ b/hicn-plugin/src/mapme_eventmgr.c @@ -196,22 +196,28 @@ hicn_mapme_on_face_added (vlib_main_t *vm, hicn_face_id_t face) #define CURLEN retx_len[cur] #define NXTLEN retx_len[NEXT_SLOT (cur)] -static_always_inline void * -get_packet_buffer (vlib_main_t *vm, u32 node_index, u32 dpoi_index, - ip46_address_t *addr, hicn_packet_format_t format) +static_always_inline bool +create_mapme_packet_buffer (vlib_main_t *vm, u32 node_index, u32 dpoi_index, + const hicn_prefix_t *prefix, + const mapme_params_t *params) { vlib_frame_t *f; vlib_buffer_t *b; // for newly created packet u32 *to_next; u32 bi; u8 *buffer; + size_t n; + hicn_packet_format_t format; if (vlib_buffer_alloc (vm, &bi, 1) != 1) { - clib_warning ("buffer allocation failure"); + HICN_ERROR ("buffer allocation failure"); return NULL; } + format = (params->protocol == IPPROTO_IPV6) ? HICN_PACKET_FORMAT_IPV6_ICMP : + HICN_PACKET_FORMAT_IPV4_ICMP; + /* Create a new packet from scratch */ b = vlib_get_buffer (vm, bi); ASSERT (b->current_data == 0); @@ -236,6 +242,18 @@ get_packet_buffer (vlib_main_t *vm, u32 node_index, u32 dpoi_index, EXPECTED_MAPME_V6_HDRLEN : EXPECTED_MAPME_V4_HDRLEN; + n = hicn_mapme_create_packet (buffer, prefix, params); + + if (n <= 0) + { + HICN_ERROR ("Could not create MAP-Me packet"); + return false; + } + + hicn_packet_set_buffer (pkbuf, vlib_buffer_get_current (b), + b->current_length, b->current_length); + hicn_packet_analyze (&hicn_get_buffer (b)->pkbuf); + return buffer; } @@ -243,8 +261,6 @@ static_always_inline bool hicn_mapme_send_message (vlib_main_t *vm, const hicn_prefix_t *prefix, mapme_params_t *params, hicn_face_id_t face) { - size_t n; - /* 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); @@ -259,18 +275,7 @@ hicn_mapme_send_message (vlib_main_t *vm, const hicn_prefix_t *prefix, vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) node_name); u32 node_index = node->index; - u8 *buffer = get_packet_buffer ( - vm, node_index, face, (ip46_address_t *) prefix, - (params->protocol == IPPROTO_IPV6) ? HICN_PACKET_FORMAT_IPV6_ICMP : - HICN_PACKET_FORMAT_IPV4_ICMP); - n = hicn_mapme_create_packet (buffer, prefix, params); - if (n <= 0) - { - clib_warning ("Could not create MAP-Me packet"); - return false; - } - - return true; + return create_mapme_packet_buffer (vm, node_index, face, prefix, params); } static_always_inline void diff --git a/hicn-plugin/src/route.c b/hicn-plugin/src/route.c index ff96e5cd7..2509628d9 100644 --- a/hicn-plugin/src/route.c +++ b/hicn-plugin/src/route.c @@ -231,11 +231,11 @@ sync_hicn_fib_entry (hicn_dpo_ctx_t *fib_entry, hicn_face_id_t **pvec_faces) const dpo_id_t *former_dpo = &temp; int index = 0; -#define ADD_FACE(nh) \ +#define ADD_FACE(nh, dpo_proto) \ do \ { \ /* Careful, this adds a lock on the face if it exists */ \ - hicn_face_add (dpo, nh, sw_if, &face_id); \ + hicn_face_add (dpo, nh, sw_if, &face_id, dpo_proto); \ ASSERT (face_id != HICN_FACE_NULL); \ vec_validate (vec_faces, index); \ vec_faces[index] = face_id; \ @@ -272,7 +272,7 @@ sync_hicn_fib_entry (hicn_dpo_ctx_t *fib_entry, hicn_face_id_t **pvec_faces) sw_if = adj->rewrite_header.sw_if_index; nh = get_address (&(adj->sub_type.nbr.next_hop), sw_if, fib_entry->proto); - ADD_FACE (nh); + ADD_FACE (nh, dpo->dpoi_proto); HICN_DEBUG ("Added new HICN face: %d because of route prefix %U", face_id, format_fib_prefix, &_fib_entry->fe_prefix); } @@ -285,11 +285,11 @@ sync_hicn_fib_entry (hicn_dpo_ctx_t *fib_entry, hicn_face_id_t **pvec_faces) { case FIB_PROTOCOL_IP6: ip46_address_set_ip6 (nh, &localhost6); - ADD_FACE (nh); + ADD_FACE (nh, DPO_PROTO_IP6); break; case FIB_PROTOCOL_IP4: ip46_address_set_ip4 (nh, &localhost4); - ADD_FACE (nh); + ADD_FACE (nh, DPO_PROTO_IP4); break; default: continue; @@ -302,7 +302,7 @@ sync_hicn_fib_entry (hicn_dpo_ctx_t *fib_entry, hicn_face_id_t **pvec_faces) else if (dpo_is_pgserver (dpo)) { hicnpg_server_t *pg_server = hicnpg_server_get (dpo->dpoi_index); - ADD_FACE (&pg_server->hicn_locator); + ADD_FACE (&pg_server->hicn_locator, dpo->dpoi_proto); } } @@ -370,7 +370,7 @@ disable_data_receiving_rm_fib_entry (vnet_main_t *vnm, vnet_sw_interface_t *si, } int -hicn_route_enable (fib_prefix_t *prefix, hicn_face_id_t **pvec_faces) +hicn_route_enable (const fib_prefix_t *prefix, hicn_face_id_t **pvec_faces) { int ret = HICN_ERROR_NONE; @@ -464,7 +464,7 @@ hicn_route_enable (fib_prefix_t *prefix, hicn_face_id_t **pvec_faces) */ vnet_main_t *vnm = vnet_get_main (); vnet_sw_interface_walk (vnm, enable_data_receiving_new_fib_entry, - &(prefix->fp_proto)); + (void *) (&prefix->fp_proto)); dpo_unlock (&dpo); } diff --git a/hicn-plugin/src/route.h b/hicn-plugin/src/route.h index 072926498..46204dd4c 100644 --- a/hicn-plugin/src/route.h +++ b/hicn-plugin/src/route.h @@ -109,7 +109,7 @@ 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 (fib_prefix_t *prefix, hicn_face_id_t **vec_faces); +int hicn_route_enable (const fib_prefix_t *prefix, hicn_face_id_t **vec_faces); /** * @Brief Disable an hICN for an ip prefix. If hICN wasn't enable on the prefix |