FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
interface_cli.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /*
16  * interface_cli.c: interface CLI
17  *
18  * Copyright (c) 2008 Eliot Dresselhaus
19  *
20  * Permission is hereby granted, free of charge, to any person obtaining
21  * a copy of this software and associated documentation files (the
22  * "Software"), to deal in the Software without restriction, including
23  * without limitation the rights to use, copy, modify, merge, publish,
24  * distribute, sublicense, and/or sell copies of the Software, and to
25  * permit persons to whom the Software is furnished to do so, subject to
26  * the following conditions:
27  *
28  * The above copyright notice and this permission notice shall be
29  * included in all copies or substantial portions of the Software.
30  *
31  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38  */
39 /**
40  * @file
41  * @brief Interface CLI.
42  *
43  * Source code for several CLI interface commands.
44  *
45  */
46 #include <vnet/vnet.h>
47 #include <vnet/ip/ip.h>
48 #include <vppinfra/bitmap.h>
49 #include <vnet/fib/ip4_fib.h>
50 #include <vnet/fib/ip6_fib.h>
51 #include <vnet/l2/l2_output.h>
52 #include <vnet/l2/l2_input.h>
56 static int
57 compare_interface_names (void *a1, void *a2)
58 {
59  u32 *hi1 = a1;
60  u32 *hi2 = a2;
61 
62  return vnet_hw_interface_compare (vnet_get_main (), *hi1, *hi2);
63 }
64 
65 static clib_error_t *
67  unformat_input_t * input,
68  vlib_cli_command_t * cmd, int is_show)
69 {
70  clib_error_t *error = 0;
71  vnet_main_t *vnm = vnet_get_main ();
74  u32 hw_if_index, *hw_if_indices = 0;
75  int i, verbose = -1, show_bond = 0;
76 
78  {
79  /* See if user wants to show a specific interface. */
80  if (unformat
81  (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
82  vec_add1 (hw_if_indices, hw_if_index);
83 
84  /* See if user wants to show an interface with a specific hw_if_index. */
85  else if (unformat (input, "%u", &hw_if_index))
86  vec_add1 (hw_if_indices, hw_if_index);
87 
88  else if (unformat (input, "verbose"))
89  verbose = 1; /* this is also the default */
90 
91  else if (unformat (input, "detail"))
92  verbose = 2;
93 
94  else if (unformat (input, "brief"))
95  verbose = 0;
96 
97  else if (unformat (input, "bond"))
98  {
99  show_bond = 1;
100  if (verbose < 0)
101  verbose = 0; /* default to brief for link bonding */
102  }
103 
104  else
105  {
106  error = clib_error_return (0, "unknown input `%U'",
107  format_unformat_error, input);
108  goto done;
109  }
110  }
111 
112  /* Gather interfaces. */
113  if (vec_len (hw_if_indices) == 0)
115  vec_add1 (hw_if_indices, hi - im->hw_interfaces);
116 
117  if (verbose < 0)
118  verbose = 1; /* default to verbose (except bond) */
119 
120  if (is_show)
121  {
122  /* Sort by name. */
124 
125  vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm, 0, verbose);
126  for (i = 0; i < vec_len (hw_if_indices); i++)
127  {
128  hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
129  if (show_bond == 0) /* show all interfaces */
131  hi, verbose);
132  else if ((hi->bond_info) &&
133  (hi->bond_info != VNET_HW_INTERFACE_BOND_INFO_SLAVE))
134  { /* show only bonded interface and all its slave interfaces */
135  int hw_idx;
136  vnet_hw_interface_t *shi;
138  hi, verbose);
139 
140  /* *INDENT-OFF* */
141  clib_bitmap_foreach (hw_idx, hi->bond_info)
142  {
143  shi = vnet_get_hw_interface(vnm, hw_idx);
144  vlib_cli_output (vm, "%U\n",
145  format_vnet_hw_interface, vnm, shi, verbose);
146  }
147  /* *INDENT-ON* */
148  }
149  }
150  }
151  else
152  {
153  for (i = 0; i < vec_len (hw_if_indices); i++)
154  {
156 
157  hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
158  dc = vec_elt_at_index (im->device_classes, hi->dev_class_index);
159 
160  if (dc->clear_counters)
161  dc->clear_counters (hi->dev_instance);
162  }
163  }
164 
165 done:
166  vec_free (hw_if_indices);
167  return error;
168 }
169 
170 static clib_error_t *
172  unformat_input_t * input, vlib_cli_command_t * cmd)
173 {
174  return show_or_clear_hw_interfaces (vm, input, cmd, 1 /* is_show */ );
175 }
176 
177 static clib_error_t *
179  unformat_input_t * input, vlib_cli_command_t * cmd)
180 {
181  return show_or_clear_hw_interfaces (vm, input, cmd, 0 /* is_show */ );
182 }
183 
184 
185 /*?
186  * Display more detailed information about all or a list of given interfaces.
187  * The verboseness of the output can be controlled by the following optional
188  * parameters:
189  * - brief: Only show name, index and state (default for bonded interfaces).
190  * - verbose: Also display additional attributes (default for all other interfaces).
191  * - detail: Also display all remaining attributes and extended statistics.
192  *
193  * To limit the output of the command to bonded interfaces and their slave
194  * interfaces, use the '<em>bond</em>' optional parameter.
195  *
196  * @cliexpar
197  * Example of how to display default data for all interfaces:
198  * @cliexstart{show hardware-interfaces}
199  * Name Idx Link Hardware
200  * GigabitEthernet7/0/0 1 up GigabitEthernet7/0/0
201  * Ethernet address ec:f4:bb:c0:bc:fc
202  * Intel e1000
203  * carrier up full duplex speed 1000 mtu 9216
204  * rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
205  * cpu socket 0
206  * GigabitEthernet7/0/1 2 up GigabitEthernet7/0/1
207  * Ethernet address ec:f4:bb:c0:bc:fd
208  * Intel e1000
209  * carrier up full duplex speed 1000 mtu 9216
210  * rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
211  * cpu socket 0
212  * VirtualEthernet0/0/0 3 up VirtualEthernet0/0/0
213  * Ethernet address 02:fe:a5:a9:8b:8e
214  * VirtualEthernet0/0/1 4 up VirtualEthernet0/0/1
215  * Ethernet address 02:fe:c0:4e:3b:b0
216  * VirtualEthernet0/0/2 5 up VirtualEthernet0/0/2
217  * Ethernet address 02:fe:1f:73:92:81
218  * VirtualEthernet0/0/3 6 up VirtualEthernet0/0/3
219  * Ethernet address 02:fe:f2:25:c4:68
220  * local0 0 down local0
221  * local
222  * @cliexend
223  * Example of how to display '<em>verbose</em>' data for an interface by name and
224  * software index (where 2 is the software index):
225  * @cliexstart{show hardware-interfaces GigabitEthernet7/0/0 2 verbose}
226  * Name Idx Link Hardware
227  * GigabitEthernet7/0/0 1 up GigabitEthernet7/0/0
228  * Ethernet address ec:f4:bb:c0:bc:fc
229  * Intel e1000
230  * carrier up full duplex speed 1000 mtu 9216
231  * rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
232  * cpu socket 0
233  * GigabitEthernet7/0/1 2 down GigabitEthernet7/0/1
234  * Ethernet address ec:f4:bb:c0:bc:fd
235  * Intel e1000
236  * carrier up full duplex speed 1000 mtu 9216
237  * rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
238  * cpu socket 0
239  * @cliexend
240  ?*/
241 /* *INDENT-OFF* */
243  .path = "show hardware-interfaces",
244  .short_help = "show hardware-interfaces [brief|verbose|detail] [bond] "
245  "[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
246  .function = show_hw_interfaces,
247 };
248 /* *INDENT-ON* */
249 
250 
251 /*?
252  * Clear the extended statistics for all or a list of given interfaces
253  * (statistics associated with the '<em>show hardware-interfaces</em>' command).
254  *
255  * @cliexpar
256  * Example of how to clear the extended statistics for all interfaces:
257  * @cliexcmd{clear hardware-interfaces}
258  * Example of how to clear the extended statistics for an interface by
259  * name and software index (where 2 is the software index):
260  * @cliexcmd{clear hardware-interfaces GigabitEthernet7/0/0 2}
261  ?*/
262 /* *INDENT-OFF* */
264  .path = "clear hardware-interfaces",
265  .short_help = "clear hardware-interfaces "
266  "[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
267  .function = clear_hw_interfaces,
268 };
269 /* *INDENT-ON* */
270 
271 static int
272 sw_interface_name_compare (void *a1, void *a2)
273 {
274  vnet_sw_interface_t *si1 = a1;
275  vnet_sw_interface_t *si2 = a2;
276 
278  si1->sw_if_index, si2->sw_if_index);
279 }
280 
281 static clib_error_t *
283  unformat_input_t * input, vlib_cli_command_t * cmd)
284 {
285  clib_error_t *error = 0;
286  vnet_main_t *vnm = vnet_get_main ();
287  unformat_input_t _linput, *linput = &_linput;
289  vnet_sw_interface_t *si, *sorted_sis = 0;
290  u32 sw_if_index = ~(u32) 0;
291  u8 show_addresses = 0;
292  u8 show_features = 0;
293  u8 show_tag = 0;
294  u8 show_vtr = 0;
295  int verbose = 0;
296 
297  /*
298  * Get a line of input. Won't work if the user typed
299  * "show interface" and nothing more.
300  */
301  if (unformat_user (input, unformat_line_input, linput))
302  {
303  while (unformat_check_input (linput) != UNFORMAT_END_OF_INPUT)
304  {
305  /* See if user wants to show specific interface */
306  if (unformat
307  (linput, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
308  {
310  vec_add1 (sorted_sis, si[0]);
311  }
312  else if (unformat (linput, "address") || unformat (linput, "addr"))
313  show_addresses = 1;
314  else if (unformat (linput, "features") || unformat (linput, "feat"))
315  show_features = 1;
316  else if (unformat (linput, "tag"))
317  show_tag = 1;
318  else if (unformat (linput, "vtr"))
319  show_vtr = 1;
320  else if (unformat (linput, "verbose"))
321  verbose = 1;
322  else if (unformat (linput, "%d", &sw_if_index))
323  {
325  {
327  vec_add1 (sorted_sis, si[0]);
328  }
329  else
330  {
331  vec_free (sorted_sis);
332  error = clib_error_return (0, "unknown interface index `%d'",
333  sw_if_index);
334  goto done;
335  }
336  }
337  else
338  {
339  vec_free (sorted_sis);
340  error = clib_error_return (0, "unknown input `%U'",
341  format_unformat_error, linput);
342  goto done;
343  }
344  }
345  unformat_free (linput);
346  }
347  if (show_features || show_tag || show_vtr)
348  {
349  if (sw_if_index == ~(u32) 0)
350  {
351  vec_free (sorted_sis);
352  return clib_error_return (0, "Interface not specified...");
353  }
354  }
355 
356  if (show_features)
357  {
360 
362  vlib_cli_output (vm, "\nl2-output:");
363  if (l2_output->out_vtr_flag)
364  vlib_cli_output (vm, "%10s (%s)", "VTR", "--internal--");
366  l2_output->feature_bitmap, 1);
367  vec_free (sorted_sis);
368  return 0;
369  }
370  if (show_tag)
371  {
372  u8 *tag;
374  vlib_cli_output (vm, "%U: %s",
376  tag ? (char *) tag : "(none)");
377  vec_free (sorted_sis);
378  return 0;
379  }
380 
381  /*
382  * Show vlan tag rewrite data for one interface.
383  */
384  if (show_vtr)
385  {
386  u32 vtr_op = L2_VTR_DISABLED;
387  u32 push_dot1q = 0, tag1 = 0, tag2 = 0;
388 
389  if (l2vtr_get (vm, vnm, sw_if_index,
390  &vtr_op, &push_dot1q, &tag1, &tag2) != 0)
391  {
392  vlib_cli_output (vm, "%U: Problem getting vlan tag-rewrite data",
394  return 0;
395  }
396  vlib_cli_output (vm, "%U: VTR %0U",
398  format_vtr, vtr_op, push_dot1q, tag1, tag2);
399  return 0;
400  }
401 
402  if (!show_addresses)
403  vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, 0);
404 
405  if (vec_len (sorted_sis) == 0) /* Get all interfaces */
406  {
407  /* Gather interfaces. */
408  sorted_sis =
410  _vec_len (sorted_sis) = 0;
411  /* *INDENT-OFF* */
413  {
414  int visible = vnet_swif_is_api_visible (si);
415  if (visible)
416  vec_add1 (sorted_sis, si[0]);
417  }
418  /* *INDENT-ON* */
419  /* Sort by name. */
421  }
422 
423  if (show_addresses)
424  {
425  vec_foreach (si, sorted_sis)
426  {
427  ip4_main_t *im4 = &ip4_main;
428  ip6_main_t *im6 = &ip6_main;
429  ip_lookup_main_t *lm4 = &im4->lookup_main;
430  ip_lookup_main_t *lm6 = &im6->lookup_main;
431  ip_interface_address_t *ia = 0;
432  u32 fib_index4 = 0, fib_index6 = 0;
433 
435  fib_index4 = vec_elt (im4->fib_index_by_sw_if_index,
436  si->sw_if_index);
437 
439  fib_index6 = vec_elt (im6->fib_index_by_sw_if_index,
440  si->sw_if_index);
441 
442  ip4_fib_t *fib4 = ip4_fib_get (fib_index4);
443  ip6_fib_t *fib6 = ip6_fib_get (fib_index6);
444 
447  (vm, "%U (%s): \n unnumbered, use %U",
449  (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn",
451  else
453  (vm, "%U (%s):",
455  (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn");
456 
457  /* Display any L2 info */
459 
460  /* *INDENT-OFF* */
461  /* Display any IP4 addressing info */
463  1 /* honor unnumbered */,
464  ({
465  ip4_address_t *r4 = ip_interface_address_get_address (lm4, ia);
466  if (fib4->hash.table_id)
467  vlib_cli_output (
468  vm, " L3 %U/%d ip4 table-id %d fib-idx %d", format_ip4_address,
469  r4, ia->address_length, fib4->hash.table_id,
470  ip4_fib_index_from_table_id (fib4->hash.table_id));
471  else
472  vlib_cli_output (vm, " L3 %U/%d",
473  format_ip4_address, r4, ia->address_length);
474  }));
475  /* *INDENT-ON* */
476 
477  /* *INDENT-OFF* */
478  /* Display any IP6 addressing info */
480  1 /* honor unnumbered */,
481  ({
482  ip6_address_t *r6 = ip_interface_address_get_address (lm6, ia);
483  if (fib6->table_id)
484  vlib_cli_output (vm, " L3 %U/%d ip6 table-id %d fib-idx %d",
485  format_ip6_address, r6, ia->address_length,
486  fib6->table_id,
487  ip6_fib_index_from_table_id (fib6->table_id));
488  else
489  vlib_cli_output (vm, " L3 %U/%d",
490  format_ip6_address, r6, ia->address_length);
491  }));
492  /* *INDENT-ON* */
493  }
494  }
495  else
496  {
497  vec_foreach (si, sorted_sis)
498  {
500  }
501  }
502 
503 done:
504  vec_free (sorted_sis);
505  return error;
506 }
507 
508 /* *INDENT-OFF* */
510  .path = "show interface",
511  .short_help = "show interface [address|addr|features|feat|vtr] [<interface> [<interface> [..]]] [verbose]",
512  .function = show_sw_interfaces,
513  .is_mp_safe = 1,
514 };
515 /* *INDENT-ON* */
516 
517 /* Root of all interface commands. */
518 /* *INDENT-OFF* */
520  .path = "interface",
521  .short_help = "Interface commands",
522 };
523 /* *INDENT-ON* */
524 
525 /* *INDENT-OFF* */
527  .path = "set interface",
528  .short_help = "Interface commands",
529 };
530 /* *INDENT-ON* */
531 
532 static clib_error_t *
534  unformat_input_t * input, vlib_cli_command_t * cmd)
535 {
536  vnet_main_t *vnm = vnet_get_main ();
540  int j, n_counters;
541 
542  n_counters = vec_len (im->combined_sw_if_counters);
543 
544  for (j = 0; j < n_counters; j++)
545  {
546  im = &vnm->interface_main;
549  }
550 
551  n_counters = vec_len (im->sw_if_counters);
552 
553  for (j = 0; j < n_counters; j++)
554  {
555  im = &vnm->interface_main;
556  sm = im->sw_if_counters + j;
558  }
559 
560  return 0;
561 }
562 
563 /*?
564  * Clear the statistics for all interfaces (statistics associated with the
565  * '<em>show interface</em>' command).
566  *
567  * @cliexpar
568  * Example of how to clear the statistics for all interfaces:
569  * @cliexcmd{clear interfaces}
570  ?*/
571 /* *INDENT-OFF* */
573  .path = "clear interfaces",
574  .short_help = "clear interfaces",
575  .function = clear_interface_counters,
576 };
577 /* *INDENT-ON* */
578 
579 /**
580  * Parse subinterface names.
581  *
582  * The following subinterface syntax is supported. The first two are for
583  * backwards compatability:
584  *
585  * <intf-name> <id>
586  * - a subinterface with the name <intf-name>.<id>. The subinterface
587  * is a single dot1q vlan with vlan id <id> and exact-match semantics.
588  *
589  * <intf-name> <min_id>-<max_id>
590  * - a set of the above subinterfaces, repeating for each id
591  * in the range <min_id> to <max_id>
592  *
593  * In the following, exact-match semantics (i.e. the number of vlan tags on the
594  * packet must match the number of tags in the configuration) are used only if
595  * the keyword exact-match is present. Non-exact match is the default.
596  *
597  * <intf-name> <id> dot1q <outer_id> [exact-match]
598  * - a subinterface with the name <intf-name>.<id>. The subinterface
599  * is a single dot1q vlan with vlan id <outer_id>.
600  *
601  * <intf-name> <id> dot1q any [exact-match]
602  * - a subinterface with the name <intf-name>.<id>. The subinterface
603  * is a single dot1q vlan with any vlan id.
604  *
605  * <intf-name> <id> dot1q <outer_id> inner-dot1q <inner_id> [exact-match]
606  * - a subinterface with the name <intf-name>.<id>. The subinterface
607  * is a double dot1q vlan with outer vlan id <outer_id> and inner vlan id
608  * <inner_id>.
609  *
610  * <intf-name> <id> dot1q <outer_id> inner-dot1q any [exact-match]
611  * - a subinterface with the name <intf-name>.<id>. The subinterface
612  * is a double dot1q vlan with outer vlan id <id> and any inner vlan id.
613  *
614  * <intf-name> <id> dot1q any inner-dot1q any [exact-match]
615  *
616  * - a subinterface with the name <intf-name>.<id>. The subinterface
617  * is a double dot1q vlan with any outer vlan id and any inner vlan id.
618  *
619  * For each of the above CLI, there is a duplicate that uses the keyword
620  * "dot1ad" in place of the first "dot1q". These interfaces use ethertype
621  * 0x88ad in place of 0x8100 for the outer ethertype. Note that for double-
622  * tagged packets the inner ethertype is always 0x8100. Also note that
623  * the dot1q and dot1ad naming spaces are independent, so it is legal to
624  * have both "Gig3/0/0.1 dot1q 100" and "Gig3/0/0.2 dot1ad 100". For example:
625  *
626  * <intf-name> <id> dot1ad <outer_id> inner-dot1q <inner_id> [exact-match]
627  * - a subinterface with the name <intf-name>.<id>. The subinterface
628  * is a double dot1ad vlan with outer vlan id <outer_id> and inner vlan
629  * id <inner_id>.
630  *
631  * <intf-name> <id> untagged
632  * - a subinterface with the name <intf-name>.<id>. The subinterface
633  * has no vlan tags. Only one can be specified per interface.
634  *
635  * <intf-name> <id> default
636  * - a subinterface with the name <intf-name>.<id>. This is associated
637  * with a packet that did not match any other configured subinterface
638  * on this interface. Only one can be specified per interface.
639  */
640 
641 static clib_error_t *
643  vnet_sw_interface_t * template)
644 {
645  clib_error_t *error = 0;
646  u32 inner_vlan, outer_vlan;
647 
648  if (unformat (input, "any inner-dot1q any"))
649  {
650  template->sub.eth.flags.two_tags = 1;
651  template->sub.eth.flags.outer_vlan_id_any = 1;
652  template->sub.eth.flags.inner_vlan_id_any = 1;
653  }
654  else if (unformat (input, "any"))
655  {
656  template->sub.eth.flags.one_tag = 1;
657  template->sub.eth.flags.outer_vlan_id_any = 1;
658  }
659  else if (unformat (input, "%d inner-dot1q any", &outer_vlan))
660  {
661  template->sub.eth.flags.two_tags = 1;
662  template->sub.eth.flags.inner_vlan_id_any = 1;
663  template->sub.eth.outer_vlan_id = outer_vlan;
664  }
665  else if (unformat (input, "%d inner-dot1q %d", &outer_vlan, &inner_vlan))
666  {
667  template->sub.eth.flags.two_tags = 1;
668  template->sub.eth.outer_vlan_id = outer_vlan;
669  template->sub.eth.inner_vlan_id = inner_vlan;
670  }
671  else if (unformat (input, "%d", &outer_vlan))
672  {
673  template->sub.eth.flags.one_tag = 1;
674  template->sub.eth.outer_vlan_id = outer_vlan;
675  }
676  else
677  {
678  error = clib_error_return (0, "expected dot1q config, got `%U'",
679  format_unformat_error, input);
680  goto done;
681  }
682 
684  {
685  if (unformat (input, "exact-match"))
686  {
687  template->sub.eth.flags.exact_match = 1;
688  }
689  }
690 
691 done:
692  return error;
693 }
694 
695 static clib_error_t *
697  unformat_input_t * input, vlib_cli_command_t * cmd)
698 {
699  vnet_main_t *vnm = vnet_get_main ();
700  clib_error_t *error = 0;
701  u32 hw_if_index, sw_if_index;
703  u32 id, id_min, id_max;
704  vnet_sw_interface_t template;
705 
706  hw_if_index = ~0;
707  if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
708  {
709  error = clib_error_return (0, "unknown interface `%U'",
710  format_unformat_error, input);
711  goto done;
712  }
713 
714  clib_memset (&template, 0, sizeof (template));
715  template.sub.eth.raw_flags = 0;
716 
717  if (unformat (input, "%d default", &id_min))
718  {
719  id_max = id_min;
720  template.sub.eth.flags.default_sub = 1;
721  }
722  else if (unformat (input, "%d untagged", &id_min))
723  {
724  id_max = id_min;
725  template.sub.eth.flags.no_tags = 1;
726  template.sub.eth.flags.exact_match = 1;
727  }
728  else if (unformat (input, "%d dot1q", &id_min))
729  {
730  /* parse dot1q config */
731  id_max = id_min;
732  error = parse_vlan_sub_interfaces (input, &template);
733  if (error)
734  goto done;
735  }
736  else if (unformat (input, "%d dot1ad", &id_min))
737  {
738  /* parse dot1ad config */
739  id_max = id_min;
740  template.sub.eth.flags.dot1ad = 1;
741  error = parse_vlan_sub_interfaces (input, &template);
742  if (error)
743  goto done;
744  }
745  else if (unformat (input, "%d-%d", &id_min, &id_max))
746  {
747  template.sub.eth.flags.one_tag = 1;
748  template.sub.eth.flags.exact_match = 1;
749  if (id_min > id_max)
750  goto id_error;
751  }
752  else if (unformat (input, "%d", &id_min))
753  {
754  id_max = id_min;
755  template.sub.eth.flags.one_tag = 1;
756  template.sub.eth.outer_vlan_id = id_min;
757  template.sub.eth.flags.exact_match = 1;
758  }
759  else
760  {
761  id_error:
762  error = clib_error_return (0, "expected ID or ID MIN-MAX, got `%U'",
763  format_unformat_error, input);
764  goto done;
765  }
766 
767  hi = vnet_get_hw_interface (vnm, hw_if_index);
768 
769  if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
770  {
771  error =
773  "not allowed as %v belong to a BondEthernet interface",
774  hi->name);
775  goto done;
776  }
777 
778  for (id = id_min; id <= id_max; id++)
779  {
780  uword *p;
782  u64 sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
783  u64 *kp;
784 
785  p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
786  if (p)
787  {
788  if (CLIB_DEBUG > 0)
789  clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
790  hi->sw_if_index, id);
791  continue;
792  }
793 
794  template.type = VNET_SW_INTERFACE_TYPE_SUB;
795  template.flood_class = VNET_FLOOD_CLASS_NORMAL;
796  template.sup_sw_if_index = hi->sw_if_index;
797  template.sub.id = id;
798  if (id_min < id_max)
799  template.sub.eth.outer_vlan_id = id;
800 
801  error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
802  if (error)
803  goto done;
804 
805  kp = clib_mem_alloc (sizeof (*kp));
806  *kp = sup_and_sub_key;
807 
808  hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
812  }
813 
814 done:
815  return error;
816 }
817 
818 /*?
819  * This command is used to add VLAN IDs to interfaces, also known as subinterfaces.
820  * The primary input to this command is the '<em>interface</em>' and '<em>subId</em>'
821  * (subinterface Id) parameters. If no additional VLAN ID is provide, the VLAN ID is
822  * assumed to be the '<em>subId</em>'. The VLAN ID and '<em>subId</em>' can be different,
823  * but this is not recommended.
824  *
825  * This command has several variations:
826  * - <b>create sub-interfaces <interface> <subId></b> - Create a subinterface to
827  * process packets with a given 802.1q VLAN ID (same value as the '<em>subId</em>').
828  *
829  * - <b>create sub-interfaces <interface> <subId> default</b> - Adding the
830  * '<em>default</em>' parameter indicates that packets with VLAN IDs that do not
831  * match any other subinterfaces should be sent to this subinterface.
832  *
833  * - <b>create sub-interfaces <interface> <subId> untagged</b> - Adding the
834  * '<em>untagged</em>' parameter indicates that packets no VLAN IDs should be sent
835  * to this subinterface.
836  *
837  * - <b>create sub-interfaces <interface> <subId>-<subId></b> - Create a range of
838  * subinterfaces to handle a range of VLAN IDs.
839  *
840  * - <b>create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any [exact-match]</b> -
841  * Use this command to specify the outer VLAN ID, to either be explicit or to make the
842  * VLAN ID different from the '<em>subId</em>'.
843  *
844  * - <b>create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any inner-dot1q
845  * <vlanId>|any [exact-match]</b> - Use this command to specify the outer VLAN ID and
846  * the inner VLAN ID.
847  *
848  * When '<em>dot1q</em>' or '<em>dot1ad</em>' is explicitly entered, subinterfaces
849  * can be configured as either exact-match or non-exact match. Non-exact match is the CLI
850  * default. If '<em>exact-match</em>' is specified, packets must have the same number of
851  * VLAN tags as the configuration. For non-exact-match, packets must at least that number
852  * of tags. L3 (routed) interfaces must be configured as exact-match. L2 interfaces are
853  * typically configured as non-exact-match. If '<em>dot1q</em>' or '<em>dot1ad</em>' is NOT
854  * entered, then the default behavior is exact-match.
855  *
856  * Use the '<em>show interface</em>' command to display all subinterfaces.
857  *
858  * @cliexpar
859  * @parblock
860  * Example of how to create a VLAN subinterface 11 to process packets on 802.1q VLAN ID 11:
861  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11}
862  *
863  * The previous example is shorthand and is equivalent to:
864  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 11 exact-match}
865  *
866  *
867  * Example of how to create a subinterface number that is different from the VLAN ID:
868  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100}
869  *
870  *
871  * Examples of how to create q-in-q and q-in-any subinterfaces:
872  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100 inner-dot1q 200}
873  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 12 dot1q 100 inner-dot1q any}
874  *
875  * Examples of how to create dot1ad interfaces:
876  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1ad 11}
877  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 12 dot1ad 100 inner-dot1q 200}
878  *
879  *
880  * Examples of '<em>exact-match</em>' versus non-exact match. A packet with
881  * outer VLAN 100 and inner VLAN 200 would match this interface, because the default
882  * is non-exact match:
883  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100}
884  *
885  * However, the same packet would NOT match this interface because '<em>exact-match</em>'
886  * is specified and only one VLAN is configured, but packet contains two VLANs:
887  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100 exact-match}
888  *
889  *
890  * Example of how to created a subinterface to process untagged packets:
891  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 untagged}
892  *
893  * Example of how to created a subinterface to process any packet with a VLAN ID that
894  * does not match any other subinterface:
895  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 7 default}
896  *
897  * When subinterfaces are created, they are in the down state. Example of how to
898  * enable a newly created subinterface:
899  * @cliexcmd{set interface GigabitEthernet2/0/0.7 up}
900  * @endparblock
901  ?*/
902 /* *INDENT-OFF* */
904  .path = "create sub-interfaces",
905  .short_help = "create sub-interfaces <interface> "
906  "{<subId> [default|untagged]} | "
907  "{<subId>-<subId>} | "
908  "{<subId> dot1q|dot1ad <vlanId>|any [inner-dot1q <vlanId>|any] [exact-match]}",
909  .function = create_sub_interfaces,
910 };
911 /* *INDENT-ON* */
912 
913 static clib_error_t *
915  unformat_input_t * input, vlib_cli_command_t * cmd)
916 {
917  vnet_main_t *vnm = vnet_get_main ();
920 
921  sw_if_index = ~0;
923  {
924  error = clib_error_return (0, "unknown interface `%U'",
925  format_unformat_error, input);
926  goto done;
927  }
928 
929  if (!unformat (input, "%U", unformat_vnet_sw_interface_flags, &flags))
930  {
931  error = clib_error_return (0, "unknown flags `%U'",
932  format_unformat_error, input);
933  goto done;
934  }
935 
937  if (error)
938  goto done;
939 
940 done:
941  return error;
942 }
943 
944 
945 /*?
946  * This command is used to change the admin state (up/down) of an interface.
947  *
948  * If an interface is down, the optional '<em>punt</em>' flag can also be set.
949  * The '<em>punt</em>' flag implies the interface is disabled for forwarding
950  * but punt all traffic to slow-path. Use the '<em>enable</em>' flag to clear
951  * '<em>punt</em>' flag (interface is still down).
952  *
953  * @cliexpar
954  * Example of how to configure the admin state of an interface to '<em>up</em?':
955  * @cliexcmd{set interface state GigabitEthernet2/0/0 up}
956  * Example of how to configure the admin state of an interface to '<em>down</em?':
957  * @cliexcmd{set interface state GigabitEthernet2/0/0 down}
958  ?*/
959 /* *INDENT-OFF* */
961  .path = "set interface state",
962  .short_help = "set interface state <interface> [up|down|punt|enable]",
963  .function = set_state,
964 };
965 /* *INDENT-ON* */
966 
967 static clib_error_t *
969  unformat_input_t * input, vlib_cli_command_t * cmd)
970 {
971  vnet_main_t *vnm = vnet_get_main ();
972  u32 unnumbered_sw_if_index = ~0;
973  u32 inherit_from_sw_if_index = ~0;
974  int enable = 1;
975 
976  if (unformat (input, "%U use %U",
977  unformat_vnet_sw_interface, vnm, &unnumbered_sw_if_index,
978  unformat_vnet_sw_interface, vnm, &inherit_from_sw_if_index))
979  enable = 1;
980  else if (unformat (input, "del %U",
982  &unnumbered_sw_if_index))
983  enable = 0;
984  else
985  return clib_error_return (0, "parse error '%U'",
986  format_unformat_error, input);
987 
988  if (~0 == unnumbered_sw_if_index)
989  return clib_error_return (0, "Specify the unnumbered interface");
990  if (enable && ~0 == inherit_from_sw_if_index)
991  return clib_error_return (0, "When enabling unnumbered specify the"
992  " IP enabled interface that it uses");
993 
995  unnumbered_sw_if_index, inherit_from_sw_if_index, enable);
996 
997  switch (rv)
998  {
999  case 0:
1000  break;
1001 
1002  case VNET_API_ERROR_UNEXPECTED_INTF_STATE:
1003  return clib_error_return (
1004  0,
1005  "When enabling unnumbered both interfaces must be in the same tables");
1006 
1007  default:
1008  return clib_error_return (
1009  0, "vnet_sw_interface_update_unnumbered returned %d", rv);
1010  }
1011 
1012  return (NULL);
1013 }
1014 
1015 /* *INDENT-OFF* */
1017  .path = "set interface unnumbered",
1018  .short_help = "set interface unnumbered [<interface> use <interface> | del <interface>]",
1019  .function = set_unnumbered,
1020 };
1021 /* *INDENT-ON* */
1022 
1023 
1024 
1025 static clib_error_t *
1027  unformat_input_t * input, vlib_cli_command_t * cmd)
1028 {
1029  vnet_main_t *vnm = vnet_get_main ();
1032  u32 hw_if_index, hw_class_index;
1033 
1034  hw_if_index = ~0;
1035  if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
1036  {
1037  error = clib_error_return (0, "unknown hardware interface `%U'",
1038  format_unformat_error, input);
1039  goto done;
1040  }
1041 
1042  if (!unformat_user (input, unformat_hash_string,
1043  im->hw_interface_class_by_name, &hw_class_index))
1044  {
1045  error = clib_error_return (0, "unknown hardware class `%U'",
1046  format_unformat_error, input);
1047  goto done;
1048  }
1049 
1050  error = vnet_hw_interface_set_class (vnm, hw_if_index, hw_class_index);
1051  if (error)
1052  goto done;
1053 
1054 done:
1055  return error;
1056 }
1057 
1058 /* *INDENT-OFF* */
1060  .path = "set interface hw-class",
1061  .short_help = "Set interface hardware class",
1062  .function = set_hw_class,
1063 };
1064 /* *INDENT-ON* */
1065 
1066 static clib_error_t *
1068 {
1069  return 0;
1070 }
1071 
1073 
1074 static clib_error_t *
1076  unformat_input_t * input,
1077  vlib_cli_command_t * cmd)
1078 {
1079  u32 hw_if_index;
1080  u32 new_dev_instance;
1081  vnet_main_t *vnm = vnet_get_main ();
1082  int rv;
1083 
1084  if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
1085  return clib_error_return (0, "unknown hardware interface `%U'",
1086  format_unformat_error, input);
1087 
1088  if (!unformat (input, "%d", &new_dev_instance))
1089  return clib_error_return (0, "new dev instance missing");
1090 
1091  rv = vnet_interface_name_renumber (hw_if_index, new_dev_instance);
1092 
1093  switch (rv)
1094  {
1095  case 0:
1096  break;
1097 
1098  default:
1099  return clib_error_return (0, "vnet_interface_name_renumber returned %d",
1100  rv);
1101 
1102  }
1103 
1104  return 0;
1105 }
1106 
1107 
1108 /* *INDENT-OFF* */
1110  .path = "renumber interface",
1111  .short_help = "renumber interface <interface> <new-dev-instance>",
1112  .function = renumber_interface_command_fn,
1113 };
1114 /* *INDENT-ON* */
1115 
1116 static clib_error_t *
1118  unformat_input_t * input, vlib_cli_command_t * cmd)
1119 {
1120  vnet_main_t *vnm = vnet_get_main ();
1121  u32 hw_if_index;
1124  ethernet_interface_t *eif;
1125 
1126  if (unformat (input, "on %U",
1127  unformat_vnet_hw_interface, vnm, &hw_if_index))
1128  ;
1129  else if (unformat (input, "off %U",
1130  unformat_ethernet_interface, vnm, &hw_if_index))
1131  flags = 0;
1132  else
1133  return clib_error_return (0, "unknown input `%U'",
1134  format_unformat_error, input);
1135 
1136  eif = ethernet_get_interface (em, hw_if_index);
1137  if (!eif)
1138  return clib_error_return (0, "not supported");
1139 
1140  ethernet_set_flags (vnm, hw_if_index, flags);
1141  return 0;
1142 }
1143 
1144 /* *INDENT-OFF* */
1146  .path = "set interface promiscuous",
1147  .short_help = "set interface promiscuous [on|off] <interface>",
1148  .function = promiscuous_cmd,
1149 };
1150 /* *INDENT-ON* */
1151 
1152 static clib_error_t *
1154 {
1155  vnet_main_t *vnm = vnet_get_main ();
1156  u32 hw_if_index, sw_if_index, mtu;
1158  u32 mtus[VNET_N_MTU] = { 0, 0, 0, 0 };
1159 
1160  if (unformat (input, "%d %U", &mtu,
1161  unformat_vnet_hw_interface, vnm, &hw_if_index))
1162  {
1163  /*
1164  * Change physical MTU on interface. Only supported for Ethernet
1165  * interfaces
1166  */
1167  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
1168  ethernet_interface_t *eif = ethernet_get_interface (em, hw_if_index);
1169 
1170  if (!eif)
1171  return clib_error_return (0, "not supported");
1172 
1173  if (mtu < hi->min_supported_packet_bytes)
1174  return clib_error_return (0, "Invalid mtu (%d): "
1175  "must be >= min pkt bytes (%d)", mtu,
1176  hi->min_supported_packet_bytes);
1177 
1178  if (mtu > hi->max_supported_packet_bytes)
1179  return clib_error_return (0, "Invalid mtu (%d): must be <= (%d)", mtu,
1180  hi->max_supported_packet_bytes);
1181 
1182  vnet_hw_interface_set_mtu (vnm, hw_if_index, mtu);
1183  goto done;
1184  }
1185  else if (unformat (input, "packet %d %U", &mtu,
1187  /* Set default packet MTU (including L3 header */
1188  mtus[VNET_MTU_L3] = mtu;
1189  else if (unformat (input, "ip4 %d %U", &mtu,
1191  mtus[VNET_MTU_IP4] = mtu;
1192  else if (unformat (input, "ip6 %d %U", &mtu,
1194  mtus[VNET_MTU_IP6] = mtu;
1195  else if (unformat (input, "mpls %d %U", &mtu,
1197  mtus[VNET_MTU_MPLS] = mtu;
1198  else
1199  return clib_error_return (0, "unknown input `%U'",
1200  format_unformat_error, input);
1201 
1203 
1204 done:
1205  return 0;
1206 }
1207 
1208 /* *INDENT-OFF* */
1210  .path = "set interface mtu",
1211  .short_help = "set interface mtu [packet|ip4|ip6|mpls] <value> <interface>",
1212  .function = mtu_cmd,
1213 };
1214 /* *INDENT-ON* */
1215 
1216 static clib_error_t *
1218  vlib_cli_command_t * cmd)
1219 {
1220  vnet_main_t *vnm = vnet_get_main ();
1223  u32 sw_if_index = ~0;
1224  vnet_sw_interface_t *si, *sorted_sis = 0;
1225 
1226  if (unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
1227  {
1229  vec_add1 (sorted_sis, si[0]);
1230  }
1231 
1232  /* if an interface name was not passed, get all interfaces */
1233  if (vec_len (sorted_sis) == 0)
1234  {
1235  sorted_sis =
1237  _vec_len (sorted_sis) = 0;
1238  /* *INDENT-OFF* */
1240  {
1241  int visible = vnet_swif_is_api_visible (si);
1242  if (visible)
1243  vec_add1 (sorted_sis, si[0]);
1244  }
1245  /* *INDENT-ON* */
1246  /* Sort by name. */
1248  }
1249 
1250  vec_foreach (si, sorted_sis)
1251  {
1252  vnet_sw_interface_t *sup_si;
1254 
1255  sup_si = vnet_get_sup_sw_interface (vnm, si->sw_if_index);
1256  ei = ethernet_get_interface (em, sup_si->hw_if_index);
1257 
1258  vlib_cli_output (vm, "%U (%s):",
1261  "up" : "dn");
1262 
1263  if (ei && ei->secondary_addrs)
1264  {
1265  ethernet_interface_address_t *sec_addr;
1266 
1267  vec_foreach (sec_addr, ei->secondary_addrs)
1268  {
1269  vlib_cli_output (vm, " %U", format_mac_address_t, &sec_addr->mac);
1270  }
1271  }
1272  }
1273 
1274  vec_free (sorted_sis);
1275  return 0;
1276 }
1277 
1278 /*?
1279  * This command is used to display interface secondary mac addresses.
1280  *
1281  * @cliexpar
1282  * Example of how to display interface secondary mac addresses:
1283  * @cliexstart{show interface secondary-mac-address}
1284  * @cliexend
1285 ?*/
1286 /* *INDENT-OFF* */
1288  .path = "show interface secondary-mac-address",
1289  .short_help = "show interface secondary-mac-address [<interface>]",
1290  .function = show_interface_sec_mac_addr_fn,
1291 };
1292 /* *INDENT-ON* */
1293 
1294 static clib_error_t *
1296  vlib_cli_command_t * cmd)
1297 {
1298  vnet_main_t *vnm = vnet_get_main ();
1299  vnet_sw_interface_t *si = NULL;
1300  clib_error_t *error = 0;
1301  u32 sw_if_index = ~0;
1302  u8 mac[6] = { 0 };
1303  u8 is_add, is_del;
1304 
1305  is_add = is_del = 0;
1306 
1308  {
1309  error = clib_error_return (0, "unknown interface `%U'",
1310  format_unformat_error, input);
1311  goto done;
1312  }
1314  {
1315  error = clib_error_return (0, "expected mac address `%U'",
1316  format_unformat_error, input);
1317  goto done;
1318  }
1319 
1320  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1321  {
1322  if (unformat (input, "add"))
1323  is_add = 1;
1324  else if (unformat (input, "del"))
1325  is_del = 1;
1326  else
1327  break;
1328  }
1329 
1330  if (is_add == is_del)
1331  {
1332  error = clib_error_return (0, "must choose one of add or del");
1333  goto done;
1334  }
1335 
1337  error =
1339 
1340 done:
1341  return error;
1342 }
1343 
1344 /*?
1345  * The '<em>set interface secondary-mac-address </em>' command allows adding
1346  * or deleting extra MAC addresses on a given interface without changing the
1347  * default MAC address. This could allow packets sent to these MAC addresses
1348  * to be received without setting the interface to promiscuous mode.
1349  * Not all interfaces support this operation. The ones that do are mostly
1350  * hardware NICs, though virtio does also.
1351  *
1352  * @cliexpar
1353  * @parblock
1354  * Example of how to add a secondary MAC Address on an interface:
1355  * @cliexcmd{set interface secondary-mac-address GigabitEthernet0/8/0 aa:bb:cc:dd:ee:01 add}
1356  * Example of how to delete a secondary MAC address from an interface:
1357  * @cliexcmd{set interface secondary-mac-address GigabitEthernet0/8/0 aa:bb:cc:dd:ee:01 del}
1358  * @endparblock
1359 ?*/
1360 /* *INDENT-OFF* */
1362  .path = "set interface secondary-mac-address",
1363  .short_help = "set interface secondary-mac-address <interface> <mac-address> [(add|del)]",
1364  .function = interface_add_del_mac_address,
1365 };
1366 /* *INDENT-ON* */
1367 
1368 static clib_error_t *
1370  vlib_cli_command_t * cmd)
1371 {
1372  vnet_main_t *vnm = vnet_get_main ();
1373  vnet_sw_interface_t *si = NULL;
1374  clib_error_t *error = 0;
1375  u32 sw_if_index = ~0;
1376  u8 mac[6] = { 0 };
1377 
1379  {
1380  error = clib_error_return (0, "unknown interface `%U'",
1381  format_unformat_error, input);
1382  goto done;
1383  }
1385  {
1386  error = clib_error_return (0, "expected mac address `%U'",
1387  format_unformat_error, input);
1388  goto done;
1389  }
1392 done:
1393  return error;
1394 }
1395 
1396 /*?
1397  * The '<em>set interface mac address </em>' command allows to set MAC address of given interface.
1398  * In case of NIC interfaces the one has to support MAC address change. A side effect of MAC address
1399  * change are changes of MAC addresses in FIB tables (ipv4 and ipv6).
1400  *
1401  * @cliexpar
1402  * @parblock
1403  * Example of how to change MAC Address of interface:
1404  * @cliexcmd{set interface mac address GigabitEthernet0/8/0 aa:bb:cc:dd:ee:01}
1405  * @cliexcmd{set interface mac address host-vpp0 aa:bb:cc:dd:ee:02}
1406  * @cliexcmd{set interface mac address tap-0 aa:bb:cc:dd:ee:03}
1407  * @cliexcmd{set interface mac address pg0 aa:bb:cc:dd:ee:04}
1408  * @endparblock
1409 ?*/
1410 /* *INDENT-OFF* */
1412  .path = "set interface mac address",
1413  .short_help = "set interface mac address <interface> <mac-address>",
1414  .function = set_interface_mac_address,
1415 };
1416 /* *INDENT-ON* */
1417 
1418 static clib_error_t *
1420 {
1421  vnet_main_t *vnm = vnet_get_main ();
1422  u32 sw_if_index = ~0;
1423  u8 *tag = 0;
1424 
1425  if (!unformat (input, "%U %s", unformat_vnet_sw_interface,
1426  vnm, &sw_if_index, &tag))
1427  return clib_error_return (0, "unknown input `%U'",
1428  format_unformat_error, input);
1429 
1431 
1432  return 0;
1433 }
1434 
1435 /* *INDENT-OFF* */
1437  .path = "set interface tag",
1438  .short_help = "set interface tag <interface> <tag>",
1439  .function = set_tag,
1440 };
1441 /* *INDENT-ON* */
1442 
1443 static clib_error_t *
1445  vlib_cli_command_t * cmd)
1446 {
1447  vnet_main_t *vnm = vnet_get_main ();
1448  u32 sw_if_index = ~0;
1449 
1450  if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
1451  return clib_error_return (0, "unknown input `%U'",
1452  format_unformat_error, input);
1453 
1455 
1456  return 0;
1457 }
1458 
1459 /* *INDENT-OFF* */
1461  .path = "clear interface tag",
1462  .short_help = "clear interface tag <interface>",
1463  .function = clear_tag,
1464 };
1465 /* *INDENT-ON* */
1466 
1467 static clib_error_t *
1469  unformat_input_t * input, vlib_cli_command_t * cmd)
1470 {
1471  vnet_main_t *vnm = vnet_get_main ();
1472  u32 sw_if_index = ~0;
1473  u8 enable = 0;
1474 
1475  if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index));
1476  else if (unformat (input, "enable"))
1477  enable = 1;
1478  else if (unformat (input, "disable"))
1479  enable = 0;
1480  else
1481  return clib_error_return (0, "unknown input: `%U'",
1482  format_unformat_error, input);
1483 
1484  if (~0 == sw_if_index)
1485  return clib_error_return (0, "specify an interface: `%U'",
1486  format_unformat_error, input);
1487 
1489 
1490  return 0;
1491 }
1492 
1493 /*?
1494  * This command is used to enable/disable IP directed broadcast
1495  * If directed broadcast is enabled a packet sent to the interface's
1496  * subnet broadcast address will be sent L2 broadcast on the interface,
1497  * otherwise it is dropped.
1498  ?*/
1499 /* *INDENT-OFF* */
1501  .path = "set interface ip directed-broadcast",
1502  .short_help = "set interface enable <interface> <enable|disable>",
1503  .function = set_ip_directed_broadcast,
1504 };
1505 /* *INDENT-ON* */
1506 
1507 clib_error_t *
1509  u8 queue_id_valid, u32 queue_id,
1511 {
1512  clib_error_t *error = 0;
1513  vnet_hw_interface_t *hw;
1514  u32 *queue_indices = 0;
1515 
1516  hw = vnet_get_hw_interface (vnm, hw_if_index);
1517 
1518  if (queue_id_valid)
1519  {
1520  u32 queue_index;
1521  queue_index =
1522  vnet_hw_if_get_rx_queue_index_by_id (vnm, hw_if_index, queue_id);
1523  if (queue_index == ~0)
1524  return clib_error_return (0, "unknown queue %u on interface %s",
1525  queue_id, hw->name);
1526  vec_add1 (queue_indices, queue_index);
1527  }
1528  else
1529  queue_indices = hw->rx_queue_indices;
1530 
1531  for (int i = 0; i < vec_len (queue_indices); i++)
1532  {
1533  int rv = vnet_hw_if_set_rx_queue_mode (vnm, queue_indices[i], mode);
1534  if (rv)
1535  goto done;
1536  }
1537 
1538 done:
1539  if (queue_indices != hw->rx_queue_indices)
1540  vec_free (queue_indices);
1541  vnet_hw_if_update_runtime_data (vnm, hw_if_index);
1542  return error;
1543 }
1544 
1545 static clib_error_t *
1547  vlib_cli_command_t * cmd)
1548 {
1549  clib_error_t *error = 0;
1550  unformat_input_t _line_input, *line_input = &_line_input;
1551  vnet_main_t *vnm = vnet_get_main ();
1552  u32 hw_if_index = (u32) ~ 0;
1553  u32 queue_id = (u32) ~ 0;
1555  u8 queue_id_valid = 0;
1556 
1557  if (!unformat_user (input, unformat_line_input, line_input))
1558  return 0;
1559 
1560  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1561  {
1562  if (unformat
1563  (line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
1564  ;
1565  else if (unformat (line_input, "queue %d", &queue_id))
1566  queue_id_valid = 1;
1567  else if (unformat (line_input, "polling"))
1569  else if (unformat (line_input, "interrupt"))
1571  else if (unformat (line_input, "adaptive"))
1573  else
1574  {
1575  error = clib_error_return (0, "parse error: '%U'",
1576  format_unformat_error, line_input);
1577  unformat_free (line_input);
1578  return error;
1579  }
1580  }
1581 
1582  unformat_free (line_input);
1583 
1584  if (hw_if_index == (u32) ~ 0)
1585  return clib_error_return (0, "please specify valid interface name");
1586 
1588  return clib_error_return (0, "please specify valid rx-mode");
1589 
1590  error = set_hw_interface_change_rx_mode (vnm, hw_if_index, queue_id_valid,
1591  queue_id, mode);
1592 
1593  return (error);
1594 }
1595 
1596 /*?
1597  * This command is used to assign the RX packet processing mode (polling,
1598  * interrupt, adaptive) of the a given interface, and optionally a
1599  * given queue. If the '<em>queue</em>' is not provided, the '<em>mode</em>'
1600  * is applied to all queues of the interface. Not all interfaces support
1601  * all modes. To display the current rx-mode use the command
1602  * '<em>show interface rx-placement</em>'.
1603  *
1604  * @cliexpar
1605  * Example of how to assign rx-mode to all queues on an interface:
1606  * @cliexcmd{set interface rx-mode VirtualEthernet0/0/12 polling}
1607  * Example of how to assign rx-mode to one queue of an interface:
1608  * @cliexcmd{set interface rx-mode VirtualEthernet0/0/12 queue 0 interrupt}
1609  * Example of how to display the rx-mode of all interfaces:
1610  * @cliexstart{show interface rx-placement}
1611  * Thread 1 (vpp_wk_0):
1612  * node dpdk-input:
1613  * GigabitEthernet7/0/0 queue 0 (polling)
1614  * node vhost-user-input:
1615  * VirtualEthernet0/0/12 queue 0 (interrupt)
1616  * VirtualEthernet0/0/12 queue 2 (polling)
1617  * VirtualEthernet0/0/13 queue 0 (polling)
1618  * VirtualEthernet0/0/13 queue 2 (polling)
1619  * Thread 2 (vpp_wk_1):
1620  * node dpdk-input:
1621  * GigabitEthernet7/0/1 queue 0 (polling)
1622  * node vhost-user-input:
1623  * VirtualEthernet0/0/12 queue 1 (polling)
1624  * VirtualEthernet0/0/12 queue 3 (polling)
1625  * VirtualEthernet0/0/13 queue 1 (polling)
1626  * VirtualEthernet0/0/13 queue 3 (polling)
1627  * @cliexend
1628 ?*/
1629 /* *INDENT-OFF* */
1631  .path = "set interface rx-mode",
1632  .short_help = "set interface rx-mode <interface> [queue <n>] [polling | interrupt | adaptive]",
1633  .function = set_interface_rx_mode,
1634 };
1635 /* *INDENT-ON* */
1636 
1637 static clib_error_t *
1639  vlib_cli_command_t * cmd)
1640 {
1641  u8 *s = 0;
1642  vnet_main_t *vnm = vnet_get_main ();
1643  vnet_hw_if_rx_queue_t **all_queues = 0;
1644  vnet_hw_if_rx_queue_t **qptr;
1647  vec_add1 (all_queues, q);
1649  u32 prev_node = ~0;
1650 
1651  vec_foreach (qptr, all_queues)
1652  {
1653  u32 current_thread = qptr[0]->thread_index;
1654  u32 hw_if_index = qptr[0]->hw_if_index;
1655  vnet_hw_interface_t *hw_if = vnet_get_hw_interface (vnm, hw_if_index);
1656  u32 current_node = hw_if->input_node_index;
1657  if (current_node != prev_node)
1658  s = format (s, " node %U:\n", format_vlib_node_name, vm, current_node);
1659  s = format (s, " %U queue %u (%U)\n", format_vnet_sw_if_index_name,
1660  vnm, hw_if->sw_if_index, qptr[0]->queue_id,
1661  format_vnet_hw_if_rx_mode, qptr[0]->mode);
1662  if (qptr == all_queues + vec_len (all_queues) - 1 ||
1663  current_thread != qptr[1]->thread_index)
1664  {
1665  vlib_cli_output (vm, "Thread %u (%s):\n%v", current_thread,
1666  vlib_worker_threads[current_thread].name, s);
1667  vec_reset_length (s);
1668  }
1669  prev_node = current_node;
1670  }
1671  vec_free (s);
1672  vec_free (all_queues);
1673  return 0;
1674 }
1675 
1676 /*?
1677  * This command is used to display the interface and queue worker
1678  * thread placement.
1679  *
1680  * @cliexpar
1681  * Example of how to display the interface placement:
1682  * @cliexstart{show interface rx-placement}
1683  * Thread 1 (vpp_wk_0):
1684  * node dpdk-input:
1685  * GigabitEthernet7/0/0 queue 0 (polling)
1686  * node vhost-user-input:
1687  * VirtualEthernet0/0/12 queue 0 (polling)
1688  * VirtualEthernet0/0/12 queue 2 (polling)
1689  * VirtualEthernet0/0/13 queue 0 (polling)
1690  * VirtualEthernet0/0/13 queue 2 (polling)
1691  * Thread 2 (vpp_wk_1):
1692  * node dpdk-input:
1693  * GigabitEthernet7/0/1 queue 0 (polling)
1694  * node vhost-user-input:
1695  * VirtualEthernet0/0/12 queue 1 (polling)
1696  * VirtualEthernet0/0/12 queue 3 (polling)
1697  * VirtualEthernet0/0/13 queue 1 (polling)
1698  * VirtualEthernet0/0/13 queue 3 (polling)
1699  * @cliexend
1700 ?*/
1701 /* *INDENT-OFF* */
1703  .path = "show interface rx-placement",
1704  .short_help = "show interface rx-placement",
1705  .function = show_interface_rx_placement_fn,
1706 };
1707 /* *INDENT-ON* */
1708 clib_error_t *
1709 set_hw_interface_rx_placement (u32 hw_if_index, u32 queue_id,
1710  u32 thread_index, u8 is_main)
1711 {
1712  vnet_main_t *vnm = vnet_get_main ();
1714  vnet_hw_interface_t *hw;
1715  u32 queue_index;
1716 
1717  if (is_main)
1718  thread_index = 0;
1719  else
1721 
1723  return clib_error_return (0,
1724  "please specify valid worker thread or main");
1725 
1726  hw = vnet_get_hw_interface (vnm, hw_if_index);
1727 
1728  queue_index =
1729  vnet_hw_if_get_rx_queue_index_by_id (vnm, hw_if_index, queue_id);
1730  if (queue_index == ~0)
1731  return clib_error_return (0, "unknown queue %u on interface %s", queue_id,
1732  hw->name);
1734  vnet_hw_if_update_runtime_data (vnm, hw_if_index);
1735  return 0;
1736 }
1737 
1738 static clib_error_t *
1740  vlib_cli_command_t *cmd)
1741 {
1742  clib_error_t *error = 0;
1743  unformat_input_t _line_input, *line_input = &_line_input;
1744  vnet_main_t *vnm = vnet_get_main ();
1745  u32 hw_if_index = (u32) ~ 0;
1746  u32 queue_id = (u32) 0;
1747  u32 thread_index = (u32) ~ 0;
1748  u8 is_main = 0;
1749 
1750  if (!unformat_user (input, unformat_line_input, line_input))
1751  return 0;
1752 
1753  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1754  {
1755  if (unformat
1756  (line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
1757  ;
1758  else if (unformat (line_input, "queue %d", &queue_id))
1759  ;
1760  else if (unformat (line_input, "main", &thread_index))
1761  is_main = 1;
1762  else if (unformat (line_input, "worker %d", &thread_index))
1763  ;
1764  else
1765  {
1766  error = clib_error_return (0, "parse error: '%U'",
1767  format_unformat_error, line_input);
1768  unformat_free (line_input);
1769  return error;
1770  }
1771  }
1772 
1773  unformat_free (line_input);
1774 
1775  if (hw_if_index == (u32) ~ 0)
1776  return clib_error_return (0, "please specify valid interface name");
1777 
1778  error = set_hw_interface_rx_placement (hw_if_index, queue_id, thread_index,
1779  is_main);
1780 
1781  return (error);
1782 }
1783 
1784 /*?
1785  * This command is used to assign a given interface, and optionally a
1786  * given queue, to a different thread. If the '<em>queue</em>' is not provided,
1787  * it defaults to 0. The '<em>worker</em>' parameter is zero based and the index
1788  * in the thread name, for example, 0 in the thread name '<em>vpp_wk_0</em>'.
1789  *
1790  * @cliexpar
1791  * Example of how to display the interface placement:
1792  * @cliexstart{show interface rx-placement}
1793  * Thread 1 (vpp_wk_0):
1794  * node dpdk-input:
1795  * GigabitEthernet7/0/0 queue 0 (polling)
1796  * node vhost-user-input:
1797  * VirtualEthernet0/0/12 queue 0 (polling)
1798  * VirtualEthernet0/0/12 queue 2 (polling)
1799  * VirtualEthernet0/0/13 queue 0 (polling)
1800  * VirtualEthernet0/0/13 queue 2 (polling)
1801  * Thread 2 (vpp_wk_1):
1802  * node dpdk-input:
1803  * GigabitEthernet7/0/1 queue 0 (polling)
1804  * node vhost-user-input:
1805  * VirtualEthernet0/0/12 queue 1 (polling)
1806  * VirtualEthernet0/0/12 queue 3 (polling)
1807  * VirtualEthernet0/0/13 queue 1 (polling)
1808  * VirtualEthernet0/0/13 queue 3 (polling)
1809  * @cliexend
1810  * Example of how to assign a interface and queue to a worker thread:
1811  * @cliexcmd{set interface rx-placement VirtualEthernet0/0/12 queue 1 worker 0}
1812  * Example of how to display the interface placement:
1813  * @cliexstart{show interface rx-placement}
1814  * Thread 1 (vpp_wk_0):
1815  * node dpdk-input:
1816  * GigabitEthernet7/0/0 queue 0 (polling)
1817  * node vhost-user-input:
1818  * VirtualEthernet0/0/12 queue 0 (polling)
1819  * VirtualEthernet0/0/12 queue 1 (polling)
1820  * VirtualEthernet0/0/12 queue 2 (polling)
1821  * VirtualEthernet0/0/13 queue 0 (polling)
1822  * VirtualEthernet0/0/13 queue 2 (polling)
1823  * Thread 2 (vpp_wk_1):
1824  * node dpdk-input:
1825  * GigabitEthernet7/0/1 queue 0 (polling)
1826  * node vhost-user-input:
1827  * VirtualEthernet0/0/12 queue 3 (polling)
1828  * VirtualEthernet0/0/13 queue 1 (polling)
1829  * VirtualEthernet0/0/13 queue 3 (polling)
1830  * @cliexend
1831 ?*/
1832 /* *INDENT-OFF* */
1834  .path = "set interface rx-placement",
1835  .short_help = "set interface rx-placement <interface> [queue <n>] "
1836  "[worker <n> | main]",
1837  .function = set_interface_rx_placement,
1838  .is_mp_safe = 1,
1839 };
1840 /* *INDENT-ON* */
1841 
1842 clib_error_t *
1843 set_hw_interface_tx_queue (u32 hw_if_index, u32 queue_id, uword *bitmap)
1844 {
1845  vnet_main_t *vnm = vnet_get_main ();
1847  vnet_hw_interface_t *hw;
1848  vnet_hw_if_tx_queue_t *txq;
1849  u32 queue_index;
1850  u32 thread_index;
1851 
1852  hw = vnet_get_hw_interface (vnm, hw_if_index);
1853 
1854  /* highest set bit in bitmap should not exceed last worker thread index */
1856  if ((thread_index != ~0) && (thread_index > vdm->last_worker_thread_index))
1857  return clib_error_return (0, "please specify valid thread(s)");
1858 
1859  queue_index =
1860  vnet_hw_if_get_tx_queue_index_by_id (vnm, hw_if_index, queue_id);
1861  if (queue_index == ~0)
1862  return clib_error_return (0, "unknown queue %u on interface %s", queue_id,
1863  hw->name);
1864 
1865  txq = vnet_hw_if_get_tx_queue (vnm, queue_index);
1866 
1867  // free the existing bitmap
1869  {
1870  txq->shared_queue = 0;
1871  clib_bitmap_free (txq->threads);
1872  }
1873 
1875  vnet_hw_if_tx_queue_assign_thread (vnm, queue_index, thread_index);
1876 
1877  vnet_hw_if_update_runtime_data (vnm, hw_if_index);
1878  return 0;
1879 }
1880 
1881 static clib_error_t *
1883  vlib_cli_command_t *cmd)
1884 {
1885  clib_error_t *error = 0;
1886  unformat_input_t _line_input, *line_input = &_line_input;
1887  vnet_main_t *vnm = vnet_get_main ();
1888  u32 hw_if_index = (u32) ~0;
1889  u32 queue_id = (u32) 0;
1890  uword *bitmap = 0;
1891 
1892  if (!unformat_user (input, unformat_line_input, line_input))
1893  return 0;
1894 
1895  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1896  {
1897  if (unformat (line_input, "%U", unformat_vnet_hw_interface, vnm,
1898  &hw_if_index))
1899  ;
1900  else if (unformat (line_input, "queue %d", &queue_id))
1901  ;
1902  else if (unformat (line_input, "threads %U", unformat_bitmap_list,
1903  &bitmap))
1904  ;
1905  else
1906  {
1907  error = clib_error_return (0, "parse error: '%U'",
1908  format_unformat_error, line_input);
1909  unformat_free (line_input);
1910  return error;
1911  }
1912  }
1913 
1914  unformat_free (line_input);
1915 
1916  if (hw_if_index == (u32) ~0)
1917  {
1918  error = clib_error_return (0, "please specify valid interface name");
1919  goto error;
1920  }
1921 
1922  error = set_hw_interface_tx_queue (hw_if_index, queue_id, bitmap);
1923 
1924 error:
1925  clib_bitmap_free (bitmap);
1926  return (error);
1927 }
1928 
1930  .path = "set interface tx-queue",
1931  .short_help = "set interface tx-queue <interface> queue <n> "
1932  "[threads <list>]",
1933  .function = set_interface_tx_queue,
1934  .is_mp_safe = 1,
1935 };
1936 
1937 clib_error_t *
1939  clib_bitmap_t * bitmap)
1940 {
1941  vnet_main_t *vnm = vnet_get_main ();
1942  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
1943 
1944  return vnet_hw_interface_set_rss_queues (vnm, hi, bitmap);
1945 }
1946 
1947 static clib_error_t *
1949  unformat_input_t * input,
1950  vlib_cli_command_t * cmd)
1951 {
1952  clib_error_t *error = 0;
1953  unformat_input_t _line_input, *line_input = &_line_input;
1954  vnet_main_t *vnm = vnet_get_main ();
1955  u32 hw_if_index = (u32) ~ 0;
1956  clib_bitmap_t *bitmap = NULL;
1957 
1958  if (!unformat_user (input, unformat_line_input, line_input))
1959  return 0;
1960 
1961  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1962  {
1963  if (unformat
1964  (line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
1965  ;
1966  else
1967  if (unformat (line_input, "list %U", unformat_bitmap_list, &bitmap))
1968  ;
1969  else
1970  {
1971  error = clib_error_return (0, "parse error: '%U'",
1972  format_unformat_error, line_input);
1973  unformat_free (line_input);
1974  goto done;
1975  }
1976  }
1977 
1978  unformat_free (line_input);
1979 
1980  if (hw_if_index == (u32) ~ 0)
1981  {
1982  error = clib_error_return (0, "please specify valid interface name");
1983  goto done;
1984  }
1985 
1986  if (bitmap == NULL)
1987  {
1988  error = clib_error_return (0, "please specify the valid rss queues");
1989  goto done;
1990  }
1991 
1992  error = set_interface_rss_queues (vm, hw_if_index, bitmap);
1993 
1994 done:
1995  if (bitmap)
1996  clib_bitmap_free (bitmap);
1997 
1998  return (error);
1999 }
2000 
2001 /*?
2002  * This command is used to set the rss queues of a given interface
2003  * Not all the interfaces support this operation.
2004  * To display the current rss queues, use the command
2005  * '<em>show hardware-interfaces</em>'.
2006  *
2007  * @cliexpar
2008  * Example of how to set the rss queues to 0,2-5,7 of an interface:
2009  * @cliexstart{set interface rss queues VirtualFunctionEthernet18/1/0 list 0,2-5,7}
2010  * @cliexend
2011 ?*/
2012 /* *INDENT-OFF* */
2014  .path = "set interface rss queues",
2015  .short_help = "set interface rss queues <interface> <list <queue-list>>",
2016  .function = set_interface_rss_queues_fn,
2017 };
2018 /* *INDENT-ON* */
2019 
2020 static u8 *
2021 format_vnet_pcap (u8 * s, va_list * args)
2022 {
2023  vnet_pcap_t *pp = va_arg (*args, vnet_pcap_t *);
2024  int type = va_arg (*args, int);
2025  int printed = 0;
2026 
2027  if (type == 0)
2028  {
2029  if (pp->pcap_rx_enable)
2030  {
2031  s = format (s, "rx");
2032  printed = 1;
2033  }
2034  if (pp->pcap_tx_enable)
2035  {
2036  if (printed)
2037  s = format (s, " and ");
2038  s = format (s, "tx");
2039  printed = 1;
2040  }
2041  if (pp->pcap_drop_enable)
2042  {
2043  if (printed)
2044  s = format (s, " and ");
2045  s = format (s, "drop");
2046  printed = 1;
2047  }
2048  return s;
2049  }
2050  s = format (s, "unknown type %d!", type);
2051  return s;
2052 }
2053 
2054 
2055 int
2057 {
2059  vnet_main_t *vnm = vnet_get_main ();
2060  vnet_pcap_t *pp = &vnm->pcap;
2061  pcap_main_t *pm = &pp->pcap_main;
2063 
2064  if (a->status)
2065  {
2066  if (pp->pcap_rx_enable || pp->pcap_tx_enable || pp->pcap_drop_enable)
2067  {
2069  (vm, "pcap %U dispatch capture enabled: %d of %d pkts...",
2070  format_vnet_pcap, pp, 0 /* print type */ ,
2072  vlib_cli_output (vm, "capture to file %s", pm->file_name);
2073  }
2074  else
2075  vlib_cli_output (vm, "pcap dispatch capture disabled");
2076 
2077  return 0;
2078  }
2079 
2080  /* Consistency checks */
2081 
2082  /* Enable w/ capture already enabled not allowed */
2083  if ((pp->pcap_rx_enable + pp->pcap_tx_enable + pp->pcap_drop_enable)
2084  && (a->rx_enable + a->tx_enable + a->drop_enable))
2085  return VNET_API_ERROR_INVALID_VALUE;
2086 
2087  /* Disable capture with capture already disabled, not interesting */
2088  if (((pp->pcap_rx_enable + pp->pcap_tx_enable + pp->pcap_drop_enable) ==
2089  0) &&
2090  ((a->rx_enable + a->tx_enable + a->drop_enable == 0)))
2091  return VNET_API_ERROR_VALUE_EXIST;
2092 
2093  /* Change number of packets to capture while capturing */
2094  if ((pp->pcap_rx_enable + pp->pcap_tx_enable + pp->pcap_drop_enable)
2095  && (a->rx_enable + a->tx_enable + a->drop_enable)
2096  && (pm->n_packets_to_capture != a->packets_to_capture))
2097  return VNET_API_ERROR_INVALID_VALUE_2;
2098 
2099  /* Classify filter specified, but no classify filter configured */
2100  if ((a->rx_enable + a->tx_enable + a->drop_enable) && a->filter &&
2101  (!cm->classify_table_index_by_sw_if_index ||
2102  cm->classify_table_index_by_sw_if_index[0] == ~0))
2103  return VNET_API_ERROR_NO_SUCH_LABEL;
2104 
2105  if (a->rx_enable + a->tx_enable + a->drop_enable)
2106  {
2107  void *save_pcap_data;
2108 
2109  /* Sanity check max bytes per pkt */
2110  if (a->max_bytes_per_pkt < 32 || a->max_bytes_per_pkt > 9000)
2111  return VNET_API_ERROR_INVALID_MEMORY_SIZE;
2112 
2113  /* Clean up from previous run, if any */
2115 
2116  /* Throw away the data buffer? */
2117  if (a->free_data)
2118  vec_free (pm->pcap_data);
2119 
2120  save_pcap_data = pm->pcap_data;
2121 
2122  memset (pm, 0, sizeof (*pm));
2123 
2124  pm->pcap_data = save_pcap_data;
2125 
2128  if (pm->lock == 0)
2129  clib_spinlock_init (&(pm->lock));
2130 
2131  if (a->filename == 0)
2132  {
2133  u8 *stem = 0;
2134 
2135  if (a->rx_enable)
2136  stem = format (stem, "rx");
2137  if (a->tx_enable)
2138  stem = format (stem, "tx");
2139  if (a->drop_enable)
2140  stem = format (stem, "drop");
2141  a->filename = format (0, "/tmp/%v.pcap%c", stem, 0);
2142  vec_free (stem);
2143  }
2144 
2145  pm->file_name = (char *) a->filename;
2146  pm->n_packets_captured = 0;
2147  pm->packet_type = PCAP_PACKET_TYPE_ethernet;
2148  /* Preallocate the data vector? */
2149  if (a->preallocate_data)
2150  {
2151  vec_validate
2152  (pm->pcap_data, a->packets_to_capture
2153  * ((sizeof (pcap_packet_header_t) + a->max_bytes_per_pkt)));
2155  }
2156  pm->n_packets_to_capture = a->packets_to_capture;
2157  pp->pcap_sw_if_index = a->sw_if_index;
2158  if (a->filter)
2160  cm->classify_table_index_by_sw_if_index[0];
2161  else
2162  pp->filter_classify_table_index = ~0;
2163  pp->pcap_error_index = a->drop_err;
2164  pp->pcap_rx_enable = a->rx_enable;
2165  pp->pcap_tx_enable = a->tx_enable;
2166  pp->pcap_drop_enable = a->drop_enable;
2167  pp->max_bytes_per_pkt = a->max_bytes_per_pkt;
2168  }
2169  else
2170  {
2171  pp->pcap_rx_enable = 0;
2172  pp->pcap_tx_enable = 0;
2173  pp->pcap_drop_enable = 0;
2174  pp->filter_classify_table_index = ~0;
2175  pp->pcap_error_index = ~0;
2176  if (pm->n_packets_captured)
2177  {
2180  vlib_cli_output (vm, "Write %d packets to %s, and stop capture...",
2181  pm->n_packets_captured, pm->file_name);
2182  error = pcap_write (pm);
2183  if (pm->flags & PCAP_MAIN_INIT_DONE)
2184  pcap_close (pm);
2185  /* Report I/O errors... */
2186  if (error)
2187  {
2189  return VNET_API_ERROR_SYSCALL_ERROR_1;
2190  }
2191  vec_free (pm->file_name);
2192  if (a->free_data)
2193  vec_free (pm->pcap_data);
2194  return 0;
2195  }
2196  else
2197  return VNET_API_ERROR_NO_SUCH_ENTRY;
2198  }
2199 
2200  return 0;
2201 }
2202 
2203 static clib_error_t *
2205  unformat_input_t * input, vlib_cli_command_t * cmd)
2206 {
2207  unformat_input_t _line_input, *line_input = &_line_input;
2209  vnet_main_t *vnm = vnet_get_main ();
2210  u8 *filename = 0;
2211  u32 max = 1000;
2212  u32 max_bytes_per_pkt = 512;
2213  int rv;
2214  int rx_enable = 0;
2215  int tx_enable = 0;
2216  int preallocate_data = 0;
2217  int drop_enable = 0;
2218  int status = 0;
2219  int filter = 0;
2220  int free_data = 0;
2221  u32 sw_if_index = 0; /* default: any interface */
2222  vlib_error_t drop_err = ~0; /* default: any error */
2223 
2224  /* Get a line of input. */
2225  if (!unformat_user (input, unformat_line_input, line_input))
2226  return 0;
2227 
2228  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
2229  {
2230  if (unformat (line_input, "rx"))
2231  rx_enable = 1;
2232  else if (unformat (line_input, "tx"))
2233  tx_enable = 1;
2234  else if (unformat (line_input, "drop"))
2235  drop_enable = 1;
2236  else if (unformat (line_input, "off"))
2237  rx_enable = tx_enable = drop_enable = 0;
2238  else if (unformat (line_input, "max-bytes-per-pkt %u",
2239  &max_bytes_per_pkt))
2240  ;
2241  else if (unformat (line_input, "max %d", &max))
2242  ;
2243  else if (unformat (line_input, "packets-to-capture %d", &max))
2244  ;
2245  else if (unformat (line_input, "file %U", unformat_vlib_tmpfile,
2246  &filename))
2247  ;
2248  else if (unformat (line_input, "status %=", &status, 1))
2249  ;
2250  else if (unformat (line_input, "intfc %U",
2252  ;
2253  else if (unformat (line_input, "interface %U",
2255  ;
2256  else if (unformat (line_input, "error %U", unformat_vlib_error, vm,
2257  &drop_err))
2258  ;
2259  else if (unformat (line_input, "preallocate-data %=",
2260  &preallocate_data, 1))
2261  ;
2262  else if (unformat (line_input, "free-data %=", &free_data, 1))
2263  ;
2264  else if (unformat (line_input, "intfc any")
2265  || unformat (line_input, "interface any"))
2266  sw_if_index = 0;
2267  else if (unformat (line_input, "filter"))
2268  filter = 1;
2269  else
2270  {
2271  return clib_error_return (0, "unknown input `%U'",
2272  format_unformat_error, line_input);
2273  }
2274  }
2275 
2276  unformat_free (line_input);
2277 
2278  /* no need for memset (a, 0, sizeof (*a)), set all fields here. */
2279  a->filename = filename;
2280  a->rx_enable = rx_enable;
2281  a->tx_enable = tx_enable;
2282  a->preallocate_data = preallocate_data;
2283  a->free_data = free_data;
2284  a->drop_enable = drop_enable;
2285  a->status = status;
2286  a->packets_to_capture = max;
2287  a->sw_if_index = sw_if_index;
2288  a->filter = filter;
2289  a->max_bytes_per_pkt = max_bytes_per_pkt;
2290  a->drop_err = drop_err;
2291 
2293 
2294  switch (rv)
2295  {
2296  case 0:
2297  break;
2298 
2299  case VNET_API_ERROR_INVALID_VALUE:
2300  return clib_error_return (0, "dispatch trace already enabled...");
2301 
2302  case VNET_API_ERROR_VALUE_EXIST:
2303  return clib_error_return (0, "dispatch trace already disabled...");
2304 
2305  case VNET_API_ERROR_INVALID_VALUE_2:
2306  return clib_error_return
2307  (0, "can't change number of records to capture while tracing...");
2308 
2309  case VNET_API_ERROR_SYSCALL_ERROR_1:
2310  return clib_error_return (0, "I/O writing trace capture...");
2311 
2312  case VNET_API_ERROR_NO_SUCH_ENTRY:
2313  return clib_error_return (0, "No packets captured...");
2314 
2315  case VNET_API_ERROR_INVALID_MEMORY_SIZE:
2316  return clib_error_return (0,
2317  "Max bytes per pkt must be > 32, < 9000...");
2318 
2319  case VNET_API_ERROR_NO_SUCH_LABEL:
2320  return clib_error_return
2321  (0, "No classify filter configured, see 'classify filter...'");
2322 
2323  default:
2324  vlib_cli_output (vm, "WARNING: trace configure returned %d", rv);
2325  break;
2326  }
2327  return 0;
2328 }
2329 
2330 /*?
2331  * This command is used to start or stop a packet capture, or show
2332  * the status of packet capture.
2333  *
2334  * This command has the following optional parameters:
2335  *
2336  *
2337  * - <b>rx</b> - Capture received packets
2338  *
2339  * - <b>tx</b> - Capture transmitted packets
2340  *
2341  * - <b>drop</b> - Capture dropped packets
2342  *
2343  * - <b>off</b> - Stop capturing packets, write results to the specified file
2344  *
2345  * - <b>max <nn></b> - Depth of local buffer. Once '<em>nn</em>' number
2346  * of packets have been received, buffer is flushed to file. Once another
2347  * '<em>nn</em>' number of packets have been received, buffer is flushed
2348  * to file, overwriting previous write. If not entered, value defaults
2349  * to 100. Can only be updated if packet capture is off.
2350  *
2351  * - <b>max-bytes-per-pkt <nnnn></b> - Maximum number of bytes to capture
2352  * for each packet. Must be >= 32, <= 9000.
2353  *
2354  * - <b>preallocate-data</b> - Preallocate the data buffer, to avoid
2355  * vector expansion delays during pcap capture
2356  *
2357  * - <b>free-data</b> - Free the data buffer. Ordinarily it's a feature
2358  * to retain the data buffer so this option is seldom used.
2359  *
2360  * - <b>intfc <interface-name>|any</b> - Used to specify a given interface,
2361  * or use '<em>any</em>' to run packet capture on all interfaces.
2362  * '<em>any</em>' is the default if not provided. Settings from a previous
2363  * packet capture are preserved, so '<em>any</em>' can be used to reset
2364  * the interface setting.
2365  *
2366  * - <b>filter</b> - Use the pcap rx / tx / drop trace filter, which
2367  * must be configured. Use <b>classify filter pcap...</b> to configure the
2368  * filter. The filter will only be executed if the per-interface or
2369  * any-interface tests fail.
2370  *
2371  * - <b>error <node>.<error></b> - filter packets based on a specific error.
2372  * For example: error {ip4-udp-lookup}.{No listener for dst port}
2373  *
2374  * - <b>file <name></b> - Used to specify the output filename. The file will
2375  * be placed in the '<em>/tmp</em>' directory, so only the filename is
2376  * supported. Directory should not be entered. If file already exists, file
2377  * will be overwritten. If no filename is provided, the file will be
2378  * named "/tmp/rx.pcap", "/tmp/tx.pcap", "/tmp/rxandtx.pcap", etc.
2379  * Can only be updated if packet capture is off.
2380  *
2381  * - <b>status</b> - Displays the current status and configured attributes
2382  * associated with a packet capture. If packet capture is in progress,
2383  * '<em>status</em>' also will return the number of packets currently in
2384  * the local buffer. All additional attributes entered on command line
2385  * with '<em>status</em>' will be ignored and not applied.
2386  *
2387  * @cliexpar
2388  * Example of how to display the status of a tx packet capture when off:
2389  * @cliexstart{pcap trace status}
2390  * max is 100, for any interface to file /tmp/vpe.pcap
2391  * pcap tx capture is off...
2392  * @cliexend
2393  * Example of how to start a tx packet capture:
2394  * @cliexstart{pcap trace tx max 35 intfc GigabitEthernet0/8/0 file
2395 vppTest.pcap}
2396  * @cliexend
2397  * Example of how to display the status of a tx packet capture in progress:
2398  * @cliexstart{pcap trace status}
2399  * max is 35, for interface GigabitEthernet0/8/0 to file /tmp/vppTest.pcap
2400  * pcap tx capture is on: 20 of 35 pkts...
2401  * @cliexend
2402  * Example of how to stop a tx packet capture:
2403  * @cliexstart{pcap trace off}
2404  * captured 21 pkts...
2405  * saved to /tmp/vppTest.pcap...
2406  * @cliexend
2407 ?*/
2408 /* *INDENT-OFF* */
2409 
2411  .path = "pcap trace",
2412  .short_help =
2413  "pcap trace [rx] [tx] [drop] [off] [max <nn>] [intfc <interface>|any]\n"
2414  " [file <name>] [status] [max-bytes-per-pkt <nnnn>][filter]\n"
2415  " [preallocate-data][free-data]",
2416  .function = pcap_trace_command_fn,
2417 };
2418 /* *INDENT-ON* */
2419 
2420 static clib_error_t *
2422  vlib_cli_command_t *cmd)
2423 {
2424  clib_error_t *error = 0;
2425  unformat_input_t _line_input, *line_input = &_line_input;
2426  vnet_main_t *vnm = vnet_get_main ();
2427  u32 hw_if_index = ~0;
2428  char *name = 0;
2429 
2430  if (!unformat_user (input, unformat_line_input, line_input))
2431  return 0;
2432 
2433  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
2434  {
2435  if (unformat (line_input, "%U %s", unformat_vnet_hw_interface, vnm,
2436  &hw_if_index, &name))
2437  ;
2438  else
2439  {
2440  error = clib_error_return (0, "parse error: '%U'",
2441  format_unformat_error, line_input);
2442  unformat_free (line_input);
2443  vec_free (name);
2444  return error;
2445  }
2446  }
2447 
2448  unformat_free (line_input);
2449 
2450  if (hw_if_index == (u32) ~0 || name == 0)
2451  {
2452  vec_free (name);
2453  error = clib_error_return (0, "please specify valid interface name");
2454  return error;
2455  }
2456 
2457  error = vnet_rename_interface (vnm, hw_if_index, name);
2458  vec_free (name);
2459 
2460  return (error);
2461 }
2462 
2464  .path = "set interface name",
2465  .short_help = "set interface name <interface-name> <new-interface-name>",
2466  .function = set_interface_name,
2467  .is_mp_safe = 1,
2468 };
2469 /*
2470  * fd.io coding-style-patch-verification: ON
2471  *
2472  * Local Variables:
2473  * eval: (c-set-style "gnu")
2474  * End:
2475  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
clib_spinlock_init
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
clear_interface_counters_command
static vlib_cli_command_t clear_interface_counters_command
(constructor) VLIB_CLI_COMMAND (clear_interface_counters_command)
Definition: interface_cli.c:572
vnet_device_main_t::last_worker_thread_index
uword last_worker_thread_index
Definition: devices.h:64
vnet_device_main
vnet_device_main_t vnet_device_main
Definition: devices.c:22
im
vnet_interface_main_t * im
Definition: interface_output.c:415
show_interface_sec_mac_addr_fn
static clib_error_t * show_interface_sec_mac_addr_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1217
unformat_ethernet_address
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
Definition: format.c:233
vnet_sw_interface_set_flags
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
Definition: interface.c:523
vnet_pcap_t::pcap_main
pcap_main_t pcap_main
Definition: vnet.h:71
set_interface_tx_queue
static clib_error_t * set_interface_tx_queue(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1882
mac
vl_api_mac_address_t mac
Definition: l2.api:559
vnet_interface_main_t::hw_interface_class_by_name
uword * hw_interface_class_by_name
Definition: interface.h:1011
unformat_user
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
hash_set
#define hash_set(h, key, value)
Definition: hash.h:255
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
set_hw_class_command
static vlib_cli_command_t set_hw_class_command
(constructor) VLIB_CLI_COMMAND (set_hw_class_command)
Definition: interface_cli.c:1059
foreach_ip_interface_address
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
Definition: ip_interface.h:57
vnet_hw_interface_set_mtu
void vnet_hw_interface_set_mtu(vnet_main_t *vnm, u32 hw_if_index, u32 mtu)
Definition: interface.c:775
VNET_HW_IF_RX_MODE_ADAPTIVE
@ VNET_HW_IF_RX_MODE_ADAPTIVE
Definition: interface.h:58
vnet_sw_interface_t
Definition: interface.h:869
show_interface_rx_placement_fn
static clib_error_t * show_interface_rx_placement_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1638
vnet_device_class_t
struct _vnet_device_class vnet_device_class_t
show_bond
static void show_bond(vlib_main_t *vm)
Definition: cli.c:893
ip4_main_t::lookup_main
ip_lookup_main_t lookup_main
Definition: ip4.h:109
vnet_hw_interface_set_class
clib_error_t * vnet_hw_interface_set_class(vnet_main_t *vnm, u32 hw_if_index, u32 hw_class_index)
Definition: interface.c:1251
clear_tag_command
static vlib_cli_command_t clear_tag_command
(constructor) VLIB_CLI_COMMAND (clear_tag_command)
Definition: interface_cli.c:1460
renumber_interface_command_fn
static clib_error_t * renumber_interface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1075
pcap_main_t::flags
u32 flags
flags
Definition: pcap.h:173
vnet_hw_if_rxq_cmp_cli_api
static_always_inline int vnet_hw_if_rxq_cmp_cli_api(vnet_hw_if_rx_queue_t **a, vnet_hw_if_rx_queue_t **b)
Definition: rx_queue_funcs.h:99
vec_new
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:365
vnet_hw_interface_set_rss_queues
clib_error_t * vnet_hw_interface_set_rss_queues(vnet_main_t *vnm, vnet_hw_interface_t *hi, clib_bitmap_t *bitmap)
Definition: interface.c:1814
clear_tag
static clib_error_t * clear_tag(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1444
vnet_hw_if_get_tx_queue_index_by_id
u32 vnet_hw_if_get_tx_queue_index_by_id(vnet_main_t *vnm, u32 hw_if_index, u32 queue_id)
Definition: tx_queue.c:25
vnet_interface_name_renumber
int vnet_interface_name_renumber(u32 sw_if_index, u32 new_show_dev_instance)
Definition: interface.c:1474
set_interface_name
static clib_error_t * set_interface_name(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:2421
l2_output_config_t::feature_bitmap
u32 feature_bitmap
Definition: l2_output.h:41
ip4_main
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1104
clear_interface_counters
static clib_error_t * clear_interface_counters(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:533
vnet_hw_if_rx_queue_t::mode
vnet_hw_if_rx_mode mode
Definition: interface.h:597
ethernet_set_flags
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:441
vnet_hw_if_set_rx_queue_mode
int vnet_hw_if_set_rx_queue_mode(vnet_main_t *vnm, u32 queue_index, vnet_hw_if_rx_mode mode)
Definition: rx_queue.c:167
unformat_line_input
unformat_function_t unformat_line_input
Definition: format.h:275
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
name
string name[64]
Definition: fib.api:25
bitmap.h
vlib_clear_combined_counters
void vlib_clear_combined_counters(vlib_combined_counter_main_t *cm)
Clear a collection of combined counters.
Definition: counter.c:61
vnet_hw_interface_t::sw_if_index
u32 sw_if_index
Definition: interface.h:670
format_l2_output_features
u8 * format_l2_output_features(u8 *s, va_list *args)
Definition: l2_output.c:44
clib_bitmap_t
uword clib_bitmap_t
Definition: bitmap.h:50
pcap_packet_header_t
Packet header.
Definition: pcap.h:143
vnet_hw_if_rx_queue_t::thread_index
u32 thread_index
Definition: interface.h:588
pcap_close
__clib_export clib_error_t * pcap_close(pcap_main_t *pm)
Close PCAP file.
Definition: pcap.c:74
set_hw_interface_rx_placement
clib_error_t * set_hw_interface_rx_placement(u32 hw_if_index, u32 queue_id, u32 thread_index, u8 is_main)
Definition: interface_cli.c:1709
vnet_classify_main
vnet_classify_main_t vnet_classify_main
Definition: vnet_classify.c:32
clear_hw_interfaces
static clib_error_t * clear_hw_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:178
set_interface_rx_mode
static clib_error_t * set_interface_rx_mode(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1546
VNET_SW_INTERFACE_TYPE_SUB
@ VNET_SW_INTERFACE_TYPE_SUB
Definition: interface.h:767
set_interface_promiscuous_cmd
static vlib_cli_command_t set_interface_promiscuous_cmd
(constructor) VLIB_CLI_COMMAND (set_interface_promiscuous_cmd)
Definition: interface_cli.c:1145
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
vnet_swif_is_api_visible
static uword vnet_swif_is_api_visible(vnet_sw_interface_t *si)
Definition: interface_funcs.h:272
vnet_pcap_t::pcap_rx_enable
u8 pcap_rx_enable
Definition: vnet.h:63
vlib_cli_command_t::path
char * path
Definition: cli.h:96
VNET_MTU_MPLS
@ VNET_MTU_MPLS
Definition: interface.h:833
vnet_interface_main_t
Definition: interface.h:990
VNET_FLOOD_CLASS_NORMAL
@ VNET_FLOOD_CLASS_NORMAL
Definition: interface.h:819
vnet_hw_if_tx_queue_assign_thread
void vnet_hw_if_tx_queue_assign_thread(vnet_main_t *vnm, u32 queue_index, u32 thread_index)
Definition: tx_queue.c:109
promiscuous_cmd
static clib_error_t * promiscuous_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1117
compare_interface_names
static int compare_interface_names(void *a1, void *a2)
Definition: interface_cli.c:57
hash_set_mem
#define hash_set_mem(h, key, value)
Definition: hash.h:275
ip4_fib_8_t_
The IPv4 FIB.
Definition: ip4_fib_8.h:36
mode
vl_api_tunnel_mode_t mode
Definition: gre.api:48
show_interface_rx_placement
static vlib_cli_command_t show_interface_rx_placement
(constructor) VLIB_CLI_COMMAND (show_interface_rx_placement)
Definition: interface_cli.c:1702
VNET_SW_INTERFACE_FLAG_ADMIN_UP
@ VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:844
VNET_HW_IF_RX_MODE_POLLING
@ VNET_HW_IF_RX_MODE_POLLING
Definition: interface.h:56
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
set_interface_mac_address_cmd
static vlib_cli_command_t set_interface_mac_address_cmd
(constructor) VLIB_CLI_COMMAND (set_interface_mac_address_cmd)
Definition: interface_cli.c:1411
vnet_get_sw_interface
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:58
vnet_interface_main_t::sw_if_counters
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:1023
pcap_main_t::packet_type
pcap_packet_type_t packet_type
Packet type.
Definition: pcap.h:167
vnet_pcap_t::pcap_sw_if_index
u32 pcap_sw_if_index
Definition: vnet.h:70
hi
vl_api_ip4_address_t hi
Definition: arp.api:37
vnet_interface_main_t::hw_interfaces
vnet_hw_interface_t * hw_interfaces
Definition: interface.h:993
show_hw_interfaces_command
static vlib_cli_command_t show_hw_interfaces_command
(constructor) VLIB_CLI_COMMAND (show_hw_interfaces_command)
Definition: interface_cli.c:242
clib_error_report
#define clib_error_report(e)
Definition: error.h:113
unformat_input_t
struct _unformat_input_t unformat_input_t
pcap_main_t
PCAP main state data structure.
Definition: pcap.h:155
cmd_set_if_name
static vlib_cli_command_t cmd_set_if_name
(constructor) VLIB_CLI_COMMAND (cmd_set_if_name)
Definition: interface_cli.c:2463
vnet_interface_main_t::hw_if_rx_queues
vnet_hw_if_rx_queue_t * hw_if_rx_queues
Definition: interface.h:996
vlib_worker_threads
vlib_worker_thread_t * vlib_worker_threads
Definition: threads.c:35
pcap_tx_trace_command
static vlib_cli_command_t pcap_tx_trace_command
(constructor) VLIB_CLI_COMMAND (pcap_tx_trace_command)
Definition: interface_cli.c:2410
vnet_interface_cli_init
static clib_error_t * vnet_interface_cli_init(vlib_main_t *vm)
Definition: interface_cli.c:1067
set_tag
static clib_error_t * set_tag(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1419
ip6_fib_get
static ip6_fib_t * ip6_fib_get(fib_node_index_t index)
Definition: ip6_fib.h:213
format_vnet_pcap
static u8 * format_vnet_pcap(u8 *s, va_list *args)
Definition: interface_cli.c:2021
unformat_ethernet_interface
uword unformat_ethernet_interface(unformat_input_t *input, va_list *args)
Definition: interface.c:327
error
Definition: cJSON.c:88
vnet_sw_interface_ip_directed_broadcast
void vnet_sw_interface_ip_directed_broadcast(vnet_main_t *vnm, u32 sw_if_index, u8 enable)
Definition: interface.c:748
set_hw_interface_change_rx_mode
clib_error_t * set_hw_interface_change_rx_mode(vnet_main_t *vnm, u32 hw_if_index, u8 queue_id_valid, u32 queue_id, vnet_hw_if_rx_mode mode)
Definition: interface_cli.c:1508
vnet_sw_interface_compare
word vnet_sw_interface_compare(vnet_main_t *vnm, uword sw_if_index0, uword sw_if_index1)
Definition: interface.c:1287
set_ip_directed_broadcast_command
static vlib_cli_command_t set_ip_directed_broadcast_command
(constructor) VLIB_CLI_COMMAND (set_ip_directed_broadcast_command)
Definition: interface_cli.c:1500
vnet_sw_interface_t::flags
vnet_sw_interface_flags_t flags
Definition: interface.h:873
pcap_main_t::lock
clib_spinlock_t lock
spinlock to protect e.g.
Definition: pcap.h:158
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
pool_is_free_index
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:302
set_hw_interface_tx_queue
clib_error_t * set_hw_interface_tx_queue(u32 hw_if_index, u32 queue_id, uword *bitmap)
Definition: interface_cli.c:1843
vec_elt
#define vec_elt(v, i)
Get vector value at index i.
Definition: vec_bootstrap.h:210
vnet_get_sw_interface_tag
static u8 * vnet_get_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:131
set_ip_directed_broadcast
static clib_error_t * set_ip_directed_broadcast(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1468
vnet_sw_interface_t::sw_if_index
u32 sw_if_index
Definition: interface.h:876
ip4_main_t::fib_index_by_sw_if_index
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:120
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
vnet_hw_if_rx_queue_t::queue_id
u32 queue_id
Definition: interface.h:594
set_hw_class
static clib_error_t * set_hw_class(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1026
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
ethernet_interface_address
Definition: ethernet.h:135
unformat_vlib_error
unformat_function_t unformat_vlib_error
Definition: error.h:79
unformat_free
static void unformat_free(unformat_input_t *i)
Definition: format.h:155
format_vnet_hw_if_rx_mode
format_function_t format_vnet_hw_if_rx_mode
Definition: interface_funcs.h:453
l2_output_config_t::out_vtr_flag
u8 out_vtr_flag
Definition: l2_output.h:47
vnet_cli_set_interface_command
static vlib_cli_command_t vnet_cli_set_interface_command
(constructor) VLIB_CLI_COMMAND (vnet_cli_set_interface_command)
Definition: interface_cli.c:526
VNET_MTU_IP4
@ VNET_MTU_IP4
Definition: interface.h:831
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
vnet_hw_if_get_rx_queue_index_by_id
u32 vnet_hw_if_get_rx_queue_index_by_id(vnet_main_t *vnm, u32 hw_if_index, u32 queue_id)
Definition: rx_queue.c:54
vnet_sw_interface_update_unnumbered
int vnet_sw_interface_update_unnumbered(u32 unnumbered_sw_if_index, u32 ip_sw_if_index, u8 enable)
Definition: interface.c:1661
ethernet_main_t_
Definition: ethernet.h:288
vnet_hw_interface_change_mac_address
clib_error_t * vnet_hw_interface_change_mac_address(vnet_main_t *vnm, u32 hw_if_index, const u8 *mac_address)
Definition: interface.c:1629
l2_output.h
interface_add_del_mac_address
static clib_error_t * interface_add_del_mac_address(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1295
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
vnet_get_hw_interface
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface_funcs.h:44
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
clib_bitmap_count_set_bits
static uword clib_bitmap_count_set_bits(uword *ai)
Return the number of set bits in a bitmap.
Definition: bitmap.h:449
set_unnumbered
static clib_error_t * set_unnumbered(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:968
format_mac_address_t
u8 * format_mac_address_t(u8 *s, va_list *args)
Definition: mac_address.c:27
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
rx_queue_funcs.h
vec_validate_aligned
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:534
cmd_set_if_rx_mode
static vlib_cli_command_t cmd_set_if_rx_mode
(constructor) VLIB_CLI_COMMAND (cmd_set_if_rx_mode)
Definition: interface_cli.c:1630
vnet_hw_if_rx_mode
vnet_hw_if_rx_mode
Definition: interface.h:53
L2_VTR_DISABLED
@ L2_VTR_DISABLED
Definition: l2_vtr.h:30
mtu_cmd
static clib_error_t * mtu_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1153
cmd_set_if_rx_placement
static vlib_cli_command_t cmd_set_if_rx_placement
(constructor) VLIB_CLI_COMMAND (cmd_set_if_rx_placement)
Definition: interface_cli.c:1833
set_interface_rss_queues_fn
static clib_error_t * set_interface_rss_queues_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1948
vnet_create_sw_interface
clib_error_t * vnet_create_sw_interface(vnet_main_t *vnm, vnet_sw_interface_t *template, u32 *sw_if_index)
Definition: interface.c:619
interface_add_del_mac_address_cmd
static vlib_cli_command_t interface_add_del_mac_address_cmd
(constructor) VLIB_CLI_COMMAND (interface_add_del_mac_address_cmd)
Definition: interface_cli.c:1361
clib_bitmap_free
#define clib_bitmap_free(v)
Free a bitmap.
Definition: bitmap.h:92
cmd_set_if_tx_queue
static vlib_cli_command_t cmd_set_if_tx_queue
(constructor) VLIB_CLI_COMMAND (cmd_set_if_tx_queue)
Definition: interface_cli.c:1929
uword
u64 uword
Definition: types.h:112
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
vnet_hw_if_update_runtime_data
void vnet_hw_if_update_runtime_data(vnet_main_t *vnm, u32 hw_if_index)
Definition: runtime.c:58
ethernet_interface
Definition: ethernet.h:146
show_sw_interfaces_command
static vlib_cli_command_t show_sw_interfaces_command
(constructor) VLIB_CLI_COMMAND (show_sw_interfaces_command)
Definition: interface_cli.c:509
VNET_HW_IF_RX_MODE_INTERRUPT
@ VNET_HW_IF_RX_MODE_INTERRUPT
Definition: interface.h:57
vnet_set_sw_interface_tag
static void vnet_set_sw_interface_tag(vnet_main_t *vnm, u8 *tag, u32 sw_if_index)
Definition: interface_funcs.h:141
unformat_hash_string
unformat_function_t unformat_hash_string
Definition: hash.h:718
vnet_hw_if_get_tx_queue
static_always_inline vnet_hw_if_tx_queue_t * vnet_hw_if_get_tx_queue(vnet_main_t *vnm, u32 queue_index)
Definition: tx_queue_funcs.h:23
ip4_fib_get
static ip4_fib_t * ip4_fib_get(u32 index)
Get the FIB at the given index.
Definition: ip4_fib.h:88
cm
vnet_feature_config_main_t * cm
Definition: nat44_ei_hairpinning.c:594
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
pcap_main_t::pcap_data
u8 * pcap_data
Vector of pcap data.
Definition: pcap.h:183
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
ip6_main_t::fib_index_by_sw_if_index
u32 * fib_index_by_sw_if_index
Definition: ip6.h:127
VNET_SW_INTERFACE_FLAG_UNNUMBERED
@ VNET_SW_INTERFACE_FLAG_UNNUMBERED
Definition: interface.h:851
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
ip6_fib_t
Definition: ip6.h:61
vnet_interface_main_t::device_classes
vnet_device_class_t * device_classes
Definition: interface.h:1008
vnet_pcap_t::filter_classify_table_index
u32 filter_classify_table_index
Definition: vnet.h:72
VNET_HW_INTERFACE_BOND_INFO_SLAVE
#define VNET_HW_INTERFACE_BOND_INFO_SLAVE
Definition: interface.h:715
vnet_rename_interface
clib_error_t * vnet_rename_interface(vnet_main_t *vnm, u32 hw_if_index, char *new_name)
Definition: interface.c:1503
unformat_vlib_tmpfile
uword unformat_vlib_tmpfile(unformat_input_t *input, va_list *args)
Definition: format.c:192
set_interface_mtu_cmd
static vlib_cli_command_t set_interface_mtu_cmd
(constructor) VLIB_CLI_COMMAND (set_interface_mtu_cmd)
Definition: interface_cli.c:1209
set_interface_rss_queues
clib_error_t * set_interface_rss_queues(vlib_main_t *vm, u32 hw_if_index, clib_bitmap_t *bitmap)
Definition: interface_cli.c:1938
format_vnet_hw_interface
format_function_t format_vnet_hw_interface
Definition: interface_funcs.h:452
vnet_pcap_t
Definition: vnet.h:60
unformat_vnet_hw_interface
unformat_function_t unformat_vnet_hw_interface
Definition: interface_funcs.h:463
set_interface_rx_placement
static clib_error_t * set_interface_rx_placement(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1739
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
vnet_interface_main_t::combined_sw_if_counters
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:1024
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
vnet_interface_main_t::sw_interfaces
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:1015
sw_interface_name_compare
static int sw_interface_name_compare(void *a1, void *a2)
Definition: interface_cli.c:272
VNET_MTU_IP6
@ VNET_MTU_IP6
Definition: interface.h:832
format_l2_input_features
u8 * format_l2_input_features(u8 *s, va_list *args)
Definition: l2_input.c:98
ethernet_get_interface
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
Definition: interface.c:982
l2_input.h
vnet_sw_interface_t::unnumbered_sw_if_index
u32 unnumbered_sw_if_index
Definition: interface.h:884
show_sw_interfaces
static clib_error_t * show_sw_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:282
create_sub_interfaces_command
static vlib_cli_command_t create_sub_interfaces_command
(constructor) VLIB_CLI_COMMAND (create_sub_interfaces_command)
Definition: interface_cli.c:903
vnet_pcap_t::max_bytes_per_pkt
u32 max_bytes_per_pkt
Definition: vnet.h:69
cmd_set_interface_rss_queues
static vlib_cli_command_t cmd_set_interface_rss_queues
(constructor) VLIB_CLI_COMMAND (cmd_set_interface_rss_queues)
Definition: interface_cli.c:2013
ip6_main
ip6_main_t ip6_main
Definition: ip6_forward.c:2785
vnet_pcap_t::pcap_tx_enable
u8 pcap_tx_enable
Definition: vnet.h:65
l2output_intf_config
l2_output_config_t * l2output_intf_config(u32 sw_if_index)
Get a pointer to the config for the given interface.
Definition: l2_output.c:615
id
u8 id[64]
Definition: dhcp.api:160
set_interface_mac_address
static clib_error_t * set_interface_mac_address(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:1369
ethernet_interface_address::mac
mac_address_t mac
Definition: ethernet.h:139
hash_get_mem
#define hash_get_mem(h, key)
Definition: hash.h:269
vnet_device_main_t::first_worker_thread_index
uword first_worker_thread_index
Definition: devices.h:63
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
vnet_interface_features_show
void vnet_interface_features_show(vlib_main_t *vm, u32 sw_if_index, int verbose)
Display the set of driver features configured on a specific interface Called by "show interface" hand...
Definition: feature.c:491
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
VNET_N_MTU
@ VNET_N_MTU
Definition: interface.h:834
format_vlib_node_name
format_function_t format_vlib_node_name
Definition: node_funcs.h:1235
set_tag_command
static vlib_cli_command_t set_tag_command
(constructor) VLIB_CLI_COMMAND (set_tag_command)
Definition: interface_cli.c:1436
ethernet_main
ethernet_main_t ethernet_main
Definition: init.c:45
vnet_pcap_t::pcap_drop_enable
u8 pcap_drop_enable
Definition: vnet.h:67
u64
unsigned long u64
Definition: types.h:89
format_vnet_sw_if_index_name
format_function_t format_vnet_sw_if_index_name
Definition: interface_funcs.h:458
vnet_trace_placeholder
u8 * vnet_trace_placeholder
Definition: trace.c:44
unformat_vnet_sw_interface
unformat_function_t unformat_vnet_sw_interface
Definition: interface_funcs.h:462
format
description fragment has unexpected format
Definition: map.api:433
vlib_combined_counter_main_t
A collection of combined counters.
Definition: counter.h:203
ip.h
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
vnet_main_t::pcap
vnet_pcap_t pcap
Definition: vnet.h:103
format_vtr
format_function_t format_vtr
Definition: interface_funcs.h:472
l2vtr_get
u32 l2vtr_get(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 *vtr_op, u32 *push_dot1q, u32 *vtr_tag1, u32 *vtr_tag2)
Get vtag tag rewrite on the given interface.
Definition: l2_vtr.c:347
show_or_clear_hw_interfaces
static clib_error_t * show_or_clear_hw_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd, int is_show)
Definition: interface_cli.c:66
vnet_clear_sw_interface_tag
static void vnet_clear_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:156
si
vnet_sw_interface_t * si
Definition: interface_output.c:418
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
unformat_vnet_sw_interface_flags
unformat_function_t unformat_vnet_sw_interface_flags
Definition: interface_funcs.h:469
vnet_classify_main_t
struct _vnet_classify_main vnet_classify_main_t
Definition: vnet_classify.h:61
pool_elts
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:127
ip6_main_t::lookup_main
ip_lookup_main_t lookup_main
Definition: ip6.h:112
vnet_hw_if_tx_queue_t
Definition: interface.h:602
l2_output_config_t
Definition: l2_output.h:28
vnet_pcap_dispatch_trace_args_t
Definition: interface.h:1074
set_unnumbered_command
static vlib_cli_command_t set_unnumbered_command
(constructor) VLIB_CLI_COMMAND (set_unnumbered_command)
Definition: interface_cli.c:1016
ip6_main_t
Definition: ip6.h:110
vnet_classify.h
ip4_fib.h
pcap_write
__clib_export clib_error_t * pcap_write(pcap_main_t *pm)
Write PCAP file.
Definition: pcap.c:89
ip6_fib.h
ip_lookup_main_t
Definition: lookup.h:121
vnet_hw_if_tx_queue_t::shared_queue
u8 shared_queue
Definition: interface.h:604
vec_sort_with_function
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:1097
vnet_hw_interface_compare
word vnet_hw_interface_compare(vnet_main_t *vnm, uword hw_if_index0, uword hw_if_index1)
Definition: interface.c:1301
clib_bitmap_last_set
static uword clib_bitmap_last_set(uword *ai)
Return the higest numbered set bit in a bitmap.
Definition: bitmap.h:410
pcap_main_t::n_packets_to_capture
u32 n_packets_to_capture
Number of packets to capture.
Definition: pcap.h:164
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vnet_hw_interface_add_del_mac_address
clib_error_t * vnet_hw_interface_add_del_mac_address(vnet_main_t *vnm, u32 hw_if_index, const u8 *mac_address, u8 is_add)
Definition: interface.c:1539
vlib_main_t
Definition: main.h:102
vlib_simple_counter_main_t
A collection of simple counters.
Definition: counter.h:57
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
a
a
Definition: bitmap.h:525
format_vnet_sw_interface
format_function_t format_vnet_sw_interface
Definition: interface_funcs.h:455
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
Definition: ethernet.h:162
vnet_hw_if_tx_queue_t::threads
clib_bitmap_t * threads
Definition: interface.h:612
vnet_interface_main_t::sw_if_index_by_sup_and_sub
uword * sw_if_index_by_sup_and_sub
Definition: interface.h:1018
PCAP_MAIN_INIT_DONE
#define PCAP_MAIN_INIT_DONE
Definition: pcap.h:174
i
int i
Definition: flowhash_template.h:376
format_l2_input
u8 * format_l2_input(u8 *s, va_list *args)
Definition: l2_input.c:118
vnet_hw_if_rx_queue_t::hw_if_index
u32 hw_if_index
Definition: interface.h:582
pcap_main_t::file_name
char * file_name
File name of pcap output.
Definition: pcap.h:161
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
vnet_hw_if_rx_queue_t
Definition: interface.h:579
vnet_sw_interface_t::hw_if_index
u32 hw_if_index
Definition: interface.h:887
vnet_hw_interface_t::name
u8 * name
Definition: interface.h:678
rv
int __clib_unused rv
Definition: application.c:491
parse_vlan_sub_interfaces
static clib_error_t * parse_vlan_sub_interfaces(unformat_input_t *input, vnet_sw_interface_t *template)
Parse subinterface names.
Definition: interface_cli.c:642
vnet_hw_if_set_rx_queue_thread_index
void vnet_hw_if_set_rx_queue_thread_index(vnet_main_t *vnm, u32 queue_index, u32 thread_index)
Definition: rx_queue.c:215
tx_queue_funcs.h
vnet_hw_interface_t::input_node_index
u32 input_node_index
Definition: interface.h:718
ip_interface_address_t
Definition: lookup.h:89
vlib_error_t
u16 vlib_error_t
Definition: error.h:45
vnet.h
show_interface_sec_mac_addr
static vlib_cli_command_t show_interface_sec_mac_addr
(constructor) VLIB_CLI_COMMAND (show_interface_sec_mac_addr)
Definition: interface_cli.c:1287
clib_bitmap_foreach
#define clib_bitmap_foreach(i, ai)
Macro to iterate across set bits in a bitmap.
Definition: bitmap.h:361
vnet_get_sup_sw_interface
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:81
vlib_cli_command_t
Definition: cli.h:92
pcap_trace_command_fn
static clib_error_t * pcap_trace_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:2204
ip4_main_t
IPv4 main type.
Definition: ip4.h:107
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
ethernet_interface::secondary_addrs
ethernet_interface_address_t * secondary_addrs
Definition: ethernet.h:176
create_sub_interfaces
static clib_error_t * create_sub_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:696
vlib_clear_simple_counters
void vlib_clear_simple_counters(vlib_simple_counter_main_t *cm)
Clear a collection of simple counters.
Definition: counter.c:44
renumber_interface_command
static vlib_cli_command_t renumber_interface_command
(constructor) VLIB_CLI_COMMAND (renumber_interface_command)
Definition: interface_cli.c:1109
pcap_main_t::n_packets_captured
u32 n_packets_captured
Number of packets currently captured.
Definition: pcap.h:170
VNET_MTU_L3
@ VNET_MTU_L3
Definition: interface.h:830
vnet_hw_interface_t::rx_queue_indices
u32 * rx_queue_indices
Definition: interface.h:726
vnet_device_main_t
Definition: devices.h:60
vnet_pcap_t::pcap_error_index
vlib_error_t pcap_error_index
Definition: vnet.h:73
vnet_cli_interface_command
static vlib_cli_command_t vnet_cli_interface_command
(constructor) VLIB_CLI_COMMAND (vnet_cli_interface_command)
Definition: interface_cli.c:519
clib_mem_alloc
static void * clib_mem_alloc(uword size)
Definition: mem.h:256
unformat_bitmap_list
__clib_export uword unformat_bitmap_list(unformat_input_t *input, va_list *va)
unformat a list of bit ranges into a bitmap (eg "0-3,5-7,11" )
Definition: bitmap.c:55
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
set_state
static clib_error_t * set_state(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:914
vnet_main_t::interface_main
vnet_interface_main_t interface_main
Definition: vnet.h:81
vnet_pcap_dispatch_trace_configure
int vnet_pcap_dispatch_trace_configure(vnet_pcap_dispatch_trace_args_t *a)
Definition: interface_cli.c:2056
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
set_state_command
static vlib_cli_command_t set_state_command
(constructor) VLIB_CLI_COMMAND (set_state_command)
Definition: interface_cli.c:960
vnet_sw_interface_set_protocol_mtu
void vnet_sw_interface_set_protocol_mtu(vnet_main_t *vnm, u32 sw_if_index, u32 mtu[])
Definition: interface.c:721
VNET_HW_IF_RX_MODE_UNKNOWN
@ VNET_HW_IF_RX_MODE_UNKNOWN
Definition: interface.h:55
clear_hw_interface_counters_command
static vlib_cli_command_t clear_hw_interface_counters_command
(constructor) VLIB_CLI_COMMAND (clear_hw_interface_counters_command)
Definition: interface_cli.c:263
show_hw_interfaces
static clib_error_t * show_hw_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:171
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105