19 #include <sys/ioctl.h> 28 #include <linux/virtio_net.h> 29 #include <linux/vhost.h> 59 else if (
unformat (line_input,
"host-mac-addr %U",
65 else if (
unformat (line_input,
"host-ip4-addr %U/%d",
69 else if (
unformat (line_input,
"host-ip4-gw %U",
72 else if (
unformat (line_input,
"host-ip6-addr %U/%d",
76 else if (
unformat (line_input,
"host-ip6-gw %U",
79 else if (
unformat (line_input,
"num-rx-queues %d", &tmp))
81 else if (
unformat (line_input,
"rx-ring-size %d", &tmp))
83 else if (
unformat (line_input,
"tx-ring-size %d", &tmp))
89 else if (
unformat (line_input,
"no-gso"))
91 else if (
unformat (line_input,
"gso"))
93 else if (
unformat (line_input,
"gro-coalesce"))
95 else if (
unformat (line_input,
"csum-offload"))
97 else if (
unformat (line_input,
"persist"))
99 else if (
unformat (line_input,
"attach"))
101 else if (
unformat (line_input,
"tun"))
103 else if (
unformat (line_input,
"hw-addr %U",
136 .path =
"create tap",
137 .short_help =
"create tap {id <if-id>} [hw-addr <mac-address>] " 138 "[num-rx-queues <n>] [rx-ring-size <size>] [tx-ring-size <size>] " 139 "[host-ns <netns>] [host-bridge <bridge-name>] " 140 "[host-ip4-addr <ip4addr/mask>] [host-ip6-addr <ip6-addr>] " 141 "[host-ip4-gw <ip4-addr>] [host-ip6-gw <ip6-addr>] " 142 "[host-mac-addr <host-mac-address>] [host-if-name <name>] " 143 "[host-mtu-size <size>] [no-gso|gso|csum-offload|gro-coalesce] " 144 "[persist] [attach] [tun]",
164 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
175 if (sw_if_index == ~0)
177 "please specify interface name or sw_if_index");
180 if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
191 .path =
"delete tap",
192 .short_help =
"delete tap {<interface> | sw_if_index <sw_idx>}",
204 int gso_enable = 0, gso_disable = 0;
205 int csum_offload_enable = 0, csum_offload_disable = 0;
214 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
219 else if (
unformat (line_input,
"gso-enable"))
221 else if (
unformat (line_input,
"gso-disable"))
223 else if (
unformat (line_input,
"csum-offload-enable"))
224 csum_offload_enable = 1;
225 else if (
unformat (line_input,
"csum-offload-disable"))
226 csum_offload_disable = 1;
233 if (sw_if_index == ~0)
235 "please specify interface name or sw_if_index");
239 else if (csum_offload_enable)
241 else if (gso_disable)
243 else if (csum_offload_disable)
246 if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
257 .path =
"set tap offload",
258 .short_help =
"set tap offload {<interface> | sw_if_index <sw_idx>}" 259 " <gso-enable | gso-disable | csum-offload-enable | csum-offload-disable>",
273 u32 hw_if_index, *hw_if_indices = 0;
279 vec_add1 (hw_if_indices, hw_if_index);
280 else if (
unformat (input,
"descriptors"))
290 if (
vec_len (hw_if_indices) == 0)
299 virtio_show (vm, hw_if_indices, show_descr, VIRTIO_IF_TYPE_TAP);
309 .short_help =
"show tap {<interface>] [descriptors]",
323 u32 hw_if_index, *hw_if_indices = 0;
329 vec_add1 (hw_if_indices, hw_if_index);
330 else if (
unformat (input,
"descriptors"))
340 if (
vec_len (hw_if_indices) == 0)
349 virtio_show (vm, hw_if_indices, show_descr, VIRTIO_IF_TYPE_TUN);
359 .short_help =
"show tun {<interface>] [descriptors]",
unformat_function_t unformat_vnet_hw_interface
static clib_error_t * tun_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
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)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
unformat_function_t unformat_vnet_sw_interface
int tap_csum_offload_enable_disable(vlib_main_t *vm, u32 sw_if_index, int enable_disable)
format_function_t format_vnet_sw_if_index_name
static clib_error_t * tap_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * tap_offload_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...)
static clib_error_t * tap_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * tap_cli_init(vlib_main_t *vm)
static clib_error_t * tap_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
ip4_address_t host_ip4_gw
ip6_address_t host_ip6_addr
#define vec_free(V)
Free vector's memory (no header).
#define VLIB_CLI_COMMAND(x,...)
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
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)
mac_address_t host_mac_addr