Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /*--------------------------------------------------------------------------- |
| 2 | * Copyright (c) 2009-2014 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | *--------------------------------------------------------------------------- |
| 15 | */ |
| 16 | /* |
| 17 | * IPv4 Fragmentation Node |
| 18 | * |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include "ip_frag.h" |
| 23 | |
| 24 | #include <vnet/ip/ip.h> |
| 25 | |
Rajesh Goel | d6f1c9c | 2019-10-06 13:17:36 +0530 | [diff] [blame] | 26 | /* |
| 27 | * Copy the mpls header if present. |
| 28 | * The current is pointing to the ip header. |
| 29 | * Adjust the buffer and point to the mpls headers on these fragments |
| 30 | * before sending the packet back to mpls-output node. |
| 31 | */ |
| 32 | static inline void |
| 33 | copy_mpls_hdr (vlib_buffer_t * to_b, vlib_buffer_t * from_b) |
| 34 | { |
| 35 | if ((vnet_buffer (from_b)->ip_frag.flags) & IP_FRAG_FLAG_MPLS_HEADER) |
| 36 | { |
| 37 | u8 mpls_hdr_length = vnet_buffer (from_b)->mpls.mpls_hdr_length; |
| 38 | u8 *org_from_mpls_packet = |
| 39 | from_b->data + (from_b->current_data - mpls_hdr_length); |
| 40 | clib_memcpy_fast ((to_b->data - mpls_hdr_length), org_from_mpls_packet, |
| 41 | mpls_hdr_length); |
| 42 | vlib_buffer_advance (to_b, -vnet_buffer (to_b)->mpls.mpls_hdr_length); |
| 43 | } |
| 44 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 45 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 46 | typedef struct |
| 47 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 48 | u8 ipv6; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 49 | u16 mtu; |
| 50 | u8 next; |
| 51 | u16 n_fragments; |
| 52 | } ip_frag_trace_t; |
| 53 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 54 | static u8 * |
| 55 | format_ip_frag_trace (u8 * s, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 56 | { |
| 57 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 58 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 59 | ip_frag_trace_t *t = va_arg (*args, ip_frag_trace_t *); |
Rajesh Goel | d6f1c9c | 2019-10-06 13:17:36 +0530 | [diff] [blame] | 60 | s = format (s, "IPv%s mtu: %u fragments: %u next: %d", |
| 61 | t->ipv6 ? "6" : "4", t->mtu, t->n_fragments, t->next); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 62 | return s; |
| 63 | } |
| 64 | |
| 65 | static u32 running_fragment_id; |
| 66 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 67 | static void |
| 68 | frag_set_sw_if_index (vlib_buffer_t * to, vlib_buffer_t * from) |
| 69 | { |
| 70 | vnet_buffer (to)->sw_if_index[VLIB_RX] = |
| 71 | vnet_buffer (from)->sw_if_index[VLIB_RX]; |
| 72 | vnet_buffer (to)->sw_if_index[VLIB_TX] = |
| 73 | vnet_buffer (from)->sw_if_index[VLIB_TX]; |
| 74 | |
| 75 | /* Copy adj_index in case DPO based node is sending for the |
| 76 | * fragmentation, the packet would be sent back to the proper |
| 77 | * DPO next node and Index |
| 78 | */ |
| 79 | vnet_buffer (to)->ip.adj_index[VLIB_RX] = |
| 80 | vnet_buffer (from)->ip.adj_index[VLIB_RX]; |
| 81 | vnet_buffer (to)->ip.adj_index[VLIB_TX] = |
| 82 | vnet_buffer (from)->ip.adj_index[VLIB_TX]; |
Vijayabhaskar Katamreddy | 64fb995 | 2018-11-28 12:05:23 -0800 | [diff] [blame] | 83 | |
| 84 | /* Copy QoS Bits */ |
| 85 | if (PREDICT_TRUE (from->flags & VNET_BUFFER_F_QOS_DATA_VALID)) |
| 86 | { |
| 87 | vnet_buffer2 (to)->qos = vnet_buffer2 (from)->qos; |
| 88 | to->flags |= VNET_BUFFER_F_QOS_DATA_VALID; |
| 89 | } |
Rajesh Goel | d6f1c9c | 2019-10-06 13:17:36 +0530 | [diff] [blame] | 90 | |
| 91 | /* Copy mpls opaque data */ |
| 92 | if ((vnet_buffer (from)->ip_frag.flags) & IP_FRAG_FLAG_MPLS_HEADER) |
| 93 | { |
| 94 | vnet_buffer (to)->mpls.pyld_proto = vnet_buffer (from)->mpls.pyld_proto; |
| 95 | vnet_buffer (to)->mpls.mpls_hdr_length = |
| 96 | vnet_buffer (from)->mpls.mpls_hdr_length; |
| 97 | } |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | static vlib_buffer_t * |
| 101 | frag_buffer_alloc (vlib_buffer_t * org_b, u32 * bi) |
| 102 | { |
| 103 | vlib_main_t *vm = vlib_get_main (); |
| 104 | if (vlib_buffer_alloc (vm, bi, 1) != 1) |
| 105 | return 0; |
| 106 | |
| 107 | vlib_buffer_t *b = vlib_get_buffer (vm, *bi); |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 108 | VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b); |
| 109 | vlib_buffer_copy_trace_flag (vm, org_b, *bi); |
| 110 | |
| 111 | return b; |
| 112 | } |
| 113 | |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 114 | /* |
| 115 | * Limitation: Does follow buffer chains in the packet to fragment, |
| 116 | * but does not generate buffer chains. I.e. a fragment is always |
| 117 | * contained with in a single buffer and limited to the max buffer |
| 118 | * size. |
| 119 | */ |
Vijayabhaskar Katamreddy | e95d1a1 | 2018-06-28 11:08:29 -0700 | [diff] [blame] | 120 | void |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 121 | ip4_frag_do_fragment (vlib_main_t * vm, u32 from_bi, u32 ** buffer, |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 122 | ip_frag_error_t * error) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 123 | { |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 124 | vlib_buffer_t *from_b; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 125 | ip4_header_t *ip4; |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 126 | u16 mtu, len, max, rem, ip_frag_id, ip_frag_offset; |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 127 | u8 *org_from_packet, more; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 128 | |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 129 | from_b = vlib_get_buffer (vm, from_bi); |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 130 | mtu = vnet_buffer (from_b)->ip_frag.mtu; |
| 131 | org_from_packet = vlib_buffer_get_current (from_b); |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 132 | ip4 = (ip4_header_t *) vlib_buffer_get_current (from_b); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 133 | |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 134 | rem = clib_net_to_host_u16 (ip4->length) - sizeof (ip4_header_t); |
Juraj Sloboda | 68b7cb8 | 2018-10-16 12:18:21 +0200 | [diff] [blame] | 135 | max = |
Damjan Marion | 8934a04 | 2019-02-09 23:29:26 +0100 | [diff] [blame] | 136 | (clib_min (mtu, vlib_buffer_get_default_data_size (vm)) - |
Damjan Marion | 5de3fec | 2019-02-06 14:22:32 +0100 | [diff] [blame] | 137 | sizeof (ip4_header_t)) & ~0x7; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 138 | |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 139 | if (rem > |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 140 | (vlib_buffer_length_in_chain (vm, from_b) - sizeof (ip4_header_t))) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 141 | { |
| 142 | *error = IP_FRAG_ERROR_MALFORMED; |
| 143 | return; |
| 144 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 145 | |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 146 | if (mtu < sizeof (ip4_header_t)) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 147 | { |
| 148 | *error = IP_FRAG_ERROR_CANT_FRAGMENT_HEADER; |
| 149 | return; |
| 150 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 151 | |
| 152 | if (ip4->flags_and_fragment_offset & |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 153 | clib_host_to_net_u16 (IP4_HEADER_FLAG_DONT_FRAGMENT)) |
| 154 | { |
| 155 | *error = IP_FRAG_ERROR_DONT_FRAGMENT_SET; |
| 156 | return; |
| 157 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 158 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 159 | if (ip4_is_fragment (ip4)) |
| 160 | { |
| 161 | ip_frag_id = ip4->fragment_id; |
| 162 | ip_frag_offset = ip4_get_fragment_offset (ip4); |
| 163 | more = |
Vijayabhaskar Katamreddy | ce07412 | 2017-11-15 13:50:26 -0800 | [diff] [blame] | 164 | !(!(ip4->flags_and_fragment_offset & |
| 165 | clib_host_to_net_u16 (IP4_HEADER_FLAG_MORE_FRAGMENTS))); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 166 | } |
| 167 | else |
| 168 | { |
| 169 | ip_frag_id = (++running_fragment_id); |
| 170 | ip_frag_offset = 0; |
| 171 | more = 0; |
| 172 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 173 | |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 174 | u8 *from_data = (void *) (ip4 + 1); |
| 175 | vlib_buffer_t *org_from_b = from_b; |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 176 | u16 fo = 0; |
| 177 | u16 left_in_from_buffer = from_b->current_length - sizeof (ip4_header_t); |
| 178 | u16 ptr = 0; |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 179 | |
| 180 | /* Do the actual fragmentation */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 181 | while (rem) |
| 182 | { |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 183 | u32 to_bi; |
| 184 | vlib_buffer_t *to_b; |
| 185 | ip4_header_t *to_ip4; |
| 186 | u8 *to_data; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 187 | |
Juraj Sloboda | 68b7cb8 | 2018-10-16 12:18:21 +0200 | [diff] [blame] | 188 | len = (rem > max ? max : rem); |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 189 | if (len != rem) /* Last fragment does not need to divisible by 8 */ |
| 190 | len &= ~0x7; |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 191 | if ((to_b = frag_buffer_alloc (org_from_b, &to_bi)) == 0) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 192 | { |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 193 | *error = IP_FRAG_ERROR_MEMORY; |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 194 | return; |
| 195 | } |
| 196 | vec_add1 (*buffer, to_bi); |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 197 | frag_set_sw_if_index (to_b, org_from_b); |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 198 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 199 | /* Copy ip4 header */ |
Dave Barach | 178cf49 | 2018-11-13 16:34:13 -0500 | [diff] [blame] | 200 | clib_memcpy_fast (to_b->data, org_from_packet, sizeof (ip4_header_t)); |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 201 | to_ip4 = vlib_buffer_get_current (to_b); |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 202 | to_data = (void *) (to_ip4 + 1); |
Neale Ranns | 0b6a857 | 2019-10-30 17:34:14 +0000 | [diff] [blame] | 203 | vnet_buffer (to_b)->l3_hdr_offset = to_b->current_data; |
| 204 | to_b->flags |= VNET_BUFFER_F_L3_HDR_OFFSET_VALID; |
| 205 | |
| 206 | if (from_b->flags & VNET_BUFFER_F_L4_HDR_OFFSET_VALID) |
| 207 | { |
| 208 | vnet_buffer (to_b)->l4_hdr_offset = |
| 209 | (vnet_buffer (to_b)->l3_hdr_offset + |
| 210 | (vnet_buffer (from_b)->l4_hdr_offset - |
| 211 | vnet_buffer (from_b)->l3_hdr_offset)); |
| 212 | to_b->flags |= VNET_BUFFER_F_L4_HDR_OFFSET_VALID; |
| 213 | } |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 214 | |
Ole Troan | 7eb9d96 | 2018-08-10 14:39:48 +0200 | [diff] [blame] | 215 | /* Spin through from buffers filling up the to buffer */ |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 216 | u16 left_in_to_buffer = len, to_ptr = 0; |
Ole Troan | 7eb9d96 | 2018-08-10 14:39:48 +0200 | [diff] [blame] | 217 | while (1) |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 218 | { |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 219 | u16 bytes_to_copy; |
| 220 | |
Ole Troan | 7eb9d96 | 2018-08-10 14:39:48 +0200 | [diff] [blame] | 221 | /* Figure out how many bytes we can safely copy */ |
| 222 | bytes_to_copy = left_in_to_buffer <= left_in_from_buffer ? |
| 223 | left_in_to_buffer : left_in_from_buffer; |
Dave Barach | 178cf49 | 2018-11-13 16:34:13 -0500 | [diff] [blame] | 224 | clib_memcpy_fast (to_data + to_ptr, from_data + ptr, bytes_to_copy); |
Ole Troan | 7eb9d96 | 2018-08-10 14:39:48 +0200 | [diff] [blame] | 225 | left_in_to_buffer -= bytes_to_copy; |
| 226 | ptr += bytes_to_copy; |
| 227 | left_in_from_buffer -= bytes_to_copy; |
| 228 | if (left_in_to_buffer == 0) |
| 229 | break; |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 230 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 231 | ASSERT (left_in_from_buffer <= 0); |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 232 | /* Move buffer */ |
| 233 | if (!(from_b->flags & VLIB_BUFFER_NEXT_PRESENT)) |
| 234 | { |
| 235 | *error = IP_FRAG_ERROR_MALFORMED; |
| 236 | return; |
| 237 | } |
| 238 | from_b = vlib_get_buffer (vm, from_b->next_buffer); |
| 239 | from_data = (u8 *) vlib_buffer_get_current (from_b); |
Ole Troan | 7eb9d96 | 2018-08-10 14:39:48 +0200 | [diff] [blame] | 240 | ptr = 0; |
| 241 | left_in_from_buffer = from_b->current_length; |
| 242 | to_ptr += bytes_to_copy; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 243 | } |
Ole Troan | 7eb9d96 | 2018-08-10 14:39:48 +0200 | [diff] [blame] | 244 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 245 | to_b->current_length = len + sizeof (ip4_header_t); |
Neale Ranns | 0b6a857 | 2019-10-30 17:34:14 +0000 | [diff] [blame] | 246 | to_b->flags |= VNET_BUFFER_F_IS_IP4; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 247 | |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 248 | to_ip4->fragment_id = ip_frag_id; |
| 249 | to_ip4->flags_and_fragment_offset = |
| 250 | clib_host_to_net_u16 ((fo >> 3) + ip_frag_offset); |
| 251 | to_ip4->flags_and_fragment_offset |= |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 252 | clib_host_to_net_u16 (((len != rem) || more) << 13); |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 253 | to_ip4->length = clib_host_to_net_u16 (len + sizeof (ip4_header_t)); |
| 254 | to_ip4->checksum = ip4_header_checksum (to_ip4); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 255 | |
Neale Ranns | 0b6a857 | 2019-10-30 17:34:14 +0000 | [diff] [blame] | 256 | /* we've just done the IP checksum .. */ |
| 257 | to_b->flags &= ~VNET_BUFFER_F_OFFLOAD_IP_CKSUM; |
| 258 | |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 259 | if (vnet_buffer (org_from_b)->ip_frag.flags & IP_FRAG_FLAG_IP4_HEADER) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 260 | { |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 261 | /* Encapsulating ipv4 header */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 262 | ip4_header_t *encap_header4 = |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 263 | (ip4_header_t *) vlib_buffer_get_current (to_b); |
| 264 | encap_header4->length = clib_host_to_net_u16 (to_b->current_length); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 265 | encap_header4->checksum = ip4_header_checksum (encap_header4); |
| 266 | } |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 267 | else if (vnet_buffer (org_from_b)-> |
| 268 | ip_frag.flags & IP_FRAG_FLAG_IP6_HEADER) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 269 | { |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 270 | /* Encapsulating ipv6 header */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 271 | ip6_header_t *encap_header6 = |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 272 | (ip6_header_t *) vlib_buffer_get_current (to_b); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 273 | encap_header6->payload_length = |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 274 | clib_host_to_net_u16 (to_b->current_length - |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 275 | sizeof (*encap_header6)); |
| 276 | } |
Rajesh Goel | d6f1c9c | 2019-10-06 13:17:36 +0530 | [diff] [blame] | 277 | |
| 278 | /* Copy mpls header if present */ |
| 279 | copy_mpls_hdr (to_b, org_from_b); |
| 280 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 281 | rem -= len; |
Ole Troan | 4146c65 | 2018-08-08 22:23:19 +0200 | [diff] [blame] | 282 | fo += len; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 283 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 284 | } |
| 285 | |
Ole Troan | 9fb8755 | 2016-01-13 22:30:43 +0100 | [diff] [blame] | 286 | void |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 287 | ip_frag_set_vnet_buffer (vlib_buffer_t * b, u16 mtu, u8 next_index, u8 flags) |
Ole Troan | 9fb8755 | 2016-01-13 22:30:43 +0100 | [diff] [blame] | 288 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 289 | vnet_buffer (b)->ip_frag.mtu = mtu; |
| 290 | vnet_buffer (b)->ip_frag.next_index = next_index; |
| 291 | vnet_buffer (b)->ip_frag.flags = flags; |
Ole Troan | 9fb8755 | 2016-01-13 22:30:43 +0100 | [diff] [blame] | 292 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 293 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 294 | |
| 295 | static inline uword |
| 296 | frag_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 297 | vlib_frame_t * frame, u32 node_index, bool is_ip6) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 298 | { |
| 299 | u32 n_left_from, *from, next_index, *to_next, n_left_to_next; |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 300 | vlib_node_runtime_t *error_node = vlib_node_get_runtime (vm, node_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 301 | from = vlib_frame_vector_args (frame); |
| 302 | n_left_from = frame->n_vectors; |
| 303 | next_index = node->cached_next_index; |
| 304 | u32 frag_sent = 0, small_packets = 0; |
| 305 | u32 *buffer = 0; |
| 306 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 307 | while (n_left_from > 0) |
| 308 | { |
| 309 | vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 310 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 311 | while (n_left_from > 0 && n_left_to_next > 0) |
| 312 | { |
| 313 | u32 pi0, *frag_from, frag_left; |
| 314 | vlib_buffer_t *p0; |
| 315 | ip_frag_error_t error0; |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 316 | int next0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 317 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 318 | /* |
| 319 | * Note: The packet is not enqueued now. It is instead put |
| 320 | * in a vector where other fragments will be put as well. |
| 321 | */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 322 | pi0 = from[0]; |
| 323 | from += 1; |
| 324 | n_left_from -= 1; |
| 325 | error0 = IP_FRAG_ERROR_NONE; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 326 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 327 | p0 = vlib_get_buffer (vm, pi0); |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 328 | if (is_ip6) |
| 329 | ip6_frag_do_fragment (vm, pi0, &buffer, &error0); |
| 330 | else |
| 331 | ip4_frag_do_fragment (vm, pi0, &buffer, &error0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 332 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 333 | if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED)) |
| 334 | { |
| 335 | ip_frag_trace_t *tr = |
| 336 | vlib_add_trace (vm, node, p0, sizeof (*tr)); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 337 | tr->mtu = vnet_buffer (p0)->ip_frag.mtu; |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 338 | tr->ipv6 = is_ip6 ? 1 : 0; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 339 | tr->n_fragments = vec_len (buffer); |
| 340 | tr->next = vnet_buffer (p0)->ip_frag.next_index; |
| 341 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 342 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 343 | if (!is_ip6 && error0 == IP_FRAG_ERROR_DONT_FRAGMENT_SET) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 344 | { |
| 345 | icmp4_error_set_vnet_buffer (p0, ICMP4_destination_unreachable, |
| 346 | ICMP4_destination_unreachable_fragmentation_needed_and_dont_fragment_set, |
| 347 | vnet_buffer (p0)->ip_frag.mtu); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 348 | next0 = IP4_FRAG_NEXT_ICMP_ERROR; |
| 349 | } |
| 350 | else |
Vijayabhaskar Katamreddy | ce07412 | 2017-11-15 13:50:26 -0800 | [diff] [blame] | 351 | { |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 352 | if (is_ip6) |
| 353 | next0 = |
| 354 | (error0 == |
| 355 | IP_FRAG_ERROR_NONE) ? vnet_buffer (p0)-> |
| 356 | ip_frag.next_index : IP6_FRAG_NEXT_DROP; |
| 357 | else |
| 358 | next0 = |
| 359 | (error0 == |
| 360 | IP_FRAG_ERROR_NONE) ? vnet_buffer (p0)-> |
| 361 | ip_frag.next_index : IP4_FRAG_NEXT_DROP; |
Vijayabhaskar Katamreddy | ce07412 | 2017-11-15 13:50:26 -0800 | [diff] [blame] | 362 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 363 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 364 | if (error0 == IP_FRAG_ERROR_NONE) |
| 365 | { |
Ole Troan | 7eb9d96 | 2018-08-10 14:39:48 +0200 | [diff] [blame] | 366 | /* Free original buffer chain */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 367 | frag_sent += vec_len (buffer); |
| 368 | small_packets += (vec_len (buffer) == 1); |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 369 | vlib_buffer_free_one (vm, pi0); /* Free original packet */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 370 | } |
| 371 | else |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 372 | { |
| 373 | vlib_error_count (vm, node_index, error0, 1); |
| 374 | vec_add1 (buffer, pi0); /* Get rid of the original buffer */ |
| 375 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 376 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 377 | /* Send fragments that were added in the frame */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 378 | frag_from = buffer; |
| 379 | frag_left = vec_len (buffer); |
| 380 | |
| 381 | while (frag_left > 0) |
| 382 | { |
| 383 | while (frag_left > 0 && n_left_to_next > 0) |
| 384 | { |
| 385 | u32 i; |
| 386 | i = to_next[0] = frag_from[0]; |
| 387 | frag_from += 1; |
| 388 | frag_left -= 1; |
| 389 | to_next += 1; |
| 390 | n_left_to_next -= 1; |
| 391 | |
| 392 | vlib_get_buffer (vm, i)->error = error_node->errors[error0]; |
| 393 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, |
| 394 | to_next, n_left_to_next, i, |
| 395 | next0); |
| 396 | } |
| 397 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 398 | vlib_get_next_frame (vm, node, next_index, to_next, |
| 399 | n_left_to_next); |
| 400 | } |
| 401 | vec_reset_length (buffer); |
| 402 | } |
| 403 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 404 | } |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 405 | vec_free (buffer); |
| 406 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 407 | vlib_node_increment_counter (vm, node_index, |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 408 | IP_FRAG_ERROR_FRAGMENT_SENT, frag_sent); |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 409 | vlib_node_increment_counter (vm, node_index, |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 410 | IP_FRAG_ERROR_SMALL_PACKET, small_packets); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 411 | |
| 412 | return frame->n_vectors; |
| 413 | } |
| 414 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 415 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 416 | |
| 417 | static uword |
| 418 | ip4_frag (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 419 | { |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 420 | return frag_node_inline (vm, node, frame, ip4_frag_node.index, |
| 421 | 0 /* is_ip6 */ ); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | static uword |
| 425 | ip6_frag (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) |
| 426 | { |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 427 | return frag_node_inline (vm, node, frame, ip6_frag_node.index, |
| 428 | 1 /* is_ip6 */ ); |
| 429 | } |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 430 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 431 | /* |
| 432 | * Fragments the packet given in from_bi. Fragments are returned in the buffer vector. |
| 433 | * Caller must ensure the original packet is freed. |
| 434 | */ |
| 435 | void |
| 436 | ip6_frag_do_fragment (vlib_main_t * vm, u32 from_bi, u32 ** buffer, |
| 437 | ip_frag_error_t * error) |
| 438 | { |
| 439 | vlib_buffer_t *from_b; |
| 440 | ip6_header_t *ip6; |
| 441 | u16 mtu, len, max, rem, ip_frag_id; |
| 442 | |
| 443 | from_b = vlib_get_buffer (vm, from_bi); |
| 444 | mtu = vnet_buffer (from_b)->ip_frag.mtu; |
| 445 | ip6 = (ip6_header_t *) vlib_buffer_get_current (from_b); |
| 446 | |
| 447 | rem = clib_net_to_host_u16 (ip6->payload_length); |
| 448 | max = (mtu - sizeof (ip6_header_t) - sizeof (ip6_frag_hdr_t)) & ~0x7; // TODO: Is max correct?? |
| 449 | |
| 450 | if (rem > |
| 451 | (vlib_buffer_length_in_chain (vm, from_b) - sizeof (ip6_header_t))) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 452 | { |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 453 | *error = IP_FRAG_ERROR_MALFORMED; |
| 454 | return; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 455 | } |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 456 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 457 | /* TODO: Look through header chain for fragmentation header */ |
| 458 | if (ip6->protocol == IP_PROTOCOL_IPV6_FRAGMENTATION) |
| 459 | { |
| 460 | *error = IP_FRAG_ERROR_MALFORMED; |
| 461 | return; |
| 462 | } |
| 463 | |
| 464 | u8 *from_data = (void *) (ip6 + 1); |
| 465 | vlib_buffer_t *org_from_b = from_b; |
| 466 | u16 fo = 0; |
| 467 | u16 left_in_from_buffer = from_b->current_length - sizeof (ip6_header_t); |
| 468 | u16 ptr = 0; |
| 469 | |
| 470 | ip_frag_id = ++running_fragment_id; // Fix |
| 471 | |
| 472 | /* Do the actual fragmentation */ |
| 473 | while (rem) |
| 474 | { |
| 475 | u32 to_bi; |
| 476 | vlib_buffer_t *to_b; |
| 477 | ip6_header_t *to_ip6; |
| 478 | ip6_frag_hdr_t *to_frag_hdr; |
| 479 | u8 *to_data; |
| 480 | |
| 481 | len = |
| 482 | (rem > |
| 483 | (mtu - sizeof (ip6_header_t) - sizeof (ip6_frag_hdr_t)) ? max : rem); |
| 484 | if (len != rem) /* Last fragment does not need to divisible by 8 */ |
| 485 | len &= ~0x7; |
| 486 | if ((to_b = frag_buffer_alloc (org_from_b, &to_bi)) == 0) |
| 487 | { |
| 488 | *error = IP_FRAG_ERROR_MEMORY; |
| 489 | return; |
| 490 | } |
| 491 | vec_add1 (*buffer, to_bi); |
| 492 | frag_set_sw_if_index (to_b, org_from_b); |
| 493 | |
| 494 | /* Copy ip6 header */ |
Dave Barach | 178cf49 | 2018-11-13 16:34:13 -0500 | [diff] [blame] | 495 | clib_memcpy_fast (to_b->data, ip6, sizeof (ip6_header_t)); |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 496 | to_ip6 = vlib_buffer_get_current (to_b); |
| 497 | to_frag_hdr = (ip6_frag_hdr_t *) (to_ip6 + 1); |
| 498 | to_data = (void *) (to_frag_hdr + 1); |
| 499 | |
Neale Ranns | 0b6a857 | 2019-10-30 17:34:14 +0000 | [diff] [blame] | 500 | vnet_buffer (to_b)->l3_hdr_offset = to_b->current_data; |
| 501 | to_b->flags |= VNET_BUFFER_F_L3_HDR_OFFSET_VALID; |
| 502 | |
| 503 | if (from_b->flags & VNET_BUFFER_F_L4_HDR_OFFSET_VALID) |
| 504 | { |
| 505 | vnet_buffer (to_b)->l4_hdr_offset = |
| 506 | (vnet_buffer (to_b)->l3_hdr_offset + |
| 507 | (vnet_buffer (from_b)->l4_hdr_offset - |
| 508 | vnet_buffer (from_b)->l3_hdr_offset)); |
| 509 | to_b->flags |= VNET_BUFFER_F_L4_HDR_OFFSET_VALID; |
| 510 | } |
| 511 | to_b->flags |= VNET_BUFFER_F_IS_IP6; |
| 512 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 513 | /* Spin through from buffers filling up the to buffer */ |
| 514 | u16 left_in_to_buffer = len, to_ptr = 0; |
| 515 | while (1) |
| 516 | { |
| 517 | u16 bytes_to_copy; |
| 518 | |
| 519 | /* Figure out how many bytes we can safely copy */ |
| 520 | bytes_to_copy = left_in_to_buffer <= left_in_from_buffer ? |
| 521 | left_in_to_buffer : left_in_from_buffer; |
Dave Barach | 178cf49 | 2018-11-13 16:34:13 -0500 | [diff] [blame] | 522 | clib_memcpy_fast (to_data + to_ptr, from_data + ptr, bytes_to_copy); |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 523 | left_in_to_buffer -= bytes_to_copy; |
| 524 | ptr += bytes_to_copy; |
| 525 | left_in_from_buffer -= bytes_to_copy; |
| 526 | if (left_in_to_buffer == 0) |
| 527 | break; |
| 528 | |
| 529 | ASSERT (left_in_from_buffer <= 0); |
| 530 | /* Move buffer */ |
| 531 | if (!(from_b->flags & VLIB_BUFFER_NEXT_PRESENT)) |
| 532 | { |
| 533 | *error = IP_FRAG_ERROR_MALFORMED; |
| 534 | return; |
| 535 | } |
| 536 | from_b = vlib_get_buffer (vm, from_b->next_buffer); |
| 537 | from_data = (u8 *) vlib_buffer_get_current (from_b); |
| 538 | ptr = 0; |
| 539 | left_in_from_buffer = from_b->current_length; |
| 540 | to_ptr += bytes_to_copy; |
| 541 | } |
| 542 | |
| 543 | to_b->current_length = |
| 544 | len + sizeof (ip6_header_t) + sizeof (ip6_frag_hdr_t); |
| 545 | to_ip6->payload_length = |
| 546 | clib_host_to_net_u16 (len + sizeof (ip6_frag_hdr_t)); |
| 547 | to_ip6->protocol = IP_PROTOCOL_IPV6_FRAGMENTATION; |
| 548 | to_frag_hdr->fragment_offset_and_more = |
| 549 | ip6_frag_hdr_offset_and_more ((fo >> 3), len != rem); |
| 550 | to_frag_hdr->identification = ip_frag_id; |
| 551 | to_frag_hdr->next_hdr = ip6->protocol; |
| 552 | to_frag_hdr->rsv = 0; |
| 553 | |
Rajesh Goel | d6f1c9c | 2019-10-06 13:17:36 +0530 | [diff] [blame] | 554 | /* Copy mpls header if present */ |
| 555 | copy_mpls_hdr (to_b, org_from_b); |
| 556 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 557 | rem -= len; |
| 558 | fo += len; |
| 559 | } |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | static char *ip4_frag_error_strings[] = { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 563 | #define _(sym,string) string, |
| 564 | foreach_ip_frag_error |
| 565 | #undef _ |
| 566 | }; |
| 567 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 568 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 569 | VLIB_REGISTER_NODE (ip4_frag_node) = { |
| 570 | .function = ip4_frag, |
| 571 | .name = IP4_FRAG_NODE_NAME, |
| 572 | .vector_size = sizeof (u32), |
| 573 | .format_trace = format_ip_frag_trace, |
| 574 | .type = VLIB_NODE_TYPE_INTERNAL, |
| 575 | |
| 576 | .n_errors = IP_FRAG_N_ERROR, |
| 577 | .error_strings = ip4_frag_error_strings, |
| 578 | |
| 579 | .n_next_nodes = IP4_FRAG_N_NEXT, |
| 580 | .next_nodes = { |
Ole Troan | b3655e5 | 2018-08-16 22:08:49 +0200 | [diff] [blame] | 581 | [IP4_FRAG_NEXT_IP4_REWRITE] = "ip4-rewrite", |
Neale Ranns | 0b6a857 | 2019-10-30 17:34:14 +0000 | [diff] [blame] | 582 | [IP4_FRAG_NEXT_IP4_REWRITE_MIDCHAIN] = "ip4-midchain", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 583 | [IP4_FRAG_NEXT_IP4_LOOKUP] = "ip4-lookup", |
| 584 | [IP4_FRAG_NEXT_IP6_LOOKUP] = "ip6-lookup", |
Rajesh Goel | d6f1c9c | 2019-10-06 13:17:36 +0530 | [diff] [blame] | 585 | [IP4_FRAG_NEXT_MPLS_OUTPUT] = "mpls-output", |
Ole Troan | 9fb8755 | 2016-01-13 22:30:43 +0100 | [diff] [blame] | 586 | [IP4_FRAG_NEXT_ICMP_ERROR] = "ip4-icmp-error", |
Vijayabhaskar Katamreddy | ce07412 | 2017-11-15 13:50:26 -0800 | [diff] [blame] | 587 | [IP4_FRAG_NEXT_DROP] = "ip4-drop" |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 588 | }, |
| 589 | }; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 590 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 591 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 592 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 593 | VLIB_REGISTER_NODE (ip6_frag_node) = { |
| 594 | .function = ip6_frag, |
| 595 | .name = IP6_FRAG_NODE_NAME, |
| 596 | .vector_size = sizeof (u32), |
| 597 | .format_trace = format_ip_frag_trace, |
| 598 | .type = VLIB_NODE_TYPE_INTERNAL, |
| 599 | |
| 600 | .n_errors = IP_FRAG_N_ERROR, |
| 601 | .error_strings = ip4_frag_error_strings, |
| 602 | |
| 603 | .n_next_nodes = IP6_FRAG_N_NEXT, |
| 604 | .next_nodes = { |
Ole Troan | b3655e5 | 2018-08-16 22:08:49 +0200 | [diff] [blame] | 605 | [IP6_FRAG_NEXT_IP6_REWRITE] = "ip6-rewrite", |
Neale Ranns | 0b6a857 | 2019-10-30 17:34:14 +0000 | [diff] [blame] | 606 | [IP6_FRAG_NEXT_IP6_REWRITE_MIDCHAIN] = "ip6-midchain", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 607 | [IP6_FRAG_NEXT_IP4_LOOKUP] = "ip4-lookup", |
| 608 | [IP6_FRAG_NEXT_IP6_LOOKUP] = "ip6-lookup", |
Rajesh Goel | d6f1c9c | 2019-10-06 13:17:36 +0530 | [diff] [blame] | 609 | [IP6_FRAG_NEXT_MPLS_OUTPUT] = "mpls-output", |
Vijayabhaskar Katamreddy | ce07412 | 2017-11-15 13:50:26 -0800 | [diff] [blame] | 610 | [IP6_FRAG_NEXT_DROP] = "ip6-drop" |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 611 | }, |
| 612 | }; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 613 | /* *INDENT-ON* */ |
| 614 | |
| 615 | /* |
| 616 | * fd.io coding-style-patch-verification: ON |
| 617 | * |
| 618 | * Local Variables: |
| 619 | * eval: (c-set-style "gnu") |
| 620 | * End: |
| 621 | */ |