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 | * interface_output.c: interface output node |
| 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 <vnet/vnet.h> |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 41 | #include <vnet/ip/icmp46_packet.h> |
| 42 | #include <vnet/ip/ip4.h> |
| 43 | #include <vnet/ip/ip6.h> |
| 44 | #include <vnet/udp/udp_packet.h> |
Damjan Marion | 152e21d | 2016-11-29 14:55:43 +0100 | [diff] [blame] | 45 | #include <vnet/feature/feature.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 46 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 47 | typedef struct |
| 48 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 49 | u32 sw_if_index; |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 50 | u32 flags; |
| 51 | u16 gso_size; |
| 52 | u8 gso_l4_hdr_sz; |
| 53 | u8 data[128 - 3 * sizeof (u32)]; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 54 | } |
| 55 | interface_output_trace_t; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 56 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 57 | u8 * |
| 58 | format_vnet_interface_output_trace (u8 * s, va_list * va) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 59 | { |
| 60 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 61 | vlib_node_t *node = va_arg (*va, vlib_node_t *); |
| 62 | interface_output_trace_t *t = va_arg (*va, interface_output_trace_t *); |
| 63 | vnet_main_t *vnm = vnet_get_main (); |
| 64 | vnet_sw_interface_t *si; |
Christophe Fontaine | d3c008d | 2017-10-02 18:10:54 +0200 | [diff] [blame] | 65 | u32 indent; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 66 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 67 | if (t->sw_if_index != (u32) ~ 0) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 68 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 69 | indent = format_get_indent (s); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 70 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 71 | if (pool_is_free_index |
| 72 | (vnm->interface_main.sw_interfaces, t->sw_if_index)) |
| 73 | { |
| 74 | /* the interface may have been deleted by the time the trace is printed */ |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 75 | s = format (s, "sw_if_index: %d ", t->sw_if_index); |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 76 | } |
| 77 | else |
| 78 | { |
| 79 | si = vnet_get_sw_interface (vnm, t->sw_if_index); |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 80 | s = |
| 81 | format (s, "%U ", format_vnet_sw_interface_name, vnm, si, |
| 82 | t->flags); |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 83 | } |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 84 | #define _(bit, name, v, x) \ |
| 85 | if (v && (t->flags & VNET_BUFFER_F_##name)) \ |
| 86 | s = format (s, "%s ", v); |
| 87 | foreach_vnet_buffer_flag |
| 88 | #undef _ |
| 89 | if (t->flags & VNET_BUFFER_F_GSO) |
| 90 | { |
| 91 | s = format (s, "\n%Ugso_sz %d gso_l4_hdr_sz %d", |
| 92 | format_white_space, indent + 2, t->gso_size, |
| 93 | t->gso_l4_hdr_sz); |
| 94 | } |
| 95 | s = |
| 96 | format (s, "\n%U%U", format_white_space, indent, |
| 97 | node->format_buffer ? node->format_buffer : format_hex_bytes, |
| 98 | t->data, sizeof (t->data)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 99 | } |
| 100 | return s; |
| 101 | } |
| 102 | |
| 103 | static void |
| 104 | vnet_interface_output_trace (vlib_main_t * vm, |
| 105 | vlib_node_runtime_t * node, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 106 | vlib_frame_t * frame, uword n_buffers) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 107 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 108 | u32 n_left, *from; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 109 | |
| 110 | n_left = n_buffers; |
Damjan Marion | a3d5986 | 2018-11-10 10:23:00 +0100 | [diff] [blame] | 111 | from = vlib_frame_vector_args (frame); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 112 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 113 | while (n_left >= 4) |
| 114 | { |
| 115 | u32 bi0, bi1; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 116 | vlib_buffer_t *b0, *b1; |
| 117 | interface_output_trace_t *t0, *t1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 118 | |
| 119 | /* Prefetch next iteration. */ |
| 120 | vlib_prefetch_buffer_with_index (vm, from[2], LOAD); |
| 121 | vlib_prefetch_buffer_with_index (vm, from[3], LOAD); |
| 122 | |
| 123 | bi0 = from[0]; |
| 124 | bi1 = from[1]; |
| 125 | |
| 126 | b0 = vlib_get_buffer (vm, bi0); |
| 127 | b1 = vlib_get_buffer (vm, bi1); |
| 128 | |
| 129 | if (b0->flags & VLIB_BUFFER_IS_TRACED) |
| 130 | { |
| 131 | t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0])); |
| 132 | t0->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 133 | t0->flags = b0->flags; |
| 134 | t0->gso_size = vnet_buffer2 (b0)->gso_size; |
| 135 | t0->gso_l4_hdr_sz = vnet_buffer2 (b0)->gso_l4_hdr_sz; |
Dave Barach | 178cf49 | 2018-11-13 16:34:13 -0500 | [diff] [blame] | 136 | clib_memcpy_fast (t0->data, vlib_buffer_get_current (b0), |
| 137 | sizeof (t0->data)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 138 | } |
| 139 | if (b1->flags & VLIB_BUFFER_IS_TRACED) |
| 140 | { |
| 141 | t1 = vlib_add_trace (vm, node, b1, sizeof (t1[0])); |
| 142 | t1->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_TX]; |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 143 | t1->flags = b1->flags; |
| 144 | t1->gso_size = vnet_buffer2 (b1)->gso_size; |
| 145 | t1->gso_l4_hdr_sz = vnet_buffer2 (b1)->gso_l4_hdr_sz; |
Dave Barach | 178cf49 | 2018-11-13 16:34:13 -0500 | [diff] [blame] | 146 | clib_memcpy_fast (t1->data, vlib_buffer_get_current (b1), |
| 147 | sizeof (t1->data)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 148 | } |
| 149 | from += 2; |
| 150 | n_left -= 2; |
| 151 | } |
| 152 | |
| 153 | while (n_left >= 1) |
| 154 | { |
| 155 | u32 bi0; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 156 | vlib_buffer_t *b0; |
| 157 | interface_output_trace_t *t0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 158 | |
| 159 | bi0 = from[0]; |
| 160 | |
| 161 | b0 = vlib_get_buffer (vm, bi0); |
| 162 | |
| 163 | if (b0->flags & VLIB_BUFFER_IS_TRACED) |
| 164 | { |
| 165 | t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0])); |
| 166 | t0->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 167 | t0->flags = b0->flags; |
| 168 | t0->gso_size = vnet_buffer2 (b0)->gso_size; |
| 169 | t0->gso_l4_hdr_sz = vnet_buffer2 (b0)->gso_l4_hdr_sz; |
Dave Barach | 178cf49 | 2018-11-13 16:34:13 -0500 | [diff] [blame] | 170 | clib_memcpy_fast (t0->data, vlib_buffer_get_current (b0), |
| 171 | sizeof (t0->data)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 172 | } |
| 173 | from += 1; |
| 174 | n_left -= 1; |
| 175 | } |
| 176 | } |
| 177 | |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 178 | static_always_inline void |
| 179 | calc_checksums (vlib_main_t * vm, vlib_buffer_t * b) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 180 | { |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 181 | ip4_header_t *ip4; |
| 182 | ip6_header_t *ip6; |
| 183 | tcp_header_t *th; |
| 184 | udp_header_t *uh; |
| 185 | |
| 186 | int is_ip4 = (b->flags & VNET_BUFFER_F_IS_IP4) != 0; |
| 187 | int is_ip6 = (b->flags & VNET_BUFFER_F_IS_IP6) != 0; |
| 188 | |
| 189 | ASSERT (!(is_ip4 && is_ip6)); |
| 190 | |
| 191 | ip4 = (ip4_header_t *) (b->data + vnet_buffer (b)->l3_hdr_offset); |
| 192 | ip6 = (ip6_header_t *) (b->data + vnet_buffer (b)->l3_hdr_offset); |
| 193 | th = (tcp_header_t *) (b->data + vnet_buffer (b)->l4_hdr_offset); |
| 194 | uh = (udp_header_t *) (b->data + vnet_buffer (b)->l4_hdr_offset); |
| 195 | |
| 196 | if (is_ip4) |
| 197 | { |
| 198 | ip4 = (ip4_header_t *) (b->data + vnet_buffer (b)->l3_hdr_offset); |
| 199 | if (b->flags & VNET_BUFFER_F_OFFLOAD_IP_CKSUM) |
| 200 | ip4->checksum = ip4_header_checksum (ip4); |
| 201 | if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM) |
Andrej Kozemcak | 9d7570c | 2019-01-07 08:39:22 +0100 | [diff] [blame] | 202 | { |
| 203 | th->checksum = 0; |
| 204 | th->checksum = ip4_tcp_udp_compute_checksum (vm, b, ip4); |
| 205 | } |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 206 | if (b->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM) |
| 207 | uh->checksum = ip4_tcp_udp_compute_checksum (vm, b, ip4); |
| 208 | } |
| 209 | if (is_ip6) |
| 210 | { |
| 211 | int bogus; |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 212 | if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM) |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 213 | { |
| 214 | th->checksum = 0; |
| 215 | th->checksum = |
| 216 | ip6_tcp_udp_icmp_compute_checksum (vm, b, ip6, &bogus); |
| 217 | } |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 218 | if (b->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM) |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 219 | { |
| 220 | uh->checksum = 0; |
| 221 | uh->checksum = |
| 222 | ip6_tcp_udp_icmp_compute_checksum (vm, b, ip6, &bogus); |
| 223 | } |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | b->flags &= ~VNET_BUFFER_F_OFFLOAD_TCP_CKSUM; |
| 227 | b->flags &= ~VNET_BUFFER_F_OFFLOAD_UDP_CKSUM; |
| 228 | b->flags &= ~VNET_BUFFER_F_OFFLOAD_IP_CKSUM; |
| 229 | } |
| 230 | |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 231 | static_always_inline u16 |
| 232 | tso_alloc_tx_bufs (vlib_main_t * vm, |
| 233 | vnet_interface_per_thread_data_t * ptd, |
| 234 | vlib_buffer_t * b0, u16 l4_hdr_sz) |
| 235 | { |
| 236 | u32 n_bytes_b0 = vlib_buffer_length_in_chain (vm, b0); |
| 237 | u16 gso_size = vnet_buffer2 (b0)->gso_size; |
| 238 | u16 l234_sz = vnet_buffer (b0)->l4_hdr_offset + l4_hdr_sz; |
| 239 | /* rounded-up division */ |
| 240 | u16 n_bufs = (n_bytes_b0 - l234_sz + (gso_size - 1)) / gso_size; |
| 241 | u16 n_alloc; |
| 242 | |
| 243 | ASSERT (n_bufs > 0); |
| 244 | vec_validate (ptd->split_buffers, n_bufs - 1); |
| 245 | |
| 246 | n_alloc = vlib_buffer_alloc (vm, ptd->split_buffers, n_bufs); |
| 247 | if (n_alloc < n_bufs) |
| 248 | { |
| 249 | vlib_buffer_free (vm, ptd->split_buffers, n_alloc); |
| 250 | return 0; |
| 251 | } |
| 252 | return 1; |
| 253 | } |
| 254 | |
| 255 | static_always_inline void |
| 256 | tso_init_buf_from_template_base (vlib_buffer_t * nb0, vlib_buffer_t * b0, |
| 257 | u32 flags, u16 length) |
| 258 | { |
| 259 | nb0->current_data = 0; |
| 260 | nb0->total_length_not_including_first_buffer = 0; |
| 261 | nb0->flags = VLIB_BUFFER_TOTAL_LENGTH_VALID | flags; |
| 262 | clib_memcpy_fast (&nb0->opaque, &b0->opaque, sizeof (nb0->opaque)); |
| 263 | clib_memcpy_fast (nb0->data, b0->data, length); |
| 264 | nb0->current_length = length; |
| 265 | } |
| 266 | |
| 267 | static_always_inline void |
| 268 | tso_init_buf_from_template (vlib_main_t * vm, vlib_buffer_t * nb0, |
| 269 | vlib_buffer_t * b0, u16 template_data_sz, |
| 270 | u16 gso_size, u8 ** p_dst_ptr, u16 * p_dst_left, |
| 271 | u32 next_tcp_seq, u32 flags) |
| 272 | { |
| 273 | tso_init_buf_from_template_base (nb0, b0, flags, template_data_sz); |
| 274 | |
| 275 | *p_dst_left = |
| 276 | clib_min (gso_size, |
| 277 | vlib_buffer_get_default_data_size (vm) - template_data_sz); |
| 278 | *p_dst_ptr = nb0->data + template_data_sz; |
| 279 | |
| 280 | tcp_header_t *tcp = |
| 281 | (tcp_header_t *) (nb0->data + vnet_buffer (nb0)->l4_hdr_offset); |
| 282 | tcp->seq_number = clib_host_to_net_u32 (next_tcp_seq); |
| 283 | } |
| 284 | |
| 285 | static_always_inline void |
| 286 | tso_fixup_segmented_buf (vlib_buffer_t * b0, u8 tcp_flags, int is_ip6) |
| 287 | { |
| 288 | u16 l3_hdr_offset = vnet_buffer (b0)->l3_hdr_offset; |
| 289 | u16 l4_hdr_offset = vnet_buffer (b0)->l4_hdr_offset; |
| 290 | ip4_header_t *ip4 = (ip4_header_t *) (b0->data + l3_hdr_offset); |
| 291 | ip6_header_t *ip6 = (ip6_header_t *) (b0->data + l3_hdr_offset); |
| 292 | tcp_header_t *tcp = (tcp_header_t *) (b0->data + l4_hdr_offset); |
| 293 | |
| 294 | tcp->flags = tcp_flags; |
| 295 | |
| 296 | if (is_ip6) |
| 297 | ip6->payload_length = |
| 298 | clib_host_to_net_u16 (b0->current_length - |
| 299 | vnet_buffer (b0)->l4_hdr_offset); |
| 300 | else |
| 301 | ip4->length = |
| 302 | clib_host_to_net_u16 (b0->current_length - |
| 303 | vnet_buffer (b0)->l3_hdr_offset); |
| 304 | } |
| 305 | |
| 306 | /** |
| 307 | * Allocate the necessary number of ptd->split_buffers, |
| 308 | * and segment the possibly chained buffer(s) from b0 into |
| 309 | * there. |
| 310 | * |
| 311 | * Return the cumulative number of bytes sent or zero |
| 312 | * if allocation failed. |
| 313 | */ |
| 314 | |
| 315 | static_always_inline u32 |
| 316 | tso_segment_buffer (vlib_main_t * vm, vnet_interface_per_thread_data_t * ptd, |
| 317 | int do_tx_offloads, u32 sbi0, vlib_buffer_t * sb0, |
| 318 | u32 n_bytes_b0) |
| 319 | { |
| 320 | u32 n_tx_bytes = 0; |
| 321 | int is_ip4 = sb0->flags & VNET_BUFFER_F_IS_IP4; |
| 322 | int is_ip6 = sb0->flags & VNET_BUFFER_F_IS_IP6; |
| 323 | ASSERT (is_ip4 || is_ip6); |
| 324 | ASSERT (sb0->flags & VNET_BUFFER_F_L2_HDR_OFFSET_VALID); |
| 325 | ASSERT (sb0->flags & VNET_BUFFER_F_L3_HDR_OFFSET_VALID); |
| 326 | ASSERT (sb0->flags & VNET_BUFFER_F_L4_HDR_OFFSET_VALID); |
| 327 | u16 gso_size = vnet_buffer2 (sb0)->gso_size; |
| 328 | |
| 329 | int l4_hdr_sz = vnet_buffer2 (sb0)->gso_l4_hdr_sz; |
| 330 | u8 save_tcp_flags = 0; |
| 331 | u8 tcp_flags_no_fin_psh = 0; |
| 332 | u32 next_tcp_seq = 0; |
| 333 | |
| 334 | tcp_header_t *tcp = |
| 335 | (tcp_header_t *) (sb0->data + vnet_buffer (sb0)->l4_hdr_offset); |
| 336 | next_tcp_seq = clib_net_to_host_u32 (tcp->seq_number); |
| 337 | /* store original flags for last packet and reset FIN and PSH */ |
| 338 | save_tcp_flags = tcp->flags; |
| 339 | tcp_flags_no_fin_psh = tcp->flags & ~(TCP_FLAG_FIN | TCP_FLAG_PSH); |
| 340 | tcp->checksum = 0; |
| 341 | |
| 342 | u32 default_bflags = |
| 343 | sb0->flags & ~(VNET_BUFFER_F_GSO | VLIB_BUFFER_NEXT_PRESENT); |
| 344 | u16 l234_sz = vnet_buffer (sb0)->l4_hdr_offset + l4_hdr_sz; |
| 345 | int first_data_size = clib_min (gso_size, sb0->current_length - l234_sz); |
| 346 | next_tcp_seq += first_data_size; |
| 347 | |
| 348 | if (PREDICT_FALSE (!tso_alloc_tx_bufs (vm, ptd, sb0, l4_hdr_sz))) |
| 349 | return 0; |
| 350 | |
| 351 | vlib_buffer_t *b0 = vlib_get_buffer (vm, ptd->split_buffers[0]); |
| 352 | tso_init_buf_from_template_base (b0, sb0, default_bflags, |
| 353 | l4_hdr_sz + first_data_size); |
| 354 | |
| 355 | u32 total_src_left = n_bytes_b0 - l234_sz - first_data_size; |
| 356 | if (total_src_left) |
| 357 | { |
| 358 | /* Need to copy more segments */ |
| 359 | u8 *src_ptr, *dst_ptr; |
| 360 | u16 src_left, dst_left; |
| 361 | /* current source buffer */ |
| 362 | vlib_buffer_t *csb0 = sb0; |
| 363 | u32 csbi0 = sbi0; |
| 364 | /* current dest buffer */ |
| 365 | vlib_buffer_t *cdb0; |
| 366 | u16 dbi = 1; /* the buffer [0] is b0 */ |
| 367 | |
| 368 | src_ptr = sb0->data + l234_sz + first_data_size; |
| 369 | src_left = sb0->current_length - l234_sz - first_data_size; |
| 370 | b0->current_length = l234_sz + first_data_size; |
| 371 | |
| 372 | tso_fixup_segmented_buf (b0, tcp_flags_no_fin_psh, is_ip6); |
| 373 | if (do_tx_offloads) |
| 374 | calc_checksums (vm, b0); |
| 375 | |
| 376 | /* grab a second buffer and prepare the loop */ |
| 377 | ASSERT (dbi < vec_len (ptd->split_buffers)); |
| 378 | cdb0 = vlib_get_buffer (vm, ptd->split_buffers[dbi++]); |
| 379 | tso_init_buf_from_template (vm, cdb0, b0, l234_sz, gso_size, &dst_ptr, |
| 380 | &dst_left, next_tcp_seq, default_bflags); |
| 381 | |
| 382 | /* an arbitrary large number to catch the runaway loops */ |
| 383 | int nloops = 2000; |
| 384 | while (total_src_left) |
| 385 | { |
Dave Barach | a2aefef | 2019-02-27 12:36:28 -0500 | [diff] [blame] | 386 | if (nloops-- <= 0) |
| 387 | clib_panic ("infinite loop detected"); |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 388 | u16 bytes_to_copy = clib_min (src_left, dst_left); |
| 389 | |
| 390 | clib_memcpy_fast (dst_ptr, src_ptr, bytes_to_copy); |
| 391 | |
| 392 | src_left -= bytes_to_copy; |
| 393 | src_ptr += bytes_to_copy; |
| 394 | total_src_left -= bytes_to_copy; |
| 395 | dst_left -= bytes_to_copy; |
| 396 | dst_ptr += bytes_to_copy; |
| 397 | next_tcp_seq += bytes_to_copy; |
| 398 | cdb0->current_length += bytes_to_copy; |
| 399 | |
| 400 | if (0 == src_left) |
| 401 | { |
| 402 | int has_next = (csb0->flags & VLIB_BUFFER_NEXT_PRESENT); |
| 403 | u32 next_bi = csb0->next_buffer; |
| 404 | |
| 405 | /* init src to the next buffer in chain */ |
| 406 | if (has_next) |
| 407 | { |
| 408 | csbi0 = next_bi; |
| 409 | csb0 = vlib_get_buffer (vm, csbi0); |
| 410 | src_left = csb0->current_length; |
| 411 | src_ptr = csb0->data; |
| 412 | } |
| 413 | else |
| 414 | { |
| 415 | ASSERT (total_src_left == 0); |
| 416 | break; |
| 417 | } |
| 418 | } |
| 419 | if (0 == dst_left && total_src_left) |
| 420 | { |
| 421 | if (do_tx_offloads) |
| 422 | calc_checksums (vm, cdb0); |
| 423 | n_tx_bytes += cdb0->current_length; |
| 424 | ASSERT (dbi < vec_len (ptd->split_buffers)); |
| 425 | cdb0 = vlib_get_buffer (vm, ptd->split_buffers[dbi++]); |
| 426 | tso_init_buf_from_template (vm, cdb0, b0, l234_sz, |
| 427 | gso_size, &dst_ptr, &dst_left, |
| 428 | next_tcp_seq, default_bflags); |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | tso_fixup_segmented_buf (cdb0, save_tcp_flags, is_ip6); |
| 433 | if (do_tx_offloads) |
| 434 | calc_checksums (vm, cdb0); |
| 435 | |
| 436 | n_tx_bytes += cdb0->current_length; |
| 437 | } |
| 438 | n_tx_bytes += b0->current_length; |
| 439 | return n_tx_bytes; |
| 440 | } |
| 441 | |
| 442 | static_always_inline void |
| 443 | drop_one_buffer_and_count (vlib_main_t * vm, vnet_main_t * vnm, |
| 444 | vlib_node_runtime_t * node, u32 * pbi0, |
| 445 | u32 drop_error_code) |
| 446 | { |
| 447 | u32 thread_index = vm->thread_index; |
| 448 | vnet_interface_output_runtime_t *rt = (void *) node->runtime_data; |
| 449 | |
| 450 | vlib_simple_counter_main_t *cm; |
| 451 | cm = |
| 452 | vec_elt_at_index (vnm->interface_main.sw_if_counters, |
| 453 | VNET_INTERFACE_COUNTER_TX_ERROR); |
| 454 | vlib_increment_simple_counter (cm, thread_index, rt->sw_if_index, 1); |
| 455 | |
| 456 | vlib_error_drop_buffers (vm, node, pbi0, |
| 457 | /* buffer stride */ 1, |
| 458 | /* n_buffers */ 1, |
| 459 | VNET_INTERFACE_OUTPUT_NEXT_DROP, |
| 460 | node->node_index, drop_error_code); |
| 461 | } |
| 462 | |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 463 | static_always_inline uword |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 464 | vnet_interface_output_node_inline_gso (vlib_main_t * vm, |
| 465 | vlib_node_runtime_t * node, |
| 466 | vlib_frame_t * frame, |
| 467 | vnet_main_t * vnm, |
| 468 | vnet_hw_interface_t * hi, |
| 469 | int do_tx_offloads, |
| 470 | int do_segmentation) |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 471 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 472 | vnet_interface_output_runtime_t *rt = (void *) node->runtime_data; |
| 473 | vnet_sw_interface_t *si; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 474 | u32 n_left_to_tx, *from, *from_end, *to_tx; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 475 | u32 n_bytes, n_buffers, n_packets; |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 476 | u32 n_bytes_b0, n_bytes_b1, n_bytes_b2, n_bytes_b3; |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 477 | u32 thread_index = vm->thread_index; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 478 | vnet_interface_main_t *im = &vnm->interface_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 479 | u32 next_index = VNET_INTERFACE_OUTPUT_NEXT_TX; |
Damjan Marion | 152e21d | 2016-11-29 14:55:43 +0100 | [diff] [blame] | 480 | u32 current_config_index = ~0; |
| 481 | u8 arc = im->output_feature_arc_index; |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 482 | vnet_interface_per_thread_data_t *ptd = |
| 483 | vec_elt_at_index (im->per_thread_data, thread_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 484 | |
| 485 | n_buffers = frame->n_vectors; |
| 486 | |
| 487 | if (node->flags & VLIB_NODE_FLAG_TRACE) |
| 488 | vnet_interface_output_trace (vm, node, frame, n_buffers); |
| 489 | |
Damjan Marion | a3d5986 | 2018-11-10 10:23:00 +0100 | [diff] [blame] | 490 | from = vlib_frame_vector_args (frame); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 491 | |
| 492 | if (rt->is_deleted) |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 493 | return vlib_error_drop_buffers (vm, node, from, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 494 | /* buffer stride */ 1, |
| 495 | n_buffers, |
| 496 | VNET_INTERFACE_OUTPUT_NEXT_DROP, |
| 497 | node->node_index, |
| 498 | VNET_INTERFACE_OUTPUT_ERROR_INTERFACE_DELETED); |
| 499 | |
| 500 | si = vnet_get_sw_interface (vnm, rt->sw_if_index); |
| 501 | hi = vnet_get_sup_hw_interface (vnm, rt->sw_if_index); |
Steve Shin | 042a621 | 2017-07-07 14:57:46 -0700 | [diff] [blame] | 502 | if (!(si->flags & (VNET_SW_INTERFACE_FLAG_ADMIN_UP | |
| 503 | VNET_SW_INTERFACE_FLAG_BOND_SLAVE)) || |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 504 | !(hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 505 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 506 | vlib_simple_counter_main_t *cm; |
| 507 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 508 | cm = vec_elt_at_index (vnm->interface_main.sw_if_counters, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 509 | VNET_INTERFACE_COUNTER_TX_ERROR); |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 510 | vlib_increment_simple_counter (cm, thread_index, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 511 | rt->sw_if_index, n_buffers); |
| 512 | |
| 513 | return vlib_error_drop_buffers (vm, node, from, |
| 514 | /* buffer stride */ 1, |
| 515 | n_buffers, |
| 516 | VNET_INTERFACE_OUTPUT_NEXT_DROP, |
| 517 | node->node_index, |
| 518 | VNET_INTERFACE_OUTPUT_ERROR_INTERFACE_DOWN); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | from_end = from + n_buffers; |
| 522 | |
| 523 | /* Total byte count of all buffers. */ |
| 524 | n_bytes = 0; |
| 525 | n_packets = 0; |
| 526 | |
Damjan Marion | 152e21d | 2016-11-29 14:55:43 +0100 | [diff] [blame] | 527 | /* interface-output feature arc handling */ |
| 528 | if (PREDICT_FALSE (vnet_have_features (arc, rt->sw_if_index))) |
| 529 | { |
| 530 | vnet_feature_config_main_t *fcm; |
| 531 | fcm = vnet_feature_get_config_main (arc); |
| 532 | current_config_index = vnet_get_feature_config_index (arc, |
| 533 | rt->sw_if_index); |
| 534 | vnet_get_config_data (&fcm->config_main, ¤t_config_index, |
| 535 | &next_index, 0); |
| 536 | } |
| 537 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 538 | while (from < from_end) |
| 539 | { |
| 540 | /* Get new next frame since previous incomplete frame may have less |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 541 | than VNET_FRAME_SIZE vectors in it. */ |
| 542 | vlib_get_new_next_frame (vm, node, next_index, to_tx, n_left_to_tx); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 543 | |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 544 | while (from + 8 <= from_end && n_left_to_tx >= 4) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 545 | { |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 546 | u32 bi0, bi1, bi2, bi3; |
| 547 | vlib_buffer_t *b0, *b1, *b2, *b3; |
| 548 | u32 tx_swif0, tx_swif1, tx_swif2, tx_swif3; |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 549 | u32 or_flags; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 550 | |
| 551 | /* Prefetch next iteration. */ |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 552 | vlib_prefetch_buffer_with_index (vm, from[4], LOAD); |
| 553 | vlib_prefetch_buffer_with_index (vm, from[5], LOAD); |
| 554 | vlib_prefetch_buffer_with_index (vm, from[6], LOAD); |
| 555 | vlib_prefetch_buffer_with_index (vm, from[7], LOAD); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 556 | |
| 557 | bi0 = from[0]; |
| 558 | bi1 = from[1]; |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 559 | bi2 = from[2]; |
| 560 | bi3 = from[3]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 561 | to_tx[0] = bi0; |
| 562 | to_tx[1] = bi1; |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 563 | to_tx[2] = bi2; |
| 564 | to_tx[3] = bi3; |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 565 | if (!do_segmentation) |
| 566 | { |
| 567 | from += 4; |
| 568 | to_tx += 4; |
| 569 | n_left_to_tx -= 4; |
| 570 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 571 | |
| 572 | b0 = vlib_get_buffer (vm, bi0); |
| 573 | b1 = vlib_get_buffer (vm, bi1); |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 574 | b2 = vlib_get_buffer (vm, bi2); |
| 575 | b3 = vlib_get_buffer (vm, bi3); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 576 | |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 577 | if (do_segmentation) |
| 578 | { |
| 579 | or_flags = b0->flags | b1->flags | b2->flags | b3->flags; |
| 580 | |
| 581 | /* go to single loop if we need TSO segmentation */ |
| 582 | if (PREDICT_FALSE (or_flags & VNET_BUFFER_F_GSO)) |
| 583 | break; |
| 584 | from += 4; |
| 585 | to_tx += 4; |
| 586 | n_left_to_tx -= 4; |
| 587 | } |
| 588 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 589 | /* Be grumpy about zero length buffers for benefit of |
| 590 | driver tx function. */ |
| 591 | ASSERT (b0->current_length > 0); |
| 592 | ASSERT (b1->current_length > 0); |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 593 | ASSERT (b2->current_length > 0); |
| 594 | ASSERT (b3->current_length > 0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 595 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 596 | n_bytes_b0 = vlib_buffer_length_in_chain (vm, b0); |
| 597 | n_bytes_b1 = vlib_buffer_length_in_chain (vm, b1); |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 598 | n_bytes_b2 = vlib_buffer_length_in_chain (vm, b2); |
| 599 | n_bytes_b3 = vlib_buffer_length_in_chain (vm, b3); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 600 | tx_swif0 = vnet_buffer (b0)->sw_if_index[VLIB_TX]; |
| 601 | tx_swif1 = vnet_buffer (b1)->sw_if_index[VLIB_TX]; |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 602 | tx_swif2 = vnet_buffer (b2)->sw_if_index[VLIB_TX]; |
| 603 | tx_swif3 = vnet_buffer (b3)->sw_if_index[VLIB_TX]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 604 | |
| 605 | n_bytes += n_bytes_b0 + n_bytes_b1; |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 606 | n_bytes += n_bytes_b2 + n_bytes_b3; |
| 607 | n_packets += 4; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 608 | |
Damjan Marion | 152e21d | 2016-11-29 14:55:43 +0100 | [diff] [blame] | 609 | if (PREDICT_FALSE (current_config_index != ~0)) |
| 610 | { |
Damjan Marion | aa682a3 | 2018-04-26 22:45:40 +0200 | [diff] [blame] | 611 | vnet_buffer (b0)->feature_arc_index = arc; |
| 612 | vnet_buffer (b1)->feature_arc_index = arc; |
| 613 | vnet_buffer (b2)->feature_arc_index = arc; |
| 614 | vnet_buffer (b3)->feature_arc_index = arc; |
Damjan Marion | 152e21d | 2016-11-29 14:55:43 +0100 | [diff] [blame] | 615 | b0->current_config_index = current_config_index; |
| 616 | b1->current_config_index = current_config_index; |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 617 | b2->current_config_index = current_config_index; |
| 618 | b3->current_config_index = current_config_index; |
Damjan Marion | 152e21d | 2016-11-29 14:55:43 +0100 | [diff] [blame] | 619 | } |
| 620 | |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 621 | /* update vlan subif tx counts, if required */ |
Damjan Marion | 9c6ae5f | 2016-11-15 23:20:01 +0100 | [diff] [blame] | 622 | if (PREDICT_FALSE (tx_swif0 != rt->sw_if_index)) |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 623 | { |
Damjan Marion | 9c6ae5f | 2016-11-15 23:20:01 +0100 | [diff] [blame] | 624 | vlib_increment_combined_counter (im->combined_sw_if_counters + |
| 625 | VNET_INTERFACE_COUNTER_TX, |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 626 | thread_index, tx_swif0, 1, |
Damjan Marion | 9c6ae5f | 2016-11-15 23:20:01 +0100 | [diff] [blame] | 627 | n_bytes_b0); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 628 | } |
Damjan Marion | 9c6ae5f | 2016-11-15 23:20:01 +0100 | [diff] [blame] | 629 | |
Damjan Marion | 9c6ae5f | 2016-11-15 23:20:01 +0100 | [diff] [blame] | 630 | if (PREDICT_FALSE (tx_swif1 != rt->sw_if_index)) |
| 631 | { |
| 632 | |
| 633 | vlib_increment_combined_counter (im->combined_sw_if_counters + |
| 634 | VNET_INTERFACE_COUNTER_TX, |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 635 | thread_index, tx_swif1, 1, |
Damjan Marion | 9c6ae5f | 2016-11-15 23:20:01 +0100 | [diff] [blame] | 636 | n_bytes_b1); |
| 637 | } |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 638 | |
| 639 | if (PREDICT_FALSE (tx_swif2 != rt->sw_if_index)) |
| 640 | { |
| 641 | |
| 642 | vlib_increment_combined_counter (im->combined_sw_if_counters + |
| 643 | VNET_INTERFACE_COUNTER_TX, |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 644 | thread_index, tx_swif2, 1, |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 645 | n_bytes_b2); |
| 646 | } |
| 647 | if (PREDICT_FALSE (tx_swif3 != rt->sw_if_index)) |
| 648 | { |
| 649 | |
| 650 | vlib_increment_combined_counter (im->combined_sw_if_counters + |
| 651 | VNET_INTERFACE_COUNTER_TX, |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 652 | thread_index, tx_swif3, 1, |
Damjan Marion | 363640d | 2017-03-06 11:53:10 +0100 | [diff] [blame] | 653 | n_bytes_b3); |
| 654 | } |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 655 | |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 656 | if (!do_segmentation) |
| 657 | or_flags = b0->flags | b1->flags | b2->flags | b3->flags; |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 658 | |
| 659 | if (do_tx_offloads) |
| 660 | { |
| 661 | if (or_flags & |
| 662 | (VNET_BUFFER_F_OFFLOAD_TCP_CKSUM | |
| 663 | VNET_BUFFER_F_OFFLOAD_UDP_CKSUM | |
| 664 | VNET_BUFFER_F_OFFLOAD_IP_CKSUM)) |
| 665 | { |
| 666 | calc_checksums (vm, b0); |
| 667 | calc_checksums (vm, b1); |
| 668 | calc_checksums (vm, b2); |
| 669 | calc_checksums (vm, b3); |
| 670 | } |
| 671 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | while (from + 1 <= from_end && n_left_to_tx >= 1) |
| 675 | { |
| 676 | u32 bi0; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 677 | vlib_buffer_t *b0; |
| 678 | u32 tx_swif0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 679 | |
| 680 | bi0 = from[0]; |
| 681 | to_tx[0] = bi0; |
| 682 | from += 1; |
| 683 | to_tx += 1; |
| 684 | n_left_to_tx -= 1; |
| 685 | |
| 686 | b0 = vlib_get_buffer (vm, bi0); |
| 687 | |
| 688 | /* Be grumpy about zero length buffers for benefit of |
| 689 | driver tx function. */ |
| 690 | ASSERT (b0->current_length > 0); |
| 691 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 692 | n_bytes_b0 = vlib_buffer_length_in_chain (vm, b0); |
| 693 | tx_swif0 = vnet_buffer (b0)->sw_if_index[VLIB_TX]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 694 | n_bytes += n_bytes_b0; |
| 695 | n_packets += 1; |
| 696 | |
Damjan Marion | 152e21d | 2016-11-29 14:55:43 +0100 | [diff] [blame] | 697 | if (PREDICT_FALSE (current_config_index != ~0)) |
| 698 | { |
Damjan Marion | aa682a3 | 2018-04-26 22:45:40 +0200 | [diff] [blame] | 699 | vnet_buffer (b0)->feature_arc_index = arc; |
Damjan Marion | 152e21d | 2016-11-29 14:55:43 +0100 | [diff] [blame] | 700 | b0->current_config_index = current_config_index; |
| 701 | } |
| 702 | |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 703 | if (do_segmentation) |
| 704 | { |
| 705 | if (PREDICT_FALSE (b0->flags & VNET_BUFFER_F_GSO)) |
| 706 | { |
| 707 | /* |
| 708 | * Undo the enqueue of the b0 - it is not going anywhere, |
| 709 | * and will be freed either after it's segmented or |
| 710 | * when dropped, if there is no buffers to segment into. |
| 711 | */ |
| 712 | to_tx -= 1; |
| 713 | n_left_to_tx += 1; |
| 714 | /* undo the counting. */ |
| 715 | n_bytes -= n_bytes_b0; |
| 716 | n_packets -= 1; |
| 717 | |
| 718 | u32 n_tx_bytes = 0; |
| 719 | |
| 720 | n_tx_bytes = |
| 721 | tso_segment_buffer (vm, ptd, do_tx_offloads, bi0, b0, |
| 722 | n_bytes_b0); |
| 723 | |
| 724 | if (PREDICT_FALSE (n_tx_bytes == 0)) |
| 725 | { |
| 726 | drop_one_buffer_and_count (vm, vnm, node, from - 1, |
| 727 | VNET_INTERFACE_OUTPUT_ERROR_NO_BUFFERS_FOR_GSO); |
| 728 | continue; |
| 729 | } |
| 730 | |
| 731 | u16 n_tx_bufs = vec_len (ptd->split_buffers); |
| 732 | u32 *from_tx_seg = ptd->split_buffers; |
| 733 | |
| 734 | while (n_tx_bufs > 0) |
| 735 | { |
| 736 | if (n_tx_bufs >= n_left_to_tx) |
| 737 | { |
| 738 | while (n_left_to_tx > 0) |
| 739 | { |
| 740 | to_tx[0] = from_tx_seg[0]; |
| 741 | to_tx += 1; |
| 742 | from_tx_seg += 1; |
| 743 | n_left_to_tx -= 1; |
| 744 | n_tx_bufs -= 1; |
| 745 | n_packets += 1; |
| 746 | } |
| 747 | vlib_put_next_frame (vm, node, next_index, |
| 748 | n_left_to_tx); |
| 749 | vlib_get_new_next_frame (vm, node, next_index, |
| 750 | to_tx, n_left_to_tx); |
| 751 | } |
| 752 | else |
| 753 | { |
| 754 | while (n_tx_bufs > 0) |
| 755 | { |
| 756 | to_tx[0] = from_tx_seg[0]; |
| 757 | to_tx += 1; |
| 758 | from_tx_seg += 1; |
| 759 | n_left_to_tx -= 1; |
| 760 | n_tx_bufs -= 1; |
| 761 | n_packets += 1; |
| 762 | } |
| 763 | } |
| 764 | } |
| 765 | n_bytes += n_tx_bytes; |
| 766 | if (PREDICT_FALSE (tx_swif0 != rt->sw_if_index)) |
| 767 | { |
| 768 | |
| 769 | vlib_increment_combined_counter |
| 770 | (im->combined_sw_if_counters + |
| 771 | VNET_INTERFACE_COUNTER_TX, thread_index, tx_swif0, |
| 772 | _vec_len (ptd->split_buffers), n_tx_bytes); |
| 773 | } |
| 774 | /* The buffers were enqueued. Reset the length */ |
| 775 | _vec_len (ptd->split_buffers) = 0; |
| 776 | /* Free the now segmented buffer */ |
| 777 | vlib_buffer_free_one (vm, bi0); |
| 778 | continue; |
| 779 | } |
| 780 | } |
| 781 | |
Damjan Marion | 9c6ae5f | 2016-11-15 23:20:01 +0100 | [diff] [blame] | 782 | if (PREDICT_FALSE (tx_swif0 != rt->sw_if_index)) |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 783 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 784 | |
Damjan Marion | 9c6ae5f | 2016-11-15 23:20:01 +0100 | [diff] [blame] | 785 | vlib_increment_combined_counter (im->combined_sw_if_counters + |
| 786 | VNET_INTERFACE_COUNTER_TX, |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 787 | thread_index, tx_swif0, 1, |
Damjan Marion | 9c6ae5f | 2016-11-15 23:20:01 +0100 | [diff] [blame] | 788 | n_bytes_b0); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 789 | } |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 790 | |
| 791 | if (do_tx_offloads) |
| 792 | calc_checksums (vm, b0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 793 | } |
| 794 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 795 | vlib_put_next_frame (vm, node, next_index, n_left_to_tx); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 796 | } |
| 797 | |
| 798 | /* Update main interface stats. */ |
| 799 | vlib_increment_combined_counter (im->combined_sw_if_counters |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 800 | + VNET_INTERFACE_COUNTER_TX, |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 801 | thread_index, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 802 | rt->sw_if_index, n_packets, n_bytes); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 803 | return n_buffers; |
| 804 | } |
| 805 | |
Dave Barach | 5ecd5a5 | 2019-02-25 15:27:28 -0500 | [diff] [blame] | 806 | static_always_inline void vnet_interface_pcap_tx_trace |
| 807 | (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame, |
| 808 | int sw_if_index_from_buffer) |
| 809 | { |
| 810 | u32 n_left_from, *from; |
| 811 | u32 sw_if_index; |
| 812 | |
| 813 | if (PREDICT_TRUE (vm->pcap[VLIB_TX].pcap_enable == 0)) |
| 814 | return; |
| 815 | |
| 816 | if (sw_if_index_from_buffer == 0) |
| 817 | { |
| 818 | vnet_interface_output_runtime_t *rt = (void *) node->runtime_data; |
| 819 | sw_if_index = rt->sw_if_index; |
| 820 | } |
| 821 | else |
| 822 | sw_if_index = ~0; |
| 823 | |
| 824 | n_left_from = frame->n_vectors; |
| 825 | from = vlib_frame_vector_args (frame); |
| 826 | |
| 827 | while (n_left_from > 0) |
| 828 | { |
| 829 | u32 bi0 = from[0]; |
| 830 | vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0); |
| 831 | |
| 832 | if (sw_if_index_from_buffer) |
| 833 | sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; |
| 834 | |
| 835 | if (vm->pcap[VLIB_TX].pcap_sw_if_index == 0 || |
| 836 | vm->pcap[VLIB_TX].pcap_sw_if_index == sw_if_index) |
| 837 | pcap_add_buffer (&vm->pcap[VLIB_TX].pcap_main, vm, bi0, 512); |
| 838 | from++; |
| 839 | n_left_from--; |
| 840 | } |
| 841 | } |
| 842 | |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 843 | static_always_inline uword |
| 844 | vnet_interface_output_node_inline (vlib_main_t * vm, |
| 845 | vlib_node_runtime_t * node, |
| 846 | vlib_frame_t * frame, vnet_main_t * vnm, |
| 847 | vnet_hw_interface_t * hi, |
| 848 | int do_tx_offloads) |
| 849 | { |
Dave Barach | 5ecd5a5 | 2019-02-25 15:27:28 -0500 | [diff] [blame] | 850 | vnet_interface_pcap_tx_trace (vm, node, frame, |
| 851 | 0 /* sw_if_index_from_buffer */ ); |
| 852 | |
Andrew Yourtchenko | 6a7cff7 | 2018-10-12 16:09:22 +0200 | [diff] [blame] | 853 | /* |
| 854 | * The 3-headed "if" is here because we want to err on the side |
| 855 | * of not impacting the non-GSO performance - so for the more |
| 856 | * common case of no GSO interfaces we want to prevent the |
| 857 | * segmentation codepath from being there altogether. |
| 858 | */ |
| 859 | if (PREDICT_TRUE (vnm->interface_main.gso_interface_count == 0)) |
| 860 | return vnet_interface_output_node_inline_gso (vm, node, frame, vnm, hi, |
| 861 | do_tx_offloads, |
| 862 | /* do_segmentation */ 0); |
| 863 | else if (hi->flags & VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO) |
| 864 | return vnet_interface_output_node_inline_gso (vm, node, frame, vnm, hi, |
| 865 | do_tx_offloads, |
| 866 | /* do_segmentation */ 0); |
| 867 | else |
| 868 | return vnet_interface_output_node_inline_gso (vm, node, frame, vnm, hi, |
| 869 | do_tx_offloads, |
| 870 | /* do_segmentation */ 1); |
| 871 | } |
| 872 | |
Damjan Marion | 652d2e1 | 2019-02-02 00:15:27 +0100 | [diff] [blame] | 873 | uword |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 874 | vnet_interface_output_node (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 875 | vlib_frame_t * frame) |
| 876 | { |
| 877 | vnet_main_t *vnm = vnet_get_main (); |
| 878 | vnet_hw_interface_t *hi; |
| 879 | vnet_interface_output_runtime_t *rt = (void *) node->runtime_data; |
| 880 | hi = vnet_get_sup_hw_interface (vnm, rt->sw_if_index); |
| 881 | |
Dave Barach | 5ecd5a5 | 2019-02-25 15:27:28 -0500 | [diff] [blame] | 882 | vnet_interface_pcap_tx_trace (vm, node, frame, |
| 883 | 0 /* sw_if_index_from_buffer */ ); |
| 884 | |
Dave Barach | 2c0a4f4 | 2017-06-29 09:30:15 -0400 | [diff] [blame] | 885 | if (hi->flags & VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD) |
| 886 | return vnet_interface_output_node_inline (vm, node, frame, vnm, hi, |
| 887 | /* do_tx_offloads */ 0); |
| 888 | else |
| 889 | return vnet_interface_output_node_inline (vm, node, frame, vnm, hi, |
| 890 | /* do_tx_offloads */ 1); |
| 891 | } |
| 892 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 893 | /* Use buffer's sw_if_index[VNET_TX] to choose output interface. */ |
| 894 | static uword |
| 895 | vnet_per_buffer_interface_output (vlib_main_t * vm, |
| 896 | vlib_node_runtime_t * node, |
| 897 | vlib_frame_t * frame) |
| 898 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 899 | vnet_main_t *vnm = vnet_get_main (); |
| 900 | u32 n_left_to_next, *from, *to_next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 901 | u32 n_left_from, next_index; |
| 902 | |
Dave Barach | 5ecd5a5 | 2019-02-25 15:27:28 -0500 | [diff] [blame] | 903 | vnet_interface_pcap_tx_trace (vm, node, frame, |
| 904 | 1 /* sw_if_index_from_buffer */ ); |
| 905 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 906 | n_left_from = frame->n_vectors; |
| 907 | |
Damjan Marion | a3d5986 | 2018-11-10 10:23:00 +0100 | [diff] [blame] | 908 | from = vlib_frame_vector_args (frame); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 909 | next_index = node->cached_next_index; |
| 910 | |
| 911 | while (n_left_from > 0) |
| 912 | { |
| 913 | vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); |
| 914 | |
| 915 | while (n_left_from >= 4 && n_left_to_next >= 2) |
| 916 | { |
| 917 | u32 bi0, bi1, next0, next1; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 918 | vlib_buffer_t *b0, *b1; |
| 919 | vnet_hw_interface_t *hi0, *hi1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 920 | |
| 921 | /* Prefetch next iteration. */ |
| 922 | vlib_prefetch_buffer_with_index (vm, from[2], LOAD); |
| 923 | vlib_prefetch_buffer_with_index (vm, from[3], LOAD); |
| 924 | |
| 925 | bi0 = from[0]; |
| 926 | bi1 = from[1]; |
| 927 | to_next[0] = bi0; |
| 928 | to_next[1] = bi1; |
| 929 | from += 2; |
| 930 | to_next += 2; |
| 931 | n_left_to_next -= 2; |
| 932 | n_left_from -= 2; |
| 933 | |
| 934 | b0 = vlib_get_buffer (vm, bi0); |
| 935 | b1 = vlib_get_buffer (vm, bi1); |
| 936 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 937 | hi0 = |
| 938 | vnet_get_sup_hw_interface (vnm, |
| 939 | vnet_buffer (b0)->sw_if_index |
| 940 | [VLIB_TX]); |
| 941 | hi1 = |
| 942 | vnet_get_sup_hw_interface (vnm, |
| 943 | vnet_buffer (b1)->sw_if_index |
| 944 | [VLIB_TX]); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 945 | |
John Lo | e5453d0 | 2018-01-23 19:21:34 -0500 | [diff] [blame] | 946 | next0 = hi0->output_node_next_index; |
| 947 | next1 = hi1->output_node_next_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 948 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 949 | vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next, |
| 950 | n_left_to_next, bi0, bi1, next0, |
| 951 | next1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 952 | } |
| 953 | |
| 954 | while (n_left_from > 0 && n_left_to_next > 0) |
| 955 | { |
| 956 | u32 bi0, next0; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 957 | vlib_buffer_t *b0; |
| 958 | vnet_hw_interface_t *hi0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 959 | |
| 960 | bi0 = from[0]; |
| 961 | to_next[0] = bi0; |
| 962 | from += 1; |
| 963 | to_next += 1; |
| 964 | n_left_to_next -= 1; |
| 965 | n_left_from -= 1; |
| 966 | |
| 967 | b0 = vlib_get_buffer (vm, bi0); |
| 968 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 969 | hi0 = |
| 970 | vnet_get_sup_hw_interface (vnm, |
| 971 | vnet_buffer (b0)->sw_if_index |
| 972 | [VLIB_TX]); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 973 | |
John Lo | e5453d0 | 2018-01-23 19:21:34 -0500 | [diff] [blame] | 974 | next0 = hi0->output_node_next_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 975 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 976 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, |
| 977 | n_left_to_next, bi0, next0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 981 | } |
| 982 | |
| 983 | return frame->n_vectors; |
| 984 | } |
| 985 | |
| 986 | always_inline u32 |
| 987 | counter_index (vlib_main_t * vm, vlib_error_t e) |
| 988 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 989 | vlib_node_t *n; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 990 | u32 ci, ni; |
| 991 | |
| 992 | ni = vlib_error_get_node (e); |
| 993 | n = vlib_get_node (vm, ni); |
| 994 | |
| 995 | ci = vlib_error_get_code (e); |
| 996 | ASSERT (ci < n->n_errors); |
| 997 | |
| 998 | ci += n->error_heap_index; |
| 999 | |
| 1000 | return ci; |
| 1001 | } |
| 1002 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1003 | static u8 * |
| 1004 | format_vnet_error_trace (u8 * s, va_list * va) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1005 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1006 | vlib_main_t *vm = va_arg (*va, vlib_main_t *); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1007 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1008 | vlib_error_t *e = va_arg (*va, vlib_error_t *); |
| 1009 | vlib_node_t *error_node; |
| 1010 | vlib_error_main_t *em = &vm->error_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1011 | u32 i; |
| 1012 | |
| 1013 | error_node = vlib_get_node (vm, vlib_error_get_node (e[0])); |
| 1014 | i = counter_index (vm, e[0]); |
| 1015 | s = format (s, "%v: %s", error_node->name, em->error_strings_heap[i]); |
| 1016 | |
| 1017 | return s; |
| 1018 | } |
| 1019 | |
| 1020 | static void |
| 1021 | trace_errors_with_buffers (vlib_main_t * vm, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1022 | vlib_node_runtime_t * node, vlib_frame_t * frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1023 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1024 | u32 n_left, *buffers; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1025 | |
| 1026 | buffers = vlib_frame_vector_args (frame); |
| 1027 | n_left = frame->n_vectors; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1028 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1029 | while (n_left >= 4) |
| 1030 | { |
| 1031 | u32 bi0, bi1; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1032 | vlib_buffer_t *b0, *b1; |
| 1033 | vlib_error_t *t0, *t1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1034 | |
| 1035 | /* Prefetch next iteration. */ |
| 1036 | vlib_prefetch_buffer_with_index (vm, buffers[2], LOAD); |
| 1037 | vlib_prefetch_buffer_with_index (vm, buffers[3], LOAD); |
| 1038 | |
| 1039 | bi0 = buffers[0]; |
| 1040 | bi1 = buffers[1]; |
| 1041 | |
| 1042 | b0 = vlib_get_buffer (vm, bi0); |
| 1043 | b1 = vlib_get_buffer (vm, bi1); |
| 1044 | |
| 1045 | if (b0->flags & VLIB_BUFFER_IS_TRACED) |
| 1046 | { |
| 1047 | t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0])); |
| 1048 | t0[0] = b0->error; |
| 1049 | } |
| 1050 | if (b1->flags & VLIB_BUFFER_IS_TRACED) |
| 1051 | { |
| 1052 | t1 = vlib_add_trace (vm, node, b1, sizeof (t1[0])); |
| 1053 | t1[0] = b1->error; |
| 1054 | } |
| 1055 | buffers += 2; |
| 1056 | n_left -= 2; |
| 1057 | } |
| 1058 | |
| 1059 | while (n_left >= 1) |
| 1060 | { |
| 1061 | u32 bi0; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1062 | vlib_buffer_t *b0; |
| 1063 | vlib_error_t *t0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1064 | |
| 1065 | bi0 = buffers[0]; |
| 1066 | |
| 1067 | b0 = vlib_get_buffer (vm, bi0); |
| 1068 | |
| 1069 | if (b0->flags & VLIB_BUFFER_IS_TRACED) |
| 1070 | { |
| 1071 | t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0])); |
| 1072 | t0[0] = b0->error; |
| 1073 | } |
| 1074 | buffers += 1; |
| 1075 | n_left -= 1; |
| 1076 | } |
| 1077 | } |
| 1078 | |
| 1079 | static u8 * |
| 1080 | validate_error (vlib_main_t * vm, vlib_error_t * e, u32 index) |
| 1081 | { |
| 1082 | uword node_index = vlib_error_get_node (e[0]); |
| 1083 | uword code = vlib_error_get_code (e[0]); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1084 | vlib_node_t *n; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1085 | |
| 1086 | if (node_index >= vec_len (vm->node_main.nodes)) |
| 1087 | return format (0, "[%d], node index out of range 0x%x, error 0x%x", |
| 1088 | index, node_index, e[0]); |
| 1089 | |
| 1090 | n = vlib_get_node (vm, node_index); |
| 1091 | if (code >= n->n_errors) |
| 1092 | return format (0, "[%d], code %d out of range for node %v", |
| 1093 | index, code, n->name); |
| 1094 | |
| 1095 | return 0; |
| 1096 | } |
| 1097 | |
| 1098 | static u8 * |
| 1099 | validate_error_frame (vlib_main_t * vm, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1100 | vlib_node_runtime_t * node, vlib_frame_t * f) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1101 | { |
Damjan Marion | a3d5986 | 2018-11-10 10:23:00 +0100 | [diff] [blame] | 1102 | u32 *buffers = vlib_frame_vector_args (f); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1103 | vlib_buffer_t *b; |
| 1104 | u8 *msg = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1105 | uword i; |
| 1106 | |
| 1107 | for (i = 0; i < f->n_vectors; i++) |
| 1108 | { |
| 1109 | b = vlib_get_buffer (vm, buffers[i]); |
| 1110 | msg = validate_error (vm, &b->error, i); |
| 1111 | if (msg) |
| 1112 | return msg; |
| 1113 | } |
| 1114 | |
| 1115 | return msg; |
| 1116 | } |
| 1117 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1118 | typedef enum |
| 1119 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1120 | VNET_ERROR_DISPOSITION_DROP, |
| 1121 | VNET_ERROR_DISPOSITION_PUNT, |
| 1122 | VNET_ERROR_N_DISPOSITION, |
| 1123 | } vnet_error_disposition_t; |
| 1124 | |
| 1125 | always_inline void |
| 1126 | do_packet (vlib_main_t * vm, vlib_error_t a) |
| 1127 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1128 | vlib_error_main_t *em = &vm->error_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1129 | u32 i = counter_index (vm, a); |
| 1130 | em->counters[i] += 1; |
| 1131 | vlib_error_elog_count (vm, i, 1); |
| 1132 | } |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1133 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1134 | static_always_inline uword |
| 1135 | process_drop_punt (vlib_main_t * vm, |
| 1136 | vlib_node_runtime_t * node, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1137 | vlib_frame_t * frame, vnet_error_disposition_t disposition) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1138 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1139 | vnet_main_t *vnm = vnet_get_main (); |
| 1140 | vlib_error_main_t *em = &vm->error_main; |
| 1141 | u32 *buffers, *first_buffer; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1142 | vlib_error_t current_error; |
| 1143 | u32 current_counter_index, n_errors_left; |
| 1144 | u32 current_sw_if_index, n_errors_current_sw_if_index; |
| 1145 | u64 current_counter; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1146 | vlib_simple_counter_main_t *cm; |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 1147 | u32 thread_index = vm->thread_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1148 | |
| 1149 | static vlib_error_t memory[VNET_ERROR_N_DISPOSITION]; |
| 1150 | static char memory_init[VNET_ERROR_N_DISPOSITION]; |
| 1151 | |
Damjan Marion | a3d5986 | 2018-11-10 10:23:00 +0100 | [diff] [blame] | 1152 | buffers = vlib_frame_vector_args (frame); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1153 | first_buffer = buffers; |
| 1154 | |
| 1155 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1156 | vlib_buffer_t *b = vlib_get_buffer (vm, first_buffer[0]); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1157 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1158 | if (!memory_init[disposition]) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1159 | { |
| 1160 | memory_init[disposition] = 1; |
| 1161 | memory[disposition] = b->error; |
| 1162 | } |
| 1163 | |
| 1164 | current_sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX]; |
| 1165 | n_errors_current_sw_if_index = 0; |
| 1166 | } |
| 1167 | |
| 1168 | current_error = memory[disposition]; |
| 1169 | current_counter_index = counter_index (vm, memory[disposition]); |
| 1170 | current_counter = em->counters[current_counter_index]; |
| 1171 | |
| 1172 | if (node->flags & VLIB_NODE_FLAG_TRACE) |
| 1173 | trace_errors_with_buffers (vm, node, frame); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1174 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1175 | n_errors_left = frame->n_vectors; |
| 1176 | cm = vec_elt_at_index (vnm->interface_main.sw_if_counters, |
| 1177 | (disposition == VNET_ERROR_DISPOSITION_PUNT |
| 1178 | ? VNET_INTERFACE_COUNTER_PUNT |
| 1179 | : VNET_INTERFACE_COUNTER_DROP)); |
| 1180 | |
| 1181 | while (n_errors_left >= 2) |
| 1182 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1183 | vlib_buffer_t *b0, *b1; |
| 1184 | vnet_sw_interface_t *sw_if0, *sw_if1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1185 | vlib_error_t e0, e1; |
| 1186 | u32 bi0, bi1; |
| 1187 | u32 sw_if_index0, sw_if_index1; |
| 1188 | |
| 1189 | bi0 = buffers[0]; |
| 1190 | bi1 = buffers[1]; |
| 1191 | |
| 1192 | buffers += 2; |
| 1193 | n_errors_left -= 2; |
| 1194 | |
| 1195 | b0 = vlib_get_buffer (vm, bi0); |
| 1196 | b1 = vlib_get_buffer (vm, bi1); |
| 1197 | |
| 1198 | e0 = b0->error; |
| 1199 | e1 = b1->error; |
| 1200 | |
| 1201 | sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX]; |
| 1202 | sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX]; |
| 1203 | |
| 1204 | /* Speculate that sw_if_index == sw_if_index[01]. */ |
| 1205 | n_errors_current_sw_if_index += 2; |
| 1206 | |
| 1207 | /* Speculatively assume all 2 (node, code) pairs are equal |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1208 | to current (node, code). */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1209 | current_counter += 2; |
| 1210 | |
| 1211 | if (PREDICT_FALSE (e0 != current_error |
| 1212 | || e1 != current_error |
| 1213 | || sw_if_index0 != current_sw_if_index |
| 1214 | || sw_if_index1 != current_sw_if_index)) |
| 1215 | { |
| 1216 | current_counter -= 2; |
| 1217 | n_errors_current_sw_if_index -= 2; |
| 1218 | |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 1219 | vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1); |
| 1220 | vlib_increment_simple_counter (cm, thread_index, sw_if_index1, 1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1221 | |
| 1222 | /* Increment super-interface drop/punt counters for |
| 1223 | sub-interfaces. */ |
| 1224 | sw_if0 = vnet_get_sw_interface (vnm, sw_if_index0); |
| 1225 | vlib_increment_simple_counter |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 1226 | (cm, thread_index, sw_if0->sup_sw_if_index, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1227 | sw_if0->sup_sw_if_index != sw_if_index0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1228 | |
| 1229 | sw_if1 = vnet_get_sw_interface (vnm, sw_if_index1); |
| 1230 | vlib_increment_simple_counter |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 1231 | (cm, thread_index, sw_if1->sup_sw_if_index, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1232 | sw_if1->sup_sw_if_index != sw_if_index1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1233 | |
| 1234 | em->counters[current_counter_index] = current_counter; |
| 1235 | do_packet (vm, e0); |
| 1236 | do_packet (vm, e1); |
| 1237 | |
| 1238 | /* For 2 repeated errors, change current error. */ |
| 1239 | if (e0 == e1 && e1 != current_error) |
| 1240 | { |
| 1241 | current_error = e0; |
| 1242 | current_counter_index = counter_index (vm, e0); |
| 1243 | } |
| 1244 | current_counter = em->counters[current_counter_index]; |
| 1245 | } |
| 1246 | } |
| 1247 | |
| 1248 | while (n_errors_left >= 1) |
| 1249 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1250 | vlib_buffer_t *b0; |
| 1251 | vnet_sw_interface_t *sw_if0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1252 | vlib_error_t e0; |
| 1253 | u32 bi0, sw_if_index0; |
| 1254 | |
| 1255 | bi0 = buffers[0]; |
| 1256 | |
| 1257 | buffers += 1; |
| 1258 | n_errors_left -= 1; |
| 1259 | current_counter += 1; |
| 1260 | |
| 1261 | b0 = vlib_get_buffer (vm, bi0); |
| 1262 | e0 = b0->error; |
| 1263 | |
| 1264 | sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX]; |
| 1265 | |
| 1266 | /* Increment drop/punt counters. */ |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 1267 | vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1268 | |
| 1269 | /* Increment super-interface drop/punt counters for sub-interfaces. */ |
| 1270 | sw_if0 = vnet_get_sw_interface (vnm, sw_if_index0); |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 1271 | vlib_increment_simple_counter (cm, thread_index, |
| 1272 | sw_if0->sup_sw_if_index, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1273 | sw_if0->sup_sw_if_index != sw_if_index0); |
| 1274 | |
| 1275 | if (PREDICT_FALSE (e0 != current_error)) |
| 1276 | { |
| 1277 | current_counter -= 1; |
| 1278 | |
| 1279 | vlib_error_elog_count (vm, current_counter_index, |
| 1280 | (current_counter |
| 1281 | - em->counters[current_counter_index])); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1282 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1283 | em->counters[current_counter_index] = current_counter; |
| 1284 | |
| 1285 | do_packet (vm, e0); |
| 1286 | current_error = e0; |
| 1287 | current_counter_index = counter_index (vm, e0); |
| 1288 | current_counter = em->counters[current_counter_index]; |
| 1289 | } |
| 1290 | } |
| 1291 | |
| 1292 | if (n_errors_current_sw_if_index > 0) |
| 1293 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1294 | vnet_sw_interface_t *si; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1295 | |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 1296 | vlib_increment_simple_counter (cm, thread_index, current_sw_if_index, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1297 | n_errors_current_sw_if_index); |
| 1298 | |
| 1299 | si = vnet_get_sw_interface (vnm, current_sw_if_index); |
| 1300 | if (si->sup_sw_if_index != current_sw_if_index) |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 1301 | vlib_increment_simple_counter (cm, thread_index, si->sup_sw_if_index, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1302 | n_errors_current_sw_if_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1303 | } |
| 1304 | |
| 1305 | vlib_error_elog_count (vm, current_counter_index, |
| 1306 | (current_counter |
| 1307 | - em->counters[current_counter_index])); |
| 1308 | |
| 1309 | /* Return cached counter. */ |
| 1310 | em->counters[current_counter_index] = current_counter; |
| 1311 | |
| 1312 | /* Save memory for next iteration. */ |
| 1313 | memory[disposition] = current_error; |
| 1314 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1315 | if (disposition == VNET_ERROR_DISPOSITION_DROP || !vm->os_punt_frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1316 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1317 | vlib_buffer_free (vm, first_buffer, frame->n_vectors); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1318 | |
| 1319 | /* If there is no punt function, free the frame as well. */ |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1320 | if (disposition == VNET_ERROR_DISPOSITION_PUNT && !vm->os_punt_frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1321 | vlib_frame_free (vm, node, frame); |
| 1322 | } |
| 1323 | else |
| 1324 | vm->os_punt_frame (vm, node, frame); |
| 1325 | |
| 1326 | return frame->n_vectors; |
| 1327 | } |
| 1328 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1329 | static inline void |
| 1330 | pcap_drop_trace (vlib_main_t * vm, |
| 1331 | vnet_interface_main_t * im, vlib_frame_t * f) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1332 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1333 | u32 *from; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1334 | u32 n_left = f->n_vectors; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1335 | vlib_buffer_t *b0, *p1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1336 | u32 bi0; |
| 1337 | i16 save_current_data; |
| 1338 | u16 save_current_length; |
| 1339 | |
| 1340 | from = vlib_frame_vector_args (f); |
| 1341 | |
| 1342 | while (n_left > 0) |
| 1343 | { |
| 1344 | if (PREDICT_TRUE (n_left > 1)) |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1345 | { |
| 1346 | p1 = vlib_get_buffer (vm, from[1]); |
| 1347 | vlib_prefetch_buffer_header (p1, LOAD); |
| 1348 | } |
| 1349 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1350 | bi0 = from[0]; |
| 1351 | b0 = vlib_get_buffer (vm, bi0); |
| 1352 | from++; |
| 1353 | n_left--; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1354 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1355 | /* See if we're pointedly ignoring this specific error */ |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1356 | if (im->pcap_drop_filter_hash |
| 1357 | && hash_get (im->pcap_drop_filter_hash, b0->error)) |
| 1358 | continue; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1359 | |
| 1360 | /* Trace all drops, or drops received on a specific interface */ |
| 1361 | if (im->pcap_sw_if_index == 0 || |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1362 | im->pcap_sw_if_index == vnet_buffer (b0)->sw_if_index[VLIB_RX]) |
| 1363 | { |
| 1364 | save_current_data = b0->current_data; |
| 1365 | save_current_length = b0->current_length; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1366 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1367 | /* |
| 1368 | * Typically, we'll need to rewind the buffer |
| 1369 | */ |
| 1370 | if (b0->current_data > 0) |
| 1371 | vlib_buffer_advance (b0, (word) - b0->current_data); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1372 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1373 | pcap_add_buffer (&im->pcap_main, vm, bi0, 512); |
| 1374 | |
| 1375 | b0->current_data = save_current_data; |
| 1376 | b0->current_length = save_current_length; |
| 1377 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1378 | } |
| 1379 | } |
| 1380 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1381 | void |
| 1382 | vnet_pcap_drop_trace_filter_add_del (u32 error_index, int is_add) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1383 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1384 | vnet_interface_main_t *im = &vnet_get_main ()->interface_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1385 | |
| 1386 | if (im->pcap_drop_filter_hash == 0) |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1387 | im->pcap_drop_filter_hash = hash_create (0, sizeof (uword)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1388 | |
| 1389 | if (is_add) |
| 1390 | hash_set (im->pcap_drop_filter_hash, error_index, 1); |
| 1391 | else |
| 1392 | hash_unset (im->pcap_drop_filter_hash, error_index); |
| 1393 | } |
| 1394 | |
| 1395 | static uword |
| 1396 | process_drop (vlib_main_t * vm, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1397 | vlib_node_runtime_t * node, vlib_frame_t * frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1398 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1399 | vnet_interface_main_t *im = &vnet_get_main ()->interface_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1400 | |
| 1401 | if (PREDICT_FALSE (im->drop_pcap_enable)) |
| 1402 | pcap_drop_trace (vm, im, frame); |
| 1403 | |
| 1404 | return process_drop_punt (vm, node, frame, VNET_ERROR_DISPOSITION_DROP); |
| 1405 | } |
| 1406 | |
| 1407 | static uword |
| 1408 | process_punt (vlib_main_t * vm, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1409 | vlib_node_runtime_t * node, vlib_frame_t * frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1410 | { |
| 1411 | return process_drop_punt (vm, node, frame, VNET_ERROR_DISPOSITION_PUNT); |
| 1412 | } |
| 1413 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1414 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1415 | VLIB_REGISTER_NODE (drop_buffers,static) = { |
| 1416 | .function = process_drop, |
| 1417 | .name = "error-drop", |
| 1418 | .flags = VLIB_NODE_FLAG_IS_DROP, |
| 1419 | .vector_size = sizeof (u32), |
| 1420 | .format_trace = format_vnet_error_trace, |
| 1421 | .validate_frame = validate_error_frame, |
| 1422 | }; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1423 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1424 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1425 | VLIB_NODE_FUNCTION_MULTIARCH (drop_buffers, process_drop); |
Damjan Marion | 1c80e83 | 2016-05-11 23:07:18 +0200 | [diff] [blame] | 1426 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1427 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1428 | VLIB_REGISTER_NODE (punt_buffers,static) = { |
| 1429 | .function = process_punt, |
| 1430 | .flags = (VLIB_NODE_FLAG_FRAME_NO_FREE_AFTER_DISPATCH |
| 1431 | | VLIB_NODE_FLAG_IS_PUNT), |
| 1432 | .name = "error-punt", |
| 1433 | .vector_size = sizeof (u32), |
| 1434 | .format_trace = format_vnet_error_trace, |
| 1435 | .validate_frame = validate_error_frame, |
| 1436 | }; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1437 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1438 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1439 | VLIB_NODE_FUNCTION_MULTIARCH (punt_buffers, process_punt); |
Damjan Marion | 1c80e83 | 2016-05-11 23:07:18 +0200 | [diff] [blame] | 1440 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1441 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1442 | VLIB_REGISTER_NODE (vnet_per_buffer_interface_output_node,static) = { |
| 1443 | .function = vnet_per_buffer_interface_output, |
| 1444 | .name = "interface-output", |
| 1445 | .vector_size = sizeof (u32), |
| 1446 | }; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1447 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1448 | |
Dave Barach | 8704097 | 2019-01-24 15:12:53 -0500 | [diff] [blame] | 1449 | /* Convenience node to drop a vector of buffers with a "misc error". */ |
| 1450 | static uword |
| 1451 | misc_drop_buffers (vlib_main_t * vm, |
| 1452 | vlib_node_runtime_t * node, vlib_frame_t * frame) |
| 1453 | { |
| 1454 | return vlib_error_drop_buffers (vm, node, vlib_frame_vector_args (frame), |
| 1455 | /* buffer stride */ 1, |
| 1456 | frame->n_vectors, |
| 1457 | /* next */ 0, |
| 1458 | node->node_index, |
| 1459 | /* error */ 0); |
| 1460 | } |
| 1461 | |
| 1462 | static char *misc_drop_buffers_error_strings[] = { |
| 1463 | [0] = "misc. errors", |
| 1464 | }; |
| 1465 | |
| 1466 | /* *INDENT-OFF* */ |
| 1467 | VLIB_REGISTER_NODE (misc_drop_buffers_node,static) = { |
| 1468 | .function = misc_drop_buffers, |
| 1469 | .name = "misc-drop-buffers", |
| 1470 | .vector_size = sizeof (u32), |
| 1471 | .n_errors = 1, |
| 1472 | .n_next_nodes = 1, |
| 1473 | .next_nodes = { |
| 1474 | "error-drop", |
| 1475 | }, |
| 1476 | .error_strings = misc_drop_buffers_error_strings, |
| 1477 | }; |
| 1478 | /* *INDENT-ON* */ |
| 1479 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1480 | VLIB_NODE_FUNCTION_MULTIARCH (vnet_per_buffer_interface_output_node, |
| 1481 | vnet_per_buffer_interface_output); |
Damjan Marion | 1c80e83 | 2016-05-11 23:07:18 +0200 | [diff] [blame] | 1482 | |
Damjan Marion | 152e21d | 2016-11-29 14:55:43 +0100 | [diff] [blame] | 1483 | static uword |
| 1484 | interface_tx_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 1485 | vlib_frame_t * from_frame) |
| 1486 | { |
| 1487 | vnet_main_t *vnm = vnet_get_main (); |
| 1488 | u32 last_sw_if_index = ~0; |
| 1489 | vlib_frame_t *to_frame = 0; |
| 1490 | vnet_hw_interface_t *hw = 0; |
| 1491 | u32 *from, *to_next = 0; |
| 1492 | u32 n_left_from; |
| 1493 | |
| 1494 | from = vlib_frame_vector_args (from_frame); |
| 1495 | n_left_from = from_frame->n_vectors; |
| 1496 | while (n_left_from > 0) |
| 1497 | { |
| 1498 | u32 bi0; |
| 1499 | vlib_buffer_t *b0; |
| 1500 | u32 sw_if_index0; |
| 1501 | |
| 1502 | bi0 = from[0]; |
| 1503 | from++; |
| 1504 | n_left_from--; |
| 1505 | b0 = vlib_get_buffer (vm, bi0); |
| 1506 | sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX]; |
| 1507 | |
| 1508 | if (PREDICT_FALSE ((last_sw_if_index != sw_if_index0) || to_frame == 0)) |
| 1509 | { |
| 1510 | if (to_frame) |
| 1511 | { |
| 1512 | hw = vnet_get_sup_hw_interface (vnm, last_sw_if_index); |
| 1513 | vlib_put_frame_to_node (vm, hw->tx_node_index, to_frame); |
| 1514 | } |
| 1515 | last_sw_if_index = sw_if_index0; |
| 1516 | hw = vnet_get_sup_hw_interface (vnm, sw_if_index0); |
| 1517 | to_frame = vlib_get_frame_to_node (vm, hw->tx_node_index); |
| 1518 | to_next = vlib_frame_vector_args (to_frame); |
| 1519 | } |
| 1520 | |
| 1521 | to_next[0] = bi0; |
| 1522 | to_next++; |
| 1523 | to_frame->n_vectors++; |
| 1524 | } |
| 1525 | vlib_put_frame_to_node (vm, hw->tx_node_index, to_frame); |
| 1526 | return from_frame->n_vectors; |
| 1527 | } |
| 1528 | |
| 1529 | /* *INDENT-OFF* */ |
| 1530 | VLIB_REGISTER_NODE (interface_tx, static) = { |
| 1531 | .function = interface_tx_node_fn, |
| 1532 | .name = "interface-tx", |
| 1533 | .vector_size = sizeof (u32), |
| 1534 | .n_next_nodes = 1, |
| 1535 | .next_nodes = { |
| 1536 | [0] = "error-drop", |
| 1537 | }, |
| 1538 | }; |
| 1539 | |
| 1540 | VNET_FEATURE_ARC_INIT (interface_output, static) = |
| 1541 | { |
| 1542 | .arc_name = "interface-output", |
| 1543 | .start_nodes = VNET_FEATURES (0), |
Dave Barach | a25def7 | 2018-11-26 11:04:45 -0500 | [diff] [blame] | 1544 | .last_in_arc = "interface-tx", |
Damjan Marion | 152e21d | 2016-11-29 14:55:43 +0100 | [diff] [blame] | 1545 | .arc_index_ptr = &vnet_main.interface_main.output_feature_arc_index, |
| 1546 | }; |
| 1547 | |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 1548 | VNET_FEATURE_INIT (span_tx, static) = { |
| 1549 | .arc_name = "interface-output", |
| 1550 | .node_name = "span-output", |
| 1551 | .runs_before = VNET_FEATURES ("interface-tx"), |
| 1552 | }; |
| 1553 | |
Matthew Smith | 537eeec | 2018-04-09 11:49:20 -0500 | [diff] [blame] | 1554 | VNET_FEATURE_INIT (ipsec_if_tx, static) = { |
| 1555 | .arc_name = "interface-output", |
| 1556 | .node_name = "ipsec-if-output", |
| 1557 | .runs_before = VNET_FEATURES ("interface-tx"), |
| 1558 | }; |
| 1559 | |
Damjan Marion | 152e21d | 2016-11-29 14:55:43 +0100 | [diff] [blame] | 1560 | VNET_FEATURE_INIT (interface_tx, static) = { |
| 1561 | .arc_name = "interface-output", |
| 1562 | .node_name = "interface-tx", |
| 1563 | .runs_before = 0, |
| 1564 | }; |
| 1565 | /* *INDENT-ON* */ |
| 1566 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1567 | clib_error_t * |
| 1568 | vnet_per_buffer_interface_output_hw_interface_add_del (vnet_main_t * vnm, |
| 1569 | u32 hw_if_index, |
| 1570 | u32 is_create) |
| 1571 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1572 | vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1573 | u32 next_index; |
| 1574 | |
John Lo | e5453d0 | 2018-01-23 19:21:34 -0500 | [diff] [blame] | 1575 | if (hi->output_node_index == 0) |
| 1576 | return 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1577 | |
John Lo | e5453d0 | 2018-01-23 19:21:34 -0500 | [diff] [blame] | 1578 | next_index = vlib_node_add_next |
| 1579 | (vnm->vlib_main, vnet_per_buffer_interface_output_node.index, |
| 1580 | hi->output_node_index); |
| 1581 | hi->output_node_next_index = next_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1582 | |
| 1583 | return 0; |
| 1584 | } |
| 1585 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1586 | VNET_HW_INTERFACE_ADD_DEL_FUNCTION |
| 1587 | (vnet_per_buffer_interface_output_hw_interface_add_del); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1588 | |
John Lo | e5453d0 | 2018-01-23 19:21:34 -0500 | [diff] [blame] | 1589 | void |
| 1590 | vnet_set_interface_output_node (vnet_main_t * vnm, |
| 1591 | u32 hw_if_index, u32 node_index) |
| 1592 | { |
| 1593 | ASSERT (node_index); |
| 1594 | vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index); |
| 1595 | u32 next_index = vlib_node_add_next |
| 1596 | (vnm->vlib_main, vnet_per_buffer_interface_output_node.index, node_index); |
| 1597 | hi->output_node_next_index = next_index; |
| 1598 | hi->output_node_index = node_index; |
| 1599 | } |
| 1600 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1601 | static clib_error_t * |
| 1602 | pcap_drop_trace_command_fn (vlib_main_t * vm, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1603 | unformat_input_t * input, |
| 1604 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1605 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1606 | vnet_main_t *vnm = vnet_get_main (); |
| 1607 | vnet_interface_main_t *im = &vnm->interface_main; |
| 1608 | u8 *filename; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1609 | u32 max; |
| 1610 | int matched = 0; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1611 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1612 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1613 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1614 | { |
| 1615 | if (unformat (input, "on")) |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1616 | { |
| 1617 | if (im->drop_pcap_enable == 0) |
| 1618 | { |
| 1619 | if (im->pcap_filename == 0) |
| 1620 | im->pcap_filename = format (0, "/tmp/drop.pcap%c", 0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1621 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 1622 | clib_memset (&im->pcap_main, 0, sizeof (im->pcap_main)); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1623 | im->pcap_main.file_name = (char *) im->pcap_filename; |
| 1624 | im->pcap_main.n_packets_to_capture = 100; |
| 1625 | if (im->pcap_pkts_to_capture) |
| 1626 | im->pcap_main.n_packets_to_capture = im->pcap_pkts_to_capture; |
| 1627 | |
| 1628 | im->pcap_main.packet_type = PCAP_PACKET_TYPE_ethernet; |
| 1629 | im->drop_pcap_enable = 1; |
| 1630 | matched = 1; |
| 1631 | vlib_cli_output (vm, "pcap drop capture on..."); |
| 1632 | } |
| 1633 | else |
| 1634 | { |
| 1635 | vlib_cli_output (vm, "pcap drop capture already on..."); |
| 1636 | } |
| 1637 | matched = 1; |
| 1638 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1639 | else if (unformat (input, "off")) |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1640 | { |
| 1641 | matched = 1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1642 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1643 | if (im->drop_pcap_enable) |
| 1644 | { |
| 1645 | vlib_cli_output (vm, "captured %d pkts...", |
| 1646 | im->pcap_main.n_packets_captured); |
| 1647 | if (im->pcap_main.n_packets_captured) |
| 1648 | { |
| 1649 | im->pcap_main.n_packets_to_capture = |
| 1650 | im->pcap_main.n_packets_captured; |
| 1651 | error = pcap_write (&im->pcap_main); |
| 1652 | if (error) |
| 1653 | clib_error_report (error); |
| 1654 | else |
| 1655 | vlib_cli_output (vm, "saved to %s...", im->pcap_filename); |
| 1656 | } |
| 1657 | } |
| 1658 | else |
| 1659 | { |
| 1660 | vlib_cli_output (vm, "pcap drop capture already off..."); |
| 1661 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1662 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1663 | im->drop_pcap_enable = 0; |
| 1664 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1665 | else if (unformat (input, "max %d", &max)) |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1666 | { |
| 1667 | im->pcap_pkts_to_capture = max; |
| 1668 | matched = 1; |
| 1669 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1670 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1671 | else if (unformat (input, "intfc %U", |
| 1672 | unformat_vnet_sw_interface, vnm, |
| 1673 | &im->pcap_sw_if_index)) |
| 1674 | matched = 1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1675 | else if (unformat (input, "intfc any")) |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1676 | { |
| 1677 | im->pcap_sw_if_index = 0; |
| 1678 | matched = 1; |
| 1679 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1680 | else if (unformat (input, "file %s", &filename)) |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1681 | { |
| 1682 | u8 *chroot_filename; |
| 1683 | /* Brain-police user path input */ |
| 1684 | if (strstr ((char *) filename, "..") |
| 1685 | || index ((char *) filename, '/')) |
| 1686 | { |
| 1687 | vlib_cli_output (vm, "illegal characters in filename '%s'", |
| 1688 | filename); |
| 1689 | continue; |
| 1690 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1691 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1692 | chroot_filename = format (0, "/tmp/%s%c", filename, 0); |
| 1693 | vec_free (filename); |
| 1694 | |
| 1695 | if (im->pcap_filename) |
| 1696 | vec_free (im->pcap_filename); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1697 | im->pcap_filename = chroot_filename; |
jerryian | 361abef | 2017-04-10 18:48:07 +0800 | [diff] [blame] | 1698 | im->pcap_main.file_name = (char *) im->pcap_filename; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1699 | matched = 1; |
| 1700 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1701 | else if (unformat (input, "status")) |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1702 | { |
| 1703 | if (im->drop_pcap_enable == 0) |
| 1704 | { |
| 1705 | vlib_cli_output (vm, "pcap drop capture is off..."); |
| 1706 | continue; |
| 1707 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1708 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1709 | vlib_cli_output (vm, "pcap drop capture: %d of %d pkts...", |
| 1710 | im->pcap_main.n_packets_captured, |
| 1711 | im->pcap_main.n_packets_to_capture); |
| 1712 | matched = 1; |
| 1713 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1714 | |
| 1715 | else |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1716 | break; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1717 | } |
| 1718 | |
| 1719 | if (matched == 0) |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1720 | return clib_error_return (0, "unknown input `%U'", |
| 1721 | format_unformat_error, input); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1722 | |
| 1723 | return 0; |
| 1724 | } |
| 1725 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1726 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1727 | VLIB_CLI_COMMAND (pcap_trace_command, static) = { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1728 | .path = "pcap drop trace", |
| 1729 | .short_help = |
| 1730 | "pcap drop trace on off max <nn> intfc <intfc> file <name> status", |
| 1731 | .function = pcap_drop_trace_command_fn, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1732 | }; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 1733 | /* *INDENT-ON* */ |
| 1734 | |
| 1735 | /* |
| 1736 | * fd.io coding-style-patch-verification: ON |
| 1737 | * |
| 1738 | * Local Variables: |
| 1739 | * eval: (c-set-style "gnu") |
| 1740 | * End: |
| 1741 | */ |