1cb9cadadSEd Warnicke/*
2cb9cadadSEd Warnicke * Copyright (c) 2015 Cisco and/or its affiliates.
3cb9cadadSEd Warnicke * Licensed under the Apache License, Version 2.0 (the "License");
4cb9cadadSEd Warnicke * you may not use this file except in compliance with the License.
5cb9cadadSEd Warnicke * You may obtain a copy of the License at:
6cb9cadadSEd Warnicke *
7cb9cadadSEd Warnicke *     http://www.apache.org/licenses/LICENSE-2.0
8cb9cadadSEd Warnicke *
9cb9cadadSEd Warnicke * Unless required by applicable law or agreed to in writing, software
10cb9cadadSEd Warnicke * distributed under the License is distributed on an "AS IS" BASIS,
11cb9cadadSEd Warnicke * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12cb9cadadSEd Warnicke * See the License for the specific language governing permissions and
13cb9cadadSEd Warnicke * limitations under the License.
14cb9cadadSEd Warnicke */
15cb9cadadSEd Warnicke/*
16cb9cadadSEd Warnicke * interface_cli.c: interface CLI
17cb9cadadSEd Warnicke *
18cb9cadadSEd Warnicke * Copyright (c) 2008 Eliot Dresselhaus
19cb9cadadSEd Warnicke *
20cb9cadadSEd Warnicke * Permission is hereby granted, free of charge, to any person obtaining
21cb9cadadSEd Warnicke * a copy of this software and associated documentation files (the
22cb9cadadSEd Warnicke * "Software"), to deal in the Software without restriction, including
23cb9cadadSEd Warnicke * without limitation the rights to use, copy, modify, merge, publish,
24cb9cadadSEd Warnicke * distribute, sublicense, and/or sell copies of the Software, and to
25cb9cadadSEd Warnicke * permit persons to whom the Software is furnished to do so, subject to
26cb9cadadSEd Warnicke * the following conditions:
27cb9cadadSEd Warnicke *
28cb9cadadSEd Warnicke * The above copyright notice and this permission notice shall be
29cb9cadadSEd Warnicke * included in all copies or substantial portions of the Software.
30cb9cadadSEd Warnicke *
31cb9cadadSEd Warnicke *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32cb9cadadSEd Warnicke *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33cb9cadadSEd Warnicke *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34cb9cadadSEd Warnicke *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35cb9cadadSEd Warnicke *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36cb9cadadSEd Warnicke *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37cb9cadadSEd Warnicke *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38cb9cadadSEd Warnicke */
39cb9cadadSEd Warnicke
4016bcf7d8SChris Luke/**
4116bcf7d8SChris Luke * @file
42e9bac695SBilly McFall * @brief Interface CLI.
43e9bac695SBilly McFall *
44e9bac695SBilly McFall * Source code for several CLI interface commands.
45e9bac695SBilly McFall *
4616bcf7d8SChris Luke */
4716bcf7d8SChris Luke
48cb9cadadSEd Warnicke#include <vnet/vnet.h>
49cb9cadadSEd Warnicke#include <vnet/ip/ip.h>
50bcebbb98SJohn Lo#include <vppinfra/bitmap.h>
510bfe5d8cSNeale Ranns#include <vnet/fib/ip4_fib.h>
520bfe5d8cSNeale Ranns#include <vnet/fib/ip6_fib.h>
53942402b0SEyal Bari#include <vnet/l2/l2_output.h>
54942402b0SEyal Bari#include <vnet/l2/l2_input.h>
55ba4a5bf8SNeale Ranns#include <vnet/classify/vnet_classify.h>
56cb9cadadSEd Warnicke
57ba868bb7SDave Barachstatic int
58ba868bb7SDave Barachcompare_interface_names (void *a1, void *a2)
59cb9cadadSEd Warnicke{
60ba868bb7SDave Barach  u32 *hi1 = a1;
61ba868bb7SDave Barach  u32 *hi2 = a2;
62cb9cadadSEd Warnicke
63ba868bb7SDave Barach  return vnet_hw_interface_compare (vnet_get_main (), *hi1, *hi2);
64cb9cadadSEd Warnicke}
65cb9cadadSEd Warnicke
66cb9cadadSEd Warnickestatic clib_error_t *
67cb9cadadSEd Warnickeshow_or_clear_hw_interfaces (vlib_main_t * vm,
68cb9cadadSEd Warnicke			     unformat_input_t * input,
69cb9cadadSEd Warnicke			     vlib_cli_command_t * cmd)
70cb9cadadSEd Warnicke{
71ba868bb7SDave Barach  clib_error_t *error = 0;
72ba868bb7SDave Barach  vnet_main_t *vnm = vnet_get_main ();
73ba868bb7SDave Barach  vnet_interface_main_t *im = &vnm->interface_main;
74ba868bb7SDave Barach  vnet_hw_interface_t *hi;
75ba868bb7SDave Barach  u32 hw_if_index, *hw_if_indices = 0;
76bcebbb98SJohn Lo  int i, verbose = -1, is_show, show_bond = 0;
77cb9cadadSEd Warnicke
78cb9cadadSEd Warnicke  is_show = strstr (cmd->path, "show") != 0;
79cb9cadadSEd Warnicke  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
80cb9cadadSEd Warnicke    {
81cb9cadadSEd Warnicke      /* See if user wants to show a specific interface. */
82ba868bb7SDave Barach      if (unformat
83ba868bb7SDave Barach	  (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
84ba868bb7SDave Barach	vec_add1 (hw_if_indices, hw_if_index);
85bcebbb98SJohn Lo
86679ea795SSean Hope      /* See if user wants to show an interface with a specific hw_if_index. */
87679ea795SSean Hope      else if (unformat (input, "%u", &hw_if_index))
88ba868bb7SDave Barach	vec_add1 (hw_if_indices, hw_if_index);
89cb9cadadSEd Warnicke
90cb9cadadSEd Warnicke      else if (unformat (input, "verbose"))
91ba868bb7SDave Barach	verbose = 1;		/* this is also the default */
92cb9cadadSEd Warnicke
93cb9cadadSEd Warnicke      else if (unformat (input, "detail"))
94cb9cadadSEd Warnicke	verbose = 2;
95cb9cadadSEd Warnicke
96cb9cadadSEd Warnicke      else if (unformat (input, "brief"))
97cb9cadadSEd Warnicke	verbose = 0;
98cb9cadadSEd Warnicke
99bcebbb98SJohn Lo      else if (unformat (input, "bond"))
100ba868bb7SDave Barach	{
101ba868bb7SDave Barach	  show_bond = 1;
102ba868bb7SDave Barach	  if (verbose < 0)
103ba868bb7SDave Barach	    verbose = 0;	/* default to brief for link bonding */
104ba868bb7SDave Barach	}
105bcebbb98SJohn Lo
106cb9cadadSEd Warnicke      else
107cb9cadadSEd Warnicke	{
108cb9cadadSEd Warnicke	  error = clib_error_return (0, "unknown input `%U'",
109cb9cadadSEd Warnicke				     format_unformat_error, input);
110cb9cadadSEd Warnicke	  goto done;
111cb9cadadSEd Warnicke	}
112cb9cadadSEd Warnicke    }
113ba868bb7SDave Barach
114cb9cadadSEd Warnicke  /* Gather interfaces. */
115cb9cadadSEd Warnicke  if (vec_len (hw_if_indices) == 0)
116cb9cadadSEd Warnicke    pool_foreach (hi, im->hw_interfaces,
117cb9cadadSEd Warnicke		  vec_add1 (hw_if_indices, hi - im->hw_interfaces));
118cb9cadadSEd Warnicke
119ba868bb7SDave Barach  if (verbose < 0)
120ba868bb7SDave Barach    verbose = 1;		/* default to verbose (except bond) */
121bcebbb98SJohn Lo
122cb9cadadSEd Warnicke  if (is_show)
123cb9cadadSEd Warnicke    {
124cb9cadadSEd Warnicke      /* Sort by name. */
125cb9cadadSEd Warnicke      vec_sort_with_function (hw_if_indices, compare_interface_names);
126cb9cadadSEd Warnicke
127cb9cadadSEd Warnicke      vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm, 0, verbose);
128cb9cadadSEd Warnicke      for (i = 0; i < vec_len (hw_if_indices); i++)
129cb9cadadSEd Warnicke	{
130cb9cadadSEd Warnicke	  hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
131ba868bb7SDave Barach	  if (show_bond == 0)	/* show all interfaces */
132ba868bb7SDave Barach	    vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm,
133ba868bb7SDave Barach			     hi, verbose);
134ba868bb7SDave Barach	  else if ((hi->bond_info) &&
135bcebbb98SJohn Lo		   (hi->bond_info != VNET_HW_INTERFACE_BOND_INFO_SLAVE))
136ba868bb7SDave Barach	    {			/* show only bonded interface and all its slave interfaces */
137bcebbb98SJohn Lo	      int hw_idx;
138ba868bb7SDave Barach	      vnet_hw_interface_t *shi;
139ba868bb7SDave Barach	      vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm,
140bcebbb98SJohn Lo			       hi, verbose);
141ba868bb7SDave Barach
142ba868bb7SDave Barach              /* *INDENT-OFF* */
143bcebbb98SJohn Lo	      clib_bitmap_foreach (hw_idx, hi->bond_info,
144ba868bb7SDave Barach              ({
145ba868bb7SDave Barach                shi = vnet_get_hw_interface(vnm, hw_idx);
146ba868bb7SDave Barach                vlib_cli_output (vm, "%U\n",
147ba868bb7SDave Barach                                 format_vnet_hw_interface, vnm, shi, verbose);
148ba868bb7SDave Barach              }));
149ba868bb7SDave Barach              /* *INDENT-ON* */
150bcebbb98SJohn Lo	    }
151cb9cadadSEd Warnicke	}
152cb9cadadSEd Warnicke    }
153cb9cadadSEd Warnicke  else
154cb9cadadSEd Warnicke    {
155cb9cadadSEd Warnicke      for (i = 0; i < vec_len (hw_if_indices); i++)
156cb9cadadSEd Warnicke	{
157ba868bb7SDave Barach	  vnet_device_class_t *dc;
158cb9cadadSEd Warnicke
159cb9cadadSEd Warnicke	  hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
160cb9cadadSEd Warnicke	  dc = vec_elt_at_index (im->device_classes, hi->dev_class_index);
161ba868bb7SDave Barach
162cb9cadadSEd Warnicke	  if (dc->clear_counters)
163cb9cadadSEd Warnicke	    dc->clear_counters (hi->dev_instance);
164cb9cadadSEd Warnicke	}
165cb9cadadSEd Warnicke    }
166cb9cadadSEd Warnicke
167ba868bb7SDave Barachdone:
168cb9cadadSEd Warnicke  vec_free (hw_if_indices);
169cb9cadadSEd Warnicke  return error;
170cb9cadadSEd Warnicke}
171cb9cadadSEd Warnicke
1726ef7bb99SKeith Burns (alagalah)/*?
173e9bac695SBilly McFall * Display more detailed information about all or a list of given interfaces.
174e9bac695SBilly McFall * The verboseness of the output can be controlled by the following optional
175e9bac695SBilly McFall * parameters:
176e9bac695SBilly McFall * - brief: Only show name, index and state (default for bonded interfaces).
177e9bac695SBilly McFall * - verbose: Also display additional attributes (default for all other interfaces).
178e9bac695SBilly McFall * - detail: Also display all remaining attributes and extended statistics.
179e9bac695SBilly McFall *
180e9bac695SBilly McFall * To limit the output of the command to bonded interfaces and their slave
181e9bac695SBilly McFall * interfaces, use the '<em>bond</em>' optional parameter.
1826ef7bb99SKeith Burns (alagalah) *
1836ef7bb99SKeith Burns (alagalah) * @cliexpar
184e9bac695SBilly McFall * Example of how to display default data for all interfaces:
185e9bac695SBilly McFall * @cliexstart{show hardware-interfaces}
186e9bac695SBilly McFall *               Name                Idx   Link  Hardware
187e9bac695SBilly McFall * GigabitEthernet7/0/0               1     up   GigabitEthernet7/0/0
188e9bac695SBilly McFall *   Ethernet address ec:f4:bb:c0:bc:fc
189e9bac695SBilly McFall *   Intel e1000
190e9bac695SBilly McFall *     carrier up full duplex speed 1000 mtu 9216
191e9bac695SBilly McFall *     rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
192e9bac695SBilly McFall *     cpu socket 0
193e9bac695SBilly McFall * GigabitEthernet7/0/1               2     up   GigabitEthernet7/0/1
194e9bac695SBilly McFall *   Ethernet address ec:f4:bb:c0:bc:fd
195e9bac695SBilly McFall *   Intel e1000
196e9bac695SBilly McFall *     carrier up full duplex speed 1000 mtu 9216
197e9bac695SBilly McFall *     rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
198e9bac695SBilly McFall *     cpu socket 0
199e9bac695SBilly McFall * VirtualEthernet0/0/0               3     up   VirtualEthernet0/0/0
200e9bac695SBilly McFall *   Ethernet address 02:fe:a5:a9:8b:8e
201e9bac695SBilly McFall * VirtualEthernet0/0/1               4     up   VirtualEthernet0/0/1
202e9bac695SBilly McFall *   Ethernet address 02:fe:c0:4e:3b:b0
203e9bac695SBilly McFall * VirtualEthernet0/0/2               5     up   VirtualEthernet0/0/2
204e9bac695SBilly McFall *   Ethernet address 02:fe:1f:73:92:81
205e9bac695SBilly McFall * VirtualEthernet0/0/3               6     up   VirtualEthernet0/0/3
206e9bac695SBilly McFall *   Ethernet address 02:fe:f2:25:c4:68
207e9bac695SBilly McFall * local0                             0    down  local0
208e9bac695SBilly McFall *   local
209e9bac695SBilly McFall * @cliexend
210e9bac695SBilly McFall * Example of how to display '<em>verbose</em>' data for an interface by name and
211e9bac695SBilly McFall * software index (where 2 is the software index):
212e9bac695SBilly McFall * @cliexstart{show hardware-interfaces GigabitEthernet7/0/0 2 verbose}
213e9bac695SBilly McFall *               Name                Idx   Link  Hardware
214e9bac695SBilly McFall * GigabitEthernet7/0/0               1     up   GigabitEthernet7/0/0
215e9bac695SBilly McFall *   Ethernet address ec:f4:bb:c0:bc:fc
216e9bac695SBilly McFall *   Intel e1000
217e9bac695SBilly McFall *     carrier up full duplex speed 1000 mtu 9216
218e9bac695SBilly McFall *     rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
219e9bac695SBilly McFall *     cpu socket 0
220e9bac695SBilly McFall * GigabitEthernet7/0/1               2    down  GigabitEthernet7/0/1
221e9bac695SBilly McFall *   Ethernet address ec:f4:bb:c0:bc:fd
222e9bac695SBilly McFall *   Intel e1000
223e9bac695SBilly McFall *     carrier up full duplex speed 1000 mtu 9216
224e9bac695SBilly McFall *     rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
225e9bac695SBilly McFall *     cpu socket 0
2266ef7bb99SKeith Burns (alagalah) * @cliexend
2276ef7bb99SKeith Burns (alagalah) ?*/
228e9bac695SBilly McFall/* *INDENT-OFF* */
229cb9cadadSEd WarnickeVLIB_CLI_COMMAND (show_hw_interfaces_command, static) = {
230cb9cadadSEd Warnicke  .path = "show hardware-interfaces",
231e9bac695SBilly McFall  .short_help = "show hardware-interfaces [brief|verbose|detail] [bond] "
232e9bac695SBilly McFall    "[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
233cb9cadadSEd Warnicke  .function = show_or_clear_hw_interfaces,
234cb9cadadSEd Warnicke};
235ba868bb7SDave Barach/* *INDENT-ON* */
236cb9cadadSEd Warnicke
237e9bac695SBilly McFall
238e9bac695SBilly McFall/*?
239e9bac695SBilly McFall * Clear the extended statistics for all or a list of given interfaces
240e9bac695SBilly McFall * (statistics associated with the '<em>show hardware-interfaces</em>' command).
241e9bac695SBilly McFall *
242e9bac695SBilly McFall * @cliexpar
243e9bac695SBilly McFall * Example of how to clear the extended statistics for all interfaces:
244e9bac695SBilly McFall * @cliexcmd{clear hardware-interfaces}
245e9bac695SBilly McFall * Example of how to clear the extended statistics for an interface by
246e9bac695SBilly McFall * name and software index (where 2 is the software index):
247e9bac695SBilly McFall * @cliexcmd{clear hardware-interfaces GigabitEthernet7/0/0 2}
248e9bac695SBilly McFall ?*/
249ba868bb7SDave Barach/* *INDENT-OFF* */
250cb9cadadSEd WarnickeVLIB_CLI_COMMAND (clear_hw_interface_counters_command, static) = {
251cb9cadadSEd Warnicke  .path = "clear hardware-interfaces",
252e9bac695SBilly McFall  .short_help = "clear hardware-interfaces "
253e9bac695SBilly McFall    "[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
254cb9cadadSEd Warnicke  .function = show_or_clear_hw_interfaces,
255cb9cadadSEd Warnicke};
256ba868bb7SDave Barach/* *INDENT-ON* */
257cb9cadadSEd Warnicke
258ba868bb7SDave Barachstatic int
259ba868bb7SDave Barachsw_interface_name_compare (void *a1, void *a2)
260cb9cadadSEd Warnicke{
261cb9cadadSEd Warnicke  vnet_sw_interface_t *si1 = a1;
262cb9cadadSEd Warnicke  vnet_sw_interface_t *si2 = a2;
263cb9cadadSEd Warnicke
264ba868bb7SDave Barach  return vnet_sw_interface_compare (vnet_get_main (),
265ba868bb7SDave Barach				    si1->sw_if_index, si2->sw_if_index);
266cb9cadadSEd Warnicke}
267cb9cadadSEd Warnicke
268cb9cadadSEd Warnickestatic clib_error_t *
269cb9cadadSEd Warnickeshow_sw_interfaces (vlib_main_t * vm,
270ba868bb7SDave Barach		    unformat_input_t * input, vlib_cli_command_t * cmd)
271cb9cadadSEd Warnicke{
272ba868bb7SDave Barach  clib_error_t *error = 0;
273ba868bb7SDave Barach  vnet_main_t *vnm = vnet_get_main ();
274525c9d0fSDave Barach  unformat_input_t _linput, *linput = &_linput;
275ba868bb7SDave Barach  vnet_interface_main_t *im = &vnm->interface_main;
276ba868bb7SDave Barach  vnet_sw_interface_t *si, *sorted_sis = 0;
2772231150bSDamjan Marion  u32 sw_if_index = ~(u32) 0;
278cb9cadadSEd Warnicke  u8 show_addresses = 0;
2792231150bSDamjan Marion  u8 show_features = 0;
2807be864adSDave Barach  u8 show_tag = 0;
2819485d99bSJon Loeliger  u8 show_vtr = 0;
282525c9d0fSDave Barach  int verbose = 0;
283cb9cadadSEd Warnicke
284525c9d0fSDave Barach  /*
285525c9d0fSDave Barach   * Get a line of input. Won't work if the user typed
286525c9d0fSDave Barach   * "show interface" and nothing more.
287525c9d0fSDave Barach   */
288525c9d0fSDave Barach  if (unformat_user (input, unformat_line_input, linput))
289cb9cadadSEd Warnicke    {
290525c9d0fSDave Barach      while (unformat_check_input (linput) != UNFORMAT_END_OF_INPUT)
291ba868bb7SDave Barach	{
292525c9d0fSDave Barach	  /* See if user wants to show specific interface */
293525c9d0fSDave Barach	  if (unformat
294525c9d0fSDave Barach	      (linput, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
295525c9d0fSDave Barach	    {
296525c9d0fSDave Barach	      si = pool_elt_at_index (im->sw_interfaces, sw_if_index);
297525c9d0fSDave Barach	      vec_add1 (sorted_sis, si[0]);
298525c9d0fSDave Barach	    }
299525c9d0fSDave Barach	  else if (unformat (linput, "address") || unformat (linput, "addr"))
300525c9d0fSDave Barach	    show_addresses = 1;
301525c9d0fSDave Barach	  else if (unformat (linput, "features") || unformat (linput, "feat"))
302525c9d0fSDave Barach	    show_features = 1;
303525c9d0fSDave Barach	  else if (unformat (linput, "tag"))
304525c9d0fSDave Barach	    show_tag = 1;
3059485d99bSJon Loeliger	  else if (unformat (linput, "vtr"))
3069485d99bSJon Loeliger	    show_vtr = 1;
307525c9d0fSDave Barach	  else if (unformat (linput, "verbose"))
308525c9d0fSDave Barach	    verbose = 1;
309525c9d0fSDave Barach	  else
310525c9d0fSDave Barach	    {
3118fdde3c2SDave Barach	      vec_free (sorted_sis);
312525c9d0fSDave Barach	      error = clib_error_return (0, "unknown input `%U'",
313525c9d0fSDave Barach					 format_unformat_error, linput);
314525c9d0fSDave Barach	      goto done;
315525c9d0fSDave Barach	    }
316ba868bb7SDave Barach	}
317525c9d0fSDave Barach      unformat_free (linput);
318cb9cadadSEd Warnicke    }
3199485d99bSJon Loeliger  if (show_features || show_tag || show_vtr)
3202231150bSDamjan Marion    {
3212231150bSDamjan Marion      if (sw_if_index == ~(u32) 0)
3228fdde3c2SDave Barach	{
3238fdde3c2SDave Barach	  vec_free (sorted_sis);
3248fdde3c2SDave Barach	  return clib_error_return (0, "Interface not specified...");
3258fdde3c2SDave Barach	}
3267be864adSDave Barach    }
3272231150bSDamjan Marion
3287be864adSDave Barach  if (show_features)
3297be864adSDave Barach    {
330525c9d0fSDave Barach      vnet_interface_features_show (vm, sw_if_index, verbose);
331942402b0SEyal Bari
332942402b0SEyal Bari      l2_input_config_t *l2_input = l2input_intf_config (sw_if_index);
333942402b0SEyal Bari      u32 fb = l2_input->feature_bitmap;
334942402b0SEyal Bari      /* intf input features are masked by bridge domain */
335942402b0SEyal Bari      if (l2_input->bridge)
336942402b0SEyal Bari	fb &= l2input_bd_config (l2_input->bd_index)->feature_bitmap;
3375d9df1dbSNeale Ranns      vlib_cli_output (vm, "\nl2-input:\n%U", format_l2_input_features, fb,
3385d9df1dbSNeale Ranns		       1);
339942402b0SEyal Bari
340942402b0SEyal Bari      l2_output_config_t *l2_output = l2output_intf_config (sw_if_index);
341942402b0SEyal Bari      vlib_cli_output (vm, "\nl2-output:");
342942402b0SEyal Bari      if (l2_output->out_vtr_flag)
343942402b0SEyal Bari	vlib_cli_output (vm, "%10s (%s)", "VTR", "--internal--");
344942402b0SEyal Bari      vlib_cli_output (vm, "%U", format_l2_output_features,
3455d9df1dbSNeale Ranns		       l2_output->feature_bitmap, 1);
3468fdde3c2SDave Barach      vec_free (sorted_sis);
3472231150bSDamjan Marion      return 0;
3482231150bSDamjan Marion    }
3497be864adSDave Barach  if (show_tag)
3507be864adSDave Barach    {
3517be864adSDave Barach      u8 *tag;
3527be864adSDave Barach      tag = vnet_get_sw_interface_tag (vnm, sw_if_index);
3537be864adSDave Barach      vlib_cli_output (vm, "%U: %s",
3547be864adSDave Barach		       format_vnet_sw_if_index_name, vnm, sw_if_index,
3557be864adSDave Barach		       tag ? (char *) tag : "(none)");
3568fdde3c2SDave Barach      vec_free (sorted_sis);
3577be864adSDave Barach      return 0;
3587be864adSDave Barach    }
3592231150bSDamjan Marion
3609485d99bSJon Loeliger  /*
3619485d99bSJon Loeliger   * Show vlan tag rewrite data for one interface.
3629485d99bSJon Loeliger   */
3639485d99bSJon Loeliger  if (show_vtr)
3649485d99bSJon Loeliger    {
3659485d99bSJon Loeliger      u32 vtr_op = L2_VTR_DISABLED;
3669485d99bSJon Loeliger      u32 push_dot1q = 0, tag1 = 0, tag2 = 0;
3679485d99bSJon Loeliger
3689485d99bSJon Loeliger      if (l2vtr_get (vm, vnm, sw_if_index,
3699485d99bSJon Loeliger		     &vtr_op, &push_dot1q, &tag1, &tag2) != 0)
3709485d99bSJon Loeliger	{
3719485d99bSJon Loeliger	  vlib_cli_output (vm, "%U: Problem getting vlan tag-rewrite data",
3729485d99bSJon Loeliger			   format_vnet_sw_if_index_name, vnm, sw_if_index);
3739485d99bSJon Loeliger	  return 0;
3749485d99bSJon Loeliger	}
3759485d99bSJon Loeliger      vlib_cli_output (vm, "%U:  VTR %0U",
3769485d99bSJon Loeliger		       format_vnet_sw_if_index_name, vnm, sw_if_index,
3779485d99bSJon Loeliger		       format_vtr, vtr_op, push_dot1q, tag1, tag2);
3789485d99bSJon Loeliger      return 0;
3799485d99bSJon Loeliger    }
3809485d99bSJon Loeliger
381cb9cadadSEd Warnicke  if (!show_addresses)
382ba868bb7SDave Barach    vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, 0);
383cb9cadadSEd Warnicke
384ba868bb7SDave Barach  if (vec_len (sorted_sis) == 0)	/* Get all interfaces */
385cb9cadadSEd Warnicke    {
386cb9cadadSEd Warnicke      /* Gather interfaces. */
387ba868bb7SDave Barach      sorted_sis =
388ba868bb7SDave Barach	vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
389cb9cadadSEd Warnicke      _vec_len (sorted_sis) = 0;
390525c9d0fSDave Barach      /* *INDENT-OFF* */
391525c9d0fSDave Barach      pool_foreach (si, im->sw_interfaces,
392525c9d0fSDave Barach      ({
393525c9d0fSDave Barach        int visible = vnet_swif_is_api_visible (si);
394525c9d0fSDave Barach        if (visible)
395525c9d0fSDave Barach          vec_add1 (sorted_sis, si[0]);}
396525c9d0fSDave Barach        ));
397d723161eSOle Troan      /* *INDENT-ON* */
398cb9cadadSEd Warnicke      /* Sort by name. */
399cb9cadadSEd Warnicke      vec_sort_with_function (sorted_sis, sw_interface_name_compare);
400cb9cadadSEd Warnicke    }
401cb9cadadSEd Warnicke
402cb9cadadSEd Warnicke  if (show_addresses)
403cb9cadadSEd Warnicke    {
404cb9cadadSEd Warnicke      vec_foreach (si, sorted_sis)
405ba868bb7SDave Barach      {
406ba868bb7SDave Barach	ip4_main_t *im4 = &ip4_main;
407ba868bb7SDave Barach	ip6_main_t *im6 = &ip6_main;
408ba868bb7SDave Barach	ip_lookup_main_t *lm4 = &im4->lookup_main;
409ba868bb7SDave Barach	ip_lookup_main_t *lm6 = &im6->lookup_main;
410ba868bb7SDave Barach	ip_interface_address_t *ia = 0;
411ba868bb7SDave Barach	u32 fib_index4 = 0, fib_index6 = 0;
412ba868bb7SDave Barach
413ba868bb7SDave Barach	if (vec_len (im4->fib_index_by_sw_if_index) > si->sw_if_index)
414ba868bb7SDave Barach	  fib_index4 = vec_elt (im4->fib_index_by_sw_if_index,
415ba868bb7SDave Barach				si->sw_if_index);
416ba868bb7SDave Barach
417ba868bb7SDave Barach	if (vec_len (im6->fib_index_by_sw_if_index) > si->sw_if_index)
418ba868bb7SDave Barach	  fib_index6 = vec_elt (im6->fib_index_by_sw_if_index,
419ba868bb7SDave Barach				si->sw_if_index);
420ba868bb7SDave Barach
4214478d8edSJohn Lo	ip4_fib_t *fib4 = ip4_fib_get (fib_index4);
4224478d8edSJohn Lo	ip6_fib_t *fib6 = ip6_fib_get (fib_index6);
423ba868bb7SDave Barach
424ba868bb7SDave Barach	if (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED)
425ba868bb7SDave Barach	  vlib_cli_output
426ba868bb7SDave Barach	    (vm, "%U (%s): \n  unnumbered, use %U",
4274478d8edSJohn Lo	     format_vnet_sw_if_index_name, vnm, si->sw_if_index,
428ba868bb7SDave Barach	     (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn",
429ba868bb7SDave Barach	     format_vnet_sw_if_index_name, vnm, si->unnumbered_sw_if_index);
430ba868bb7SDave Barach	else
4314478d8edSJohn Lo	  vlib_cli_output
4324478d8edSJohn Lo	    (vm, "%U (%s):",
4334478d8edSJohn Lo	     format_vnet_sw_if_index_name, vnm, si->sw_if_index,
4344478d8edSJohn Lo	     (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn");
435ba868bb7SDave Barach
436942402b0SEyal Bari	/* Display any L2 info */
437942402b0SEyal Bari	l2_input_config_t *l2_input = l2input_intf_config (si->sw_if_index);
438942402b0SEyal Bari	if (l2_input->bridge)
439ba868bb7SDave Barach	  {
4404478d8edSJohn Lo	    bd_main_t *bdm = &bd_main;
441942402b0SEyal Bari	    u32 bd_id = l2input_main.bd_configs[l2_input->bd_index].bd_id;
4424478d8edSJohn Lo	    vlib_cli_output (vm, "  L2 bridge bd-id %d idx %d shg %d %s",
4434478d8edSJohn Lo			     bd_id, bd_find_index (bdm, bd_id), l2_input->shg,
4444478d8edSJohn Lo			     l2_input->bvi ? "bvi" : " ");
445ba868bb7SDave Barach	  }
446942402b0SEyal Bari	else if (l2_input->xconnect)
4474478d8edSJohn Lo	  vlib_cli_output (vm, "  L2 xconnect %U",
4484478d8edSJohn Lo			   format_vnet_sw_if_index_name, vnm,
4494478d8edSJohn Lo			   l2_input->output_sw_if_index);
450ba868bb7SDave Barach
4514478d8edSJohn Lo	/* *INDENT-OFF* */
452ba868bb7SDave Barach	/* Display any IP4 addressing info */
4534478d8edSJohn Lo	foreach_ip_interface_address (lm4, ia, si->sw_if_index,
4544478d8edSJohn Lo				      1 /* honor unnumbered */,
4554478d8edSJohn Lo	({
4564478d8edSJohn Lo	  ip4_address_t *r4 = ip_interface_address_get_address (lm4, ia);
4574478d8edSJohn Lo	  if (fib4->table_id)
4584478d8edSJohn Lo	    vlib_cli_output (vm, "  L3 %U/%d ip4 table-id %d fib-idx %d",
4594478d8edSJohn Lo			     format_ip4_address, r4, ia->address_length,
4604478d8edSJohn Lo			     fib4->table_id,
4614478d8edSJohn Lo			     ip4_fib_index_from_table_id (fib4->table_id));
4624478d8edSJohn Lo	  else
4634478d8edSJohn Lo	    vlib_cli_output (vm, "  L3 %U/%d",
4644478d8edSJohn Lo			     format_ip4_address, r4, ia->address_length);
4654478d8edSJohn Lo        }));
4664478d8edSJohn Lo	/* *INDENT-ON* */
4674478d8edSJohn Lo
4684478d8edSJohn Lo	/* *INDENT-OFF* */
469ba868bb7SDave Barach	/* Display any IP6 addressing info */
4704478d8edSJohn Lo	foreach_ip_interface_address (lm6, ia, si->sw_if_index,
4714478d8edSJohn Lo				      1 /* honor unnumbered */,
4724478d8edSJohn Lo        ({
4734478d8edSJohn Lo	  ip6_address_t *r6 = ip_interface_address_get_address (lm6, ia);
4744478d8edSJohn Lo	  if (fib6->table_id)
4754478d8edSJohn Lo	    vlib_cli_output (vm, "  L3 %U/%d ip6 table-id %d fib-idx %d",
4764478d8edSJohn Lo			     format_ip6_address, r6, ia->address_length,
4774478d8edSJohn Lo			     fib6->table_id,
4784478d8edSJohn Lo			     ip6_fib_index_from_table_id (fib6->table_id));
4794478d8edSJohn Lo	  else
4804478d8edSJohn Lo	    vlib_cli_output (vm, "  L3 %U/%d",
4814478d8edSJohn Lo			     format_ip6_address, r6, ia->address_length);
4824478d8edSJohn Lo        }));
4834478d8edSJohn Lo	/* *INDENT-ON* */
484d723161eSOle Troan      }
485d723161eSOle Troan    }
486d723161eSOle Troan  else
487d723161eSOle Troan    {
488d723161eSOle Troan      vec_foreach (si, sorted_sis)
489d723161eSOle Troan      {
490d723161eSOle Troan	vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, si);
491d723161eSOle Troan      }
492cb9cadadSEd Warnicke    }
493cb9cadadSEd Warnicke
494ba868bb7SDave Barachdone:
495d723161eSOle Troan  vec_free (sorted_sis);
496d723161eSOle Troan  return error;
497cb9cadadSEd Warnicke}
498cb9cadadSEd Warnicke
499ba868bb7SDave Barach/* *INDENT-OFF* */
500cb9cadadSEd WarnickeVLIB_CLI_COMMAND (show_sw_interfaces_command, static) = {
50113ad1f02SDave Barach  .path = "show interface",
5029485d99bSJon Loeliger  .short_help = "show interface [address|addr|features|feat|vtr] [<interface> [<interface> [..]]] [verbose]",
503cb9cadadSEd Warnicke  .function = show_sw_interfaces,
504c5fa2b80SSteven Luong  .is_mp_safe = 1,
505cb9cadadSEd Warnicke};
506ba868bb7SDave Barach/* *INDENT-ON* */
507cb9cadadSEd Warnicke
508cb9cadadSEd Warnicke/* Root of all interface commands. */
509ba868bb7SDave Barach/* *INDENT-OFF* */
510cb9cadadSEd WarnickeVLIB_CLI_COMMAND (vnet_cli_interface_command, static) = {
511cb9cadadSEd Warnicke  .path = "interface",
512cb9cadadSEd Warnicke  .short_help = "Interface commands",
513cb9cadadSEd Warnicke};
514ba868bb7SDave Barach/* *INDENT-ON* */
515cb9cadadSEd Warnicke
516ba868bb7SDave Barach/* *INDENT-OFF* */
517cb9cadadSEd WarnickeVLIB_CLI_COMMAND (vnet_cli_set_interface_command, static) = {
518cb9cadadSEd Warnicke  .path = "set interface",
519cb9cadadSEd Warnicke  .short_help = "Interface commands",
520cb9cadadSEd Warnicke};
521ba868bb7SDave Barach/* *INDENT-ON* */
522cb9cadadSEd Warnicke
523cb9cadadSEd Warnickestatic clib_error_t *
524cb9cadadSEd Warnickeclear_interface_counters (vlib_main_t * vm,
525ba868bb7SDave Barach			  unformat_input_t * input, vlib_cli_command_t * cmd)
526cb9cadadSEd Warnicke{
527ba868bb7SDave Barach  vnet_main_t *vnm = vnet_get_main ();
528ba868bb7SDave Barach  vnet_interface_main_t *im = &vnm->interface_main;
529ba868bb7SDave Barach  vlib_simple_counter_main_t *sm;
530ba868bb7SDave Barach  vlib_combined_counter_main_t *cm;
5318fdde3c2SDave Barach  int j, n_counters;
532cb9cadadSEd Warnicke
533cb9cadadSEd Warnicke  n_counters = vec_len (im->combined_sw_if_counters);
534cb9cadadSEd Warnicke
535cb9cadadSEd Warnicke  for (j = 0; j < n_counters; j++)
536cb9cadadSEd Warnicke    {
5378fdde3c2SDave Barach      im = &vnm->interface_main;
5388fdde3c2SDave Barach      cm = im->combined_sw_if_counters + j;
5398fdde3c2SDave Barach      vlib_clear_combined_counters (cm);
540cb9cadadSEd Warnicke    }
541cb9cadadSEd Warnicke
542cb9cadadSEd Warnicke  n_counters = vec_len (im->sw_if_counters);
543cb9cadadSEd Warnicke
544cb9cadadSEd Warnicke  for (j = 0; j < n_counters; j++)
545cb9cadadSEd Warnicke    {
5468fdde3c2SDave Barach      im = &vnm->interface_main;
5478fdde3c2SDave Barach      sm = im->sw_if_counters + j;
5488fdde3c2SDave Barach      vlib_clear_simple_counters (sm);
549cb9cadadSEd Warnicke    }
550cb9cadadSEd Warnicke
551cb9cadadSEd Warnicke  return 0;
552cb9cadadSEd Warnicke}
553cb9cadadSEd Warnicke
554e9bac695SBilly McFall/*?
555e9bac695SBilly McFall * Clear the statistics for all interfaces (statistics associated with the
556e9bac695SBilly McFall * '<em>show interface</em>' command).
557e9bac695SBilly McFall *
558e9bac695SBilly McFall * @cliexpar
559e9bac695SBilly McFall * Example of how to clear the statistics for all interfaces:
560e9bac695SBilly McFall * @cliexcmd{clear interfaces}
561e9bac695SBilly McFall ?*/
562ba868bb7SDave Barach/* *INDENT-OFF* */
563cb9cadadSEd WarnickeVLIB_CLI_COMMAND (clear_interface_counters_command, static) = {
564cb9cadadSEd Warnicke  .path = "clear interfaces",
565e9bac695SBilly McFall  .short_help = "clear interfaces",
566cb9cadadSEd Warnicke  .function = clear_interface_counters,
567cb9cadadSEd Warnicke};
568ba868bb7SDave Barach/* *INDENT-ON* */
569cb9cadadSEd Warnicke
57016bcf7d8SChris Luke/**
57116bcf7d8SChris Luke * Parse subinterface names.
57216bcf7d8SChris Luke *
573ba868bb7SDave Barach * The following subinterface syntax is supported. The first two are for
574ba868bb7SDave Barach * backwards compatability:
575ba868bb7SDave Barach *
576ba868bb7SDave Barach * <intf-name> <id>
577ba868bb7SDave Barach *     - a subinterface with the name <intf-name>.<id>. The subinterface
578ba868bb7SDave Barach *       is a single dot1q vlan with vlan id <id> and exact-match semantics.
579ba868bb7SDave Barach *
580ba868bb7SDave Barach * <intf-name> <min_id>-<max_id>
581ba868bb7SDave Barach *     - a set of the above subinterfaces, repeating for each id
582ba868bb7SDave Barach *       in the range <min_id> to <max_id>
583ba868bb7SDave Barach *
584ba868bb7SDave Barach * In the following, exact-match semantics (i.e. the number of vlan tags on the
585ba868bb7SDave Barach * packet must match the number of tags in the configuration) are used only if
586ba868bb7SDave Barach * the keyword exact-match is present. Non-exact match is the default.
587ba868bb7SDave Barach *
588ba868bb7SDave Barach * <intf-name> <id> dot1q <outer_id> [exact-match]
589ba868bb7SDave Barach *     - a subinterface with the name <intf-name>.<id>. The subinterface
590ba868bb7SDave Barach *       is a single dot1q vlan with vlan id <outer_id>.
591ba868bb7SDave Barach *
592ba868bb7SDave Barach * <intf-name> <id> dot1q any [exact-match]
593ba868bb7SDave Barach *     - a subinterface with the name <intf-name>.<id>. The subinterface
594ba868bb7SDave Barach *       is a single dot1q vlan with any vlan id.
595ba868bb7SDave Barach *
596ba868bb7SDave Barach * <intf-name> <id> dot1q <outer_id> inner-dot1q <inner_id> [exact-match]
597ba868bb7SDave Barach *     - a subinterface with the name <intf-name>.<id>. The subinterface
598ba868bb7SDave Barach *       is a double dot1q vlan with outer vlan id <outer_id> and inner vlan id
599ba868bb7SDave Barach *       <inner_id>.
600ba868bb7SDave Barach *
601ba868bb7SDave Barach * <intf-name> <id> dot1q <outer_id> inner-dot1q any [exact-match]
602ba868bb7SDave Barach *     - a subinterface with the name <intf-name>.<id>. The subinterface
603ba868bb7SDave Barach *       is a double dot1q vlan with outer vlan id <id> and any inner vlan id.
604ba868bb7SDave Barach *
605ba868bb7SDave Barach * <intf-name> <id> dot1q any inner-dot1q any [exact-match]
606ba868bb7SDave Barach *
607ba868bb7SDave Barach *     - a subinterface with the name <intf-name>.<id>. The subinterface
608ba868bb7SDave Barach *       is a double dot1q vlan with any outer vlan id and any inner vlan id.
609ba868bb7SDave Barach *
610ba868bb7SDave Barach * For each of the above CLI, there is a duplicate that uses the keyword
611ba868bb7SDave Barach * "dot1ad" in place of the first "dot1q". These interfaces use ethertype
612ba868bb7SDave Barach * 0x88ad in place of 0x8100 for the outer ethertype. Note that for double-
613ba868bb7SDave Barach * tagged packets the inner ethertype is always 0x8100. Also note that
614ba868bb7SDave Barach * the dot1q and dot1ad naming spaces are independent, so it is legal to
615ba868bb7SDave Barach * have both "Gig3/0/0.1 dot1q 100" and "Gig3/0/0.2 dot1ad 100". For example:
616ba868bb7SDave Barach *
617ba868bb7SDave Barach * <intf-name> <id> dot1ad <outer_id> inner-dot1q <inner_id> [exact-match]
618ba868bb7SDave Barach *     - a subinterface with the name <intf-name>.<id>. The subinterface
619ba868bb7SDave Barach *       is a double dot1ad vlan with outer vlan id <outer_id> and inner vlan
620ba868bb7SDave Barach *       id <inner_id>.
621ba868bb7SDave Barach *
622ba868bb7SDave Barach * <intf-name> <id> untagged
623ba868bb7SDave Barach *     - a subinterface with the name <intf-name>.<id>. The subinterface
624ba868bb7SDave Barach *       has no vlan tags. Only one can be specified per interface.
625ba868bb7SDave Barach *
626ba868bb7SDave Barach * <intf-name> <id> default
627ba868bb7SDave Barach *     - a subinterface with the name <intf-name>.<id>. This is associated
628ba868bb7SDave Barach *       with a packet that did not match any other configured subinterface
629ba868bb7SDave Barach *       on this interface. Only one can be specified per interface.
630ba868bb7SDave Barach */
631cb9cadadSEd Warnicke
632cb9cadadSEd Warnickestatic clib_error_t *
633ba868bb7SDave Barachparse_vlan_sub_interfaces (unformat_input_t * input,
634ba868bb7SDave Barach			   vnet_sw_interface_t * template)
635cb9cadadSEd Warnicke{
636ba868bb7SDave Barach  clib_error_t *error = 0;
637cb9cadadSEd Warnicke  u32 inner_vlan, outer_vlan;
638cb9cadadSEd Warnicke
639ba868bb7SDave Barach  if (unformat (input, "any inner-dot1q any"))
640ba868bb7SDave Barach    {
641ba868bb7SDave Barach      template->sub.eth.flags.two_tags = 1;
642ba868bb7SDave Barach      template->sub.eth.flags.outer_vlan_id_any = 1;
643ba868bb7SDave Barach      template->sub.eth.flags.inner_vlan_id_any = 1;
644ba868bb7SDave Barach    }
645ba868bb7SDave Barach  else if (unformat (input, "any"))
646ba868bb7SDave Barach    {
647ba868bb7SDave Barach      template->sub.eth.flags.one_tag = 1;
648ba868bb7SDave Barach      template->sub.eth.flags.outer_vlan_id_any = 1;
649ba868bb7SDave Barach    }
650ba868bb7SDave Barach  else if (unformat (input, "%d inner-dot1q any", &outer_vlan))
651ba868bb7SDave Barach    {
652ba868bb7SDave Barach      template->sub.eth.flags.two_tags = 1;
653ba868bb7SDave Barach      template->sub.eth.flags.inner_vlan_id_any = 1;
654ba868bb7SDave Barach      template->sub.eth.outer_vlan_id = outer_vlan;
655ba868bb7SDave Barach    }
656ba868bb7SDave Barach  else if (unformat (input, "%d inner-dot1q %d", &outer_vlan, &inner_vlan))
657ba868bb7SDave Barach    {
658ba868bb7SDave Barach      template->sub.eth.flags.two_tags = 1;
659ba868bb7SDave Barach      template->sub.eth.outer_vlan_id = outer_vlan;
660ba868bb7SDave Barach      template->sub.eth.inner_vlan_id = inner_vlan;
661ba868bb7SDave Barach    }
662ba868bb7SDave Barach  else if (unformat (input, "%d", &outer_vlan))
663ba868bb7SDave Barach    {
664ba868bb7SDave Barach      template->sub.eth.flags.one_tag = 1;
665ba868bb7SDave Barach      template->sub.eth.outer_vlan_id = outer_vlan;
666ba868bb7SDave Barach    }
667ba868bb7SDave Barach  else
668ba868bb7SDave Barach    {
669ba868bb7SDave Barach      error = clib_error_return (0, "expected dot1q config, got `%U'",
670ba868bb7SDave Barach				 format_unformat_error, input);
671ba868bb7SDave Barach      goto done;
672ba868bb7SDave Barach    }
673cb9cadadSEd Warnicke
674ba868bb7SDave Barach  if (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
675ba868bb7SDave Barach    {
676ba868bb7SDave Barach      if (unformat (input, "exact-match"))
677ba868bb7SDave Barach	{
678ba868bb7SDave Barach	  template->sub.eth.flags.exact_match = 1;
679ba868bb7SDave Barach	}
680cb9cadadSEd Warnicke    }
681cb9cadadSEd Warnicke
682ba868bb7SDave Barachdone:
683cb9cadadSEd Warnicke  return error;
684cb9cadadSEd Warnicke}
685cb9cadadSEd Warnicke
686cb9cadadSEd Warnickestatic clib_error_t *
687cb9cadadSEd Warnickecreate_sub_interfaces (vlib_main_t * vm,
688ba868bb7SDave Barach		       unformat_input_t * input, vlib_cli_command_t * cmd)
689cb9cadadSEd Warnicke{
690ba868bb7SDave Barach  vnet_main_t *vnm = vnet_get_main ();
691ba868bb7SDave Barach  clib_error_t *error = 0;
692cb9cadadSEd Warnicke  u32 hw_if_index, sw_if_index;
693ba868bb7SDave Barach  vnet_hw_interface_t *hi;
694cb9cadadSEd Warnicke  u32 id, id_min, id_max;
695cb9cadadSEd Warnicke  vnet_sw_interface_t template;
696cb9cadadSEd Warnicke
697cb9cadadSEd Warnicke  hw_if_index = ~0;
698ba868bb7SDave Barach  if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
699cb9cadadSEd Warnicke    {
700cb9cadadSEd Warnicke      error = clib_error_return (0, "unknown interface `%U'",
701cb9cadadSEd Warnicke				 format_unformat_error, input);
702cb9cadadSEd Warnicke      goto done;
703cb9cadadSEd Warnicke    }
704cb9cadadSEd Warnicke
705b7b92993SDave Barach  clib_memset (&template, 0, sizeof (template));
706cb9cadadSEd Warnicke  template.sub.eth.raw_flags = 0;
707cb9cadadSEd Warnicke
708ba868bb7SDave Barach  if (unformat (input, "%d default", &id_min))
709ba868bb7SDave Barach    {
710ba868bb7SDave Barach      id_max = id_min;
711ba868bb7SDave Barach      template.sub.eth.flags.default_sub = 1;
712ba868bb7SDave Barach    }
713ba868bb7SDave Barach  else if (unformat (input, "%d untagged", &id_min))
714ba868bb7SDave Barach    {
715ba868bb7SDave Barach      id_max = id_min;
716ba868bb7SDave Barach      template.sub.eth.flags.no_tags = 1;
717ba868bb7SDave Barach      template.sub.eth.flags.exact_match = 1;
718ba868bb7SDave Barach    }
719ba868bb7SDave Barach  else if (unformat (input, "%d dot1q", &id_min))
720ba868bb7SDave Barach    {
721ba868bb7SDave Barach      /* parse dot1q config */
722ba868bb7SDave Barach      id_max = id_min;
723ba868bb7SDave Barach      error = parse_vlan_sub_interfaces (input, &template);
724ba868bb7SDave Barach      if (error)
725ba868bb7SDave Barach	goto done;
726ba868bb7SDave Barach    }
727ba868bb7SDave Barach  else if (unformat (input, "%d dot1ad", &id_min))
728ba868bb7SDave Barach    {
729ba868bb7SDave Barach      /* parse dot1ad config */
730ba868bb7SDave Barach      id_max = id_min;
731ba868bb7SDave Barach      template.sub.eth.flags.dot1ad = 1;
732ba868bb7SDave Barach      error = parse_vlan_sub_interfaces (input, &template);
733ba868bb7SDave Barach      if (error)
734ba868bb7SDave Barach	goto done;
735ba868bb7SDave Barach    }
736ba868bb7SDave Barach  else if (unformat (input, "%d-%d", &id_min, &id_max))
737ba868bb7SDave Barach    {
738ba868bb7SDave Barach      template.sub.eth.flags.one_tag = 1;
739ba868bb7SDave Barach      template.sub.eth.flags.exact_match = 1;
740ba868bb7SDave Barach      if (id_min > id_max)
741ba868bb7SDave Barach	goto id_error;
742ba868bb7SDave Barach    }
743ba868bb7SDave Barach  else if (unformat (input, "%d", &id_min))
744ba868bb7SDave Barach    {
745ba868bb7SDave Barach      id_max = id_min;
746ba868bb7SDave Barach      template.sub.eth.flags.one_tag = 1;
747ba868bb7SDave Barach      template.sub.eth.outer_vlan_id = id_min;
748ba868bb7SDave Barach      template.sub.eth.flags.exact_match = 1;
749ba868bb7SDave Barach    }
750ba868bb7SDave Barach  else
751ba868bb7SDave Barach    {
752cb9cadadSEd Warnicke    id_error:
753cb9cadadSEd Warnicke      error = clib_error_return (0, "expected ID or ID MIN-MAX, got `%U'",
754cb9cadadSEd Warnicke				 format_unformat_error, input);
755cb9cadadSEd Warnicke      goto done;
756ba868bb7SDave Barach    }
757cb9cadadSEd Warnicke
758cb9cadadSEd Warnicke  hi = vnet_get_hw_interface (vnm, hw_if_index);
759bcebbb98SJohn Lo
760ba868bb7SDave Barach  if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
761ba868bb7SDave Barach    {
762ba868bb7SDave Barach      error =
763ba868bb7SDave Barach	clib_error_return (0,
764ba868bb7SDave Barach			   "not allowed as %v belong to a BondEthernet interface",
765ba868bb7SDave Barach			   hi->name);
766ba868bb7SDave Barach      goto done;
767ba868bb7SDave Barach    }
768bcebbb98SJohn Lo
769cb9cadadSEd Warnicke  for (id = id_min; id <= id_max; id++)
770cb9cadadSEd Warnicke    {
771ba868bb7SDave Barach      uword *p;
772ba868bb7SDave Barach      vnet_interface_main_t *im = &vnm->interface_main;
773ba868bb7SDave Barach      u64 sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
774ba868bb7SDave Barach      u64 *kp;
775cb9cadadSEd Warnicke
776cb9cadadSEd Warnicke      p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
777cb9cadadSEd Warnicke      if (p)
778ba868bb7SDave Barach	{
779ba868bb7SDave Barach	  if (CLIB_DEBUG > 0)
780ba868bb7SDave Barach	    clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
781ba868bb7SDave Barach			  hi->sw_if_index, id);
782ba868bb7SDave Barach	  continue;
783ba868bb7SDave Barach	}
784cb9cadadSEd Warnicke
785cb9cadadSEd Warnicke      template.type = VNET_SW_INTERFACE_TYPE_SUB;
786c5b13600SEyal Bari      template.flood_class = VNET_FLOOD_CLASS_NORMAL;
787cb9cadadSEd Warnicke      template.sup_sw_if_index = hi->sw_if_index;
788cb9cadadSEd Warnicke      template.sub.id = id;
789a4509cfdSEyal Bari      if (id_min < id_max)
790a4509cfdSEyal Bari	template.sub.eth.outer_vlan_id = id;
791a4509cfdSEyal Bari
792cb9cadadSEd Warnicke      error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
793ba868bb7SDave Barach      if (error)
794ba868bb7SDave Barach	goto done;
79516ad6ae7SDave Barach
796b22e1f06SJon Loeliger      kp = clib_mem_alloc (sizeof (*kp));
797b22e1f06SJon Loeliger      *kp = sup_and_sub_key;
798b22e1f06SJon Loeliger
799cb9cadadSEd Warnicke      hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
800cb9cadadSEd Warnicke      hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
801ba868bb7SDave Barach      vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name,
802ba868bb7SDave Barach		       vnet_get_main (), sw_if_index);
803cb9cadadSEd Warnicke    }
804cb9cadadSEd Warnicke
805ba868bb7SDave Barachdone:
806cb9cadadSEd Warnicke  return error;
807cb9cadadSEd Warnicke}
808cb9cadadSEd Warnicke
8096ef7bb99SKeith Burns (alagalah)/*?
810e9bac695SBilly McFall * This command is used to add VLAN IDs to interfaces, also known as subinterfaces.
811e9bac695SBilly McFall * The primary input to this command is the '<em>interface</em>' and '<em>subId</em>'
812e9bac695SBilly McFall * (subinterface Id) parameters. If no additional VLAN ID is provide, the VLAN ID is
813e9bac695SBilly McFall * assumed to be the '<em>subId</em>'. The VLAN ID and '<em>subId</em>' can be different,
814e9bac695SBilly McFall * but this is not recommended.
815e9bac695SBilly McFall *
816e9bac695SBilly McFall * This command has several variations:
817e9bac695SBilly McFall * - <b>create sub-interfaces <interface> <subId></b> - Create a subinterface to
818e9bac695SBilly McFall * process packets with a given 802.1q VLAN ID (same value as the '<em>subId</em>').
819e9bac695SBilly McFall *
820e9bac695SBilly McFall * - <b>create sub-interfaces <interface> <subId> default</b> - Adding the
821e9bac695SBilly McFall * '<em>default</em>' parameter indicates that packets with VLAN IDs that do not
822e9bac695SBilly McFall * match any other subinterfaces should be sent to this subinterface.
823e9bac695SBilly McFall *
824e9bac695SBilly McFall * - <b>create sub-interfaces <interface> <subId> untagged</b> - Adding the
825e9bac695SBilly McFall * '<em>untagged</em>' parameter indicates that packets no VLAN IDs should be sent
826e9bac695SBilly McFall * to this subinterface.
827e9bac695SBilly McFall *
828e9bac695SBilly McFall * - <b>create sub-interfaces <interface> <subId>-<subId></b> - Create a range of
829e9bac695SBilly McFall * subinterfaces to handle a range of VLAN IDs.
830e9bac695SBilly McFall *
831e9bac695SBilly McFall * - <b>create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any [exact-match]</b> -
832bdc0e6b7SPaul Vinciguerra * Use this command to specify the outer VLAN ID, to either be explicit or to make the
833e9bac695SBilly McFall * VLAN ID different from the '<em>subId</em>'.
834e9bac695SBilly McFall *
835e9bac695SBilly McFall * - <b>create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any inner-dot1q
836e9bac695SBilly McFall * <vlanId>|any [exact-match]</b> - Use this command to specify the outer VLAN ID and
837bdc0e6b7SPaul Vinciguerra * the inner VLAN ID.
838e9bac695SBilly McFall *
839bdc0e6b7SPaul Vinciguerra * When '<em>dot1q</em>' or '<em>dot1ad</em>' is explicitly entered, subinterfaces
840e9bac695SBilly McFall * can be configured as either exact-match or non-exact match. Non-exact match is the CLI
841e9bac695SBilly McFall * default. If '<em>exact-match</em>' is specified, packets must have the same number of
842e9bac695SBilly McFall * VLAN tags as the configuration. For non-exact-match, packets must at least that number
843e9bac695SBilly McFall * of tags. L3 (routed) interfaces must be configured as exact-match. L2 interfaces are
844e9bac695SBilly McFall * typically configured as non-exact-match. If '<em>dot1q</em>' or '<em>dot1ad</em>' is NOT
845e9bac695SBilly McFall * entered, then the default behavior is exact-match.
846e9bac695SBilly McFall *
847e9bac695SBilly McFall * Use the '<em>show interface</em>' command to display all subinterfaces.
8486ef7bb99SKeith Burns (alagalah) *
8496ef7bb99SKeith Burns (alagalah) * @cliexpar
850e9bac695SBilly McFall * @parblock
851e9bac695SBilly McFall * Example of how to create a VLAN subinterface 11 to process packets on 802.1q VLAN ID 11:
852e9bac695SBilly McFall * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11}
8536ef7bb99SKeith Burns (alagalah) *
854e9bac695SBilly McFall * The previous example is shorthand and is equivalent to:
855e9bac695SBilly McFall * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 11 exact-match}
8566ef7bb99SKeith Burns (alagalah) *
8576ef7bb99SKeith Burns (alagalah) *
858e9bac695SBilly McFall * Example of how to create a subinterface number that is different from the VLAN ID:
859e9bac695SBilly McFall * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100}
8606ef7bb99SKeith Burns (alagalah) *
8616ef7bb99SKeith Burns (alagalah) *
862e9bac695SBilly McFall * Examples of how to create q-in-q and q-in-any subinterfaces:
863e9bac695SBilly McFall * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100 inner-dot1q 200}
864e9bac695SBilly McFall * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 12 dot1q 100 inner-dot1q any}
8656ef7bb99SKeith Burns (alagalah) *
866e9bac695SBilly McFall * Examples of how to create dot1ad interfaces:
867e9bac695SBilly McFall * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1ad 11}
868e9bac695SBilly McFall * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 12 dot1ad 100 inner-dot1q 200}
8696ef7bb99SKeith Burns (alagalah) *
8706ef7bb99SKeith Burns (alagalah) *
871e9bac695SBilly McFall * Examples of '<em>exact-match</em>' versus non-exact match. A packet with
872e9bac695SBilly McFall * outer VLAN 100 and inner VLAN 200 would match this interface, because the default
873e9bac695SBilly McFall * is non-exact match:
874e9bac695SBilly McFall * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100}
8756ef7bb99SKeith Burns (alagalah) *
876e9bac695SBilly McFall * However, the same packet would NOT match this interface because '<em>exact-match</em>'
877e9bac695SBilly McFall * is specified and only one VLAN is configured, but packet contains two VLANs:
878e9bac695SBilly McFall * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100 exact-match}
8796ef7bb99SKeith Burns (alagalah) *
8806ef7bb99SKeith Burns (alagalah) *
881e9bac695SBilly McFall * Example of how to created a subinterface to process untagged packets:
882e9bac695SBilly McFall * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 untagged}
883e9bac695SBilly McFall *
884e9bac695SBilly McFall * Example of how to created a subinterface to process any packet with a VLAN ID that
885e9bac695SBilly McFall * does not match any other subinterface:
886e9bac695SBilly McFall * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 7 default}
887e9bac695SBilly McFall *
888e9bac695SBilly McFall * When subinterfaces are created, they are in the down state. Example of how to
889e9bac695SBilly McFall * enable a newly created subinterface:
890e9bac695SBilly McFall * @cliexcmd{set interface GigabitEthernet2/0/0.7 up}
891e9bac695SBilly McFall * @endparblock
8926ef7bb99SKeith Burns (alagalah) ?*/
893e9bac695SBilly McFall/* *INDENT-OFF* */
894cb9cadadSEd WarnickeVLIB_CLI_COMMAND (create_sub_interfaces_command, static) = {
8956ef7bb99SKeith Burns (alagalah)  .path = "create sub-interfaces",
896e9bac695SBilly McFall  .short_help = "create sub-interfaces <interface> "
897e9bac695SBilly McFall    "{<subId> [default|untagged]} | "
898e9bac695SBilly McFall    "{<subId>-<subId>} | "
899e9bac695SBilly McFall    "{<subId> dot1q|dot1ad <vlanId>|any [inner-dot1q <vlanId>|any] [exact-match]}",
900cb9cadadSEd Warnicke  .function = create_sub_interfaces,
901cb9cadadSEd Warnicke};
902ba868bb7SDave Barach/* *INDENT-ON* */
903cb9cadadSEd Warnicke
904cb9cadadSEd Warnickestatic clib_error_t *
905cb9cadadSEd Warnickeset_state (vlib_main_t * vm,
906ba868bb7SDave Barach	   unformat_input_t * input, vlib_cli_command_t * cmd)
907cb9cadadSEd Warnicke{
908ba868bb7SDave Barach  vnet_main_t *vnm = vnet_get_main ();
909ba868bb7SDave Barach  clib_error_t *error;
910cb9cadadSEd Warnicke  u32 sw_if_index, flags;
911cb9cadadSEd Warnicke
912cb9cadadSEd Warnicke  sw_if_index = ~0;
913ba868bb7SDave Barach  if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
914cb9cadadSEd Warnicke    {
915cb9cadadSEd Warnicke      error = clib_error_return (0, "unknown interface `%U'",
916cb9cadadSEd Warnicke				 format_unformat_error, input);
917cb9cadadSEd Warnicke      goto done;
918cb9cadadSEd Warnicke    }
919cb9cadadSEd Warnicke
920ba868bb7SDave Barach  if (!unformat (input, "%U", unformat_vnet_sw_interface_flags, &flags))
921cb9cadadSEd Warnicke    {
922cb9cadadSEd Warnicke      error = clib_error_return (0, "unknown flags `%U'",
923cb9cadadSEd Warnicke				 format_unformat_error, input);
924cb9cadadSEd Warnicke      goto done;
925cb9cadadSEd Warnicke    }
926cb9cadadSEd Warnicke
927cb9cadadSEd Warnicke  error = vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
928cb9cadadSEd Warnicke  if (error)
929cb9cadadSEd Warnicke    goto done;
930cb9cadadSEd Warnicke
931ba868bb7SDave Barachdone:
932cb9cadadSEd Warnicke  return error;
933cb9cadadSEd Warnicke}
934cb9cadadSEd Warnicke
9356ef7bb99SKeith Burns (alagalah)
9366ef7bb99SKeith Burns (alagalah)/*?
937e9bac695SBilly McFall * This command is used to change the admin state (up/down) of an interface.
938e9bac695SBilly McFall *
939e9bac695SBilly McFall * If an interface is down, the optional '<em>punt</em>' flag can also be set.
940e9bac695SBilly McFall * The '<em>punt</em>' flag implies the interface is disabled for forwarding
941e9bac695SBilly McFall * but punt all traffic to slow-path. Use the '<em>enable</em>' flag to clear
942e9bac695SBilly McFall * '<em>punt</em>' flag (interface is still down).
9436ef7bb99SKeith Burns (alagalah) *
9446ef7bb99SKeith Burns (alagalah) * @cliexpar
945e9bac695SBilly McFall * Example of how to configure the admin state of an interface to '<em>up</em?':
946e9bac695SBilly McFall * @cliexcmd{set interface state GigabitEthernet2/0/0 up}
947e9bac695SBilly McFall * Example of how to configure the admin state of an interface to '<em>down</em?':
948e9bac695SBilly McFall * @cliexcmd{set interface state GigabitEthernet2/0/0 down}
9496ef7bb99SKeith Burns (alagalah) ?*/
950e9bac695SBilly McFall/* *INDENT-OFF* */
951cb9cadadSEd WarnickeVLIB_CLI_COMMAND (set_state_command, static) = {
952cb9cadadSEd Warnicke  .path = "set interface state",
953e9bac695SBilly McFall  .short_help = "set interface state <interface> [up|down|punt|enable]",
954cb9cadadSEd Warnicke  .function = set_state,
955cb9cadadSEd Warnicke};
956ba868bb7SDave Barach/* *INDENT-ON* */
957cb9cadadSEd Warnicke
958cb9cadadSEd Warnickestatic clib_error_t *
959cb9cadadSEd Warnickeset_unnumbered (vlib_main_t * vm,
960ba868bb7SDave Barach		unformat_input_t * input, vlib_cli_command_t * cmd)
961cb9cadadSEd Warnicke{
962ba868bb7SDave Barach  vnet_main_t *vnm = vnet_get_main ();
9632ae2bc53SNeale Ranns  u32 unnumbered_sw_if_index = ~0;
9642ae2bc53SNeale Ranns  u32 inherit_from_sw_if_index = ~0;
9652ae2bc53SNeale Ranns  int enable = 1;
966cb9cadadSEd Warnicke
967ab3e42b0SIgor Mikhailov (imichail)  if (unformat (input, "%U use %U",
968ab3e42b0SIgor Mikhailov (imichail)		unformat_vnet_sw_interface, vnm, &unnumbered_sw_if_index,
969ab3e42b0SIgor Mikhailov (imichail)		unformat_vnet_sw_interface, vnm, &inherit_from_sw_if_index))
9702ae2bc53SNeale Ranns    enable = 1;
971ab3e42b0SIgor Mikhailov (imichail)  else if (unformat (input, "del %U",
972ab3e42b0SIgor Mikhailov (imichail)		     unformat_vnet_sw_interface, vnm,
973ab3e42b0SIgor Mikhailov (imichail)		     &unnumbered_sw_if_index))
9742ae2bc53SNeale Ranns    enable = 0;
975ab3e42b0SIgor Mikhailov (imichail)  else
976ab3e42b0SIgor Mikhailov (imichail)    return clib_error_return (0, "parse error '%U'",
977ab3e42b0SIgor Mikhailov (imichail)			      format_unformat_error, input);
978cb9cadadSEd Warnicke
9792ae2bc53SNeale Ranns  if (~0 == unnumbered_sw_if_index)
9802ae2bc53SNeale Ranns    return clib_error_return (0, "Specify the unnumbered interface");
9812ae2bc53SNeale Ranns  if (enable && ~0 == inherit_from_sw_if_index)
982bdc0e6b7SPaul Vinciguerra    return clib_error_return (0, "When enabling unnumbered specify the"
9832ae2bc53SNeale Ranns			      " IP enabled interface that it uses");
984898273fbSNeale Ranns
9852ae2bc53SNeale Ranns  vnet_sw_interface_update_unnumbered (unnumbered_sw_if_index,
9862ae2bc53SNeale Ranns				       inherit_from_sw_if_index, enable);
987898273fbSNeale Ranns
9882ae2bc53SNeale Ranns  return (NULL);
989cb9cadadSEd Warnicke}
990cb9cadadSEd Warnicke
991ba868bb7SDave Barach/* *INDENT-OFF* */
992cb9cadadSEd WarnickeVLIB_CLI_COMMAND (set_unnumbered_command, static) = {
993cb9cadadSEd Warnicke  .path = "set interface unnumbered",
994e9bac695SBilly McFall  .short_help = "set interface unnumbered [<interface> use <interface> | del <interface>]",
995cb9cadadSEd Warnicke  .function = set_unnumbered,
996cb9cadadSEd Warnicke};
997ba868bb7SDave Barach/* *INDENT-ON* */
998cb9cadadSEd Warnicke
999cb9cadadSEd Warnicke
1000cb9cadadSEd Warnicke
1001cb9cadadSEd Warnickestatic clib_error_t *
1002cb9cadadSEd Warnickeset_hw_class (vlib_main_t * vm,
1003ba868bb7SDave Barach	      unformat_input_t * input, vlib_cli_command_t * cmd)
1004cb9cadadSEd Warnicke{
1005ba868bb7SDave Barach  vnet_main_t *vnm = vnet_get_main ();
1006ba868bb7SDave Barach  vnet_interface_main_t *im = &vnm->interface_main;
1007ba868bb7SDave Barach  clib_error_t *error;
1008cb9cadadSEd Warnicke  u32 hw_if_index, hw_class_index;
1009cb9cadadSEd Warnicke
1010cb9cadadSEd Warnicke  hw_if_index = ~0;
1011ba868bb7SDave Barach  if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
1012cb9cadadSEd Warnicke    {
1013cb9cadadSEd Warnicke      error = clib_error_return (0, "unknown hardware interface `%U'",
1014cb9cadadSEd Warnicke				 format_unformat_error, input);
1015cb9cadadSEd Warnicke      goto done;
1016cb9cadadSEd Warnicke    }
1017cb9cadadSEd Warnicke
1018ba868bb7SDave Barach  if (!unformat_user (input, unformat_hash_string,
1019ba868bb7SDave Barach		      im->hw_interface_class_by_name, &hw_class_index))
1020cb9cadadSEd Warnicke    {
1021cb9cadadSEd Warnicke      error = clib_error_return (0, "unknown hardware class `%U'",
1022cb9cadadSEd Warnicke				 format_unformat_error, input);
1023cb9cadadSEd Warnicke      goto done;
1024cb9cadadSEd Warnicke    }
1025cb9cadadSEd Warnicke
1026cb9cadadSEd Warnicke  error = vnet_hw_interface_set_class (vnm, hw_if_index, hw_class_index);
1027cb9cadadSEd Warnicke  if (error)
1028cb9cadadSEd Warnicke    goto done;
1029cb9cadadSEd Warnicke
1030ba868bb7SDave Barachdone:
1031cb9cadadSEd Warnicke  return error;
1032cb9cadadSEd Warnicke}
1033cb9cadadSEd Warnicke
1034ba868bb7SDave Barach/* *INDENT-OFF* */
1035cb9cadadSEd WarnickeVLIB_CLI_COMMAND (set_hw_class_command, static) = {
1036cb9cadadSEd Warnicke  .path = "set interface hw-class",
1037cb9cadadSEd Warnicke  .short_help = "Set interface hardware class",
1038cb9cadadSEd Warnicke  .function = set_hw_class,
1039cb9cadadS