19 #include <sys/ioctl.h> 28 #include <linux/virtio_net.h> 29 #include <linux/vhost.h> 58 else if (
unformat (line_input,
"host-mac-addr %U",
63 else if (
unformat (line_input,
"host-ip4-addr %U/%d",
67 else if (
unformat (line_input,
"host-ip4-gw %U",
70 else if (
unformat (line_input,
"host-ip6-addr %U/%d",
74 else if (
unformat (line_input,
"host-ip6-gw %U",
77 else if (
unformat (line_input,
"rx-ring-size %d", &tmp))
79 else if (
unformat (line_input,
"tx-ring-size %d", &tmp))
85 else if (
unformat (line_input,
"no-gso"))
87 else if (
unformat (line_input,
"gso"))
89 else if (
unformat (line_input,
"hw-addr %U",
122 .path =
"create tap",
123 .short_help =
"create tap {id <if-id>} [hw-addr <mac-address>] " 124 "[rx-ring-size <size>] [tx-ring-size <size>] [host-ns <netns>] " 125 "[host-bridge <bridge-name>] [host-ip4-addr <ip4addr/mask>] " 126 "[host-ip6-addr <ip6-addr>] [host-ip4-gw <ip4-addr>] " 127 "[host-ip6-gw <ip6-addr>] [host-mac-addr <host-mac-address>] " 128 "[host-if-name <name>] [host-mtu-size <size>] [no-gso|gso]",
148 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
159 if (sw_if_index == ~0)
161 "please specify interface name or sw_if_index");
164 if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
175 .path =
"delete tap",
176 .short_help =
"delete tap {<interface> | sw_if_index <sw_idx>}",
197 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
202 else if (
unformat (line_input,
"enable"))
204 else if (
unformat (line_input,
"disable"))
212 if (sw_if_index == ~0)
214 "please specify interface name or sw_if_index");
217 if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
228 .path =
"set tap gso",
229 .short_help =
"set tap gso {<interface> | sw_if_index <sw_idx>} <enable|disable>",
243 u32 hw_if_index, *hw_if_indices = 0;
249 vec_add1 (hw_if_indices, hw_if_index);
250 else if (
unformat (input,
"descriptors"))
260 if (
vec_len (hw_if_indices) == 0)
279 .short_help =
"show tap {<interface>] [descriptors]",
unformat_function_t unformat_vnet_hw_interface
void virtio_show(vlib_main_t *vm, u32 *hw_if_indices, u8 show_descr, u32 type)
ip4_address_t host_ip4_addr
vnet_main_t * vnet_get_main(void)
int tap_gso_enable_disable(vlib_main_t *vm, u32 sw_if_index, int enable_disable)
static clib_error_t * tap_gso_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * tap_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
unformat_function_t unformat_vnet_sw_interface
format_function_t format_vnet_sw_if_index_name
clib_error_t * tap_cli_init(vlib_main_t *vm)
static clib_error_t * tap_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
int tap_delete_if(vlib_main_t *vm, u32 sw_if_index)
#define clib_error_return(e, args...)
ip4_address_t host_ip4_gw
ip6_address_t host_ip6_addr
#define vec_free(V)
Free vector's memory (no header).
static clib_error_t * tap_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_CLI_COMMAND(x,...)
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
ip6_address_t host_ip6_gw
virtio_main_t virtio_main
void tap_create_if(vlib_main_t *vm, tap_create_if_args_t *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)