2 * Copyright (c) 2018 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #include <vnet/vnet.h>
19 test_interface_command_fn (vlib_main_t * vm,
20 unformat_input_t * input, vlib_cli_command_t * cmd)
22 vnet_hw_interface_flags_t flags;
26 flags = VNET_HW_INTERFACE_FLAG_NONE;
28 vnm = vnet_get_main ();
30 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
33 (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
35 else if (unformat (input, "up"))
36 flags = VNET_HW_INTERFACE_FLAG_LINK_UP;
37 else if (unformat (input, "down"))
43 if (~0 != sw_if_index)
45 vnet_sw_interface_t *sw;
47 sw = vnet_get_sw_interface (vnm, sw_if_index);
49 vnet_hw_interface_set_flags (vnm, sw->hw_if_index, flags);
53 return clib_error_return (0, "unknown interface `%U'",
54 format_unformat_error, input);
60 VLIB_CLI_COMMAND (test_interface_command, static) =
62 .path = "test interface link-state",
63 .short_help = "test interface link-state <interface> [up] [down]",
64 .function = test_interface_command_fn,
68 * fd.io coding-style-patch-verification: ON
71 * eval: (c-set-style "gnu")