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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 * interface_output.c: interface output node
18 * Copyright (c) 2008 Eliot Dresselhaus
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:
28 * The above copyright notice and this permission notice shall be
29 * included in all copies or substantial portions of the Software.
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.
40 #include <vnet/vnet.h>
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>
45 #include <vnet/feature/feature.h>
46 #include <vnet/classify/trace_classify.h>
54 u8 data[128 - 3 * sizeof (u32)];
56 interface_output_trace_t;
58 #ifndef CLIB_MARCH_VARIANT
60 format_vnet_interface_output_trace (u8 * s, va_list * va)
62 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
63 vlib_node_t *node = va_arg (*va, vlib_node_t *);
64 interface_output_trace_t *t = va_arg (*va, interface_output_trace_t *);
65 vnet_main_t *vnm = vnet_get_main ();
66 vnet_sw_interface_t *si;
69 if (t->sw_if_index != (u32) ~ 0)
71 indent = format_get_indent (s);
73 if (pool_is_free_index
74 (vnm->interface_main.sw_interfaces, t->sw_if_index))
76 /* the interface may have been deleted by the time the trace is printed */
77 s = format (s, "sw_if_index: %d ", t->sw_if_index);
81 si = vnet_get_sw_interface (vnm, t->sw_if_index);
83 format (s, "%U ", format_vnet_sw_interface_name, vnm, si,
86 #define _(bit, name, v, x) \
87 if (v && (t->flags & VNET_BUFFER_F_##name)) \
88 s = format (s, "%s ", v);
89 foreach_vnet_buffer_flag
91 if (t->flags & VNET_BUFFER_F_GSO)
93 s = format (s, "\n%Ugso_sz %d gso_l4_hdr_sz %d",
94 format_white_space, indent + 2, t->gso_size,
98 format (s, "\n%U%U", format_white_space, indent,
99 node->format_buffer ? node->format_buffer : format_hex_bytes,
100 t->data, sizeof (t->data));
106 vnet_interface_output_trace (vlib_main_t * vm,
107 vlib_node_runtime_t * node,
108 vlib_frame_t * frame, uword n_buffers)
113 from = vlib_frame_vector_args (frame);
118 vlib_buffer_t *b0, *b1;
119 interface_output_trace_t *t0, *t1;
121 /* Prefetch next iteration. */
122 vlib_prefetch_buffer_with_index (vm, from[2], LOAD);
123 vlib_prefetch_buffer_with_index (vm, from[3], LOAD);
128 b0 = vlib_get_buffer (vm, bi0);
129 b1 = vlib_get_buffer (vm, bi1);
131 if (b0->flags & VLIB_BUFFER_IS_TRACED)
133 t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
134 t0->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX];
135 t0->flags = b0->flags;
136 t0->gso_size = vnet_buffer2 (b0)->gso_size;
137 t0->gso_l4_hdr_sz = vnet_buffer2 (b0)->gso_l4_hdr_sz;
138 clib_memcpy_fast (t0->data, vlib_buffer_get_current (b0),
141 if (b1->flags & VLIB_BUFFER_IS_TRACED)
143 t1 = vlib_add_trace (vm, node, b1, sizeof (t1[0]));
144 t1->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_TX];
145 t1->flags = b1->flags;
146 t1->gso_size = vnet_buffer2 (b1)->gso_size;
147 t1->gso_l4_hdr_sz = vnet_buffer2 (b1)->gso_l4_hdr_sz;
148 clib_memcpy_fast (t1->data, vlib_buffer_get_current (b1),
159 interface_output_trace_t *t0;
163 b0 = vlib_get_buffer (vm, bi0);
165 if (b0->flags & VLIB_BUFFER_IS_TRACED)
167 t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
168 t0->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX];
169 t0->flags = b0->flags;
170 t0->gso_size = vnet_buffer2 (b0)->gso_size;
171 t0->gso_l4_hdr_sz = vnet_buffer2 (b0)->gso_l4_hdr_sz;
172 clib_memcpy_fast (t0->data, vlib_buffer_get_current (b0),
180 static_always_inline void
181 calc_checksums (vlib_main_t * vm, vlib_buffer_t * b)
186 int is_ip4 = (b->flags & VNET_BUFFER_F_IS_IP4) != 0;
187 int is_ip6 = (b->flags & VNET_BUFFER_F_IS_IP6) != 0;
189 ASSERT (!(is_ip4 && is_ip6));
191 th = (tcp_header_t *) (b->data + vnet_buffer (b)->l4_hdr_offset);
192 uh = (udp_header_t *) (b->data + vnet_buffer (b)->l4_hdr_offset);
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)
204 th->checksum = ip4_tcp_udp_compute_checksum (vm, b, ip4);
206 else if (b->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM)
207 uh->checksum = ip4_tcp_udp_compute_checksum (vm, b, ip4);
214 ip6 = (ip6_header_t *) (b->data + vnet_buffer (b)->l3_hdr_offset);
215 if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
219 ip6_tcp_udp_icmp_compute_checksum (vm, b, ip6, &bogus);
221 else if (b->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM)
225 ip6_tcp_udp_icmp_compute_checksum (vm, b, ip6, &bogus);
228 b->flags &= ~VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
229 b->flags &= ~VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
230 b->flags &= ~VNET_BUFFER_F_OFFLOAD_IP_CKSUM;
233 static_always_inline u16
234 tso_alloc_tx_bufs (vlib_main_t * vm,
235 vnet_interface_per_thread_data_t * ptd,
236 vlib_buffer_t * b0, u32 n_bytes_b0, u16 l234_sz,
240 clib_min (gso_size, vlib_buffer_get_default_data_size (vm) - l234_sz);
242 /* rounded-up division */
243 u16 n_bufs = (n_bytes_b0 - l234_sz + (size - 1)) / size;
247 vec_validate (ptd->split_buffers, n_bufs - 1);
249 n_alloc = vlib_buffer_alloc (vm, ptd->split_buffers, n_bufs);
250 if (n_alloc < n_bufs)
252 vlib_buffer_free (vm, ptd->split_buffers, n_alloc);
258 static_always_inline void
259 tso_init_buf_from_template_base (vlib_buffer_t * nb0, vlib_buffer_t * b0,
260 u32 flags, u16 length)
262 nb0->current_data = b0->current_data;
263 nb0->total_length_not_including_first_buffer = 0;
264 nb0->flags = VLIB_BUFFER_TOTAL_LENGTH_VALID | flags;
265 clib_memcpy_fast (&nb0->opaque, &b0->opaque, sizeof (nb0->opaque));
266 clib_memcpy_fast (vlib_buffer_get_current (nb0),
267 vlib_buffer_get_current (b0), length);
268 nb0->current_length = length;
271 static_always_inline void
272 tso_init_buf_from_template (vlib_main_t * vm, vlib_buffer_t * nb0,
273 vlib_buffer_t * b0, u16 template_data_sz,
274 u16 gso_size, u8 ** p_dst_ptr, u16 * p_dst_left,
275 u32 next_tcp_seq, u32 flags)
277 tso_init_buf_from_template_base (nb0, b0, flags, template_data_sz);
281 vlib_buffer_get_default_data_size (vm) - (template_data_sz +
283 *p_dst_ptr = vlib_buffer_get_current (nb0) + template_data_sz;
286 (tcp_header_t *) (nb0->data + vnet_buffer (nb0)->l4_hdr_offset);
287 tcp->seq_number = clib_host_to_net_u32 (next_tcp_seq);
290 static_always_inline void
291 tso_fixup_segmented_buf (vlib_buffer_t * b0, u8 tcp_flags, int is_ip6)
293 u16 l3_hdr_offset = vnet_buffer (b0)->l3_hdr_offset;
294 u16 l4_hdr_offset = vnet_buffer (b0)->l4_hdr_offset;
295 ip4_header_t *ip4 = (ip4_header_t *) (b0->data + l3_hdr_offset);
296 ip6_header_t *ip6 = (ip6_header_t *) (b0->data + l3_hdr_offset);
297 tcp_header_t *tcp = (tcp_header_t *) (b0->data + l4_hdr_offset);
299 tcp->flags = tcp_flags;
302 ip6->payload_length =
303 clib_host_to_net_u16 (b0->current_length -
304 (l4_hdr_offset - b0->current_data));
307 clib_host_to_net_u16 (b0->current_length -
308 (l3_hdr_offset - b0->current_data));
312 * Allocate the necessary number of ptd->split_buffers,
313 * and segment the possibly chained buffer(s) from b0 into
316 * Return the cumulative number of bytes sent or zero
317 * if allocation failed.
320 static_always_inline u32
321 tso_segment_buffer (vlib_main_t * vm, vnet_interface_per_thread_data_t * ptd,
322 int do_tx_offloads, u32 sbi0, vlib_buffer_t * sb0,
326 int is_ip4 = sb0->flags & VNET_BUFFER_F_IS_IP4;
327 int is_ip6 = sb0->flags & VNET_BUFFER_F_IS_IP6;
328 ASSERT (is_ip4 || is_ip6);
329 ASSERT (sb0->flags & VNET_BUFFER_F_L2_HDR_OFFSET_VALID);
330 ASSERT (sb0->flags & VNET_BUFFER_F_L3_HDR_OFFSET_VALID);
331 ASSERT (sb0->flags & VNET_BUFFER_F_L4_HDR_OFFSET_VALID);
332 u16 gso_size = vnet_buffer2 (sb0)->gso_size;
334 int l4_hdr_sz = vnet_buffer2 (sb0)->gso_l4_hdr_sz;
335 u8 save_tcp_flags = 0;
336 u8 tcp_flags_no_fin_psh = 0;
337 u32 next_tcp_seq = 0;
340 (tcp_header_t *) (sb0->data + vnet_buffer (sb0)->l4_hdr_offset);
341 next_tcp_seq = clib_net_to_host_u32 (tcp->seq_number);
342 /* store original flags for last packet and reset FIN and PSH */
343 save_tcp_flags = tcp->flags;
344 tcp_flags_no_fin_psh = tcp->flags & ~(TCP_FLAG_FIN | TCP_FLAG_PSH);
348 sb0->flags & ~(VNET_BUFFER_F_GSO | VLIB_BUFFER_NEXT_PRESENT);
349 u16 l234_sz = vnet_buffer (sb0)->l4_hdr_offset + l4_hdr_sz
351 int first_data_size = clib_min (gso_size, sb0->current_length - l234_sz);
352 next_tcp_seq += first_data_size;
355 (!tso_alloc_tx_bufs (vm, ptd, sb0, n_bytes_b0, l234_sz, gso_size)))
358 vlib_buffer_t *b0 = vlib_get_buffer (vm, ptd->split_buffers[0]);
359 tso_init_buf_from_template_base (b0, sb0, default_bflags,
360 l234_sz + first_data_size);
362 u32 total_src_left = n_bytes_b0 - l234_sz - first_data_size;
365 /* Need to copy more segments */
366 u8 *src_ptr, *dst_ptr;
367 u16 src_left, dst_left;
368 /* current source buffer */
369 vlib_buffer_t *csb0 = sb0;
371 /* current dest buffer */
373 u16 dbi = 1; /* the buffer [0] is b0 */
375 src_ptr = vlib_buffer_get_current (sb0) + l234_sz + first_data_size;
376 src_left = sb0->current_length - l234_sz - first_data_size;
378 tso_fixup_segmented_buf (b0, tcp_flags_no_fin_psh, is_ip6);
380 calc_checksums (vm, b0);
382 /* grab a second buffer and prepare the loop */
383 ASSERT (dbi < vec_len (ptd->split_buffers));
384 cdb0 = vlib_get_buffer (vm, ptd->split_buffers[dbi++]);
385 tso_init_buf_from_template (vm, cdb0, b0, l234_sz, gso_size, &dst_ptr,
386 &dst_left, next_tcp_seq, default_bflags);
388 /* an arbitrary large number to catch the runaway loops */
390 while (total_src_left)
393 clib_panic ("infinite loop detected");
394 u16 bytes_to_copy = clib_min (src_left, dst_left);
396 clib_memcpy_fast (dst_ptr, src_ptr, bytes_to_copy);
398 src_left -= bytes_to_copy;
399 src_ptr += bytes_to_copy;
400 total_src_left -= bytes_to_copy;
401 dst_left -= bytes_to_copy;
402 dst_ptr += bytes_to_copy;
403 next_tcp_seq += bytes_to_copy;
404 cdb0->current_length += bytes_to_copy;
408 int has_next = (csb0->flags & VLIB_BUFFER_NEXT_PRESENT);
409 u32 next_bi = csb0->next_buffer;
411 /* init src to the next buffer in chain */
415 csb0 = vlib_get_buffer (vm, csbi0);
416 src_left = csb0->current_length;
417 src_ptr = vlib_buffer_get_current (csb0);
421 ASSERT (total_src_left == 0);
425 if (0 == dst_left && total_src_left)
428 calc_checksums (vm, cdb0);
429 n_tx_bytes += cdb0->current_length;
430 ASSERT (dbi < vec_len (ptd->split_buffers));
431 cdb0 = vlib_get_buffer (vm, ptd->split_buffers[dbi++]);
432 tso_init_buf_from_template (vm, cdb0, b0, l234_sz,
433 gso_size, &dst_ptr, &dst_left,
434 next_tcp_seq, default_bflags);
438 tso_fixup_segmented_buf (cdb0, save_tcp_flags, is_ip6);
440 calc_checksums (vm, cdb0);
442 n_tx_bytes += cdb0->current_length;
444 n_tx_bytes += b0->current_length;
448 static_always_inline void
449 drop_one_buffer_and_count (vlib_main_t * vm, vnet_main_t * vnm,
450 vlib_node_runtime_t * node, u32 * pbi0,
453 u32 thread_index = vm->thread_index;
454 vnet_interface_output_runtime_t *rt = (void *) node->runtime_data;
456 vlib_simple_counter_main_t *cm;
458 vec_elt_at_index (vnm->interface_main.sw_if_counters,
459 VNET_INTERFACE_COUNTER_TX_ERROR);
460 vlib_increment_simple_counter (cm, thread_index, rt->sw_if_index, 1);
462 vlib_error_drop_buffers (vm, node, pbi0,
463 /* buffer stride */ 1,
465 VNET_INTERFACE_OUTPUT_NEXT_DROP,
466 node->node_index, drop_error_code);
469 static_always_inline uword
470 vnet_interface_output_node_inline_gso (vlib_main_t * vm,
471 vlib_node_runtime_t * node,
472 vlib_frame_t * frame,
474 vnet_hw_interface_t * hi,
478 vnet_interface_output_runtime_t *rt = (void *) node->runtime_data;
479 vnet_sw_interface_t *si;
480 u32 n_left_to_tx, *from, *from_end, *to_tx;
481 u32 n_bytes, n_buffers, n_packets;
482 u32 n_bytes_b0, n_bytes_b1, n_bytes_b2, n_bytes_b3;
483 u32 thread_index = vm->thread_index;
484 vnet_interface_main_t *im = &vnm->interface_main;
485 u32 next_index = VNET_INTERFACE_OUTPUT_NEXT_TX;
486 u32 current_config_index = ~0;
487 u8 arc = im->output_feature_arc_index;
488 vnet_interface_per_thread_data_t *ptd =
489 vec_elt_at_index (im->per_thread_data, thread_index);
490 vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs;
492 n_buffers = frame->n_vectors;
494 if (node->flags & VLIB_NODE_FLAG_TRACE)
495 vnet_interface_output_trace (vm, node, frame, n_buffers);
497 from = vlib_frame_vector_args (frame);
498 vlib_get_buffers (vm, from, b, n_buffers);
501 return vlib_error_drop_buffers (vm, node, from,
502 /* buffer stride */ 1,
504 VNET_INTERFACE_OUTPUT_NEXT_DROP,
506 VNET_INTERFACE_OUTPUT_ERROR_INTERFACE_DELETED);
508 si = vnet_get_sw_interface (vnm, rt->sw_if_index);
509 hi = vnet_get_sup_hw_interface (vnm, rt->sw_if_index);
510 if (!(si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ||
511 !(hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP))
513 vlib_simple_counter_main_t *cm;
515 cm = vec_elt_at_index (vnm->interface_main.sw_if_counters,
516 VNET_INTERFACE_COUNTER_TX_ERROR);
517 vlib_increment_simple_counter (cm, thread_index,
518 rt->sw_if_index, n_buffers);
520 return vlib_error_drop_buffers (vm, node, from,
521 /* buffer stride */ 1,
523 VNET_INTERFACE_OUTPUT_NEXT_DROP,
525 VNET_INTERFACE_OUTPUT_ERROR_INTERFACE_DOWN);
528 from_end = from + n_buffers;
530 /* Total byte count of all buffers. */
534 /* interface-output feature arc handling */
535 if (PREDICT_FALSE (vnet_have_features (arc, rt->sw_if_index)))
537 vnet_feature_config_main_t *fcm;
538 fcm = vnet_feature_get_config_main (arc);
539 current_config_index = vnet_get_feature_config_index (arc,
541 vnet_get_config_data (&fcm->config_main, ¤t_config_index,
545 while (from < from_end)
547 /* Get new next frame since previous incomplete frame may have less
548 than VNET_FRAME_SIZE vectors in it. */
549 vlib_get_new_next_frame (vm, node, next_index, to_tx, n_left_to_tx);
551 while (from + 8 <= from_end && n_left_to_tx >= 4)
553 u32 bi0, bi1, bi2, bi3;
554 u32 tx_swif0, tx_swif1, tx_swif2, tx_swif3;
557 /* Prefetch next iteration. */
558 vlib_prefetch_buffer_header (b[4], LOAD);
559 vlib_prefetch_buffer_header (b[5], LOAD);
560 vlib_prefetch_buffer_header (b[6], LOAD);
561 vlib_prefetch_buffer_header (b[7], LOAD);
572 or_flags = b[0]->flags | b[1]->flags | b[2]->flags | b[3]->flags;
576 /* go to single loop if we need TSO segmentation */
577 if (PREDICT_FALSE (or_flags & VNET_BUFFER_F_GSO))
584 /* Be grumpy about zero length buffers for benefit of
585 driver tx function. */
586 ASSERT (b[0]->current_length > 0);
587 ASSERT (b[1]->current_length > 0);
588 ASSERT (b[2]->current_length > 0);
589 ASSERT (b[3]->current_length > 0);
591 n_bytes_b0 = vlib_buffer_length_in_chain (vm, b[0]);
592 n_bytes_b1 = vlib_buffer_length_in_chain (vm, b[1]);
593 n_bytes_b2 = vlib_buffer_length_in_chain (vm, b[2]);
594 n_bytes_b3 = vlib_buffer_length_in_chain (vm, b[3]);
595 tx_swif0 = vnet_buffer (b[0])->sw_if_index[VLIB_TX];
596 tx_swif1 = vnet_buffer (b[1])->sw_if_index[VLIB_TX];
597 tx_swif2 = vnet_buffer (b[2])->sw_if_index[VLIB_TX];
598 tx_swif3 = vnet_buffer (b[3])->sw_if_index[VLIB_TX];
600 n_bytes += n_bytes_b0 + n_bytes_b1;
601 n_bytes += n_bytes_b2 + n_bytes_b3;
604 if (PREDICT_FALSE (current_config_index != ~0))
606 vnet_buffer (b[0])->feature_arc_index = arc;
607 vnet_buffer (b[1])->feature_arc_index = arc;
608 vnet_buffer (b[2])->feature_arc_index = arc;
609 vnet_buffer (b[3])->feature_arc_index = arc;
610 b[0]->current_config_index = current_config_index;
611 b[1]->current_config_index = current_config_index;
612 b[2]->current_config_index = current_config_index;
613 b[3]->current_config_index = current_config_index;
616 /* update vlan subif tx counts, if required */
617 if (PREDICT_FALSE (tx_swif0 != rt->sw_if_index))
619 vlib_increment_combined_counter (im->combined_sw_if_counters +
620 VNET_INTERFACE_COUNTER_TX,
621 thread_index, tx_swif0, 1,
625 if (PREDICT_FALSE (tx_swif1 != rt->sw_if_index))
628 vlib_increment_combined_counter (im->combined_sw_if_counters +
629 VNET_INTERFACE_COUNTER_TX,
630 thread_index, tx_swif1, 1,
634 if (PREDICT_FALSE (tx_swif2 != rt->sw_if_index))
637 vlib_increment_combined_counter (im->combined_sw_if_counters +
638 VNET_INTERFACE_COUNTER_TX,
639 thread_index, tx_swif2, 1,
642 if (PREDICT_FALSE (tx_swif3 != rt->sw_if_index))
645 vlib_increment_combined_counter (im->combined_sw_if_counters +
646 VNET_INTERFACE_COUNTER_TX,
647 thread_index, tx_swif3, 1,
654 (VNET_BUFFER_F_OFFLOAD_TCP_CKSUM |
655 VNET_BUFFER_F_OFFLOAD_UDP_CKSUM |
656 VNET_BUFFER_F_OFFLOAD_IP_CKSUM))
658 calc_checksums (vm, b[0]);
659 calc_checksums (vm, b[1]);
660 calc_checksums (vm, b[2]);
661 calc_checksums (vm, b[3]);
668 while (from + 1 <= from_end && n_left_to_tx >= 1)
679 /* Be grumpy about zero length buffers for benefit of
680 driver tx function. */
681 ASSERT (b[0]->current_length > 0);
683 n_bytes_b0 = vlib_buffer_length_in_chain (vm, b[0]);
684 tx_swif0 = vnet_buffer (b[0])->sw_if_index[VLIB_TX];
685 n_bytes += n_bytes_b0;
688 if (PREDICT_FALSE (current_config_index != ~0))
690 vnet_buffer (b[0])->feature_arc_index = arc;
691 b[0]->current_config_index = current_config_index;
696 if (PREDICT_FALSE (b[0]->flags & VNET_BUFFER_F_GSO))
699 * Undo the enqueue of the b0 - it is not going anywhere,
700 * and will be freed either after it's segmented or
701 * when dropped, if there is no buffers to segment into.
705 /* undo the counting. */
706 n_bytes -= n_bytes_b0;
712 tso_segment_buffer (vm, ptd, do_tx_offloads, bi0, b[0],
715 if (PREDICT_FALSE (n_tx_bytes == 0))
717 drop_one_buffer_and_count (vm, vnm, node, from - 1,
718 VNET_INTERFACE_OUTPUT_ERROR_NO_BUFFERS_FOR_GSO);
723 u16 n_tx_bufs = vec_len (ptd->split_buffers);
724 u32 *from_tx_seg = ptd->split_buffers;
726 while (n_tx_bufs > 0)
728 if (n_tx_bufs >= n_left_to_tx)
730 while (n_left_to_tx > 0)
732 to_tx[0] = from_tx_seg[0];
739 vlib_put_next_frame (vm, node, next_index,
741 vlib_get_new_next_frame (vm, node, next_index,
742 to_tx, n_left_to_tx);
744 while (n_tx_bufs > 0)
746 to_tx[0] = from_tx_seg[0];
754 n_bytes += n_tx_bytes;
755 if (PREDICT_FALSE (tx_swif0 != rt->sw_if_index))
758 vlib_increment_combined_counter
759 (im->combined_sw_if_counters +
760 VNET_INTERFACE_COUNTER_TX, thread_index, tx_swif0,
761 _vec_len (ptd->split_buffers), n_tx_bytes);
763 /* The buffers were enqueued. Reset the length */
764 _vec_len (ptd->split_buffers) = 0;
765 /* Free the now segmented buffer */
766 vlib_buffer_free_one (vm, bi0);
772 if (PREDICT_FALSE (tx_swif0 != rt->sw_if_index))
775 vlib_increment_combined_counter (im->combined_sw_if_counters +
776 VNET_INTERFACE_COUNTER_TX,
777 thread_index, tx_swif0, 1,
782 calc_checksums (vm, b[0]);
787 vlib_put_next_frame (vm, node, next_index, n_left_to_tx);
790 /* Update main interface stats. */
791 vlib_increment_combined_counter (im->combined_sw_if_counters
792 + VNET_INTERFACE_COUNTER_TX,
794 rt->sw_if_index, n_packets, n_bytes);
797 #endif /* CLIB_MARCH_VARIANT */
799 static_always_inline void vnet_interface_pcap_tx_trace
800 (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame,
801 int sw_if_index_from_buffer)
803 u32 n_left_from, *from;
806 if (PREDICT_TRUE (vlib_global_main.pcap[VLIB_TX].pcap_enable == 0))
809 if (sw_if_index_from_buffer == 0)
811 vnet_interface_output_runtime_t *rt = (void *) node->runtime_data;
812 sw_if_index = rt->sw_if_index;
817 vnet_main_t *vnm = vnet_get_main ();
818 n_left_from = frame->n_vectors;
819 from = vlib_frame_vector_args (frame);
821 while (n_left_from > 0)
823 int classify_filter_result;
825 vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0);
829 if (vec_len (vnm->classify_filter_table_indices))
831 classify_filter_result =
832 vnet_is_packet_traced_inline
833 (b0, vnm->classify_filter_table_indices[0],
834 0 /* full classify */ );
835 if (classify_filter_result)
836 pcap_add_buffer (&vlib_global_main.pcap[VLIB_TX].pcap_main, vm,
841 if (sw_if_index_from_buffer)
842 sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX];
844 if (vlib_global_main.pcap[VLIB_TX].pcap_sw_if_index == 0 ||
845 vlib_global_main.pcap[VLIB_TX].pcap_sw_if_index == sw_if_index)
846 pcap_add_buffer (&vlib_global_main.pcap[VLIB_TX].pcap_main, vm, bi0,
851 #ifndef CLIB_MARCH_VARIANT
852 static_always_inline uword
853 vnet_interface_output_node_inline (vlib_main_t * vm,
854 vlib_node_runtime_t * node,
855 vlib_frame_t * frame, vnet_main_t * vnm,
856 vnet_hw_interface_t * hi,
860 * The 3-headed "if" is here because we want to err on the side
861 * of not impacting the non-GSO performance - so for the more
862 * common case of no GSO interfaces we want to prevent the
863 * segmentation codepath from being there altogether.
865 if (PREDICT_TRUE (vnm->interface_main.gso_interface_count == 0))
866 return vnet_interface_output_node_inline_gso (vm, node, frame, vnm, hi,
868 /* do_segmentation */ 0);
869 else if (hi->flags & VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO)
870 return vnet_interface_output_node_inline_gso (vm, node, frame, vnm, hi,
872 /* do_segmentation */ 0);
874 return vnet_interface_output_node_inline_gso (vm, node, frame, vnm, hi,
876 /* do_segmentation */ 1);
880 vnet_interface_output_node (vlib_main_t * vm, vlib_node_runtime_t * node,
881 vlib_frame_t * frame)
883 vnet_main_t *vnm = vnet_get_main ();
884 vnet_hw_interface_t *hi;
885 vnet_interface_output_runtime_t *rt = (void *) node->runtime_data;
886 hi = vnet_get_sup_hw_interface (vnm, rt->sw_if_index);
888 vnet_interface_pcap_tx_trace (vm, node, frame,
889 0 /* sw_if_index_from_buffer */ );
891 if (hi->flags & VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD)
892 return vnet_interface_output_node_inline (vm, node, frame, vnm, hi,
893 /* do_tx_offloads */ 0);
895 return vnet_interface_output_node_inline (vm, node, frame, vnm, hi,
896 /* do_tx_offloads */ 1);
898 #endif /* CLIB_MARCH_VARIANT */
900 /* Use buffer's sw_if_index[VNET_TX] to choose output interface. */
901 VLIB_NODE_FN (vnet_per_buffer_interface_output_node) (vlib_main_t * vm,
902 vlib_node_runtime_t *
904 vlib_frame_t * frame)
906 vnet_main_t *vnm = vnet_get_main ();
907 u32 n_left_to_next, *from, *to_next;
908 u32 n_left_from, next_index;
910 vnet_interface_pcap_tx_trace (vm, node, frame,
911 1 /* sw_if_index_from_buffer */ );
913 n_left_from = frame->n_vectors;
915 from = vlib_frame_vector_args (frame);
916 next_index = node->cached_next_index;
918 while (n_left_from > 0)
920 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
922 while (n_left_from >= 4 && n_left_to_next >= 2)
924 u32 bi0, bi1, next0, next1;
925 vlib_buffer_t *b0, *b1;
926 vnet_hw_interface_t *hi0, *hi1;
928 /* Prefetch next iteration. */
929 vlib_prefetch_buffer_with_index (vm, from[2], LOAD);
930 vlib_prefetch_buffer_with_index (vm, from[3], LOAD);
941 b0 = vlib_get_buffer (vm, bi0);
942 b1 = vlib_get_buffer (vm, bi1);
945 vnet_get_sup_hw_interface (vnm,
946 vnet_buffer (b0)->sw_if_index
949 vnet_get_sup_hw_interface (vnm,
950 vnet_buffer (b1)->sw_if_index
953 next0 = hi0->output_node_next_index;
954 next1 = hi1->output_node_next_index;
956 vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
957 n_left_to_next, bi0, bi1, next0,
961 while (n_left_from > 0 && n_left_to_next > 0)
965 vnet_hw_interface_t *hi0;
974 b0 = vlib_get_buffer (vm, bi0);
977 vnet_get_sup_hw_interface (vnm,
978 vnet_buffer (b0)->sw_if_index
981 next0 = hi0->output_node_next_index;
983 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
984 n_left_to_next, bi0, next0);
987 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
990 return frame->n_vectors;
993 typedef struct vnet_error_trace_t_
996 } vnet_error_trace_t;
1000 format_vnet_error_trace (u8 * s, va_list * va)
1002 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
1003 CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
1004 vnet_error_trace_t *t = va_arg (*va, vnet_error_trace_t *);
1006 s = format (s, "rx:%U", format_vnet_sw_if_index_name,
1007 vnet_get_main (), t->sw_if_index);
1013 interface_trace_buffers (vlib_main_t * vm,
1014 vlib_node_runtime_t * node, vlib_frame_t * frame)
1016 u32 n_left, *buffers;
1018 buffers = vlib_frame_vector_args (frame);
1019 n_left = frame->n_vectors;
1024 vlib_buffer_t *b0, *b1;
1025 vnet_error_trace_t *t0, *t1;
1027 /* Prefetch next iteration. */
1028 vlib_prefetch_buffer_with_index (vm, buffers[2], LOAD);
1029 vlib_prefetch_buffer_with_index (vm, buffers[3], LOAD);
1034 b0 = vlib_get_buffer (vm, bi0);
1035 b1 = vlib_get_buffer (vm, bi1);
1037 if (b0->flags & VLIB_BUFFER_IS_TRACED)
1039 t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
1040 t0->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX];
1042 if (b1->flags & VLIB_BUFFER_IS_TRACED)
1044 t1 = vlib_add_trace (vm, node, b1, sizeof (t1[0]));
1045 t1->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX];
1055 vnet_error_trace_t *t0;
1059 b0 = vlib_get_buffer (vm, bi0);
1061 if (b0->flags & VLIB_BUFFER_IS_TRACED)
1063 t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
1064 t0->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX];
1073 VNET_ERROR_DISPOSITION_DROP,
1074 VNET_ERROR_DISPOSITION_PUNT,
1075 VNET_ERROR_N_DISPOSITION,
1076 } vnet_error_disposition_t;
1078 static_always_inline uword
1079 interface_drop_punt (vlib_main_t * vm,
1080 vlib_node_runtime_t * node,
1081 vlib_frame_t * frame,
1082 vnet_error_disposition_t disposition)
1084 u32 *from, n_left, thread_index, *sw_if_index;
1085 vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
1086 u32 sw_if_indices[VLIB_FRAME_SIZE];
1087 vlib_simple_counter_main_t *cm;
1088 u16 nexts[VLIB_FRAME_SIZE];
1091 vnm = vnet_get_main ();
1092 thread_index = vm->thread_index;
1093 from = vlib_frame_vector_args (frame);
1094 n_left = frame->n_vectors;
1096 sw_if_index = sw_if_indices;
1098 vlib_get_buffers (vm, from, bufs, n_left);
1100 if (node->flags & VLIB_NODE_FLAG_TRACE)
1101 interface_trace_buffers (vm, node, frame);
1103 /* All going to drop regardless, this is just a counting exercise */
1104 clib_memset (nexts, 0, sizeof (nexts));
1106 cm = vec_elt_at_index (vnm->interface_main.sw_if_counters,
1107 (disposition == VNET_ERROR_DISPOSITION_PUNT
1108 ? VNET_INTERFACE_COUNTER_PUNT
1109 : VNET_INTERFACE_COUNTER_DROP));
1111 /* collect the array of interfaces first ... */
1116 /* Prefetch 8 ahead - there's not much going on in each iteration */
1117 vlib_prefetch_buffer_header (b[4], LOAD);
1118 vlib_prefetch_buffer_header (b[5], LOAD);
1119 vlib_prefetch_buffer_header (b[6], LOAD);
1120 vlib_prefetch_buffer_header (b[7], LOAD);
1122 sw_if_index[0] = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
1123 sw_if_index[1] = vnet_buffer (b[1])->sw_if_index[VLIB_RX];
1124 sw_if_index[2] = vnet_buffer (b[2])->sw_if_index[VLIB_RX];
1125 sw_if_index[3] = vnet_buffer (b[3])->sw_if_index[VLIB_RX];
1133 sw_if_index[0] = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
1140 /* ... then count against them in blocks */
1141 n_left = frame->n_vectors;
1145 vnet_sw_interface_t *sw_if0;
1148 off = frame->n_vectors - n_left;
1150 sw_if_index = sw_if_indices + off;
1152 count = clib_count_equal_u32 (sw_if_index, n_left);
1155 vlib_increment_simple_counter (cm, thread_index, sw_if_index[0], count);
1157 /* Increment super-interface drop/punt counters for
1159 sw_if0 = vnet_get_sw_interface (vnm, sw_if_index[0]);
1160 if (sw_if0->sup_sw_if_index != sw_if_index[0])
1161 vlib_increment_simple_counter
1162 (cm, thread_index, sw_if0->sup_sw_if_index, count);
1165 vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors);
1167 return frame->n_vectors;
1171 pcap_drop_trace (vlib_main_t * vm,
1172 vnet_interface_main_t * im, vlib_frame_t * f)
1175 u32 n_left = f->n_vectors;
1176 vlib_buffer_t *b0, *p1;
1178 i16 save_current_data;
1179 u16 save_current_length;
1181 from = vlib_frame_vector_args (f);
1185 if (PREDICT_TRUE (n_left > 1))
1187 p1 = vlib_get_buffer (vm, from[1]);
1188 vlib_prefetch_buffer_header (p1, LOAD);
1192 b0 = vlib_get_buffer (vm, bi0);
1196 /* See if we're pointedly ignoring this specific error */
1197 if (im->pcap_drop_filter_hash
1198 && hash_get (im->pcap_drop_filter_hash, b0->error))
1201 /* Trace all drops, or drops received on a specific interface */
1202 if (im->pcap_sw_if_index == 0 ||
1203 im->pcap_sw_if_index == vnet_buffer (b0)->sw_if_index[VLIB_RX])
1205 save_current_data = b0->current_data;
1206 save_current_length = b0->current_length;
1209 * Typically, we'll need to rewind the buffer
1210 * if l2_hdr_offset is valid, make sure to rewind to the start of
1211 * the L2 header. This may not be the buffer start in case we pop-ed
1213 * Otherwise, rewind to buffer start and hope for the best.
1215 if (b0->flags & VNET_BUFFER_F_L2_HDR_OFFSET_VALID)
1217 if (b0->current_data > vnet_buffer (b0)->l2_hdr_offset)
1218 vlib_buffer_advance (b0,
1219 vnet_buffer (b0)->l2_hdr_offset -
1222 else if (b0->current_data > 0)
1223 vlib_buffer_advance (b0, (word) - b0->current_data);
1225 pcap_add_buffer (&im->pcap_main, vm, bi0, 512);
1227 b0->current_data = save_current_data;
1228 b0->current_length = save_current_length;
1233 #ifndef CLIB_MARCH_VARIANT
1235 vnet_pcap_drop_trace_filter_add_del (u32 error_index, int is_add)
1237 vnet_interface_main_t *im = &vnet_get_main ()->interface_main;
1239 if (im->pcap_drop_filter_hash == 0)
1240 im->pcap_drop_filter_hash = hash_create (0, sizeof (uword));
1243 hash_set (im->pcap_drop_filter_hash, error_index, 1);
1245 hash_unset (im->pcap_drop_filter_hash, error_index);
1247 #endif /* CLIB_MARCH_VARIANT */
1249 VLIB_NODE_FN (interface_drop) (vlib_main_t * vm,
1250 vlib_node_runtime_t * node,
1251 vlib_frame_t * frame)
1253 vnet_interface_main_t *im = &vnet_get_main ()->interface_main;
1255 if (PREDICT_FALSE (im->drop_pcap_enable))
1256 pcap_drop_trace (vm, im, frame);
1258 return interface_drop_punt (vm, node, frame, VNET_ERROR_DISPOSITION_DROP);
1261 VLIB_NODE_FN (interface_punt) (vlib_main_t * vm,
1262 vlib_node_runtime_t * node,
1263 vlib_frame_t * frame)
1265 return interface_drop_punt (vm, node, frame, VNET_ERROR_DISPOSITION_PUNT);
1269 VLIB_REGISTER_NODE (interface_drop) = {
1270 .name = "error-drop",
1271 .vector_size = sizeof (u32),
1272 .format_trace = format_vnet_error_trace,
1281 VLIB_REGISTER_NODE (interface_punt) = {
1282 .name = "error-punt",
1283 .vector_size = sizeof (u32),
1284 .format_trace = format_vnet_error_trace,
1293 VLIB_REGISTER_NODE (vnet_per_buffer_interface_output_node) = {
1294 .name = "interface-output",
1295 .vector_size = sizeof (u32),
1300 interface_tx_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
1301 vlib_frame_t * from_frame)
1303 vnet_main_t *vnm = vnet_get_main ();
1304 u32 last_sw_if_index = ~0;
1305 vlib_frame_t *to_frame = 0;
1306 vnet_hw_interface_t *hw = 0;
1307 u32 *from, *to_next = 0;
1310 from = vlib_frame_vector_args (from_frame);
1311 n_left_from = from_frame->n_vectors;
1312 while (n_left_from > 0)
1321 b0 = vlib_get_buffer (vm, bi0);
1322 sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
1324 if (PREDICT_FALSE ((last_sw_if_index != sw_if_index0) || to_frame == 0))
1328 hw = vnet_get_sup_hw_interface (vnm, last_sw_if_index);
1329 vlib_put_frame_to_node (vm, hw->tx_node_index, to_frame);
1331 last_sw_if_index = sw_if_index0;
1332 hw = vnet_get_sup_hw_interface (vnm, sw_if_index0);
1333 to_frame = vlib_get_frame_to_node (vm, hw->tx_node_index);
1334 to_next = vlib_frame_vector_args (to_frame);
1339 to_frame->n_vectors++;
1341 vlib_put_frame_to_node (vm, hw->tx_node_index, to_frame);
1342 return from_frame->n_vectors;
1346 VLIB_REGISTER_NODE (interface_tx) = {
1347 .function = interface_tx_node_fn,
1348 .name = "interface-tx",
1349 .vector_size = sizeof (u32),
1356 VNET_FEATURE_ARC_INIT (interface_output, static) =
1358 .arc_name = "interface-output",
1359 .start_nodes = VNET_FEATURES (0),
1360 .last_in_arc = "interface-tx",
1361 .arc_index_ptr = &vnet_main.interface_main.output_feature_arc_index,
1364 VNET_FEATURE_INIT (span_tx, static) = {
1365 .arc_name = "interface-output",
1366 .node_name = "span-output",
1367 .runs_before = VNET_FEATURES ("interface-tx"),
1370 VNET_FEATURE_INIT (ipsec_if_tx, static) = {
1371 .arc_name = "interface-output",
1372 .node_name = "ipsec-if-output",
1373 .runs_before = VNET_FEATURES ("interface-tx"),
1376 VNET_FEATURE_INIT (interface_tx, static) = {
1377 .arc_name = "interface-output",
1378 .node_name = "interface-tx",
1383 #ifndef CLIB_MARCH_VARIANT
1385 vnet_per_buffer_interface_output_hw_interface_add_del (vnet_main_t * vnm,
1389 vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
1392 if (hi->output_node_index == 0)
1395 next_index = vlib_node_add_next
1396 (vnm->vlib_main, vnet_per_buffer_interface_output_node.index,
1397 hi->output_node_index);
1398 hi->output_node_next_index = next_index;
1403 VNET_HW_INTERFACE_ADD_DEL_FUNCTION
1404 (vnet_per_buffer_interface_output_hw_interface_add_del);
1407 vnet_set_interface_output_node (vnet_main_t * vnm,
1408 u32 hw_if_index, u32 node_index)
1410 ASSERT (node_index);
1411 vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
1412 u32 next_index = vlib_node_add_next
1413 (vnm->vlib_main, vnet_per_buffer_interface_output_node.index, node_index);
1414 hi->output_node_next_index = next_index;
1415 hi->output_node_index = node_index;
1417 #endif /* CLIB_MARCH_VARIANT */
1419 static clib_error_t *
1420 pcap_drop_trace_command_fn (vlib_main_t * vm,
1421 unformat_input_t * input,
1422 vlib_cli_command_t * cmd)
1424 vnet_main_t *vnm = vnet_get_main ();
1425 vnet_interface_main_t *im = &vnm->interface_main;
1429 clib_error_t *error = 0;
1431 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1433 if (unformat (input, "on"))
1435 if (im->drop_pcap_enable == 0)
1437 if (im->pcap_filename == 0)
1438 im->pcap_filename = format (0, "/tmp/drop.pcap%c", 0);
1440 clib_memset (&im->pcap_main, 0, sizeof (im->pcap_main));
1441 im->pcap_main.file_name = (char *) im->pcap_filename;
1442 im->pcap_main.n_packets_to_capture = PCAP_DEF_PKT_TO_CAPTURE;
1443 if (im->pcap_pkts_to_capture)
1444 im->pcap_main.n_packets_to_capture = im->pcap_pkts_to_capture;
1446 im->pcap_main.packet_type = PCAP_PACKET_TYPE_ethernet;
1447 im->drop_pcap_enable = 1;
1449 vlib_cli_output (vm, "pcap drop capture on...");
1453 vlib_cli_output (vm, "pcap drop capture already on...");
1457 else if (unformat (input, "off"))
1461 if (im->drop_pcap_enable)
1463 vlib_cli_output (vm, "captured %d pkts...",
1464 im->pcap_main.n_packets_captured);
1465 if (im->pcap_main.n_packets_captured)
1467 im->pcap_main.n_packets_to_capture =
1468 im->pcap_main.n_packets_captured;
1469 error = pcap_write (&im->pcap_main);
1470 if (im->pcap_main.file_descriptor >= 0)
1471 pcap_close (&im->pcap_main);
1473 clib_error_report (error);
1475 vlib_cli_output (vm, "saved to %s...", im->pcap_filename);
1480 vlib_cli_output (vm, "pcap drop capture already off...");
1483 im->drop_pcap_enable = 0;
1485 else if (unformat (input, "max %d", &max))
1487 im->pcap_pkts_to_capture = max;
1491 else if (unformat (input, "intfc %U",
1492 unformat_vnet_sw_interface, vnm,
1493 &im->pcap_sw_if_index))
1495 else if (unformat (input, "intfc any"))
1497 im->pcap_sw_if_index = 0;
1500 else if (unformat (input, "file %s", &filename))
1502 u8 *chroot_filename;
1503 /* Brain-police user path input */
1504 if (strstr ((char *) filename, "..")
1505 || index ((char *) filename, '/'))
1507 vlib_cli_output (vm, "illegal characters in filename '%s'",
1512 chroot_filename = format (0, "/tmp/%s%c", filename, 0);
1513 vec_free (filename);
1515 if (im->pcap_filename)
1516 vec_free (im->pcap_filename);
1517 im->pcap_filename = chroot_filename;
1518 im->pcap_main.file_name = (char *) im->pcap_filename;
1521 else if (unformat (input, "status"))
1523 if (im->drop_pcap_enable == 0)
1525 vlib_cli_output (vm, "pcap drop capture is off...");
1529 vlib_cli_output (vm, "pcap drop capture: %d of %d pkts...",
1530 im->pcap_main.n_packets_captured,
1531 im->pcap_main.n_packets_to_capture);
1540 return clib_error_return (0, "unknown input `%U'",
1541 format_unformat_error, input);
1547 VLIB_CLI_COMMAND (pcap_trace_command, static) = {
1548 .path = "pcap drop trace",
1550 "pcap drop trace on off max <nn> intfc <intfc> file <name> status",
1551 .function = pcap_drop_trace_command_fn,
1556 * fd.io coding-style-patch-verification: ON
1559 * eval: (c-set-style "gnu")