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