2 * p2p_ethernet.c: p2p ethernet
4 * Copyright (c) 2012 Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include <vppinfra/bihash_16_8.h>
19 #include <vnet/vnet.h>
20 #include <vnet/ethernet/p2p_ethernet.h>
23 p2p_ethernet_add_del (vlib_main_t * vm, u32 parent_if_index,
24 u8 * client_mac, int is_add)
30 vnet_p2p_ethernet_add_del (vlib_main_t * vm, unformat_input_t * input,
31 vlib_cli_command_t * cmd)
33 vnet_main_t *vnm = vnet_get_main ();
40 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
43 (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
45 else if (unformat (input, "%U", unformat_ethernet_address, &client_mac))
47 else if (unformat (input, "del"))
53 if (hw_if_index == ~0)
54 return clib_error_return (0, "Please specify parent interface ...");
56 return clib_error_return (0, "Please specify client MAC address ...");
59 rv = p2p_ethernet_add_del (vm, hw_if_index, client_mac, is_add);
62 case VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED:
63 return clib_error_return (0,
64 "not allowed as parent interface belongs to a BondEthernet interface");
66 return clib_error_return (0,
67 "p2p ethernet for given parent interface and client mac already exists");
69 return clib_error_return (0,
70 "couldn't create p2p ethernet subinterface");
72 return clib_error_return (0,
73 "p2p ethernet for given parent interface and client mac doesn't exist");
81 VLIB_CLI_COMMAND (p2p_ethernet_add_del_command, static) =
83 .path = "p2p_ethernet ",
84 .function = vnet_p2p_ethernet_add_del,
85 .short_help = "p2p_ethernet <intfc> <mac-address> [del]",};
89 p2p_ethernet_init (vlib_main_t * vm)
94 VLIB_INIT_FUNCTION (p2p_ethernet_init);
97 * fd.io coding-style-patch-verification: ON
100 * eval: (c-set-style "gnu")