aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/map/ip6_map_t.c
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2018-12-18 10:11:30 +0100
committerNeale Ranns <nranns@cisco.com>2018-12-18 11:54:08 +0000
commit02782d6ebd13ce02f2d3facebb54fec3c2137c88 (patch)
tree6960723f611aaaa4b04e03baf3050f6dc22f2400 /src/plugins/map/ip6_map_t.c
parente78ac9debbe364f1bd6c59eb368d1f6bd38dfa32 (diff)
MAP: Remove dual loop in MAP-T in preparation for refactor.
Change-Id: I3c77cadaa7b677073af00407f368bd48d703fdac Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/plugins/map/ip6_map_t.c')
-rw-r--r--src/plugins/map/ip6_map_t.c389
1 files changed, 0 insertions, 389 deletions
diff --git a/src/plugins/map/ip6_map_t.c b/src/plugins/map/ip6_map_t.c
index 577dbe57001..069d392de09 100644
--- a/src/plugins/map/ip6_map_t.c
+++ b/src/plugins/map/ip6_map_t.c
@@ -18,8 +18,6 @@
#include <vnet/ip/ip6_to_ip4.h>
#include <vnet/ip/ip4_to_ip6.h>
-#define IP6_MAP_T_DUAL_LOOP
-
typedef enum
{
IP6_MAPT_NEXT_MAPT_TCP_UDP,
@@ -268,65 +266,6 @@ ip6_map_t_fragmented (vlib_main_t * vm,
{
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-#ifdef IP6_MAP_T_DUAL_LOOP
- while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- u32 pi0, pi1;
- vlib_buffer_t *p0, *p1;
- u32 next0, next1;
-
- 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;
-
- next0 = IP6_MAPT_TCP_UDP_NEXT_IP4_LOOKUP;
- next1 = IP6_MAPT_TCP_UDP_NEXT_IP4_LOOKUP;
- p0 = vlib_get_buffer (vm, pi0);
- p1 = vlib_get_buffer (vm, pi1);
-
- if (ip6_to_ip4_fragmented (p0, ip6_to_ip4_set_cb, p0))
- {
- p0->error = error_node->errors[MAP_ERROR_FRAGMENT_DROPPED];
- next0 = IP6_MAPT_FRAGMENTED_NEXT_DROP;
- }
- else
- {
- if (vnet_buffer (p0)->map_t.mtu < p0->current_length)
- {
- //Send to fragmentation node if necessary
- vnet_buffer (p0)->ip_frag.mtu = vnet_buffer (p0)->map_t.mtu;
- vnet_buffer (p0)->ip_frag.next_index =
- IP4_FRAG_NEXT_IP4_LOOKUP;
- next0 = IP6_MAPT_FRAGMENTED_NEXT_IP4_FRAG;
- }
- }
-
- if (ip6_to_ip4_fragmented (p1, ip6_to_ip4_set_cb, p1))
- {
- p1->error = error_node->errors[MAP_ERROR_FRAGMENT_DROPPED];
- next1 = IP6_MAPT_FRAGMENTED_NEXT_DROP;
- }
- else
- {
- if (vnet_buffer (p1)->map_t.mtu < p1->current_length)
- {
- //Send to fragmentation node if necessary
- vnet_buffer (p1)->ip_frag.mtu = vnet_buffer (p1)->map_t.mtu;
- vnet_buffer (p1)->ip_frag.next_index =
- IP4_FRAG_NEXT_IP4_LOOKUP;
- next1 = IP6_MAPT_FRAGMENTED_NEXT_IP4_FRAG;
- }
- }
-
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
- to_next, n_left_to_next, pi0, pi1,
- next0, next1);
- }
-#endif
-
while (n_left_from > 0 && n_left_to_next > 0)
{
u32 pi0;
@@ -383,65 +322,6 @@ ip6_map_t_tcp_udp (vlib_main_t * vm,
{
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-#ifdef IP6_MAP_T_DUAL_LOOP
- while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- u32 pi0, pi1;
- vlib_buffer_t *p0, *p1;
- ip6_mapt_tcp_udp_next_t next0, next1;
-
- 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;
- next0 = IP6_MAPT_TCP_UDP_NEXT_IP4_LOOKUP;
- next1 = IP6_MAPT_TCP_UDP_NEXT_IP4_LOOKUP;
-
- p0 = vlib_get_buffer (vm, pi0);
- p1 = vlib_get_buffer (vm, pi1);
-
- if (ip6_to_ip4_tcp_udp (p0, ip6_to_ip4_set_cb, p0, 1))
- {
- p0->error = error_node->errors[MAP_ERROR_UNKNOWN];
- next0 = IP6_MAPT_TCP_UDP_NEXT_DROP;
- }
- else
- {
- if (vnet_buffer (p0)->map_t.mtu < p0->current_length)
- {
- //Send to fragmentation node if necessary
- vnet_buffer (p0)->ip_frag.mtu = vnet_buffer (p0)->map_t.mtu;
- vnet_buffer (p0)->ip_frag.next_index =
- IP4_FRAG_NEXT_IP4_LOOKUP;
- next0 = IP6_MAPT_TCP_UDP_NEXT_IP4_FRAG;
- }
- }
-
- if (ip6_to_ip4_tcp_udp (p1, ip6_to_ip4_set_cb, p1, 1))
- {
- p1->error = error_node->errors[MAP_ERROR_UNKNOWN];
- next1 = IP6_MAPT_TCP_UDP_NEXT_DROP;
- }
- else
- {
- if (vnet_buffer (p1)->map_t.mtu < p1->current_length)
- {
- //Send to fragmentation node if necessary
- vnet_buffer (p1)->ip_frag.mtu = vnet_buffer (p1)->map_t.mtu;
- vnet_buffer (p1)->ip_frag.next_index =
- IP4_FRAG_NEXT_IP4_LOOKUP;
- next1 = IP6_MAPT_TCP_UDP_NEXT_IP4_FRAG;
- }
- }
-
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
- n_left_to_next, pi0, pi1, next0,
- next1);
- }
-#endif
-
while (n_left_from > 0 && n_left_to_next > 0)
{
u32 pi0;
@@ -483,84 +363,6 @@ ip6_map_t_tcp_udp (vlib_main_t * vm,
return frame->n_vectors;
}
-static_always_inline void
-ip6_map_t_classify (vlib_buffer_t * p0, ip6_header_t * ip60,
- map_domain_t * d0, i32 * src_port0,
- u8 * error0, ip6_mapt_next_t * next0,
- u32 l4_len0, ip6_frag_hdr_t * frag0)
-{
- if (PREDICT_FALSE (vnet_buffer (p0)->map_t.v6.frag_offset &&
- ip6_frag_hdr_offset (frag0)))
- {
- *next0 = IP6_MAPT_NEXT_MAPT_FRAGMENTED;
- if (d0->ea_bits_len == 0 && d0->rules)
- {
- *src_port0 = 0;
- }
- else
- {
- *src_port0 = ip6_map_fragment_get (ip60, frag0, d0);
- *error0 = (*src_port0 != -1) ? *error0 : MAP_ERROR_FRAGMENT_DROPPED;
- }
- }
- else
- if (PREDICT_TRUE
- (vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_TCP))
- {
- *error0 =
- l4_len0 < sizeof (tcp_header_t) ? MAP_ERROR_MALFORMED : *error0;
- vnet_buffer (p0)->map_t.checksum_offset =
- vnet_buffer (p0)->map_t.v6.l4_offset + 16;
- *next0 = IP6_MAPT_NEXT_MAPT_TCP_UDP;
- *src_port0 =
- (i32) *
- ((u16 *) u8_ptr_add (ip60, vnet_buffer (p0)->map_t.v6.l4_offset));
- }
- else
- if (PREDICT_TRUE
- (vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_UDP))
- {
- *error0 =
- l4_len0 < sizeof (udp_header_t) ? MAP_ERROR_MALFORMED : *error0;
- vnet_buffer (p0)->map_t.checksum_offset =
- vnet_buffer (p0)->map_t.v6.l4_offset + 6;
- *next0 = IP6_MAPT_NEXT_MAPT_TCP_UDP;
- *src_port0 =
- (i32) *
- ((u16 *) u8_ptr_add (ip60, vnet_buffer (p0)->map_t.v6.l4_offset));
- }
- else if (vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_ICMP6)
- {
- *error0 =
- l4_len0 < sizeof (icmp46_header_t) ? MAP_ERROR_MALFORMED : *error0;
- *next0 = IP6_MAPT_NEXT_MAPT_ICMP;
- if (d0->ea_bits_len == 0 && d0->rules)
- {
- *src_port0 = 0;
- }
- else
- if (((icmp46_header_t *)
- u8_ptr_add (ip60,
- vnet_buffer (p0)->map_t.v6.l4_offset))->code ==
- ICMP6_echo_reply
- || ((icmp46_header_t *)
- u8_ptr_add (ip60,
- vnet_buffer (p0)->map_t.v6.l4_offset))->code ==
- ICMP6_echo_request)
- {
- *src_port0 =
- (i32) *
- ((u16 *)
- u8_ptr_add (ip60, vnet_buffer (p0)->map_t.v6.l4_offset + 6));
- }
- }
- else
- {
- //TODO: In case of 1:1 mapping, it might be possible to do something with those packets.
- *error0 = MAP_ERROR_BAD_PROTOCOL;
- }
-}
-
static uword
ip6_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
{
@@ -577,197 +379,6 @@ ip6_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
{
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-#ifdef IP6_MAP_T_DUAL_LOOP
- while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- u32 pi0, pi1;
- vlib_buffer_t *p0, *p1;
- ip6_header_t *ip60, *ip61;
- u8 error0, error1;
- ip6_mapt_next_t next0, next1;
- u32 l4_len0, l4_len1;
- i32 src_port0, src_port1;
- map_domain_t *d0, *d1;
- ip6_frag_hdr_t *frag0, *frag1;
- u32 saddr0, saddr1;
- next0 = next1 = 0; //Because compiler whines
-
- 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);
- ip60 = vlib_buffer_get_current (p0);
- ip61 = vlib_buffer_get_current (p1);
-
- saddr0 = 0; /* TODO */
- saddr1 = 0; /* TODO */
- /* NOTE: ip6_map_get_domain currently doesn't utilize second argument */
-
- d0 = ip6_map_get_domain (vnet_buffer (p0)->ip.adj_index[VLIB_TX],
- (ip4_address_t *) & saddr0,
- &vnet_buffer (p0)->map_t.map_domain_index,
- &error0);
- d1 =
- ip6_map_get_domain (vnet_buffer (p1)->ip.adj_index[VLIB_TX],
- (ip4_address_t *) & saddr1,
- &vnet_buffer (p1)->map_t.map_domain_index,
- &error1);
-
- saddr0 = map_get_ip4 (&ip60->src_address, d0->flags);
- saddr1 = map_get_ip4 (&ip61->src_address, d1->flags);
-
- vnet_buffer (p0)->map_t.v6.saddr = saddr0;
- vnet_buffer (p1)->map_t.v6.saddr = saddr1;
- vnet_buffer (p0)->map_t.v6.daddr =
- ip6_map_t_embedded_address (d0, &ip60->dst_address);
- vnet_buffer (p1)->map_t.v6.daddr =
- ip6_map_t_embedded_address (d1, &ip61->dst_address);
- vnet_buffer (p0)->map_t.mtu = d0->mtu ? d0->mtu : ~0;
- vnet_buffer (p1)->map_t.mtu = d1->mtu ? d1->mtu : ~0;
-
- if (PREDICT_FALSE (ip6_parse (ip60, p0->current_length,
- &(vnet_buffer (p0)->map_t.
- v6.l4_protocol),
- &(vnet_buffer (p0)->map_t.
- v6.l4_offset),
- &(vnet_buffer (p0)->map_t.
- v6.frag_offset))))
- {
- error0 = MAP_ERROR_MALFORMED;
- next0 = IP6_MAPT_NEXT_DROP;
- }
-
- if (PREDICT_FALSE (ip6_parse (ip61, p1->current_length,
- &(vnet_buffer (p1)->map_t.
- v6.l4_protocol),
- &(vnet_buffer (p1)->map_t.
- v6.l4_offset),
- &(vnet_buffer (p1)->map_t.
- v6.frag_offset))))
- {
- error1 = MAP_ERROR_MALFORMED;
- next1 = IP6_MAPT_NEXT_DROP;
- }
-
- src_port0 = src_port1 = -1;
- l4_len0 = (u32) clib_net_to_host_u16 (ip60->payload_length) +
- sizeof (*ip60) - vnet_buffer (p0)->map_t.v6.l4_offset;
- l4_len1 = (u32) clib_net_to_host_u16 (ip61->payload_length) +
- sizeof (*ip60) - vnet_buffer (p1)->map_t.v6.l4_offset;
- frag0 =
- (ip6_frag_hdr_t *) u8_ptr_add (ip60,
- vnet_buffer (p0)->map_t.
- v6.frag_offset);
- frag1 =
- (ip6_frag_hdr_t *) u8_ptr_add (ip61,
- vnet_buffer (p1)->map_t.
- v6.frag_offset);
-
- ip6_map_t_classify (p0, ip60, d0, &src_port0, &error0, &next0,
- l4_len0, frag0);
- ip6_map_t_classify (p1, ip61, d1, &src_port1, &error1, &next1,
- l4_len1, frag1);
-
- if (PREDICT_FALSE
- ((src_port0 != -1)
- && (ip60->src_address.as_u64[0] !=
- map_get_pfx_net (d0, vnet_buffer (p0)->map_t.v6.saddr,
- src_port0)
- || ip60->src_address.as_u64[1] != map_get_sfx_net (d0,
- vnet_buffer
- (p0)->map_t.v6.saddr,
- src_port0))))
- {
- error0 = MAP_ERROR_SEC_CHECK;
- }
-
- if (PREDICT_FALSE
- ((src_port1 != -1)
- && (ip61->src_address.as_u64[0] !=
- map_get_pfx_net (d1, vnet_buffer (p1)->map_t.v6.saddr,
- src_port1)
- || ip61->src_address.as_u64[1] != map_get_sfx_net (d1,
- vnet_buffer
- (p1)->map_t.v6.saddr,
- src_port1))))
- {
- error1 = MAP_ERROR_SEC_CHECK;
- }
-
- if (PREDICT_FALSE (vnet_buffer (p0)->map_t.v6.frag_offset &&
- !ip6_frag_hdr_offset ((ip6_frag_hdr_t *)
- u8_ptr_add (ip60,
- vnet_buffer
- (p0)->map_t.
- v6.frag_offset)))
- && (src_port0 != -1) && (d0->ea_bits_len != 0 || !d0->rules)
- && (error0 == MAP_ERROR_NONE))
- {
- ip6_map_fragment_cache (ip60,
- (ip6_frag_hdr_t *) u8_ptr_add (ip60,
- vnet_buffer
- (p0)->map_t.
- v6.frag_offset),
- d0, src_port0);
- }
-
- if (PREDICT_FALSE (vnet_buffer (p1)->map_t.v6.frag_offset &&
- !ip6_frag_hdr_offset ((ip6_frag_hdr_t *)
- u8_ptr_add (ip61,
- vnet_buffer
- (p1)->map_t.
- v6.frag_offset)))
- && (src_port1 != -1) && (d1->ea_bits_len != 0 || !d1->rules)
- && (error1 == MAP_ERROR_NONE))
- {
- ip6_map_fragment_cache (ip61,
- (ip6_frag_hdr_t *) u8_ptr_add (ip61,
- vnet_buffer
- (p1)->map_t.
- v6.frag_offset),
- d1, src_port1);
- }
-
- if (PREDICT_TRUE
- (error0 == MAP_ERROR_NONE && next0 != IP6_MAPT_NEXT_MAPT_ICMP))
- {
- vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX,
- thread_index,
- vnet_buffer (p0)->
- map_t.map_domain_index, 1,
- clib_net_to_host_u16
- (ip60->payload_length));
- }
-
- if (PREDICT_TRUE
- (error1 == MAP_ERROR_NONE && next1 != IP6_MAPT_NEXT_MAPT_ICMP))
- {
- vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX,
- thread_index,
- vnet_buffer (p1)->
- map_t.map_domain_index, 1,
- clib_net_to_host_u16
- (ip61->payload_length));
- }
-
- next0 = (error0 != MAP_ERROR_NONE) ? IP6_MAPT_NEXT_DROP : next0;
- next1 = (error1 != MAP_ERROR_NONE) ? IP6_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
-
while (n_left_from > 0 && n_left_to_next > 0)
{
u32 pi0;