From 95fb62e1aacca53c750c40845aee4b10963d7c57 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Thu, 9 Feb 2023 15:30:15 +0000 Subject: fix(hicn-plugin): correctly punt mapme packets Ticket: HICN-840 Change-Id: Ib92fa130867dcfc1ed7bbc96cc72c6224d94b57b Signed-off-by: Mauro Sardara --- hicn-plugin/src/faces/face_node.c | 63 +++++++++++++++++++++----------------- hicn-plugin/src/faces/iface_node.c | 33 +++++++++++--------- 2 files changed, 53 insertions(+), 43 deletions(-) (limited to 'hicn-plugin') 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) \ -- cgit 1.2.3-korg