-#ifdef IP4_MAP_T_DUAL_LOOP
- while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- u32 pi0, pi1;
- vlib_buffer_t *p0, *p1;
- ip4_header_t *ip40, *ip41;
- map_domain_t *d0, *d1;
- ip4_mapt_next_t next0 = 0, next1 = 0;
- u16 ip4_len0, ip4_len1;
- u8 error0, error1;
- i32 map_port0, map_port1;
- ip4_mapt_pseudo_header_t *pheader0, *pheader1;
-
- pi0 = to_next[0] = from[0];
- pi1 = to_next[1] = from[1];
- from += 2;
- n_left_from -= 2;
- to_next += 2;
- n_left_to_next -= 2;
- error0 = MAP_ERROR_NONE;
- error1 = MAP_ERROR_NONE;
-
- p0 = vlib_get_buffer (vm, pi0);
- p1 = vlib_get_buffer (vm, pi1);
- ip40 = vlib_buffer_get_current (p0);
- ip41 = vlib_buffer_get_current (p1);
- ip4_len0 = clib_host_to_net_u16 (ip40->length);
- ip4_len1 = clib_host_to_net_u16 (ip41->length);
-
- if (PREDICT_FALSE (p0->current_length < ip4_len0 ||
- ip40->ip_version_and_header_length != 0x45))
- {
- error0 = MAP_ERROR_UNKNOWN;
- next0 = IP4_MAPT_NEXT_DROP;
- }
-
- if (PREDICT_FALSE (p1->current_length < ip4_len1 ||
- ip41->ip_version_and_header_length != 0x45))
- {
- error1 = MAP_ERROR_UNKNOWN;
- next1 = IP4_MAPT_NEXT_DROP;
- }
-
- vnet_buffer (p0)->map_t.map_domain_index =
- vnet_buffer (p0)->ip.adj_index[VLIB_TX];
- d0 = ip4_map_get_domain (vnet_buffer (p0)->map_t.map_domain_index);
- vnet_buffer (p1)->map_t.map_domain_index =
- vnet_buffer (p1)->ip.adj_index[VLIB_TX];
- d1 = ip4_map_get_domain (vnet_buffer (p1)->map_t.map_domain_index);
-
- vnet_buffer (p0)->map_t.mtu = d0->mtu ? d0->mtu : ~0;
- vnet_buffer (p1)->map_t.mtu = d1->mtu ? d1->mtu : ~0;
-
- map_port0 = -1;
- map_port1 = -1;
-
- ip4_map_t_classify (p0, d0, ip40, ip4_len0, &map_port0, &error0,
- &next0);
- ip4_map_t_classify (p1, d1, ip41, ip4_len1, &map_port1, &error1,
- &next1);
-
- //Add MAP-T pseudo header in front of the packet
- vlib_buffer_advance (p0, -sizeof (*pheader0));
- vlib_buffer_advance (p1, -sizeof (*pheader1));
- pheader0 = vlib_buffer_get_current (p0);
- pheader1 = vlib_buffer_get_current (p1);
-
- //Save addresses within the packet
- if (mm->is_ce)
- {
- ip4_map_t_embedded_address (d0, &pheader0->daddr,
- &ip40->dst_address);
- ip4_map_t_embedded_address (d1, &pheader1->daddr,
- &ip41->dst_address);
- pheader0->saddr.as_u64[0] =
- map_get_pfx_net (d0, ip40->src_address.as_u32,
- (u16) map_port0);
- pheader0->saddr.as_u64[1] =
- map_get_sfx_net (d0, ip40->src_address.as_u32,
- (u16) map_port0);
- pheader1->saddr.as_u64[0] =
- map_get_pfx_net (d1, ip41->src_address.as_u32,
- (u16) map_port1);
- pheader1->saddr.as_u64[1] =
- map_get_sfx_net (d1, ip41->src_address.as_u32,
- (u16) map_port1);
- }
- else
- {
- ip4_map_t_embedded_address (d0, &pheader0->saddr,
- &ip40->src_address);
- ip4_map_t_embedded_address (d1, &pheader1->saddr,
- &ip41->src_address);
- pheader0->daddr.as_u64[0] =
- map_get_pfx_net (d0, ip40->dst_address.as_u32,
- (u16) map_port0);
- pheader0->daddr.as_u64[1] =
- map_get_sfx_net (d0, ip40->dst_address.as_u32,
- (u16) map_port0);
- pheader1->daddr.as_u64[0] =
- map_get_pfx_net (d1, ip41->dst_address.as_u32,
- (u16) map_port1);
- pheader1->daddr.as_u64[1] =
- map_get_sfx_net (d1, ip41->dst_address.as_u32,
- (u16) map_port1);
- }
-
- if (PREDICT_FALSE
- (ip4_is_first_fragment (ip40) && (map_port0 != -1)
- && (d0->ea_bits_len != 0 || !d0->rules)
- && ip4_map_fragment_cache (ip40, map_port0)))
- {
- error0 = MAP_ERROR_FRAGMENT_MEMORY;
- }
-
- if (PREDICT_FALSE
- (ip4_is_first_fragment (ip41) && (map_port1 != -1)
- && (d1->ea_bits_len != 0 || !d1->rules)
- && ip4_map_fragment_cache (ip41, map_port1)))
- {
- error1 = MAP_ERROR_FRAGMENT_MEMORY;
- }
-
- if (PREDICT_TRUE
- (error0 == MAP_ERROR_NONE && next0 != IP4_MAPT_NEXT_MAPT_ICMP))
- {
- vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
- thread_index,
- vnet_buffer (p0)->
- map_t.map_domain_index, 1,
- clib_net_to_host_u16
- (ip40->length));
- }
-
- if (PREDICT_TRUE
- (error1 == MAP_ERROR_NONE && next1 != IP4_MAPT_NEXT_MAPT_ICMP))
- {
- vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
- thread_index,
- vnet_buffer (p1)->
- map_t.map_domain_index, 1,
- clib_net_to_host_u16
- (ip41->length));
- }
-
- next0 = (error0 != MAP_ERROR_NONE) ? IP4_MAPT_NEXT_DROP : next0;
- next1 = (error1 != MAP_ERROR_NONE) ? IP4_MAPT_NEXT_DROP : next1;
- p0->error = error_node->errors[error0];
- p1->error = error_node->errors[error1];
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
- n_left_to_next, pi0, pi1, next0,
- next1);
- }
-#endif
-