Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 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 | * ip/icmp6.c: ip6 icmp |
| 17 | * |
| 18 | * Copyright (c) 2008 Eliot Dresselhaus |
| 19 | * |
| 20 | * Permission is hereby granted, free of charge, to any person obtaining |
| 21 | * a copy of this software and associated documentation files (the |
| 22 | * "Software"), to deal in the Software without restriction, including |
| 23 | * without limitation the rights to use, copy, modify, merge, publish, |
| 24 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 25 | * permit persons to whom the Software is furnished to do so, subject to |
| 26 | * the following conditions: |
| 27 | * |
| 28 | * The above copyright notice and this permission notice shall be |
| 29 | * included in all copies or substantial portions of the Software. |
| 30 | * |
| 31 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 32 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 33 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 34 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 35 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 36 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 37 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 38 | */ |
| 39 | |
| 40 | #include <vlib/vlib.h> |
| 41 | #include <vnet/ip/ip.h> |
| 42 | #include <vnet/pg/pg.h> |
Ole Troan | 8034a36 | 2021-08-11 13:54:14 +0200 | [diff] [blame] | 43 | #include <vnet/ip/ip_sas.h> |
Neale Ranns | 5c6dd17 | 2022-02-17 09:08:47 +0000 | [diff] [blame] | 44 | #include <vnet/util/throttle.h> |
| 45 | |
| 46 | /** ICMP throttling */ |
| 47 | static throttle_t icmp_throttle; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 48 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 49 | static u8 * |
| 50 | format_ip6_icmp_type_and_code (u8 * s, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 51 | { |
| 52 | icmp6_type_t type = va_arg (*args, int); |
| 53 | u8 code = va_arg (*args, int); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 54 | char *t = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 55 | |
| 56 | #define _(n,f) case n: t = #f; break; |
| 57 | |
| 58 | switch (type) |
| 59 | { |
| 60 | foreach_icmp6_type; |
| 61 | |
| 62 | default: |
| 63 | break; |
| 64 | } |
| 65 | |
| 66 | #undef _ |
| 67 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 68 | if (!t) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 69 | return format (s, "unknown 0x%x", type); |
| 70 | |
| 71 | s = format (s, "%s", t); |
| 72 | |
| 73 | t = 0; |
| 74 | switch ((type << 8) | code) |
| 75 | { |
| 76 | #define _(a,n,f) case (ICMP6_##a << 8) | (n): t = #f; break; |
| 77 | |
| 78 | foreach_icmp6_code; |
| 79 | |
| 80 | #undef _ |
| 81 | } |
| 82 | |
| 83 | if (t) |
| 84 | s = format (s, " %s", t); |
| 85 | |
| 86 | return s; |
| 87 | } |
| 88 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 89 | static u8 * |
| 90 | format_icmp6_header (u8 * s, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 91 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 92 | icmp46_header_t *icmp = va_arg (*args, icmp46_header_t *); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 93 | u32 max_header_bytes = va_arg (*args, u32); |
| 94 | |
| 95 | /* Nothing to do. */ |
| 96 | if (max_header_bytes < sizeof (icmp[0])) |
| 97 | return format (s, "ICMP header truncated"); |
| 98 | |
| 99 | s = format (s, "ICMP %U checksum 0x%x", |
| 100 | format_ip6_icmp_type_and_code, icmp->type, icmp->code, |
| 101 | clib_net_to_host_u16 (icmp->checksum)); |
| 102 | |
| 103 | if (max_header_bytes >= |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 104 | sizeof (icmp6_neighbor_solicitation_or_advertisement_header_t) && |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 105 | (icmp->type == ICMP6_neighbor_solicitation || |
| 106 | icmp->type == ICMP6_neighbor_advertisement)) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 107 | { |
| 108 | icmp6_neighbor_solicitation_or_advertisement_header_t *icmp6_nd = |
| 109 | (icmp6_neighbor_solicitation_or_advertisement_header_t *) icmp; |
| 110 | s = format (s, "\n target address %U", |
| 111 | format_ip6_address, &icmp6_nd->target_address); |
| 112 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 113 | |
| 114 | return s; |
| 115 | } |
| 116 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 117 | u8 * |
| 118 | format_icmp6_input_trace (u8 * s, va_list * va) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 119 | { |
| 120 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *); |
| 121 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 122 | icmp6_input_trace_t *t = va_arg (*va, icmp6_input_trace_t *); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 123 | |
| 124 | s = format (s, "%U", |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 125 | format_ip6_header, t->packet_data, sizeof (t->packet_data)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 126 | |
| 127 | return s; |
| 128 | } |
| 129 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 130 | typedef enum |
| 131 | { |
Neale Ranns | 1afe952 | 2019-10-25 07:20:42 -0700 | [diff] [blame] | 132 | ICMP_INPUT_NEXT_PUNT, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 133 | ICMP_INPUT_N_NEXT, |
| 134 | } icmp_input_next_t; |
| 135 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 136 | typedef struct |
| 137 | { |
| 138 | uword *type_and_code_by_name; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 139 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 140 | uword *type_by_name; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 141 | |
| 142 | /* Vector dispatch table indexed by [icmp type]. */ |
| 143 | u8 input_next_index_by_type[256]; |
| 144 | |
| 145 | /* Max valid code indexed by icmp type. */ |
| 146 | u8 max_valid_code_by_type[256]; |
| 147 | |
| 148 | /* hop_limit must be >= this value for this icmp type. */ |
| 149 | u8 min_valid_hop_limit_by_type[256]; |
| 150 | |
| 151 | u8 min_valid_length_by_type[256]; |
| 152 | } icmp6_main_t; |
| 153 | |
| 154 | icmp6_main_t icmp6_main; |
| 155 | |
| 156 | static uword |
| 157 | ip6_icmp_input (vlib_main_t * vm, |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 158 | vlib_node_runtime_t * node, vlib_frame_t * frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 159 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 160 | icmp6_main_t *im = &icmp6_main; |
| 161 | u32 *from, *to_next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 162 | u32 n_left_from, n_left_to_next, next_index; |
| 163 | |
| 164 | from = vlib_frame_vector_args (frame); |
| 165 | n_left_from = frame->n_vectors; |
| 166 | next_index = node->cached_next_index; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 167 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 168 | if (node->flags & VLIB_NODE_FLAG_TRACE) |
| 169 | vlib_trace_frame_buffers_only (vm, node, from, frame->n_vectors, |
| 170 | /* stride */ 1, |
| 171 | sizeof (icmp6_input_trace_t)); |
| 172 | |
| 173 | while (n_left_from > 0) |
| 174 | { |
| 175 | vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); |
| 176 | |
| 177 | while (n_left_from > 0 && n_left_to_next > 0) |
| 178 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 179 | vlib_buffer_t *b0; |
| 180 | ip6_header_t *ip0; |
| 181 | icmp46_header_t *icmp0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 182 | icmp6_type_t type0; |
| 183 | u32 bi0, next0, error0, len0; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 184 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 185 | bi0 = to_next[0] = from[0]; |
| 186 | |
| 187 | from += 1; |
| 188 | n_left_from -= 1; |
| 189 | to_next += 1; |
| 190 | n_left_to_next -= 1; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 191 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 192 | b0 = vlib_get_buffer (vm, bi0); |
| 193 | ip0 = vlib_buffer_get_current (b0); |
| 194 | icmp0 = ip6_next_header (ip0); |
| 195 | type0 = icmp0->type; |
| 196 | |
| 197 | error0 = ICMP6_ERROR_NONE; |
| 198 | |
| 199 | next0 = im->input_next_index_by_type[type0]; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 200 | error0 = |
Neale Ranns | 1afe952 | 2019-10-25 07:20:42 -0700 | [diff] [blame] | 201 | next0 == ICMP_INPUT_NEXT_PUNT ? ICMP6_ERROR_UNKNOWN_TYPE : error0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 202 | |
| 203 | /* Check code is valid for type. */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 204 | error0 = |
| 205 | icmp0->code > |
| 206 | im->max_valid_code_by_type[type0] ? |
| 207 | ICMP6_ERROR_INVALID_CODE_FOR_TYPE : error0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 208 | |
| 209 | /* Checksum is already validated by ip6_local node so we don't need to check that. */ |
| 210 | |
| 211 | /* Check that hop limit == 255 for certain types. */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 212 | error0 = |
| 213 | ip0->hop_limit < |
| 214 | im->min_valid_hop_limit_by_type[type0] ? |
| 215 | ICMP6_ERROR_INVALID_HOP_LIMIT_FOR_TYPE : error0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 216 | |
| 217 | len0 = clib_net_to_host_u16 (ip0->payload_length); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 218 | error0 = |
| 219 | len0 < |
| 220 | im->min_valid_length_by_type[type0] ? |
| 221 | ICMP6_ERROR_LENGTH_TOO_SMALL_FOR_TYPE : error0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 222 | |
| 223 | b0->error = node->errors[error0]; |
| 224 | |
Neale Ranns | 1afe952 | 2019-10-25 07:20:42 -0700 | [diff] [blame] | 225 | next0 = error0 != ICMP6_ERROR_NONE ? ICMP_INPUT_NEXT_PUNT : next0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 226 | |
| 227 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, |
| 228 | to_next, n_left_to_next, |
| 229 | bi0, next0); |
| 230 | } |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 231 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 232 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 233 | } |
| 234 | |
| 235 | return frame->n_vectors; |
| 236 | } |
| 237 | |
| 238 | VLIB_REGISTER_NODE (ip6_icmp_input_node) = { |
| 239 | .function = ip6_icmp_input, |
| 240 | .name = "ip6-icmp-input", |
| 241 | |
| 242 | .vector_size = sizeof (u32), |
| 243 | |
| 244 | .format_trace = format_icmp6_input_trace, |
| 245 | |
Neale Ranns | b29c606 | 2022-08-12 01:50:24 +0000 | [diff] [blame] | 246 | .n_errors = ICMP6_N_ERROR, |
| 247 | .error_counters = icmp6_error_counters, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 248 | |
| 249 | .n_next_nodes = 1, |
| 250 | .next_nodes = { |
Neale Ranns | 1afe952 | 2019-10-25 07:20:42 -0700 | [diff] [blame] | 251 | [ICMP_INPUT_NEXT_PUNT] = "ip6-punt", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 252 | }, |
| 253 | }; |
| 254 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 255 | typedef enum |
| 256 | { |
Ole Troan | cda9482 | 2016-01-07 14:37:25 +0100 | [diff] [blame] | 257 | IP6_ICMP_ERROR_NEXT_DROP, |
| 258 | IP6_ICMP_ERROR_NEXT_LOOKUP, |
| 259 | IP6_ICMP_ERROR_N_NEXT, |
| 260 | } ip6_icmp_error_next_t; |
| 261 | |
| 262 | void |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 263 | icmp6_error_set_vnet_buffer (vlib_buffer_t * b, u8 type, u8 code, u32 data) |
Ole Troan | cda9482 | 2016-01-07 14:37:25 +0100 | [diff] [blame] | 264 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 265 | vnet_buffer (b)->ip.icmp.type = type; |
| 266 | vnet_buffer (b)->ip.icmp.code = code; |
| 267 | vnet_buffer (b)->ip.icmp.data = data; |
Ole Troan | cda9482 | 2016-01-07 14:37:25 +0100 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | static u8 |
| 271 | icmp6_icmp_type_to_error (u8 type) |
| 272 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 273 | switch (type) |
| 274 | { |
| 275 | case ICMP6_destination_unreachable: |
| 276 | return ICMP6_ERROR_DEST_UNREACH_SENT; |
| 277 | case ICMP6_packet_too_big: |
| 278 | return ICMP6_ERROR_PACKET_TOO_BIG_SENT; |
| 279 | case ICMP6_time_exceeded: |
| 280 | return ICMP6_ERROR_TTL_EXPIRE_SENT; |
| 281 | case ICMP6_parameter_problem: |
| 282 | return ICMP6_ERROR_PARAM_PROBLEM_SENT; |
| 283 | default: |
| 284 | return ICMP6_ERROR_DROP; |
| 285 | } |
Ole Troan | cda9482 | 2016-01-07 14:37:25 +0100 | [diff] [blame] | 286 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 287 | |
| 288 | static uword |
Ole Troan | cda9482 | 2016-01-07 14:37:25 +0100 | [diff] [blame] | 289 | ip6_icmp_error (vlib_main_t * vm, |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 290 | vlib_node_runtime_t * node, vlib_frame_t * frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 291 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 292 | u32 *from, *to_next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 293 | uword n_left_from, n_left_to_next; |
Ole Troan | cda9482 | 2016-01-07 14:37:25 +0100 | [diff] [blame] | 294 | ip6_icmp_error_next_t next_index; |
Neale Ranns | 5c6dd17 | 2022-02-17 09:08:47 +0000 | [diff] [blame] | 295 | u32 thread_index = vm->thread_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 296 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 297 | from = vlib_frame_vector_args (frame); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 298 | n_left_from = frame->n_vectors; |
| 299 | next_index = node->cached_next_index; |
| 300 | |
Neale Ranns | 5c6dd17 | 2022-02-17 09:08:47 +0000 | [diff] [blame] | 301 | u64 seed = throttle_seed (&icmp_throttle, thread_index, vlib_time_now (vm)); |
| 302 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 303 | if (node->flags & VLIB_NODE_FLAG_TRACE) |
| 304 | vlib_trace_frame_buffers_only (vm, node, from, frame->n_vectors, |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 305 | /* stride */ 1, |
| 306 | sizeof (icmp6_input_trace_t)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 307 | |
| 308 | while (n_left_from > 0) |
| 309 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 310 | 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] | 311 | |
| 312 | while (n_left_from > 0 && n_left_to_next > 0) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 313 | { |
Ole Troan | da7f7b6 | 2019-03-11 13:15:54 +0100 | [diff] [blame] | 314 | /* |
| 315 | * Duplicate first buffer and free the original chain. Keep |
| 316 | * as much of the original packet as possible, within the |
| 317 | * minimum MTU. We chat "a little" here by keeping whatever |
| 318 | * is available in the first buffer. |
| 319 | */ |
| 320 | |
| 321 | u32 pi0 = ~0; |
| 322 | u32 org_pi0 = from[0]; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 323 | u32 next0 = IP6_ICMP_ERROR_NEXT_LOOKUP; |
| 324 | u8 error0 = ICMP6_ERROR_NONE; |
Ole Troan | da7f7b6 | 2019-03-11 13:15:54 +0100 | [diff] [blame] | 325 | vlib_buffer_t *p0, *org_p0; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 326 | ip6_header_t *ip0, *out_ip0; |
| 327 | icmp46_header_t *icmp0; |
Ole Troan | 8034a36 | 2021-08-11 13:54:14 +0200 | [diff] [blame] | 328 | u32 sw_if_index0; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 329 | int bogus_length; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 330 | |
Ole Troan | da7f7b6 | 2019-03-11 13:15:54 +0100 | [diff] [blame] | 331 | org_p0 = vlib_get_buffer (vm, org_pi0); |
Neale Ranns | 5c6dd17 | 2022-02-17 09:08:47 +0000 | [diff] [blame] | 332 | ip0 = vlib_buffer_get_current (org_p0); |
| 333 | |
| 334 | /* Rate limit based on the src,dst addresses in the original packet |
| 335 | */ |
| 336 | u64 r0 = (ip6_address_hash_to_u64 (&ip0->dst_address) ^ |
| 337 | ip6_address_hash_to_u64 (&ip0->src_address)); |
| 338 | |
| 339 | if (throttle_check (&icmp_throttle, thread_index, r0, seed)) |
| 340 | { |
| 341 | vlib_error_count (vm, node->node_index, ICMP4_ERROR_DROP, 1); |
| 342 | from += 1; |
| 343 | n_left_from -= 1; |
| 344 | continue; |
| 345 | } |
| 346 | |
Ole Troan | da7f7b6 | 2019-03-11 13:15:54 +0100 | [diff] [blame] | 347 | p0 = vlib_buffer_copy_no_chain (vm, org_p0, &pi0); |
Ole Troan | da7f7b6 | 2019-03-11 13:15:54 +0100 | [diff] [blame] | 348 | if (!p0 || pi0 == ~0) /* Out of buffers */ |
| 349 | continue; |
| 350 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 351 | /* Speculatively enqueue p0 to the current next frame */ |
| 352 | to_next[0] = pi0; |
| 353 | from += 1; |
| 354 | to_next += 1; |
| 355 | n_left_from -= 1; |
| 356 | n_left_to_next -= 1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 357 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 358 | sw_if_index0 = vnet_buffer (p0)->sw_if_index[VLIB_RX]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 359 | |
Neale Ranns | 5c6dd17 | 2022-02-17 09:08:47 +0000 | [diff] [blame] | 360 | vlib_buffer_copy_trace_flag (vm, p0, pi0); |
| 361 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 362 | /* Add IP header and ICMPv6 header including a 4 byte data field */ |
Ole Troan | da7f7b6 | 2019-03-11 13:15:54 +0100 | [diff] [blame] | 363 | vlib_buffer_advance (p0, |
| 364 | -(sizeof (ip6_header_t) + |
| 365 | sizeof (icmp46_header_t) + 4)); |
Ole Troan | da6e11b | 2018-05-23 11:21:42 +0200 | [diff] [blame] | 366 | |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 367 | p0->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED; |
Ole Troan | da6e11b | 2018-05-23 11:21:42 +0200 | [diff] [blame] | 368 | p0->current_length = |
| 369 | p0->current_length > 1280 ? 1280 : p0->current_length; |
| 370 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 371 | out_ip0 = vlib_buffer_get_current (p0); |
| 372 | icmp0 = (icmp46_header_t *) & out_ip0[1]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 373 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 374 | /* Fill ip header fields */ |
| 375 | out_ip0->ip_version_traffic_class_and_flow_label = |
| 376 | clib_host_to_net_u32 (0x6 << 28); |
Ole Troan | 9fb8755 | 2016-01-13 22:30:43 +0100 | [diff] [blame] | 377 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 378 | out_ip0->payload_length = |
| 379 | clib_host_to_net_u16 (p0->current_length - sizeof (ip6_header_t)); |
| 380 | out_ip0->protocol = IP_PROTOCOL_ICMP6; |
| 381 | out_ip0->hop_limit = 0xff; |
| 382 | out_ip0->dst_address = ip0->src_address; |
Ole Troan | 8034a36 | 2021-08-11 13:54:14 +0200 | [diff] [blame] | 383 | /* Prefer a source address from "offending interface" */ |
| 384 | if (!ip6_sas_by_sw_if_index (sw_if_index0, &out_ip0->dst_address, |
| 385 | &out_ip0->src_address)) |
| 386 | { /* interface has no IP6 address - should not happen */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 387 | next0 = IP6_ICMP_ERROR_NEXT_DROP; |
| 388 | error0 = ICMP6_ERROR_DROP; |
| 389 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 390 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 391 | /* Fill icmp header fields */ |
| 392 | icmp0->type = vnet_buffer (p0)->ip.icmp.type; |
| 393 | icmp0->code = vnet_buffer (p0)->ip.icmp.code; |
| 394 | *((u32 *) (icmp0 + 1)) = |
| 395 | clib_host_to_net_u32 (vnet_buffer (p0)->ip.icmp.data); |
| 396 | icmp0->checksum = 0; |
| 397 | icmp0->checksum = |
| 398 | ip6_tcp_udp_icmp_compute_checksum (vm, p0, out_ip0, |
| 399 | &bogus_length); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 400 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 401 | /* Update error status */ |
Ole Troan | cda9482 | 2016-01-07 14:37:25 +0100 | [diff] [blame] | 402 | if (error0 == ICMP6_ERROR_NONE) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 403 | error0 = icmp6_icmp_type_to_error (icmp0->type); |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 404 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 405 | vlib_error_count (vm, node->node_index, error0, 1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 406 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 407 | /* Verify speculative enqueue, maybe switch current next frame */ |
| 408 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, |
| 409 | to_next, n_left_to_next, |
| 410 | pi0, next0); |
| 411 | } |
| 412 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 413 | } |
| 414 | |
Kingwel Xie | 27431dd | 2019-03-20 21:47:17 -0400 | [diff] [blame] | 415 | /* |
| 416 | * push the original buffers to error-drop, so that |
| 417 | * they can get the error counters handled, then freed |
| 418 | */ |
| 419 | vlib_buffer_enqueue_to_single_next (vm, node, |
| 420 | vlib_frame_vector_args (frame), |
| 421 | IP6_ICMP_ERROR_NEXT_DROP, |
| 422 | frame->n_vectors); |
| 423 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 424 | return frame->n_vectors; |
| 425 | } |
| 426 | |
Ole Troan | cda9482 | 2016-01-07 14:37:25 +0100 | [diff] [blame] | 427 | VLIB_REGISTER_NODE (ip6_icmp_error_node) = { |
| 428 | .function = ip6_icmp_error, |
| 429 | .name = "ip6-icmp-error", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 430 | .vector_size = sizeof (u32), |
| 431 | |
Neale Ranns | b29c606 | 2022-08-12 01:50:24 +0000 | [diff] [blame] | 432 | .n_errors = ICMP6_N_ERROR, |
| 433 | .error_counters = icmp6_error_counters, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 434 | |
Ole Troan | cda9482 | 2016-01-07 14:37:25 +0100 | [diff] [blame] | 435 | .n_next_nodes = IP6_ICMP_ERROR_N_NEXT, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 436 | .next_nodes = { |
Ole Troan | 282093f | 2018-09-19 12:38:51 +0200 | [diff] [blame] | 437 | [IP6_ICMP_ERROR_NEXT_DROP] = "error-drop", |
Ole Troan | cda9482 | 2016-01-07 14:37:25 +0100 | [diff] [blame] | 438 | [IP6_ICMP_ERROR_NEXT_LOOKUP] = "ip6-lookup", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 439 | }, |
| 440 | |
| 441 | .format_trace = format_icmp6_input_trace, |
| 442 | }; |
| 443 | |
| 444 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 445 | static uword |
| 446 | unformat_icmp_type_and_code (unformat_input_t * input, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 447 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 448 | icmp46_header_t *h = va_arg (*args, icmp46_header_t *); |
| 449 | icmp6_main_t *cm = &icmp6_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 450 | u32 i; |
| 451 | |
| 452 | if (unformat_user (input, unformat_vlib_number_by_name, |
| 453 | cm->type_and_code_by_name, &i)) |
| 454 | { |
| 455 | h->type = (i >> 8) & 0xff; |
| 456 | h->code = (i >> 0) & 0xff; |
| 457 | } |
| 458 | else if (unformat_user (input, unformat_vlib_number_by_name, |
| 459 | cm->type_by_name, &i)) |
| 460 | { |
| 461 | h->type = i; |
| 462 | h->code = 0; |
| 463 | } |
| 464 | else |
| 465 | return 0; |
| 466 | |
| 467 | return 1; |
| 468 | } |
| 469 | |
| 470 | static void |
| 471 | icmp6_pg_edit_function (pg_main_t * pg, |
| 472 | pg_stream_t * s, |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 473 | pg_edit_group_t * g, u32 * packets, u32 n_packets) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 474 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 475 | vlib_main_t *vm = vlib_get_main (); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 476 | u32 ip_offset, icmp_offset; |
| 477 | int bogus_length; |
| 478 | |
| 479 | icmp_offset = g->start_byte_offset; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 480 | ip_offset = (g - 1)->start_byte_offset; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 481 | |
| 482 | while (n_packets >= 1) |
| 483 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 484 | vlib_buffer_t *p0; |
| 485 | ip6_header_t *ip0; |
| 486 | icmp46_header_t *icmp0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 487 | |
| 488 | p0 = vlib_get_buffer (vm, packets[0]); |
| 489 | n_packets -= 1; |
| 490 | packets += 1; |
| 491 | |
| 492 | ASSERT (p0->current_data == 0); |
| 493 | ip0 = (void *) (p0->data + ip_offset); |
| 494 | icmp0 = (void *) (p0->data + icmp_offset); |
| 495 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 496 | icmp0->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, p0, ip0, |
| 497 | &bogus_length); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 498 | ASSERT (bogus_length == 0); |
| 499 | } |
| 500 | } |
| 501 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 502 | typedef struct |
| 503 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 504 | pg_edit_t type, code; |
| 505 | pg_edit_t checksum; |
| 506 | } pg_icmp46_header_t; |
| 507 | |
| 508 | always_inline void |
| 509 | pg_icmp_header_init (pg_icmp46_header_t * p) |
| 510 | { |
| 511 | /* Initialize fields that are not bit fields in the IP header. */ |
| 512 | #define _(f) pg_edit_init (&p->f, icmp46_header_t, f); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 513 | _(type); |
| 514 | _(code); |
| 515 | _(checksum); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 516 | #undef _ |
| 517 | } |
| 518 | |
| 519 | static uword |
| 520 | unformat_pg_icmp_header (unformat_input_t * input, va_list * args) |
| 521 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 522 | pg_stream_t *s = va_arg (*args, pg_stream_t *); |
| 523 | pg_icmp46_header_t *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 524 | u32 group_index; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 525 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 526 | p = pg_create_edit_group (s, sizeof (p[0]), sizeof (icmp46_header_t), |
| 527 | &group_index); |
| 528 | pg_icmp_header_init (p); |
| 529 | |
| 530 | p->checksum.type = PG_EDIT_UNSPECIFIED; |
| 531 | |
| 532 | { |
| 533 | icmp46_header_t tmp; |
| 534 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 535 | if (!unformat (input, "ICMP %U", unformat_icmp_type_and_code, &tmp)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 536 | goto error; |
| 537 | |
| 538 | pg_edit_set_fixed (&p->type, tmp.type); |
| 539 | pg_edit_set_fixed (&p->code, tmp.code); |
| 540 | } |
| 541 | |
| 542 | /* Parse options. */ |
| 543 | while (1) |
| 544 | { |
| 545 | if (unformat (input, "checksum %U", |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 546 | unformat_pg_edit, unformat_pg_number, &p->checksum)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 547 | ; |
| 548 | |
| 549 | /* Can't parse input: try next protocol level. */ |
| 550 | else |
| 551 | break; |
| 552 | } |
| 553 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 554 | if (!unformat_user (input, unformat_pg_payload, s)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 555 | goto error; |
| 556 | |
| 557 | if (p->checksum.type == PG_EDIT_UNSPECIFIED) |
| 558 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 559 | pg_edit_group_t *g = pg_stream_get_group (s, group_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 560 | g->edit_function = icmp6_pg_edit_function; |
| 561 | g->edit_function_opaque = 0; |
| 562 | } |
| 563 | |
| 564 | return 1; |
| 565 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 566 | error: |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 567 | /* Free up any edits we may have added. */ |
| 568 | pg_free_edit_group (s); |
| 569 | return 0; |
| 570 | } |
| 571 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 572 | void |
| 573 | icmp6_register_type (vlib_main_t * vm, icmp6_type_t type, u32 node_index) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 574 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 575 | icmp6_main_t *im = &icmp6_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 576 | |
Damjan Marion | 2c29d75 | 2015-12-18 10:26:56 +0100 | [diff] [blame] | 577 | ASSERT ((int) type < ARRAY_LEN (im->input_next_index_by_type)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 578 | im->input_next_index_by_type[type] |
| 579 | = vlib_node_add_next (vm, ip6_icmp_input_node.index, node_index); |
| 580 | } |
| 581 | |
| 582 | static clib_error_t * |
| 583 | icmp6_init (vlib_main_t * vm) |
| 584 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 585 | ip_main_t *im = &ip_main; |
| 586 | ip_protocol_info_t *pi; |
| 587 | icmp6_main_t *cm = &icmp6_main; |
| 588 | clib_error_t *error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 589 | |
| 590 | error = vlib_call_init_function (vm, ip_main_init); |
| 591 | |
| 592 | if (error) |
| 593 | return error; |
| 594 | |
| 595 | pi = ip_get_protocol_info (im, IP_PROTOCOL_ICMP6); |
| 596 | pi->format_header = format_icmp6_header; |
| 597 | pi->unformat_pg_edit = unformat_pg_icmp_header; |
| 598 | |
| 599 | cm->type_by_name = hash_create_string (0, sizeof (uword)); |
| 600 | #define _(n,t) hash_set_mem (cm->type_by_name, #t, (n)); |
| 601 | foreach_icmp6_type; |
| 602 | #undef _ |
| 603 | |
| 604 | cm->type_and_code_by_name = hash_create_string (0, sizeof (uword)); |
| 605 | #define _(a,n,t) hash_set_mem (cm->type_by_name, #t, (n) | (ICMP6_##a << 8)); |
| 606 | foreach_icmp6_code; |
| 607 | #undef _ |
| 608 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 609 | clib_memset (cm->input_next_index_by_type, |
Neale Ranns | 1afe952 | 2019-10-25 07:20:42 -0700 | [diff] [blame] | 610 | ICMP_INPUT_NEXT_PUNT, sizeof (cm->input_next_index_by_type)); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 611 | clib_memset (cm->max_valid_code_by_type, 0, |
| 612 | sizeof (cm->max_valid_code_by_type)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 613 | |
| 614 | #define _(a,n,t) cm->max_valid_code_by_type[ICMP6_##a] = clib_max (cm->max_valid_code_by_type[ICMP6_##a], n); |
| 615 | foreach_icmp6_code; |
| 616 | #undef _ |
| 617 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 618 | clib_memset (cm->min_valid_hop_limit_by_type, 0, |
| 619 | sizeof (cm->min_valid_hop_limit_by_type)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 620 | cm->min_valid_hop_limit_by_type[ICMP6_router_solicitation] = 255; |
| 621 | cm->min_valid_hop_limit_by_type[ICMP6_router_advertisement] = 255; |
| 622 | cm->min_valid_hop_limit_by_type[ICMP6_neighbor_solicitation] = 255; |
| 623 | cm->min_valid_hop_limit_by_type[ICMP6_neighbor_advertisement] = 255; |
| 624 | cm->min_valid_hop_limit_by_type[ICMP6_redirect] = 255; |
| 625 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 626 | clib_memset (cm->min_valid_length_by_type, sizeof (icmp46_header_t), |
| 627 | sizeof (cm->min_valid_length_by_type)); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 628 | cm->min_valid_length_by_type[ICMP6_router_solicitation] = |
| 629 | sizeof (icmp6_neighbor_discovery_header_t); |
| 630 | cm->min_valid_length_by_type[ICMP6_router_advertisement] = |
| 631 | sizeof (icmp6_router_advertisement_header_t); |
| 632 | cm->min_valid_length_by_type[ICMP6_neighbor_solicitation] = |
| 633 | sizeof (icmp6_neighbor_solicitation_or_advertisement_header_t); |
| 634 | cm->min_valid_length_by_type[ICMP6_neighbor_advertisement] = |
| 635 | sizeof (icmp6_neighbor_solicitation_or_advertisement_header_t); |
| 636 | cm->min_valid_length_by_type[ICMP6_redirect] = |
| 637 | sizeof (icmp6_redirect_header_t); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 638 | |
Neale Ranns | 5c6dd17 | 2022-02-17 09:08:47 +0000 | [diff] [blame] | 639 | vlib_thread_main_t *tm = &vlib_thread_main; |
| 640 | u32 n_vlib_mains = tm->n_vlib_mains; |
| 641 | |
Maxime Peim | f6ba562 | 2023-02-06 10:14:20 +0000 | [diff] [blame] | 642 | throttle_init (&icmp_throttle, n_vlib_mains, THROTTLE_BITS, 1e-3); |
Neale Ranns | 5c6dd17 | 2022-02-17 09:08:47 +0000 | [diff] [blame] | 643 | |
Neale Ranns | cbe25aa | 2019-09-30 10:53:31 +0000 | [diff] [blame] | 644 | return (NULL); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | VLIB_INIT_FUNCTION (icmp6_init); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 648 | |
| 649 | /* |
| 650 | * fd.io coding-style-patch-verification: ON |
| 651 | * |
| 652 | * Local Variables: |
| 653 | * eval: (c-set-style "gnu") |
| 654 | * End: |
| 655 | */ |