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_cli.c: interface CLI
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.
42 * @brief Interface CLI.
44 * Source code for several CLI interface commands.
48 #include <vnet/vnet.h>
49 #include <vnet/ip/ip.h>
50 #include <vppinfra/bitmap.h>
51 #include <vnet/fib/ip4_fib.h>
52 #include <vnet/fib/ip6_fib.h>
53 #include <vnet/l2/l2_output.h>
54 #include <vnet/l2/l2_input.h>
57 compare_interface_names (void *a1, void *a2)
62 return vnet_hw_interface_compare (vnet_get_main (), *hi1, *hi2);
66 show_or_clear_hw_interfaces (vlib_main_t * vm,
67 unformat_input_t * input,
68 vlib_cli_command_t * cmd)
70 clib_error_t *error = 0;
71 vnet_main_t *vnm = vnet_get_main ();
72 vnet_interface_main_t *im = &vnm->interface_main;
73 vnet_hw_interface_t *hi;
74 u32 hw_if_index, *hw_if_indices = 0;
75 int i, verbose = -1, is_show, show_bond = 0;
77 is_show = strstr (cmd->path, "show") != 0;
78 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
80 /* See if user wants to show a specific interface. */
82 (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
83 vec_add1 (hw_if_indices, hw_if_index);
85 /* See if user wants to show an interface with a specific hw_if_index. */
86 else if (unformat (input, "%u", &hw_if_index))
87 vec_add1 (hw_if_indices, hw_if_index);
89 else if (unformat (input, "verbose"))
90 verbose = 1; /* this is also the default */
92 else if (unformat (input, "detail"))
95 else if (unformat (input, "brief"))
98 else if (unformat (input, "bond"))
102 verbose = 0; /* default to brief for link bonding */
107 error = clib_error_return (0, "unknown input `%U'",
108 format_unformat_error, input);
113 /* Gather interfaces. */
114 if (vec_len (hw_if_indices) == 0)
115 pool_foreach (hi, im->hw_interfaces,
116 vec_add1 (hw_if_indices, hi - im->hw_interfaces));
119 verbose = 1; /* default to verbose (except bond) */
124 vec_sort_with_function (hw_if_indices, compare_interface_names);
126 vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm, 0, verbose);
127 for (i = 0; i < vec_len (hw_if_indices); i++)
129 hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
130 if (show_bond == 0) /* show all interfaces */
131 vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm,
133 else if ((hi->bond_info) &&
134 (hi->bond_info != VNET_HW_INTERFACE_BOND_INFO_SLAVE))
135 { /* show only bonded interface and all its slave interfaces */
137 vnet_hw_interface_t *shi;
138 vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm,
142 clib_bitmap_foreach (hw_idx, hi->bond_info,
144 shi = vnet_get_hw_interface(vnm, hw_idx);
145 vlib_cli_output (vm, "%U\n",
146 format_vnet_hw_interface, vnm, shi, verbose);
154 for (i = 0; i < vec_len (hw_if_indices); i++)
156 vnet_device_class_t *dc;
158 hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
159 dc = vec_elt_at_index (im->device_classes, hi->dev_class_index);
161 if (dc->clear_counters)
162 dc->clear_counters (hi->dev_instance);
167 vec_free (hw_if_indices);
172 * Display more detailed information about all or a list of given interfaces.
173 * The verboseness of the output can be controlled by the following optional
175 * - brief: Only show name, index and state (default for bonded interfaces).
176 * - verbose: Also display additional attributes (default for all other interfaces).
177 * - detail: Also display all remaining attributes and extended statistics.
179 * To limit the output of the command to bonded interfaces and their slave
180 * interfaces, use the '<em>bond</em>' optional parameter.
183 * Example of how to display default data for all interfaces:
184 * @cliexstart{show hardware-interfaces}
185 * Name Idx Link Hardware
186 * GigabitEthernet7/0/0 1 up GigabitEthernet7/0/0
187 * Ethernet address ec:f4:bb:c0:bc:fc
189 * carrier up full duplex speed 1000 mtu 9216
190 * rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
192 * GigabitEthernet7/0/1 2 up GigabitEthernet7/0/1
193 * Ethernet address ec:f4:bb:c0:bc:fd
195 * carrier up full duplex speed 1000 mtu 9216
196 * rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
198 * VirtualEthernet0/0/0 3 up VirtualEthernet0/0/0
199 * Ethernet address 02:fe:a5:a9:8b:8e
200 * VirtualEthernet0/0/1 4 up VirtualEthernet0/0/1
201 * Ethernet address 02:fe:c0:4e:3b:b0
202 * VirtualEthernet0/0/2 5 up VirtualEthernet0/0/2
203 * Ethernet address 02:fe:1f:73:92:81
204 * VirtualEthernet0/0/3 6 up VirtualEthernet0/0/3
205 * Ethernet address 02:fe:f2:25:c4:68
206 * local0 0 down local0
209 * Example of how to display '<em>verbose</em>' data for an interface by name and
210 * software index (where 2 is the software index):
211 * @cliexstart{show hardware-interfaces GigabitEthernet7/0/0 2 verbose}
212 * Name Idx Link Hardware
213 * GigabitEthernet7/0/0 1 up GigabitEthernet7/0/0
214 * Ethernet address ec:f4:bb:c0:bc:fc
216 * carrier up full duplex speed 1000 mtu 9216
217 * rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
219 * GigabitEthernet7/0/1 2 down GigabitEthernet7/0/1
220 * Ethernet address ec:f4:bb:c0:bc:fd
222 * carrier up full duplex speed 1000 mtu 9216
223 * rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
228 VLIB_CLI_COMMAND (show_hw_interfaces_command, static) = {
229 .path = "show hardware-interfaces",
230 .short_help = "show hardware-interfaces [brief|verbose|detail] [bond] "
231 "[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
232 .function = show_or_clear_hw_interfaces,
238 * Clear the extended statistics for all or a list of given interfaces
239 * (statistics associated with the '<em>show hardware-interfaces</em>' command).
242 * Example of how to clear the extended statistics for all interfaces:
243 * @cliexcmd{clear hardware-interfaces}
244 * Example of how to clear the extended statistics for an interface by
245 * name and software index (where 2 is the software index):
246 * @cliexcmd{clear hardware-interfaces GigabitEthernet7/0/0 2}
249 VLIB_CLI_COMMAND (clear_hw_interface_counters_command, static) = {
250 .path = "clear hardware-interfaces",
251 .short_help = "clear hardware-interfaces "
252 "[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
253 .function = show_or_clear_hw_interfaces,
258 sw_interface_name_compare (void *a1, void *a2)
260 vnet_sw_interface_t *si1 = a1;
261 vnet_sw_interface_t *si2 = a2;
263 return vnet_sw_interface_compare (vnet_get_main (),
264 si1->sw_if_index, si2->sw_if_index);
267 static clib_error_t *
268 show_sw_interfaces (vlib_main_t * vm,
269 unformat_input_t * input, vlib_cli_command_t * cmd)
271 clib_error_t *error = 0;
272 vnet_main_t *vnm = vnet_get_main ();
273 unformat_input_t _linput, *linput = &_linput;
274 vnet_interface_main_t *im = &vnm->interface_main;
275 vnet_sw_interface_t *si, *sorted_sis = 0;
276 u32 sw_if_index = ~(u32) 0;
277 u8 show_addresses = 0;
278 u8 show_features = 0;
284 * Get a line of input. Won't work if the user typed
285 * "show interface" and nothing more.
287 if (unformat_user (input, unformat_line_input, linput))
289 while (unformat_check_input (linput) != UNFORMAT_END_OF_INPUT)
291 /* See if user wants to show specific interface */
293 (linput, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
295 si = pool_elt_at_index (im->sw_interfaces, sw_if_index);
296 vec_add1 (sorted_sis, si[0]);
298 else if (unformat (linput, "address") || unformat (linput, "addr"))
300 else if (unformat (linput, "features") || unformat (linput, "feat"))
302 else if (unformat (linput, "tag"))
304 else if (unformat (linput, "vtr"))
306 else if (unformat (linput, "verbose"))
310 vec_free (sorted_sis);
311 error = clib_error_return (0, "unknown input `%U'",
312 format_unformat_error, linput);
316 unformat_free (linput);
318 if (show_features || show_tag || show_vtr)
320 if (sw_if_index == ~(u32) 0)
322 vec_free (sorted_sis);
323 return clib_error_return (0, "Interface not specified...");
329 vnet_interface_features_show (vm, sw_if_index, verbose);
331 l2_input_config_t *l2_input = l2input_intf_config (sw_if_index);
332 u32 fb = l2_input->feature_bitmap;
333 /* intf input features are masked by bridge domain */
334 if (l2_input->bridge)
335 fb &= l2input_bd_config (l2_input->bd_index)->feature_bitmap;
336 vlib_cli_output (vm, "\nl2-input:\n%U", format_l2_input_features, fb,
339 l2_output_config_t *l2_output = l2output_intf_config (sw_if_index);
340 vlib_cli_output (vm, "\nl2-output:");
341 if (l2_output->out_vtr_flag)
342 vlib_cli_output (vm, "%10s (%s)", "VTR", "--internal--");
343 vlib_cli_output (vm, "%U", format_l2_output_features,
344 l2_output->feature_bitmap, 1);
345 vec_free (sorted_sis);
351 tag = vnet_get_sw_interface_tag (vnm, sw_if_index);
352 vlib_cli_output (vm, "%U: %s",
353 format_vnet_sw_if_index_name, vnm, sw_if_index,
354 tag ? (char *) tag : "(none)");
355 vec_free (sorted_sis);
360 * Show vlan tag rewrite data for one interface.
364 u32 vtr_op = L2_VTR_DISABLED;
365 u32 push_dot1q = 0, tag1 = 0, tag2 = 0;
367 if (l2vtr_get (vm, vnm, sw_if_index,
368 &vtr_op, &push_dot1q, &tag1, &tag2) != 0)
370 vlib_cli_output (vm, "%U: Problem getting vlan tag-rewrite data",
371 format_vnet_sw_if_index_name, vnm, sw_if_index);
374 vlib_cli_output (vm, "%U: VTR %0U",
375 format_vnet_sw_if_index_name, vnm, sw_if_index,
376 format_vtr, vtr_op, push_dot1q, tag1, tag2);
381 vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, 0);
383 if (vec_len (sorted_sis) == 0) /* Get all interfaces */
385 /* Gather interfaces. */
387 vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
388 _vec_len (sorted_sis) = 0;
390 pool_foreach (si, im->sw_interfaces,
392 int visible = vnet_swif_is_api_visible (si);
394 vec_add1 (sorted_sis, si[0]);}
398 vec_sort_with_function (sorted_sis, sw_interface_name_compare);
403 vec_foreach (si, sorted_sis)
405 ip4_main_t *im4 = &ip4_main;
406 ip6_main_t *im6 = &ip6_main;
407 ip_lookup_main_t *lm4 = &im4->lookup_main;
408 ip_lookup_main_t *lm6 = &im6->lookup_main;
409 ip_interface_address_t *ia = 0;
410 u32 fib_index4 = 0, fib_index6 = 0;
412 if (vec_len (im4->fib_index_by_sw_if_index) > si->sw_if_index)
413 fib_index4 = vec_elt (im4->fib_index_by_sw_if_index,
416 if (vec_len (im6->fib_index_by_sw_if_index) > si->sw_if_index)
417 fib_index6 = vec_elt (im6->fib_index_by_sw_if_index,
420 ip4_fib_t *fib4 = ip4_fib_get (fib_index4);
421 ip6_fib_t *fib6 = ip6_fib_get (fib_index6);
423 if (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED)
425 (vm, "%U (%s): \n unnumbered, use %U",
426 format_vnet_sw_if_index_name, vnm, si->sw_if_index,
427 (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn",
428 format_vnet_sw_if_index_name, vnm, si->unnumbered_sw_if_index);
432 format_vnet_sw_if_index_name, vnm, si->sw_if_index,
433 (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn");
435 /* Display any L2 info */
436 l2_input_config_t *l2_input = l2input_intf_config (si->sw_if_index);
437 if (l2_input->bridge)
439 bd_main_t *bdm = &bd_main;
440 u32 bd_id = l2input_main.bd_configs[l2_input->bd_index].bd_id;
441 vlib_cli_output (vm, " L2 bridge bd-id %d idx %d shg %d %s",
442 bd_id, bd_find_index (bdm, bd_id), l2_input->shg,
443 l2_input->bvi ? "bvi" : " ");
445 else if (l2_input->xconnect)
446 vlib_cli_output (vm, " L2 xconnect %U",
447 format_vnet_sw_if_index_name, vnm,
448 l2_input->output_sw_if_index);
451 /* Display any IP4 addressing info */
452 foreach_ip_interface_address (lm4, ia, si->sw_if_index,
453 1 /* honor unnumbered */,
455 ip4_address_t *r4 = ip_interface_address_get_address (lm4, ia);
457 vlib_cli_output (vm, " L3 %U/%d ip4 table-id %d fib-idx %d",
458 format_ip4_address, r4, ia->address_length,
460 ip4_fib_index_from_table_id (fib4->table_id));
462 vlib_cli_output (vm, " L3 %U/%d",
463 format_ip4_address, r4, ia->address_length);
468 /* Display any IP6 addressing info */
469 foreach_ip_interface_address (lm6, ia, si->sw_if_index,
470 1 /* honor unnumbered */,
472 ip6_address_t *r6 = ip_interface_address_get_address (lm6, ia);
474 vlib_cli_output (vm, " L3 %U/%d ip6 table-id %d fib-idx %d",
475 format_ip6_address, r6, ia->address_length,
477 ip6_fib_index_from_table_id (fib6->table_id));
479 vlib_cli_output (vm, " L3 %U/%d",
480 format_ip6_address, r6, ia->address_length);
487 vec_foreach (si, sorted_sis)
489 vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, si);
494 vec_free (sorted_sis);
499 VLIB_CLI_COMMAND (show_sw_interfaces_command, static) = {
500 .path = "show interface",
501 .short_help = "show interface [address|addr|features|feat|vtr] [<interface> [<interface> [..]]] [verbose]",
502 .function = show_sw_interfaces,
507 /* Root of all interface commands. */
509 VLIB_CLI_COMMAND (vnet_cli_interface_command, static) = {
511 .short_help = "Interface commands",
516 VLIB_CLI_COMMAND (vnet_cli_set_interface_command, static) = {
517 .path = "set interface",
518 .short_help = "Interface commands",
522 static clib_error_t *
523 clear_interface_counters (vlib_main_t * vm,
524 unformat_input_t * input, vlib_cli_command_t * cmd)
526 vnet_main_t *vnm = vnet_get_main ();
527 vnet_interface_main_t *im = &vnm->interface_main;
528 vlib_simple_counter_main_t *sm;
529 vlib_combined_counter_main_t *cm;
532 n_counters = vec_len (im->combined_sw_if_counters);
534 for (j = 0; j < n_counters; j++)
536 im = &vnm->interface_main;
537 cm = im->combined_sw_if_counters + j;
538 vlib_clear_combined_counters (cm);
541 n_counters = vec_len (im->sw_if_counters);
543 for (j = 0; j < n_counters; j++)
545 im = &vnm->interface_main;
546 sm = im->sw_if_counters + j;
547 vlib_clear_simple_counters (sm);
554 * Clear the statistics for all interfaces (statistics associated with the
555 * '<em>show interface</em>' command).
558 * Example of how to clear the statistics for all interfaces:
559 * @cliexcmd{clear interfaces}
562 VLIB_CLI_COMMAND (clear_interface_counters_command, static) = {
563 .path = "clear interfaces",
564 .short_help = "clear interfaces",
565 .function = clear_interface_counters,
570 * Parse subinterface names.
572 * The following subinterface syntax is supported. The first two are for
573 * backwards compatability:
576 * - a subinterface with the name <intf-name>.<id>. The subinterface
577 * is a single dot1q vlan with vlan id <id> and exact-match semantics.
579 * <intf-name> <min_id>-<max_id>
580 * - a set of the above subinterfaces, repeating for each id
581 * in the range <min_id> to <max_id>
583 * In the following, exact-match semantics (i.e. the number of vlan tags on the
584 * packet must match the number of tags in the configuration) are used only if
585 * the keyword exact-match is present. Non-exact match is the default.
587 * <intf-name> <id> dot1q <outer_id> [exact-match]
588 * - a subinterface with the name <intf-name>.<id>. The subinterface
589 * is a single dot1q vlan with vlan id <outer_id>.
591 * <intf-name> <id> dot1q any [exact-match]
592 * - a subinterface with the name <intf-name>.<id>. The subinterface
593 * is a single dot1q vlan with any vlan id.
595 * <intf-name> <id> dot1q <outer_id> inner-dot1q <inner_id> [exact-match]
596 * - a subinterface with the name <intf-name>.<id>. The subinterface
597 * is a double dot1q vlan with outer vlan id <outer_id> and inner vlan id
600 * <intf-name> <id> dot1q <outer_id> inner-dot1q any [exact-match]
601 * - a subinterface with the name <intf-name>.<id>. The subinterface
602 * is a double dot1q vlan with outer vlan id <id> and any inner vlan id.
604 * <intf-name> <id> dot1q any inner-dot1q any [exact-match]
606 * - a subinterface with the name <intf-name>.<id>. The subinterface
607 * is a double dot1q vlan with any outer vlan id and any inner vlan id.
609 * For each of the above CLI, there is a duplicate that uses the keyword
610 * "dot1ad" in place of the first "dot1q". These interfaces use ethertype
611 * 0x88ad in place of 0x8100 for the outer ethertype. Note that for double-
612 * tagged packets the inner ethertype is always 0x8100. Also note that
613 * the dot1q and dot1ad naming spaces are independent, so it is legal to
614 * have both "Gig3/0/0.1 dot1q 100" and "Gig3/0/0.2 dot1ad 100". For example:
616 * <intf-name> <id> dot1ad <outer_id> inner-dot1q <inner_id> [exact-match]
617 * - a subinterface with the name <intf-name>.<id>. The subinterface
618 * is a double dot1ad vlan with outer vlan id <outer_id> and inner vlan
621 * <intf-name> <id> untagged
622 * - a subinterface with the name <intf-name>.<id>. The subinterface
623 * has no vlan tags. Only one can be specified per interface.
625 * <intf-name> <id> default
626 * - a subinterface with the name <intf-name>.<id>. This is associated
627 * with a packet that did not match any other configured subinterface
628 * on this interface. Only one can be specified per interface.
631 static clib_error_t *
632 parse_vlan_sub_interfaces (unformat_input_t * input,
633 vnet_sw_interface_t * template)
635 clib_error_t *error = 0;
636 u32 inner_vlan, outer_vlan;
638 if (unformat (input, "any inner-dot1q any"))
640 template->sub.eth.flags.two_tags = 1;
641 template->sub.eth.flags.outer_vlan_id_any = 1;
642 template->sub.eth.flags.inner_vlan_id_any = 1;
644 else if (unformat (input, "any"))
646 template->sub.eth.flags.one_tag = 1;
647 template->sub.eth.flags.outer_vlan_id_any = 1;
649 else if (unformat (input, "%d inner-dot1q any", &outer_vlan))
651 template->sub.eth.flags.two_tags = 1;
652 template->sub.eth.flags.inner_vlan_id_any = 1;
653 template->sub.eth.outer_vlan_id = outer_vlan;
655 else if (unformat (input, "%d inner-dot1q %d", &outer_vlan, &inner_vlan))
657 template->sub.eth.flags.two_tags = 1;
658 template->sub.eth.outer_vlan_id = outer_vlan;
659 template->sub.eth.inner_vlan_id = inner_vlan;
661 else if (unformat (input, "%d", &outer_vlan))
663 template->sub.eth.flags.one_tag = 1;
664 template->sub.eth.outer_vlan_id = outer_vlan;
668 error = clib_error_return (0, "expected dot1q config, got `%U'",
669 format_unformat_error, input);
673 if (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
675 if (unformat (input, "exact-match"))
677 template->sub.eth.flags.exact_match = 1;
685 static clib_error_t *
686 create_sub_interfaces (vlib_main_t * vm,
687 unformat_input_t * input, vlib_cli_command_t * cmd)
689 vnet_main_t *vnm = vnet_get_main ();
690 clib_error_t *error = 0;
691 u32 hw_if_index, sw_if_index;
692 vnet_hw_interface_t *hi;
693 u32 id, id_min, id_max;
694 vnet_sw_interface_t template;
697 if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
699 error = clib_error_return (0, "unknown interface `%U'",
700 format_unformat_error, input);
704 clib_memset (&template, 0, sizeof (template));
705 template.sub.eth.raw_flags = 0;
707 if (unformat (input, "%d default", &id_min))
710 template.sub.eth.flags.default_sub = 1;
712 else if (unformat (input, "%d untagged", &id_min))
715 template.sub.eth.flags.no_tags = 1;
716 template.sub.eth.flags.exact_match = 1;
718 else if (unformat (input, "%d dot1q", &id_min))
720 /* parse dot1q config */
722 error = parse_vlan_sub_interfaces (input, &template);
726 else if (unformat (input, "%d dot1ad", &id_min))
728 /* parse dot1ad config */
730 template.sub.eth.flags.dot1ad = 1;
731 error = parse_vlan_sub_interfaces (input, &template);
735 else if (unformat (input, "%d-%d", &id_min, &id_max))
737 template.sub.eth.flags.one_tag = 1;
738 template.sub.eth.flags.exact_match = 1;
742 else if (unformat (input, "%d", &id_min))
745 template.sub.eth.flags.one_tag = 1;
746 template.sub.eth.outer_vlan_id = id_min;
747 template.sub.eth.flags.exact_match = 1;
752 error = clib_error_return (0, "expected ID or ID MIN-MAX, got `%U'",
753 format_unformat_error, input);
757 hi = vnet_get_hw_interface (vnm, hw_if_index);
759 if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
762 clib_error_return (0,
763 "not allowed as %v belong to a BondEthernet interface",
768 for (id = id_min; id <= id_max; id++)
771 vnet_interface_main_t *im = &vnm->interface_main;
772 u64 sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
775 p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
779 clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
780 hi->sw_if_index, id);
784 template.type = VNET_SW_INTERFACE_TYPE_SUB;
785 template.flood_class = VNET_FLOOD_CLASS_NORMAL;
786 template.sup_sw_if_index = hi->sw_if_index;
787 template.sub.id = id;
789 template.sub.eth.outer_vlan_id = id;
791 error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
795 kp = clib_mem_alloc (sizeof (*kp));
796 *kp = sup_and_sub_key;
798 hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
799 hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
800 vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name,
801 vnet_get_main (), sw_if_index);
809 * This command is used to add VLAN IDs to interfaces, also known as subinterfaces.
810 * The primary input to this command is the '<em>interface</em>' and '<em>subId</em>'
811 * (subinterface Id) parameters. If no additional VLAN ID is provide, the VLAN ID is
812 * assumed to be the '<em>subId</em>'. The VLAN ID and '<em>subId</em>' can be different,
813 * but this is not recommended.
815 * This command has several variations:
816 * - <b>create sub-interfaces <interface> <subId></b> - Create a subinterface to
817 * process packets with a given 802.1q VLAN ID (same value as the '<em>subId</em>').
819 * - <b>create sub-interfaces <interface> <subId> default</b> - Adding the
820 * '<em>default</em>' parameter indicates that packets with VLAN IDs that do not
821 * match any other subinterfaces should be sent to this subinterface.
823 * - <b>create sub-interfaces <interface> <subId> untagged</b> - Adding the
824 * '<em>untagged</em>' parameter indicates that packets no VLAN IDs should be sent
825 * to this subinterface.
827 * - <b>create sub-interfaces <interface> <subId>-<subId></b> - Create a range of
828 * subinterfaces to handle a range of VLAN IDs.
830 * - <b>create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any [exact-match]</b> -
831 * Use this command to specify the outer VLAN ID, to either be explicit or to make the
832 * VLAN ID different from the '<em>subId</em>'.
834 * - <b>create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any inner-dot1q
835 * <vlanId>|any [exact-match]</b> - Use this command to specify the outer VLAN ID and
838 * When '<em>dot1q</em>' or '<em>dot1ad</em>' is explicitly entered, subinterfaces
839 * can be configured as either exact-match or non-exact match. Non-exact match is the CLI
840 * default. If '<em>exact-match</em>' is specified, packets must have the same number of
841 * VLAN tags as the configuration. For non-exact-match, packets must at least that number
842 * of tags. L3 (routed) interfaces must be configured as exact-match. L2 interfaces are
843 * typically configured as non-exact-match. If '<em>dot1q</em>' or '<em>dot1ad</em>' is NOT
844 * entered, then the default behavior is exact-match.
846 * Use the '<em>show interface</em>' command to display all subinterfaces.
850 * Example of how to create a VLAN subinterface 11 to process packets on 802.1q VLAN ID 11:
851 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11}
853 * The previous example is shorthand and is equivalent to:
854 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 11 exact-match}
857 * Example of how to create a subinterface number that is different from the VLAN ID:
858 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100}
861 * Examples of how to create q-in-q and q-in-any subinterfaces:
862 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100 inner-dot1q 200}
863 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 12 dot1q 100 inner-dot1q any}
865 * Examples of how to create dot1ad interfaces:
866 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1ad 11}
867 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 12 dot1ad 100 inner-dot1q 200}
870 * Examples of '<em>exact-match</em>' versus non-exact match. A packet with
871 * outer VLAN 100 and inner VLAN 200 would match this interface, because the default
872 * is non-exact match:
873 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100}
875 * However, the same packet would NOT match this interface because '<em>exact-match</em>'
876 * is specified and only one VLAN is configured, but packet contains two VLANs:
877 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100 exact-match}
880 * Example of how to created a subinterface to process untagged packets:
881 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 untagged}
883 * Example of how to created a subinterface to process any packet with a VLAN ID that
884 * does not match any other subinterface:
885 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 7 default}
887 * When subinterfaces are created, they are in the down state. Example of how to
888 * enable a newly created subinterface:
889 * @cliexcmd{set interface GigabitEthernet2/0/0.7 up}
893 VLIB_CLI_COMMAND (create_sub_interfaces_command, static) = {
894 .path = "create sub-interfaces",
895 .short_help = "create sub-interfaces <interface> "
896 "{<subId> [default|untagged]} | "
897 "{<subId>-<subId>} | "
898 "{<subId> dot1q|dot1ad <vlanId>|any [inner-dot1q <vlanId>|any] [exact-match]}",
899 .function = create_sub_interfaces,
903 static clib_error_t *
904 set_state (vlib_main_t * vm,
905 unformat_input_t * input, vlib_cli_command_t * cmd)
907 vnet_main_t *vnm = vnet_get_main ();
909 u32 sw_if_index, flags;
912 if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
914 error = clib_error_return (0, "unknown interface `%U'",
915 format_unformat_error, input);
919 if (!unformat (input, "%U", unformat_vnet_sw_interface_flags, &flags))
921 error = clib_error_return (0, "unknown flags `%U'",
922 format_unformat_error, input);
926 error = vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
936 * This command is used to change the admin state (up/down) of an interface.
938 * If an interface is down, the optional '<em>punt</em>' flag can also be set.
939 * The '<em>punt</em>' flag implies the interface is disabled for forwarding
940 * but punt all traffic to slow-path. Use the '<em>enable</em>' flag to clear
941 * '<em>punt</em>' flag (interface is still down).
944 * Example of how to configure the admin state of an interface to '<em>up</em?':
945 * @cliexcmd{set interface state GigabitEthernet2/0/0 up}
946 * Example of how to configure the admin state of an interface to '<em>down</em?':
947 * @cliexcmd{set interface state GigabitEthernet2/0/0 down}
950 VLIB_CLI_COMMAND (set_state_command, static) = {
951 .path = "set interface state",
952 .short_help = "set interface state <interface> [up|down|punt|enable]",
953 .function = set_state,
957 static clib_error_t *
958 set_unnumbered (vlib_main_t * vm,
959 unformat_input_t * input, vlib_cli_command_t * cmd)
961 vnet_main_t *vnm = vnet_get_main ();
962 u32 unnumbered_sw_if_index = ~0;
963 u32 inherit_from_sw_if_index = ~0;
966 if (unformat (input, "%U use %U",
967 unformat_vnet_sw_interface, vnm, &unnumbered_sw_if_index,
968 unformat_vnet_sw_interface, vnm, &inherit_from_sw_if_index))
970 else if (unformat (input, "del %U",
971 unformat_vnet_sw_interface, vnm,
972 &unnumbered_sw_if_index))
975 return clib_error_return (0, "parse error '%U'",
976 format_unformat_error, input);
978 if (~0 == unnumbered_sw_if_index)
979 return clib_error_return (0, "Specify the unnumbered interface");
980 if (enable && ~0 == inherit_from_sw_if_index)
981 return clib_error_return (0, "When enabling unnumbered specify the"
982 " IP enabled interface that it uses");
984 vnet_sw_interface_update_unnumbered (unnumbered_sw_if_index,
985 inherit_from_sw_if_index, enable);
991 VLIB_CLI_COMMAND (set_unnumbered_command, static) = {
992 .path = "set interface unnumbered",
993 .short_help = "set interface unnumbered [<interface> use <interface> | del <interface>]",
994 .function = set_unnumbered,
1000 static clib_error_t *
1001 set_hw_class (vlib_main_t * vm,
1002 unformat_input_t * input, vlib_cli_command_t * cmd)
1004 vnet_main_t *vnm = vnet_get_main ();
1005 vnet_interface_main_t *im = &vnm->interface_main;
1006 clib_error_t *error;
1007 u32 hw_if_index, hw_class_index;
1010 if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
1012 error = clib_error_return (0, "unknown hardware interface `%U'",
1013 format_unformat_error, input);
1017 if (!unformat_user (input, unformat_hash_string,
1018 im->hw_interface_class_by_name, &hw_class_index))
1020 error = clib_error_return (0, "unknown hardware class `%U'",
1021 format_unformat_error, input);
1025 error = vnet_hw_interface_set_class (vnm, hw_if_index, hw_class_index);
1034 VLIB_CLI_COMMAND (set_hw_class_command, static) = {
1035 .path = "set interface hw-class",
1036 .short_help = "Set interface hardware class",
1037 .function = set_hw_class,
1041 static clib_error_t *
1042 vnet_interface_cli_init (vlib_main_t * vm)
1047 VLIB_INIT_FUNCTION (vnet_interface_cli_init);
1049 static clib_error_t *
1050 renumber_interface_command_fn (vlib_main_t * vm,
1051 unformat_input_t * input,
1052 vlib_cli_command_t * cmd)
1055 u32 new_dev_instance;
1056 vnet_main_t *vnm = vnet_get_main ();
1059 if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
1060 return clib_error_return (0, "unknown hardware interface `%U'",
1061 format_unformat_error, input);
1063 if (!unformat (input, "%d", &new_dev_instance))
1064 return clib_error_return (0, "new dev instance missing");
1066 rv = vnet_interface_name_renumber (hw_if_index, new_dev_instance);
1074 return clib_error_return (0, "vnet_interface_name_renumber returned %d",
1084 VLIB_CLI_COMMAND (renumber_interface_command, static) = {
1085 .path = "renumber interface",
1086 .short_help = "renumber interface <interface> <new-dev-instance>",
1087 .function = renumber_interface_command_fn,
1091 static clib_error_t *
1092 promiscuous_cmd (vlib_main_t * vm,
1093 unformat_input_t * input, vlib_cli_command_t * cmd)
1095 vnet_main_t *vnm = vnet_get_main ();
1097 u32 flags = ETHERNET_INTERFACE_FLAG_ACCEPT_ALL;
1098 ethernet_main_t *em = ðernet_main;
1099 ethernet_interface_t *eif;
1101 if (unformat (input, "on %U",
1102 unformat_vnet_hw_interface, vnm, &hw_if_index))
1104 else if (unformat (input, "off %U",
1105 unformat_ethernet_interface, vnm, &hw_if_index))
1108 return clib_error_return (0, "unknown input `%U'",
1109 format_unformat_error, input);
1111 eif = ethernet_get_interface (em, hw_if_index);
1113 return clib_error_return (0, "not supported");
1115 ethernet_set_flags (vnm, hw_if_index, flags);
1120 VLIB_CLI_COMMAND (set_interface_promiscuous_cmd, static) = {
1121 .path = "set interface promiscuous",
1122 .short_help = "set interface promiscuous [on|off] <interface>",
1123 .function = promiscuous_cmd,
1127 static clib_error_t *
1128 mtu_cmd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
1130 vnet_main_t *vnm = vnet_get_main ();
1131 u32 hw_if_index, sw_if_index, mtu;
1132 ethernet_main_t *em = ðernet_main;
1133 u32 mtus[VNET_N_MTU] = { 0, 0, 0, 0 };
1135 if (unformat (input, "%d %U", &mtu,
1136 unformat_vnet_hw_interface, vnm, &hw_if_index))
1139 * Change physical MTU on interface. Only supported for Ethernet
1142 vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
1143 ethernet_interface_t *eif = ethernet_get_interface (em, hw_if_index);
1146 return clib_error_return (0, "not supported");
1148 if (mtu < hi->min_supported_packet_bytes)
1149 return clib_error_return (0, "Invalid mtu (%d): "
1150 "must be >= min pkt bytes (%d)", mtu,
1151 hi->min_supported_packet_bytes);
1153 if (mtu > hi->max_supported_packet_bytes)
1154 return clib_error_return (0, "Invalid mtu (%d): must be <= (%d)", mtu,
1155 hi->max_supported_packet_bytes);
1157 vnet_hw_interface_set_mtu (vnm, hw_if_index, mtu);
1160 else if (unformat (input, "packet %d %U", &mtu,
1161 unformat_vnet_sw_interface, vnm, &sw_if_index))
1162 /* Set default packet MTU (including L3 header */
1163 mtus[VNET_MTU_L3] = mtu;
1164 else if (unformat (input, "ip4 %d %U", &mtu,
1165 unformat_vnet_sw_interface, vnm, &sw_if_index))
1166 mtus[VNET_MTU_IP4] = mtu;
1167 else if (unformat (input, "ip6 %d %U", &mtu,
1168 unformat_vnet_sw_interface, vnm, &sw_if_index))
1169 mtus[VNET_MTU_IP6] = mtu;
1170 else if (unformat (input, "mpls %d %U", &mtu,
1171 unformat_vnet_sw_interface, vnm, &sw_if_index))
1172 mtus[VNET_MTU_MPLS] = mtu;
1174 return clib_error_return (0, "unknown input `%U'",
1175 format_unformat_error, input);
1177 vnet_sw_interface_set_protocol_mtu (vnm, sw_if_index, mtus);
1184 VLIB_CLI_COMMAND (set_interface_mtu_cmd, static) = {
1185 .path = "set interface mtu",
1186 .short_help = "set interface mtu [packet|ip4|ip6|mpls] <value> <interface>",
1187 .function = mtu_cmd,
1191 static clib_error_t *
1192 show_interface_sec_mac_addr_fn (vlib_main_t * vm, unformat_input_t * input,
1193 vlib_cli_command_t * cmd)
1195 vnet_main_t *vnm = vnet_get_main ();
1196 vnet_interface_main_t *im = &vnm->interface_main;
1197 ethernet_main_t *em = ðernet_main;
1198 u32 sw_if_index = ~0;
1199 vnet_sw_interface_t *si, *sorted_sis = 0;
1201 if (unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
1203 si = pool_elt_at_index (im->sw_interfaces, sw_if_index);
1204 vec_add1 (sorted_sis, si[0]);
1207 /* if an interface name was not passed, get all interfaces */
1208 if (vec_len (sorted_sis) == 0)
1211 vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
1212 _vec_len (sorted_sis) = 0;
1214 pool_foreach (si, im->sw_interfaces,
1216 int visible = vnet_swif_is_api_visible (si);
1218 vec_add1 (sorted_sis, si[0]);}
1222 vec_sort_with_function (sorted_sis, sw_interface_name_compare);
1225 vec_foreach (si, sorted_sis)
1227 vnet_sw_interface_t *sup_si;
1228 ethernet_interface_t *ei;
1230 sup_si = vnet_get_sup_sw_interface (vnm, si->sw_if_index);
1231 ei = ethernet_get_interface (em, sup_si->hw_if_index);
1233 vlib_cli_output (vm, "%U (%s):",
1234 format_vnet_sw_if_index_name, vnm, si->sw_if_index,
1235 (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ?
1238 if (ei && ei->secondary_addrs)
1240 mac_address_t *sec_addr;
1242 vec_foreach (sec_addr, ei->secondary_addrs)
1244 vlib_cli_output (vm, " %U", format_mac_address_t, sec_addr);
1249 vec_free (sorted_sis);
1254 * This command is used to display interface secondary mac addresses.
1257 * Example of how to display interface secondary mac addresses:
1258 * @cliexstart{show interface secondary-mac-address}
1262 VLIB_CLI_COMMAND (show_interface_sec_mac_addr, static) = {
1263 .path = "show interface secondary-mac-address",
1264 .short_help = "show interface secondary-mac-address [<interface>]",
1265 .function = show_interface_sec_mac_addr_fn,
1269 static clib_error_t *
1270 interface_add_del_mac_address (vlib_main_t * vm, unformat_input_t * input,
1271 vlib_cli_command_t * cmd)
1273 vnet_main_t *vnm = vnet_get_main ();
1274 vnet_sw_interface_t *si = NULL;
1275 clib_error_t *error = 0;
1276 u32 sw_if_index = ~0;
1280 is_add = is_del = 0;
1282 if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
1284 error = clib_error_return (0, "unknown interface `%U'",
1285 format_unformat_error, input);
1288 if (!unformat_user (input, unformat_ethernet_address, mac))
1290 error = clib_error_return (0, "expected mac address `%U'",
1291 format_unformat_error, input);
1295 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1297 if (unformat (input, "add"))
1299 else if (unformat (input, "del"))
1305 if (is_add == is_del)
1307 error = clib_error_return (0, "must choose one of add or del");
1311 si = vnet_get_sw_interface (vnm, sw_if_index);
1313 vnet_hw_interface_add_del_mac_address (vnm, si->hw_if_index, mac, is_add);
1320 * The '<em>set interface secondary-mac-address </em>' command allows adding
1321 * or deleting extra MAC addresses on a given interface without changing the
1322 * default MAC address. This could allow packets sent to these MAC addresses
1323 * to be received without setting the interface to promiscuous mode.
1324 * Not all interfaces support this operation. The ones that do are mostly
1325 * hardware NICs, though virtio does also.
1329 * Example of how to add a secondary MAC Address on an interface:
1330 * @cliexcmd{set interface secondary-mac-address GigabitEthernet0/8/0 aa:bb:cc:dd:ee:01 add}
1331 * Example of how to delete a secondary MAC address from an interface:
1332 * @cliexcmd{set interface secondary-mac-address GigabitEthernet0/8/0 aa:bb:cc:dd:ee:01 del}
1336 VLIB_CLI_COMMAND (interface_add_del_mac_address_cmd, static) = {
1337 .path = "set interface secondary-mac-address",
1338 .short_help = "set interface secondary-mac-address <interface> <mac-address> [(add|del)]",
1339 .function = interface_add_del_mac_address,
1343 static clib_error_t *
1344 set_interface_mac_address (vlib_main_t * vm, unformat_input_t * input,
1345 vlib_cli_command_t * cmd)
1347 vnet_main_t *vnm = vnet_get_main ();
1348 vnet_sw_interface_t *si = NULL;
1349 clib_error_t *error = 0;
1350 u32 sw_if_index = ~0;
1353 if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
1355 error = clib_error_return (0, "unknown interface `%U'",
1356 format_unformat_error, input);
1359 if (!unformat_user (input, unformat_ethernet_address, mac))
1361 error = clib_error_return (0, "expected mac address `%U'",
1362 format_unformat_error, input);
1365 si = vnet_get_sw_interface (vnm, sw_if_index);
1366 error = vnet_hw_interface_change_mac_address (vnm, si->hw_if_index, mac);
1372 * The '<em>set interface mac address </em>' command allows to set MAC address of given interface.
1373 * In case of NIC interfaces the one has to support MAC address change. A side effect of MAC address
1374 * change are changes of MAC addresses in FIB tables (ipv4 and ipv6).
1378 * Example of how to change MAC Address of interface:
1379 * @cliexcmd{set interface mac address GigabitEthernet0/8/0 aa:bb:cc:dd:ee:01}
1380 * @cliexcmd{set interface mac address host-vpp0 aa:bb:cc:dd:ee:02}
1381 * @cliexcmd{set interface mac address tap-0 aa:bb:cc:dd:ee:03}
1382 * @cliexcmd{set interface mac address pg0 aa:bb:cc:dd:ee:04}
1386 VLIB_CLI_COMMAND (set_interface_mac_address_cmd, static) = {
1387 .path = "set interface mac address",
1388 .short_help = "set interface mac address <interface> <mac-address>",
1389 .function = set_interface_mac_address,
1393 static clib_error_t *
1394 set_tag (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
1396 vnet_main_t *vnm = vnet_get_main ();
1397 u32 sw_if_index = ~0;
1400 if (!unformat (input, "%U %s", unformat_vnet_sw_interface,
1401 vnm, &sw_if_index, &tag))
1402 return clib_error_return (0, "unknown input `%U'",
1403 format_unformat_error, input);
1405 vnet_set_sw_interface_tag (vnm, tag, sw_if_index);
1411 VLIB_CLI_COMMAND (set_tag_command, static) = {
1412 .path = "set interface tag",
1413 .short_help = "set interface tag <interface> <tag>",
1414 .function = set_tag,
1418 static clib_error_t *
1419 clear_tag (vlib_main_t * vm, unformat_input_t * input,
1420 vlib_cli_command_t * cmd)
1422 vnet_main_t *vnm = vnet_get_main ();
1423 u32 sw_if_index = ~0;
1425 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
1426 return clib_error_return (0, "unknown input `%U'",
1427 format_unformat_error, input);
1429 vnet_clear_sw_interface_tag (vnm, sw_if_index);
1435 VLIB_CLI_COMMAND (clear_tag_command, static) = {
1436 .path = "clear interface tag",
1437 .short_help = "clear interface tag <interface>",
1438 .function = clear_tag,
1442 static clib_error_t *
1443 set_ip_directed_broadcast (vlib_main_t * vm,
1444 unformat_input_t * input, vlib_cli_command_t * cmd)
1446 vnet_main_t *vnm = vnet_get_main ();
1447 u32 sw_if_index = ~0;
1450 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index));
1451 else if (unformat (input, "enable"))
1453 else if (unformat (input, "disable"))
1456 return clib_error_return (0, "unknown input: `%U'",
1457 format_unformat_error, input);
1459 if (~0 == sw_if_index)
1460 return clib_error_return (0, "specify an interface: `%U'",
1461 format_unformat_error, input);
1463 vnet_sw_interface_ip_directed_broadcast (vnm, sw_if_index, enable);
1469 * This command is used to enable/disable IP directed broadcast
1470 * If directed broadcast is enabled a packet sent to the interface's
1471 * subnet broadcast address will be sent L2 broadcast on the interface,
1472 * otherwise it is dropped.
1475 VLIB_CLI_COMMAND (set_ip_directed_broadcast_command, static) = {
1476 .path = "set interface ip directed-broadcast",
1477 .short_help = "set interface enable <interface> <enable|disable>",
1478 .function = set_ip_directed_broadcast,
1482 static clib_error_t *
1483 set_hw_interface_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
1484 u32 queue_id, vnet_hw_interface_rx_mode mode)
1486 vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
1487 vnet_device_class_t *dev_class =
1488 vnet_get_device_class (vnm, hw->dev_class_index);
1489 clib_error_t *error;
1490 vnet_hw_interface_rx_mode old_mode;
1493 if (mode == VNET_HW_INTERFACE_RX_MODE_DEFAULT)
1494 mode = hw->default_rx_mode;
1496 rv = vnet_hw_interface_get_rx_mode (vnm, hw_if_index, queue_id, &old_mode);
1500 if (old_mode == mode)
1501 return 0; /* same rx-mode, no change */
1503 case VNET_API_ERROR_INVALID_INTERFACE:
1504 return clib_error_return (0, "invalid interface");
1505 case VNET_API_ERROR_INVALID_QUEUE:
1506 return clib_error_return (0, "invalid queue");
1508 return clib_error_return (0, "unknown error");
1511 if (dev_class->rx_mode_change_function)
1513 error = dev_class->rx_mode_change_function (vnm, hw_if_index, queue_id,
1519 rv = vnet_hw_interface_set_rx_mode (vnm, hw_if_index, queue_id, mode);
1524 case VNET_API_ERROR_UNSUPPORTED:
1525 return clib_error_return (0, "unsupported");
1526 case VNET_API_ERROR_INVALID_INTERFACE:
1527 return clib_error_return (0, "invalid interface");
1528 case VNET_API_ERROR_INVALID_QUEUE:
1529 return clib_error_return (0, "invalid queue");
1531 return clib_error_return (0, "unknown error");
1538 set_hw_interface_change_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
1539 u8 queue_id_valid, u32 queue_id,
1540 vnet_hw_interface_rx_mode mode)
1542 clib_error_t *error = 0;
1543 vnet_hw_interface_t *hw;
1546 hw = vnet_get_hw_interface (vnm, hw_if_index);
1548 if (queue_id_valid == 0)
1550 for (i = 0; i < vec_len (hw->dq_runtime_index_by_queue); i++)
1552 error = set_hw_interface_rx_mode (vnm, hw_if_index, i, mode);
1556 hw->default_rx_mode = mode;
1559 error = set_hw_interface_rx_mode (vnm, hw_if_index, queue_id, mode);
1564 static clib_error_t *
1565 set_interface_rx_mode (vlib_main_t * vm, unformat_input_t * input,
1566 vlib_cli_command_t * cmd)
1568 clib_error_t *error = 0;
1569 unformat_input_t _line_input, *line_input = &_line_input;
1570 vnet_main_t *vnm = vnet_get_main ();
1571 u32 hw_if_index = (u32) ~ 0;
1572 u32 queue_id = (u32) ~ 0;
1573 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
1574 u8 queue_id_valid = 0;
1576 if (!unformat_user (input, unformat_line_input, line_input))
1579 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1582 (line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
1584 else if (unformat (line_input, "queue %d", &queue_id))
1586 else if (unformat (line_input, "polling"))
1587 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
1588 else if (unformat (line_input, "interrupt"))
1589 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
1590 else if (unformat (line_input, "adaptive"))
1591 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
1594 error = clib_error_return (0, "parse error: '%U'",
1595 format_unformat_error, line_input);
1596 unformat_free (line_input);
1601 unformat_free (line_input);
1603 if (hw_if_index == (u32) ~ 0)
1604 return clib_error_return (0, "please specify valid interface name");
1606 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
1607 return clib_error_return (0, "please specify valid rx-mode");
1609 error = set_hw_interface_change_rx_mode (vnm, hw_if_index, queue_id_valid,
1616 * This command is used to assign the RX packet processing mode (polling,
1617 * interrupt, adaptive) of the a given interface, and optionally a
1618 * given queue. If the '<em>queue</em>' is not provided, the '<em>mode</em>'
1619 * is applied to all queues of the interface. Not all interfaces support
1620 * all modes. To display the current rx-mode use the command
1621 * '<em>show interface rx-placement</em>'.
1624 * Example of how to assign rx-mode to all queues on an interface:
1625 * @cliexcmd{set interface rx-mode VirtualEthernet0/0/12 polling}
1626 * Example of how to assign rx-mode to one queue of an interface:
1627 * @cliexcmd{set interface rx-mode VirtualEthernet0/0/12 queue 0 interrupt}
1628 * Example of how to display the rx-mode of all interfaces:
1629 * @cliexstart{show interface rx-placement}
1630 * Thread 1 (vpp_wk_0):
1632 * GigabitEthernet7/0/0 queue 0 (polling)
1633 * node vhost-user-input:
1634 * VirtualEthernet0/0/12 queue 0 (interrupt)
1635 * VirtualEthernet0/0/12 queue 2 (polling)
1636 * VirtualEthernet0/0/13 queue 0 (polling)
1637 * VirtualEthernet0/0/13 queue 2 (polling)
1638 * Thread 2 (vpp_wk_1):
1640 * GigabitEthernet7/0/1 queue 0 (polling)
1641 * node vhost-user-input:
1642 * VirtualEthernet0/0/12 queue 1 (polling)
1643 * VirtualEthernet0/0/12 queue 3 (polling)
1644 * VirtualEthernet0/0/13 queue 1 (polling)
1645 * VirtualEthernet0/0/13 queue 3 (polling)
1649 VLIB_CLI_COMMAND (cmd_set_if_rx_mode,static) = {
1650 .path = "set interface rx-mode",
1651 .short_help = "set interface rx-mode <interface> [queue <n>] [polling | interrupt | adaptive]",
1652 .function = set_interface_rx_mode,
1656 static clib_error_t *
1657 show_interface_rx_placement_fn (vlib_main_t * vm, unformat_input_t * input,
1658 vlib_cli_command_t * cmd)
1661 vnet_main_t *vnm = vnet_get_main ();
1662 vnet_device_input_runtime_t *rt;
1663 vnet_device_and_queue_t *dq;
1664 vlib_node_t *pn = vlib_get_node_by_name (vm, (u8 *) "device-input");
1669 foreach_vlib_main (({
1670 clib_bitmap_foreach (si, pn->sibling_bitmap,
1672 rt = vlib_node_get_runtime_data (this_vlib_main, si);
1674 if (vec_len (rt->devices_and_queues))
1675 s = format (s, " node %U:\n", format_vlib_node_name, vm, si);
1677 vec_foreach (dq, rt->devices_and_queues)
1679 vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm,
1681 s = format (s, " %U queue %u (%U)\n",
1682 format_vnet_sw_if_index_name, vnm, hi->sw_if_index,
1684 format_vnet_hw_interface_rx_mode, dq->mode);
1687 if (vec_len (s) > 0)
1689 vlib_cli_output(vm, "Thread %u (%s):\n%v", index,
1690 vlib_worker_threads[index].name, s);
1691 vec_reset_length (s);
1702 * This command is used to display the interface and queue worker
1706 * Example of how to display the interface placement:
1707 * @cliexstart{show interface rx-placement}
1708 * Thread 1 (vpp_wk_0):
1710 * GigabitEthernet7/0/0 queue 0 (polling)
1711 * node vhost-user-input:
1712 * VirtualEthernet0/0/12 queue 0 (polling)
1713 * VirtualEthernet0/0/12 queue 2 (polling)
1714 * VirtualEthernet0/0/13 queue 0 (polling)
1715 * VirtualEthernet0/0/13 queue 2 (polling)
1716 * Thread 2 (vpp_wk_1):
1718 * GigabitEthernet7/0/1 queue 0 (polling)
1719 * node vhost-user-input:
1720 * VirtualEthernet0/0/12 queue 1 (polling)
1721 * VirtualEthernet0/0/12 queue 3 (polling)
1722 * VirtualEthernet0/0/13 queue 1 (polling)
1723 * VirtualEthernet0/0/13 queue 3 (polling)
1727 VLIB_CLI_COMMAND (show_interface_rx_placement, static) = {
1728 .path = "show interface rx-placement",
1729 .short_help = "show interface rx-placement",
1730 .function = show_interface_rx_placement_fn,
1735 set_hw_interface_rx_placement (u32 hw_if_index, u32 queue_id,
1736 u32 thread_index, u8 is_main)
1738 vnet_main_t *vnm = vnet_get_main ();
1739 vnet_device_main_t *vdm = &vnet_device_main;
1740 clib_error_t *error = 0;
1741 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
1747 thread_index += vdm->first_worker_thread_index;
1749 if (thread_index > vdm->last_worker_thread_index)
1750 return clib_error_return (0,
1751 "please specify valid worker thread or main");
1753 rv = vnet_hw_interface_get_rx_mode (vnm, hw_if_index, queue_id, &mode);
1756 return clib_error_return (0, "not found");
1758 rv = vnet_hw_interface_unassign_rx_thread (vnm, hw_if_index, queue_id);
1761 return clib_error_return (0, "not found");
1763 vnet_hw_interface_assign_rx_thread (vnm, hw_if_index, queue_id,
1765 vnet_hw_interface_set_rx_mode (vnm, hw_if_index, queue_id, mode);
1770 static clib_error_t *
1771 set_interface_rx_placement (vlib_main_t * vm, unformat_input_t * input,
1772 vlib_cli_command_t * cmd)
1774 clib_error_t *error = 0;
1775 unformat_input_t _line_input, *line_input = &_line_input;
1776 vnet_main_t *vnm = vnet_get_main ();
1777 u32 hw_if_index = (u32) ~ 0;
1778 u32 queue_id = (u32) 0;
1779 u32 thread_index = (u32) ~ 0;
1782 if (!unformat_user (input, unformat_line_input, line_input))
1785 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1788 (line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
1790 else if (unformat (line_input, "queue %d", &queue_id))
1792 else if (unformat (line_input, "main", &thread_index))
1794 else if (unformat (line_input, "worker %d", &thread_index))
1798 error = clib_error_return (0, "parse error: '%U'",
1799 format_unformat_error, line_input);
1800 unformat_free (line_input);
1805 unformat_free (line_input);
1807 if (hw_if_index == (u32) ~ 0)
1808 return clib_error_return (0, "please specify valid interface name");
1810 error = set_hw_interface_rx_placement (hw_if_index, queue_id, thread_index,
1817 * This command is used to assign a given interface, and optionally a
1818 * given queue, to a different thread. If the '<em>queue</em>' is not provided,
1819 * it defaults to 0. The '<em>worker</em>' parameter is zero based and the index
1820 * in the thread name, for example, 0 in the thread name '<em>vpp_wk_0</em>'.
1823 * Example of how to display the interface placement:
1824 * @cliexstart{show interface rx-placement}
1825 * Thread 1 (vpp_wk_0):
1827 * GigabitEthernet7/0/0 queue 0 (polling)
1828 * node vhost-user-input:
1829 * VirtualEthernet0/0/12 queue 0 (polling)
1830 * VirtualEthernet0/0/12 queue 2 (polling)
1831 * VirtualEthernet0/0/13 queue 0 (polling)
1832 * VirtualEthernet0/0/13 queue 2 (polling)
1833 * Thread 2 (vpp_wk_1):
1835 * GigabitEthernet7/0/1 queue 0 (polling)
1836 * node vhost-user-input:
1837 * VirtualEthernet0/0/12 queue 1 (polling)
1838 * VirtualEthernet0/0/12 queue 3 (polling)
1839 * VirtualEthernet0/0/13 queue 1 (polling)
1840 * VirtualEthernet0/0/13 queue 3 (polling)
1842 * Example of how to assign a interface and queue to a worker thread:
1843 * @cliexcmd{set interface rx-placement VirtualEthernet0/0/12 queue 1 worker 0}
1844 * Example of how to display the interface placement:
1845 * @cliexstart{show interface rx-placement}
1846 * Thread 1 (vpp_wk_0):
1848 * GigabitEthernet7/0/0 queue 0 (polling)
1849 * node vhost-user-input:
1850 * VirtualEthernet0/0/12 queue 0 (polling)
1851 * VirtualEthernet0/0/12 queue 1 (polling)
1852 * VirtualEthernet0/0/12 queue 2 (polling)
1853 * VirtualEthernet0/0/13 queue 0 (polling)
1854 * VirtualEthernet0/0/13 queue 2 (polling)
1855 * Thread 2 (vpp_wk_1):
1857 * GigabitEthernet7/0/1 queue 0 (polling)
1858 * node vhost-user-input:
1859 * VirtualEthernet0/0/12 queue 3 (polling)
1860 * VirtualEthernet0/0/13 queue 1 (polling)
1861 * VirtualEthernet0/0/13 queue 3 (polling)
1865 VLIB_CLI_COMMAND (cmd_set_if_rx_placement,static) = {
1866 .path = "set interface rx-placement",
1867 .short_help = "set interface rx-placement <interface> [queue <n>] "
1868 "[worker <n> | main]",
1869 .function = set_interface_rx_placement,
1875 format_vnet_pcap (u8 * s, va_list * args)
1877 vnet_pcap_t *pp = va_arg (*args, vnet_pcap_t *);
1878 int type = va_arg (*args, int);
1883 if (pp->pcap_rx_enable)
1885 s = format (s, "rx");
1888 if (pp->pcap_tx_enable)
1891 s = format (s, " and ");
1892 s = format (s, "tx");
1895 if (pp->pcap_drop_enable)
1898 s = format (s, " and ");
1899 s = format (s, "drop");
1904 s = format (s, "unknown type %d!", type);
1910 vnet_pcap_dispatch_trace_configure (vnet_pcap_dispatch_trace_args_t * a)
1912 vlib_main_t *vm = vlib_get_main ();
1913 vnet_pcap_t *pp = &vm->pcap;
1914 pcap_main_t *pm = &pp->pcap_main;
1915 vnet_classify_main_t *cm = &vnet_classify_main;
1916 vnet_classify_filter_set_t *set = 0;
1920 if (pp->pcap_rx_enable || pp->pcap_tx_enable || pp->pcap_drop_enable)
1923 (vm, "pcap %U dispatch capture enabled: %d of %d pkts...",
1924 format_vnet_pcap, pp, 0 /* print type */ ,
1925 pm->n_packets_captured, pm->n_packets_to_capture);
1926 vlib_cli_output (vm, "capture to file %s", pm->file_name);
1929 vlib_cli_output (vm, "pcap dispatch capture disabled");
1934 /* Consistency checks */
1936 /* Enable w/ capture already enabled not allowed */
1937 if ((pp->pcap_rx_enable + pp->pcap_tx_enable + pp->pcap_drop_enable)
1938 && (a->rx_enable + a->tx_enable + a->drop_enable))
1939 return VNET_API_ERROR_INVALID_VALUE;
1941 /* Disable capture with capture already disabled, not interesting */
1942 if (((pp->pcap_rx_enable + pp->pcap_tx_enable + pp->pcap_drop_enable) == 0)
1943 && ((a->rx_enable + a->tx_enable + a->drop_enable == 0)))
1944 return VNET_API_ERROR_VALUE_EXIST;
1946 /* Change number of packets to capture while capturing */
1947 if ((pp->pcap_rx_enable + pp->pcap_tx_enable + pp->pcap_drop_enable)
1948 && (a->rx_enable + a->tx_enable + a->drop_enable)
1949 && (pm->n_packets_to_capture != a->packets_to_capture))
1950 return VNET_API_ERROR_INVALID_VALUE_2;
1952 set = pool_elt_at_index (cm->filter_sets, cm->filter_set_by_sw_if_index[0]);
1954 /* Classify filter specified, but no classify filter configured */
1955 if ((a->rx_enable + a->tx_enable + a->drop_enable) && a->filter &&
1956 (set->table_indices[0] == ~0))
1957 return VNET_API_ERROR_NO_SUCH_LABEL;
1959 if (a->rx_enable + a->tx_enable + a->drop_enable)
1961 /* Sanity check max bytes per pkt */
1962 if (a->max_bytes_per_pkt < 32 || a->max_bytes_per_pkt > 9000)
1963 return VNET_API_ERROR_INVALID_MEMORY_SIZE;
1965 /* Clean up from previous run, if any */
1966 vec_free (pm->file_name);
1967 vec_free (pm->pcap_data);
1968 memset (pm, 0, sizeof (*pm));
1970 vec_validate_aligned (vnet_trace_dummy, 2048, CLIB_CACHE_LINE_BYTES);
1972 clib_spinlock_init (&(pm->lock));
1974 if (a->filename == 0)
1979 stem = format (stem, "rx");
1981 stem = format (stem, "tx");
1983 stem = format (stem, "drop");
1984 a->filename = format (0, "/tmp/%s.pcap%c", stem, 0);
1988 pm->file_name = (char *) a->filename;
1989 pm->n_packets_captured = 0;
1990 pm->packet_type = PCAP_PACKET_TYPE_ethernet;
1991 pm->n_packets_to_capture = a->packets_to_capture;
1992 pp->pcap_sw_if_index = a->sw_if_index;
1994 pp->filter_classify_table_index = set->table_indices[0];
1996 pp->filter_classify_table_index = ~0;
1997 pp->pcap_rx_enable = a->rx_enable;
1998 pp->pcap_tx_enable = a->tx_enable;
1999 pp->pcap_drop_enable = a->drop_enable;
2000 pp->max_bytes_per_pkt = a->max_bytes_per_pkt;
2004 pp->pcap_rx_enable = 0;
2005 pp->pcap_tx_enable = 0;
2006 pp->pcap_drop_enable = 0;
2007 pp->filter_classify_table_index = ~0;
2008 if (pm->n_packets_captured)
2010 clib_error_t *error;
2011 pm->n_packets_to_capture = pm->n_packets_captured;
2012 vlib_cli_output (vm, "Write %d packets to %s, and stop capture...",
2013 pm->n_packets_captured, pm->file_name);
2014 error = pcap_write (pm);
2015 if (pm->flags & PCAP_MAIN_INIT_DONE)
2017 /* Report I/O errors... */
2020 clib_error_report (error);
2021 return VNET_API_ERROR_SYSCALL_ERROR_1;
2026 return VNET_API_ERROR_NO_SUCH_ENTRY;
2032 static clib_error_t *
2033 pcap_trace_command_fn (vlib_main_t * vm,
2034 unformat_input_t * input, vlib_cli_command_t * cmd)
2036 unformat_input_t _line_input, *line_input = &_line_input;
2037 vnet_pcap_dispatch_trace_args_t _a, *a = &_a;
2038 vnet_main_t *vnm = vnet_get_main ();
2041 u32 max_bytes_per_pkt = 512;
2045 int drop_enable = 0;
2048 u32 sw_if_index = ~0;
2050 /* Get a line of input. */
2051 if (!unformat_user (input, unformat_line_input, line_input))
2054 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
2056 if (unformat (line_input, "rx"))
2058 else if (unformat (line_input, "tx"))
2060 else if (unformat (line_input, "drop"))
2062 else if (unformat (line_input, "off"))
2063 rx_enable = tx_enable = drop_enable = 0;
2064 else if (unformat (line_input, "max-bytes-per-pkt %u",
2065 &max_bytes_per_pkt))
2067 else if (unformat (line_input, "max %d", &max))
2069 else if (unformat (line_input, "packets-to-capture %d", &max))
2071 else if (unformat (line_input, "file %U", unformat_vlib_tmpfile,
2074 else if (unformat (line_input, "status %=", &status, 1))
2076 else if (unformat (line_input, "intfc %U",
2077 unformat_vnet_sw_interface, vnm, &sw_if_index))
2079 else if (unformat (line_input, "intfc any"))
2081 else if (unformat (line_input, "filter"))
2085 return clib_error_return (0, "unknown input `%U'",
2086 format_unformat_error, line_input);
2090 unformat_free (line_input);
2092 /* no need for memset (a, 0, sizeof (*a)), set all fields here. */
2093 a->filename = filename;
2094 a->rx_enable = rx_enable;
2095 a->tx_enable = tx_enable;
2096 a->drop_enable = drop_enable;
2098 a->packets_to_capture = max;
2099 a->sw_if_index = sw_if_index;
2101 a->max_bytes_per_pkt = max_bytes_per_pkt;
2103 rv = vnet_pcap_dispatch_trace_configure (a);
2110 case VNET_API_ERROR_INVALID_VALUE:
2111 return clib_error_return (0, "dispatch trace already enabled...");
2113 case VNET_API_ERROR_VALUE_EXIST:
2114 return clib_error_return (0, "dispatch trace already disabled...");
2116 case VNET_API_ERROR_INVALID_VALUE_2:
2117 return clib_error_return
2118 (0, "can't change number of records to capture while tracing...");
2120 case VNET_API_ERROR_SYSCALL_ERROR_1:
2121 return clib_error_return (0, "I/O writing trace capture...");
2123 case VNET_API_ERROR_NO_SUCH_ENTRY:
2124 return clib_error_return (0, "No packets captured...");
2126 case VNET_API_ERROR_INVALID_MEMORY_SIZE:
2127 return clib_error_return (0,
2128 "Max bytes per pkt must be > 32, < 9000...");
2130 case VNET_API_ERROR_NO_SUCH_LABEL:
2131 return clib_error_return
2132 (0, "No classify filter configured, see 'classify filter...'");
2135 vlib_cli_output (vm, "WARNING: trace configure returned %d", rv);
2142 * This command is used to start or stop a packet capture, or show
2143 * the status of packet capture.
2145 * This command has the following optional parameters:
2148 * - <b>rx</b> - Capture received packets
2150 * - <b>tx</b> - Capture transmitted packets
2152 * - <b>drop</b> - Capture dropped packets
2154 * - <b>off</b> - Stop capturing packets, write results to the specified file
2156 * - <b>max <nn></b> - Depth of local buffer. Once '<em>nn</em>' number
2157 * of packets have been received, buffer is flushed to file. Once another
2158 * '<em>nn</em>' number of packets have been received, buffer is flushed
2159 * to file, overwriting previous write. If not entered, value defaults
2160 * to 100. Can only be updated if packet capture is off.
2162 * - <b>max-bytes-per-pkt <nnnn></b> - Maximum number of bytes to capture
2163 * for each packet. Must be >= 32, <= 9000.
2165 * - <b>intfc <interface-name>|any</b> - Used to specify a given interface,
2166 * or use '<em>any</em>' to run packet capture on all interfaces.
2167 * '<em>any</em>' is the default if not provided. Settings from a previous
2168 * packet capture are preserved, so '<em>any</em>' can be used to reset
2169 * the interface setting.
2171 * - <b>filter</b> - Use the pcap rx / tx / drop trace filter, which
2172 * must be configured. Use <b>classify filter pcap...</b> to configure the
2173 * filter. The filter will only be executed if the per-interface or
2174 * any-interface tests fail.
2176 * - <b>file <name></b> - Used to specify the output filename. The file will
2177 * be placed in the '<em>/tmp</em>' directory, so only the filename is
2178 * supported. Directory should not be entered. If file already exists, file
2179 * will be overwritten. If no filename is provided, the file will be
2180 * named "/tmp/rx.pcap", "/tmp/tx.pcap", "/tmp/rxandtx.pcap", etc.
2181 * Can only be updated if packet capture is off.
2183 * - <b>status</b> - Displays the current status and configured attributes
2184 * associated with a packet capture. If packet capture is in progress,
2185 * '<em>status</em>' also will return the number of packets currently in
2186 * the local buffer. All additional attributes entered on command line
2187 * with '<em>status</em>' will be ignored and not applied.
2190 * Example of how to display the status of a tx packet capture when off:
2191 * @cliexstart{pcap trace status}
2192 * max is 100, for any interface to file /tmp/vpe.pcap
2193 * pcap tx capture is off...
2195 * Example of how to start a tx packet capture:
2196 * @cliexstart{pcap trace tx max 35 intfc GigabitEthernet0/8/0 file vppTest.pcap}
2198 * Example of how to display the status of a tx packet capture in progress:
2199 * @cliexstart{pcap trace status}
2200 * max is 35, for interface GigabitEthernet0/8/0 to file /tmp/vppTest.pcap
2201 * pcap tx capture is on: 20 of 35 pkts...
2203 * Example of how to stop a tx packet capture:
2204 * @cliexstart{pcap trace off}
2205 * captured 21 pkts...
2206 * saved to /tmp/vppTest.pcap...
2211 VLIB_CLI_COMMAND (pcap_tx_trace_command, static) = {
2212 .path = "pcap trace",
2214 "pcap trace rx tx drop off [max <nn>] [intfc <interface>|any] [file <name>] [status] [max-bytes-per-pkt <nnnn>][filter]",
2215 .function = pcap_trace_command_fn,
2220 * fd.io coding-style-patch-verification: ON
2223 * eval: (c-set-style "gnu")