X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fipip%2Fnode.c;h=baaeee863fc899dc427b28dab78e1bdb49062c12;hb=e5b94dded;hp=d55b91a0b93c87180c797448967c99abf6dd3f2a;hpb=067cd6229a47ea3ba8b59a2a04090e80afb5bd2c;p=vpp.git diff --git a/src/vnet/ipip/node.c b/src/vnet/ipip/node.c index d55b91a0b93..baaeee863fc 100644 --- a/src/vnet/ipip/node.c +++ b/src/vnet/ipip/node.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #define foreach_ipip_input_next \ @@ -45,7 +45,7 @@ typedef struct u8 is_ipv6; } ipip_rx_trace_t; -u8 * +static u8 * format_ipip_rx_trace (u8 * s, va_list * args) { CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); @@ -83,9 +83,6 @@ ipip_input (vlib_main_t * vm, vlib_node_runtime_t * node, ip4_header_t *ip40; ip6_header_t *ip60; u32 next0 = IPIP_INPUT_NEXT_DROP; - ip46_address_t src0 = ip46_address_initializer, dst0 = - ip46_address_initializer; - ipip_transport_t transport0; u8 inner_protocol0; bi0 = to_next[0] = from[0]; @@ -96,38 +93,55 @@ ipip_input (vlib_main_t * vm, vlib_node_runtime_t * node, b0 = vlib_get_buffer (vm, bi0); + ipip_tunnel_key_t key0 = { + .fib_index = vnet_buffer (b0)->ip.fib_index, + .mode = IPIP_MODE_P2P, + }; + if (is_ipv6) { ip60 = vlib_buffer_get_current (b0); + /* Check for outer fragmentation */ + if (ip60->protocol == IP_PROTOCOL_IPV6_FRAGMENTATION) + { + next0 = IPIP_INPUT_NEXT_DROP; + b0->error = node->errors[IPIP_ERROR_FRAGMENTED_PACKET]; + goto drop; + } + vlib_buffer_advance (b0, sizeof (*ip60)); - ip_set (&src0, &ip60->src_address, false); - ip_set (&dst0, &ip60->dst_address, false); + ip_set (&key0.dst, &ip60->src_address, false); + ip_set (&key0.src, &ip60->dst_address, false); inner_protocol0 = ip60->protocol; - transport0 = IPIP_TRANSPORT_IP6; + key0.transport = IPIP_TRANSPORT_IP6; } else { ip40 = vlib_buffer_get_current (b0); + /* Check for outer fragmentation */ + if (ip40->flags_and_fragment_offset & + clib_host_to_net_u16 (IP4_HEADER_FLAG_MORE_FRAGMENTS)) + { + next0 = IPIP_INPUT_NEXT_DROP; + b0->error = node->errors[IPIP_ERROR_FRAGMENTED_PACKET]; + goto drop; + } vlib_buffer_advance (b0, sizeof (*ip40)); - ip_set (&src0, &ip40->src_address, true); - ip_set (&dst0, &ip40->dst_address, true); + ip_set (&key0.dst, &ip40->src_address, true); + ip_set (&key0.src, &ip40->dst_address, true); inner_protocol0 = ip40->protocol; - transport0 = IPIP_TRANSPORT_IP4; + key0.transport = IPIP_TRANSPORT_IP4; } /* * Find tunnel. First a lookup for P2P tunnels, then a lookup * for multipoint tunnels */ - ipip_tunnel_key_t key0 = {.transport = transport0, - .fib_index = vnet_buffer (b0)->ip.fib_index, - .src = dst0, - .dst = src0 - }; ipip_tunnel_t *t0 = ipip_tunnel_db_find (&key0); if (!t0) { ip46_address_reset (&key0.dst); + key0.mode = IPIP_MODE_6RD; t0 = ipip_tunnel_db_find (&key0); if (!t0) { @@ -142,9 +156,25 @@ ipip_input (vlib_main_t * vm, vlib_node_runtime_t * node, vnet_buffer (b0)->sw_if_index[VLIB_RX] = tunnel_sw_if_index; if (inner_protocol0 == IP_PROTOCOL_IPV6) - next0 = IPIP_INPUT_NEXT_IP6_INPUT; + { + next0 = IPIP_INPUT_NEXT_IP6_INPUT; + + if (is_ipv6) + tunnel_decap_fixup_6o6 (t0->flags, (ip60 + 1), ip60); + else + tunnel_decap_fixup_6o4 (t0->flags, + (ip6_header_t *) (ip40 + 1), ip40); + } else if (inner_protocol0 == IP_PROTOCOL_IP_IN_IP) - next0 = IPIP_INPUT_NEXT_IP4_INPUT; + { + next0 = IPIP_INPUT_NEXT_IP4_INPUT; + + if (is_ipv6) + tunnel_decap_fixup_4o6 (t0->flags, + (ip4_header_t *) (ip60 + 1), ip60); + else + tunnel_decap_fixup_4o4 (t0->flags, ip40 + 1, ip40); + } if (!is_ipv6 && t0->mode == IPIP_MODE_6RD && t0->sixrd.security_check) @@ -200,16 +230,14 @@ ipip_input (vlib_main_t * vm, vlib_node_runtime_t * node, return from_frame->n_vectors; } -static uword -ipip4_input (vlib_main_t * vm, vlib_node_runtime_t * node, - vlib_frame_t * from_frame) +VLIB_NODE_FN (ipip4_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node, + vlib_frame_t * from_frame) { return ipip_input (vm, node, from_frame, /* is_ip6 */ false); } -static uword -ipip6_input (vlib_main_t * vm, vlib_node_runtime_t * node, - vlib_frame_t * from_frame) +VLIB_NODE_FN (ipip6_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node, + vlib_frame_t * from_frame) { return ipip_input (vm, node, from_frame, /* is_ip6 */ true); } @@ -222,7 +250,6 @@ static char *ipip_error_strings[] = { /* *INDENT-OFF* */ VLIB_REGISTER_NODE(ipip4_input_node) = { - .function = ipip4_input, .name = "ipip4-input", /* Takes a vector of packets. */ .vector_size = sizeof(u32), @@ -239,7 +266,6 @@ VLIB_REGISTER_NODE(ipip4_input_node) = { }; VLIB_REGISTER_NODE(ipip6_input_node) = { - .function = ipip6_input, .name = "ipip6-input", /* Takes a vector of packets. */ .vector_size = sizeof(u32), @@ -255,8 +281,6 @@ VLIB_REGISTER_NODE(ipip6_input_node) = { .format_trace = format_ipip_rx_trace, }; -VLIB_NODE_FUNCTION_MULTIARCH(ipip4_input_node, ipip4_input) -VLIB_NODE_FUNCTION_MULTIARCH(ipip6_input_node, ipip6_input) /* *INDENT-ON* */ /*