diff options
author | 2016-05-23 12:51:54 +0100 | |
---|---|---|
committer | 2016-05-23 14:46:13 +0000 | |
commit | 78ea9c2869967693b77949ec154deef6340d01f5 (patch) | |
tree | 9c6d53c885c230a8bcf5b945e6f0a3e061095161 | |
parent | 53f09e36f97a28a42a2e3eb58032c75691de4f4c (diff) |
VPP-81: Print interface name after creating an interface with CLI
When the CLI is used to create an interface, and whend the operation
succeeds, the newly created interface name is printed-out.
The patch includes the following interfaces types:
- AF_PACKET
- Vhost User
- Netmap
- GRE
- L2TP
- MPLS-GRE
- Loopback
Change-Id: Id518c139ec63a261eae81d2ed95c4cd1f10b5157
Signed-off-by: Pierre Pfister <ppfister@cisco.com>
-rw-r--r-- | vnet/vnet/devices/af_packet/af_packet.c | 5 | ||||
-rw-r--r-- | vnet/vnet/devices/af_packet/af_packet.h | 2 | ||||
-rw-r--r-- | vnet/vnet/devices/af_packet/cli.c | 4 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/vhost_user.c | 1 | ||||
-rw-r--r-- | vnet/vnet/devices/netmap/cli.c | 4 | ||||
-rw-r--r-- | vnet/vnet/devices/netmap/netmap.c | 5 | ||||
-rw-r--r-- | vnet/vnet/devices/netmap/netmap.h | 3 | ||||
-rw-r--r-- | vnet/vnet/devices/virtio/vhost-user.c | 2 | ||||
-rw-r--r-- | vnet/vnet/ethernet/interface.c | 1 | ||||
-rw-r--r-- | vnet/vnet/gre/interface.c | 4 | ||||
-rw-r--r-- | vnet/vnet/interface_cli.c | 1 | ||||
-rw-r--r-- | vnet/vnet/l2tp/l2tp.c | 1 | ||||
-rw-r--r-- | vnet/vnet/mpls-gre/interface.c | 18 | ||||
-rw-r--r-- | vnet/vnet/unix/tapcli.c | 6 | ||||
-rw-r--r-- | vnet/vnet/vxlan-gpe/vxlan_gpe.c | 4 | ||||
-rw-r--r-- | vnet/vnet/vxlan/vxlan.c | 5 | ||||
-rw-r--r-- | vpp/api/api.c | 4 |
17 files changed, 48 insertions, 22 deletions
diff --git a/vnet/vnet/devices/af_packet/af_packet.c b/vnet/vnet/devices/af_packet/af_packet.c index 20c61295..b41eaf3b 100644 --- a/vnet/vnet/devices/af_packet/af_packet.c +++ b/vnet/vnet/devices/af_packet/af_packet.c @@ -162,7 +162,7 @@ error: } int -af_packet_create_if(vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set) +af_packet_create_if(vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set, u32 *sw_if_index) { af_packet_main_t * apm = &af_packet_main; int ret, fd = -1; @@ -258,7 +258,8 @@ af_packet_create_if(vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set) VNET_HW_INTERFACE_FLAG_LINK_UP); mhash_set_mem (&apm->if_index_by_host_if_name, host_if_name, &if_index, 0); - + if (sw_if_index) + *sw_if_index = apif->sw_if_index; return 0; error: diff --git a/vnet/vnet/devices/af_packet/af_packet.h b/vnet/vnet/devices/af_packet/af_packet.h index 21f41c70..258700b2 100644 --- a/vnet/vnet/devices/af_packet/af_packet.h +++ b/vnet/vnet/devices/af_packet/af_packet.h @@ -54,5 +54,5 @@ af_packet_main_t af_packet_main; extern vnet_device_class_t af_packet_device_class; extern vlib_node_registration_t af_packet_input_node; -int af_packet_create_if(vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set); +int af_packet_create_if(vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set, u32 *sw_if_index); int af_packet_delete_if(vlib_main_t * vm, u8 * host_if_name); diff --git a/vnet/vnet/devices/af_packet/cli.c b/vnet/vnet/devices/af_packet/cli.c index 4ac51cb0..3153efe8 100644 --- a/vnet/vnet/devices/af_packet/cli.c +++ b/vnet/vnet/devices/af_packet/cli.c @@ -40,6 +40,7 @@ af_packet_create_command_fn (vlib_main_t * vm, unformat_input_t * input, u8 * host_if_name = NULL; u8 hwaddr [6]; u8 * hw_addr_ptr = 0; + u32 sw_if_index; int r; /* Get a line of input. */ @@ -60,7 +61,7 @@ af_packet_create_command_fn (vlib_main_t * vm, unformat_input_t * input, if (host_if_name == NULL) return clib_error_return (0, "missing host interface name"); - r = af_packet_create_if(vm, host_if_name, hw_addr_ptr); + r = af_packet_create_if(vm, host_if_name, hw_addr_ptr, &sw_if_index); if (r == VNET_API_ERROR_SYSCALL_ERROR_1) return clib_error_return(0, "%s (errno %d)", strerror (errno), errno); @@ -71,6 +72,7 @@ af_packet_create_command_fn (vlib_main_t * vm, unformat_input_t * input, if (r == VNET_API_ERROR_SUBIF_ALREADY_EXISTS) return clib_error_return(0, "Interface elready exists"); + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); return 0; } diff --git a/vnet/vnet/devices/dpdk/vhost_user.c b/vnet/vnet/devices/dpdk/vhost_user.c index 9bf76741..a461d390 100644 --- a/vnet/vnet/devices/dpdk/vhost_user.c +++ b/vnet/vnet/devices/dpdk/vhost_user.c @@ -1702,6 +1702,7 @@ dpdk_vhost_user_connect_command_fn (vlib_main_t * vm, renumber, custom_dev_instance, hw); vec_free(sock_filename); + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); return 0; } diff --git a/vnet/vnet/devices/netmap/cli.c b/vnet/vnet/devices/netmap/cli.c index 584d6800..5bf80e7f 100644 --- a/vnet/vnet/devices/netmap/cli.c +++ b/vnet/vnet/devices/netmap/cli.c @@ -36,6 +36,7 @@ netmap_create_command_fn (vlib_main_t * vm, unformat_input_t * input, int r; u8 is_pipe = 0; u8 is_master = 0; + u32 sw_if_index = ~0; /* Get a line of input. */ if (! unformat_user (input, unformat_line_input, line_input)) @@ -61,7 +62,7 @@ netmap_create_command_fn (vlib_main_t * vm, unformat_input_t * input, if (host_if_name == NULL) return clib_error_return (0, "missing host interface name"); - r = netmap_create_if(vm, host_if_name, hw_addr_ptr, is_pipe, is_master); + r = netmap_create_if(vm, host_if_name, hw_addr_ptr, is_pipe, is_master, &sw_if_index); if (r == VNET_API_ERROR_SYSCALL_ERROR_1) return clib_error_return(0, "%s (errno %d)", strerror (errno), errno); @@ -72,6 +73,7 @@ netmap_create_command_fn (vlib_main_t * vm, unformat_input_t * input, if (r == VNET_API_ERROR_SUBIF_ALREADY_EXISTS) return clib_error_return(0, "Interface already exists"); + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); return 0; } diff --git a/vnet/vnet/devices/netmap/netmap.c b/vnet/vnet/devices/netmap/netmap.c index 2f3233a2..df3b2be4 100644 --- a/vnet/vnet/devices/netmap/netmap.c +++ b/vnet/vnet/devices/netmap/netmap.c @@ -80,7 +80,7 @@ close_netmap_if(netmap_main_t * nm, netmap_if_t * nif) int netmap_create_if(vlib_main_t * vm, u8 * if_name, u8 * hw_addr_set, - u8 is_pipe, u8 is_master) + u8 is_pipe, u8 is_master, u32 *sw_if_index) { netmap_main_t * nm = &netmap_main; int ret = 0; @@ -194,6 +194,9 @@ netmap_create_if(vlib_main_t * vm, u8 * if_name, u8 * hw_addr_set, mhash_set_mem (&nm->if_index_by_host_if_name, if_name, &nif->if_index, 0); + if (sw_if_index) + *sw_if_index = nif->sw_if_index; + return 0; error: diff --git a/vnet/vnet/devices/netmap/netmap.h b/vnet/vnet/devices/netmap/netmap.h index c5b3dfbc..6f7791c3 100644 --- a/vnet/vnet/devices/netmap/netmap.h +++ b/vnet/vnet/devices/netmap/netmap.h @@ -90,7 +90,8 @@ netmap_main_t netmap_main; extern vnet_device_class_t netmap_device_class; extern vlib_node_registration_t netmap_input_node; -int netmap_create_if(vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set, u8 is_pipe, u8 is_master); +int netmap_create_if(vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set, + u8 is_pipe, u8 is_master, u32 *sw_if_index); int netmap_delete_if(vlib_main_t * vm, u8 * host_if_name); diff --git a/vnet/vnet/devices/virtio/vhost-user.c b/vnet/vnet/devices/virtio/vhost-user.c index ef4993f9..4ed45e38 100644 --- a/vnet/vnet/devices/virtio/vhost-user.c +++ b/vnet/vnet/devices/virtio/vhost-user.c @@ -1791,7 +1791,7 @@ vhost_user_connect_command_fn (vlib_main_t * vm, renumber, custom_dev_instance, hw); vec_free(sock_filename); - + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); return 0; } diff --git a/vnet/vnet/ethernet/interface.c b/vnet/vnet/ethernet/interface.c index 833ee300..fd640308 100644 --- a/vnet/vnet/ethernet/interface.c +++ b/vnet/vnet/ethernet/interface.c @@ -431,6 +431,7 @@ create_simulated_ethernet_interfaces (vlib_main_t * vm, if (rv) return clib_error_return (0, "vnet_create_loopback_interface failed"); + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); return 0; } diff --git a/vnet/vnet/gre/interface.c b/vnet/vnet/gre/interface.c index 1e442bc9..ae59b246 100644 --- a/vnet/vnet/gre/interface.c +++ b/vnet/vnet/gre/interface.c @@ -159,6 +159,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm, int rv; u32 num_m_args = 0; u8 is_add = 1; + u32 sw_if_index; /* Get a line of input. */ if (! unformat_user (input, unformat_line_input, line_input)) @@ -191,11 +192,12 @@ create_gre_tunnel_command_fn (vlib_main_t * vm, clib_memcpy(&a->src, &src, sizeof(src)); clib_memcpy(&a->dst, &dst, sizeof(dst)); - rv = vnet_gre_add_del_tunnel (a, 0); + rv = vnet_gre_add_del_tunnel (a, &sw_if_index); switch(rv) { case 0: + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); break; case VNET_API_ERROR_INVALID_VALUE: return clib_error_return (0, "GRE tunnel already exists..."); diff --git a/vnet/vnet/interface_cli.c b/vnet/vnet/interface_cli.c index 13a7d8cf..d0d75154 100644 --- a/vnet/vnet/interface_cli.c +++ b/vnet/vnet/interface_cli.c @@ -608,6 +608,7 @@ create_sub_interfaces (vlib_main_t * vm, if (error) goto done; hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index); hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index); + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); } if (error) diff --git a/vnet/vnet/l2tp/l2tp.c b/vnet/vnet/l2tp/l2tp.c index d359a50e..7dfbe156 100644 --- a/vnet/vnet/l2tp/l2tp.c +++ b/vnet/vnet/l2tp/l2tp.c @@ -466,6 +466,7 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm, switch(rv) { case 0: + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); break; case VNET_API_ERROR_INVALID_VALUE: return clib_error_return (0, "session already exists..."); diff --git a/vnet/vnet/mpls-gre/interface.c b/vnet/vnet/mpls-gre/interface.c index 75cd022a..5b78072f 100644 --- a/vnet/vnet/mpls-gre/interface.c +++ b/vnet/vnet/mpls-gre/interface.c @@ -1083,6 +1083,8 @@ create_mpls_gre_tunnel_command_fn (vlib_main_t * vm, switch (rv) { case 0: + if (!is_del) + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), tunnel_intfc_sw_if_index); break; case VNET_API_ERROR_NO_SUCH_INNER_FIB: @@ -1521,6 +1523,7 @@ create_mpls_ethernet_tunnel_command_fn (vlib_main_t * vm, u8 is_del = 0; u8 l2_only = 0; u32 tx_sw_if_index; + u32 sw_if_index = ~0; /* Get a line of input. */ if (! unformat_user (input, unformat_line_input, line_input)) @@ -1560,11 +1563,15 @@ create_mpls_ethernet_tunnel_command_fn (vlib_main_t * vm, rv = vnet_mpls_ethernet_add_del_tunnel (dst, &intfc, mask_width, inner_fib_id, tx_sw_if_index, - 0 /* tunnel sw_if_index */, + &sw_if_index, l2_only, !is_del); switch (rv) { + case 0: + if (!is_del) + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); + break; case VNET_API_ERROR_NO_SUCH_FIB: return clib_error_return (0, "rx fib ID %d doesn't exist\n", inner_fib_id); @@ -1582,6 +1589,7 @@ create_mpls_ethernet_tunnel_command_fn (vlib_main_t * vm, break; default: + return clib_error_return (0, "vnet_mpls_ethernet_add_del_tunnel returned %d", rv); break; } return 0; @@ -1902,6 +1910,10 @@ create_mpls_ethernet_policy_tunnel_command_fn (vlib_main_t * vm, l2_only, !is_del); switch (rv) { + case 0: + if (!is_del) + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), new_tunnel_index); + break; case VNET_API_ERROR_NO_SUCH_FIB: return clib_error_return (0, "rx fib ID %d doesn't exist\n", inner_fib_id); @@ -1919,12 +1931,10 @@ create_mpls_ethernet_policy_tunnel_command_fn (vlib_main_t * vm, break; default: + return clib_error_return (0, "vnet_mpls_ethernet_add_del_policy_tunnel returned %d", rv); break; } - if (!is_del) - vlib_cli_output (vm, "tunnel index %d", new_tunnel_index); - return 0; } diff --git a/vnet/vnet/unix/tapcli.c b/vnet/vnet/unix/tapcli.c index a2999362..1d5beba1 100644 --- a/vnet/vnet/unix/tapcli.c +++ b/vnet/vnet/unix/tapcli.c @@ -1090,12 +1090,8 @@ tap_connect_command_fn (vlib_main_t * vm, return 0; } - vlib_cli_output (vm, "Created %U for Linux tap '%s'", - format_vnet_sw_if_index_name, tm->vnet_main, - sw_if_index, intfc_name); - + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); return 0; - } VLIB_CLI_COMMAND (tap_connect_command, static) = { diff --git a/vnet/vnet/vxlan-gpe/vxlan_gpe.c b/vnet/vnet/vxlan-gpe/vxlan_gpe.c index bee6e7c9..76cba053 100644 --- a/vnet/vnet/vxlan-gpe/vxlan_gpe.c +++ b/vnet/vnet/vxlan-gpe/vxlan_gpe.c @@ -326,6 +326,7 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm, int rv; u32 tmp; vnet_vxlan_gpe_add_del_tunnel_args_t _a, * a = &_a; + u32 sw_if_index; /* Get a line of input. */ if (! unformat_user (input, unformat_line_input, line_input)) @@ -389,11 +390,12 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm, foreach_gpe_copy_field; #undef _ - rv = vnet_vxlan_gpe_add_del_tunnel (a, 0 /* hw_if_indexp */); + rv = vnet_vxlan_gpe_add_del_tunnel (a, &sw_if_index); switch(rv) { case 0: + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); break; case VNET_API_ERROR_INVALID_DECAP_NEXT: return clib_error_return (0, "invalid decap-next..."); diff --git a/vnet/vnet/vxlan/vxlan.c b/vnet/vnet/vxlan/vxlan.c index 89e56e78..9e0d0a5e 100644 --- a/vnet/vnet/vxlan/vxlan.c +++ b/vnet/vnet/vxlan/vxlan.c @@ -419,6 +419,7 @@ vxlan_add_del_tunnel_command_fn (vlib_main_t * vm, u32 tmp; int rv; vnet_vxlan_add_del_tunnel_args_t _a, * a = &_a; + u32 sw_if_index; /* Get a line of input. */ if (! unformat_user (input, unformat_line_input, line_input)) @@ -504,11 +505,13 @@ vxlan_add_del_tunnel_command_fn (vlib_main_t * vm, else foreach_copy_ipv6 #undef _ - rv = vnet_vxlan_add_del_tunnel (a, 0 /* hw_if_indexp */); + rv = vnet_vxlan_add_del_tunnel (a, &sw_if_index); switch(rv) { case 0: + if (is_add) + vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); break; case VNET_API_ERROR_INVALID_DECAP_NEXT: return clib_error_return (0, "invalid decap-next..."); diff --git a/vpp/api/api.c b/vpp/api/api.c index 3b56d1c3..3bf2ed47 100644 --- a/vpp/api/api.c +++ b/vpp/api/api.c @@ -5930,7 +5930,7 @@ vl_api_af_packet_create_t_handler vec_add1 (host_if_name, 0); rv = af_packet_create_if(vm, host_if_name, - mp->use_random_hw_addr ? 0 : mp->hw_addr); + mp->use_random_hw_addr ? 0 : mp->hw_addr, 0); vec_free(host_if_name); @@ -6077,7 +6077,7 @@ vl_api_netmap_create_t_handler vec_add1 (if_name, 0); rv = netmap_create_if(vm, if_name, mp->use_random_hw_addr ? 0 : mp->hw_addr, - mp->is_pipe, mp->is_master); + mp->is_pipe, mp->is_master, 0); vec_free(if_name); |