diff options
author | Mohsin Kazmi <sykazmi@cisco.com> | 2020-04-06 14:19:54 +0200 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2020-04-17 11:28:14 +0000 |
commit | 206acf84d6a04590e385f427edba1094c3bdf195 (patch) | |
tree | c724f0d2fedd494e163394a6a339c18dc72c0a37 /src/vnet/devices/tap/cli.c | |
parent | 95eb01fdc65b692065ace6d76870d8cc9f3e2c84 (diff) |
tap: add initial support for tun
Type: feature
Change-Id: I699a01ac925fe5c475a36032edb7018618bb4dd4
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vnet/devices/tap/cli.c')
-rw-r--r-- | src/vnet/devices/tap/cli.c | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/src/vnet/devices/tap/cli.c b/src/vnet/devices/tap/cli.c index 68b8cef2a21..40086a588aa 100644 --- a/src/vnet/devices/tap/cli.c +++ b/src/vnet/devices/tap/cli.c @@ -96,6 +96,8 @@ tap_create_command_fn (vlib_main_t * vm, unformat_input_t * input, args.tap_flags |= TAP_FLAG_PERSIST; else if (unformat (line_input, "attach")) args.tap_flags |= TAP_FLAG_ATTACH; + else if (unformat (line_input, "tun")) + args.tap_flags |= TAP_FLAG_TUN; else if (unformat (line_input, "hw-addr %U", unformat_ethernet_address, args.mac_addr.bytes)) args.mac_addr_set = 1; @@ -136,7 +138,7 @@ VLIB_CLI_COMMAND (tap_create_command, static) = { "[host-ip6-addr <ip6-addr>] [host-ip4-gw <ip4-addr>] " "[host-ip6-gw <ip6-addr>] [host-mac-addr <host-mac-address>] " "[host-if-name <name>] [host-mtu-size <size>] [no-gso|gso|csum-offload] " - "[persist] [attach]", + "[persist] [attach] [tun]", .function = tap_create_command_fn, }; /* *INDENT-ON* */ @@ -306,6 +308,56 @@ VLIB_CLI_COMMAND (tap_show_command, static) = { }; /* *INDENT-ON* */ +static clib_error_t * +tun_show_command_fn (vlib_main_t * vm, unformat_input_t * input, + vlib_cli_command_t * cmd) +{ + virtio_main_t *mm = &virtio_main; + virtio_if_t *vif; + vnet_main_t *vnm = vnet_get_main (); + int show_descr = 0; + clib_error_t *error = 0; + u32 hw_if_index, *hw_if_indices = 0; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat + (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index)) + vec_add1 (hw_if_indices, hw_if_index); + else if (unformat (input, "descriptors")) + show_descr = 1; + else + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, input); + goto done; + } + } + + if (vec_len (hw_if_indices) == 0) + { + /* *INDENT-OFF* */ + pool_foreach (vif, mm->interfaces, + vec_add1 (hw_if_indices, vif->hw_if_index); + ); + /* *INDENT-ON* */ + } + + virtio_show (vm, hw_if_indices, show_descr, VIRTIO_IF_TYPE_TUN); + +done: + vec_free (hw_if_indices); + return error; +} + +/* *INDENT-OFF* */ +VLIB_CLI_COMMAND (tun_show_command, static) = { + .path = "show tun", + .short_help = "show tun {<interface>] [descriptors]", + .function = tun_show_command_fn, +}; +/* *INDENT-ON* */ + clib_error_t * tap_cli_init (vlib_main_t * vm) { |