From 7cd468a3d7dee7d6c92f69a0bb7061ae208ec727 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Mon, 19 Dec 2016 23:05:39 +0100 Subject: Reorganize source tree to use single autotools instance Change-Id: I7b51f88292e057c6443b12224486f2d0c9f8ae23 Signed-off-by: Damjan Marion --- src/vnet/unix/tuntap.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/vnet/unix/tuntap.h (limited to 'src/vnet/unix/tuntap.h') diff --git a/src/vnet/unix/tuntap.h b/src/vnet/unix/tuntap.h new file mode 100644 index 00000000..d7f96cae --- /dev/null +++ b/src/vnet/unix/tuntap.h @@ -0,0 +1,36 @@ +/* + *------------------------------------------------------------------ + * tuntap.h - kernel stack (reverse) punt/inject path + * + * Copyright (c) 2009 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ +/** + * @file + * @brief Call from VLIB_INIT_FUNCTION to set the Linux kernel inject node name. + */ +void register_tuntap_inject_node_name (char *name); + +int vnet_tap_connect (vlib_main_t * vm, u8 * intfc_name, + u8 *hwaddr_arg, u32 * sw_if_indexp); +int vnet_tap_connect_renumber (vlib_main_t * vm, u8 * intfc_name, + u8 *hwaddr_arg, u32 * sw_if_indexp, + u8 renumber, u32 custom_dev_instance); + +int vnet_tap_delete(vlib_main_t *vm, u32 sw_if_index); + +int vnet_tap_modify (vlib_main_t * vm, u32 orig_sw_if_index, + u8 * intfc_name, u8 *hwaddr_arg, + u32 * sw_if_indexp, + u8 renumber, u32 custom_dev_instance); -- cgit 1.2.3-korg From 2feaffcb4af8e311b56328015bcfd82f5b15626c Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Sat, 14 Jan 2017 10:30:50 -0500 Subject: Provision linux stack ip4 and ip6 addresses for tap interfaces To simplify system configuration. Converted existing code to use an argument structure, instead of [one or two too many] discrete parameters. Change-Id: I3eddfa74eeed918c1b04a6285fba494651594332 Signed-off-by: Dave Barach --- src/vat/api_format.c | 25 +++++ src/vnet/api_errno.h | 2 +- src/vnet/unix/tap.api | 6 ++ src/vnet/unix/tap_api.c | 43 ++++++-- src/vnet/unix/tapcli.c | 258 +++++++++++++++++++++++++++++++++------------- src/vnet/unix/tuntap.h | 51 +++++++-- src/vpp/api/custom_dump.c | 7 +- 7 files changed, 301 insertions(+), 91 deletions(-) (limited to 'src/vnet/unix/tuntap.h') diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 176fe836..1babaf40 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -5790,6 +5790,12 @@ api_tap_connect (vat_main_t * vam) u8 name_set = 0; u8 *tap_name; u8 *tag = 0; + ip4_address_t ip4_address; + u32 ip4_mask_width; + int ip4_address_set = 0; + ip6_address_t ip6_address; + u32 ip6_mask_width; + int ip6_address_set = 0; memset (mac_address, 0, sizeof (mac_address)); @@ -5806,6 +5812,12 @@ api_tap_connect (vat_main_t * vam) name_set = 1; else if (unformat (i, "tag %s", &tag)) ; + else if (unformat (i, "address %U/%d", + unformat_ip4_address, &ip4_address, &ip4_mask_width)) + ip4_address_set = 1; + else if (unformat (i, "address %U/%d", + unformat_ip6_address, &ip6_address, &ip6_mask_width)) + ip6_address_set = 1; else break; } @@ -5837,6 +5849,19 @@ api_tap_connect (vat_main_t * vam) if (tag) clib_memcpy (mp->tag, tag, vec_len (tag)); + if (ip4_address_set) + { + mp->ip4_address_set = 1; + clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address)); + mp->ip4_mask_width = ip4_mask_width; + } + if (ip6_address_set) + { + mp->ip6_address_set = 1; + clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address)); + mp->ip6_mask_width = ip6_mask_width; + } + vec_free (tap_name); vec_free (tag); diff --git a/src/vnet/api_errno.h b/src/vnet/api_errno.h index 65e3e591..7166da67 100644 --- a/src/vnet/api_errno.h +++ b/src/vnet/api_errno.h @@ -35,7 +35,7 @@ _(SYSCALL_ERROR_6, -16, "System call error #6") \ _(SYSCALL_ERROR_7, -17, "System call error #7") \ _(SYSCALL_ERROR_8, -18, "System call error #8") \ _(SYSCALL_ERROR_9, -19, "System call error #9") \ -_(SYSCALL_ERROR_10, -20, "System call error #9") \ +_(SYSCALL_ERROR_10, -20, "System call error #10") \ _(FEATURE_DISABLED, -30, "Feature disabled by configuration") \ _(INVALID_REGISTRATION, -31, "Invalid registration") \ _(NEXT_HOP_NOT_IN_FIB, -50, "Next hop not in FIB") \ diff --git a/src/vnet/unix/tap.api b/src/vnet/unix/tap.api index 9b16eadb..1fd0bb09 100644 --- a/src/vnet/unix/tap.api +++ b/src/vnet/unix/tap.api @@ -35,6 +35,12 @@ define tap_connect u8 mac_address[6]; u8 renumber; u32 custom_dev_instance; + u8 ip4_address_set; + u8 ip4_address[4]; + u8 ip4_mask_width; + u8 ip6_address_set; + u8 ip6_address[16]; + u8 ip6_mask_width; u8 tag[64]; }; diff --git a/src/vnet/unix/tap_api.c b/src/vnet/unix/tap_api.c index 99b79ba2..9b8d52a6 100644 --- a/src/vnet/unix/tap_api.c +++ b/src/vnet/unix/tap_api.c @@ -86,11 +86,30 @@ vl_api_tap_connect_t_handler (vl_api_tap_connect_t * mp) unix_shared_memory_queue_t *q; u32 sw_if_index = (u32) ~ 0; u8 *tag; + vnet_tap_connect_args_t _a, *ap = &_a; - rv = vnet_tap_connect_renumber (vm, mp->tap_name, - mp->use_random_mac ? 0 : mp->mac_address, - &sw_if_index, mp->renumber, - ntohl (mp->custom_dev_instance)); + memset (ap, 0, sizeof (*ap)); + + ap->intfc_name = mp->tap_name; + if (!mp->use_random_mac) + ap->hwaddr_arg = mp->mac_address; + ap->renumber = mp->renumber; + ap->sw_if_indexp = &sw_if_index; + ap->custom_dev_instance = ntohl (mp->custom_dev_instance); + if (mp->ip4_address_set) + { + ap->ip4_address = (ip4_address_t *) mp->ip4_address; + ap->ip4_mask_width = mp->ip4_mask_width; + ap->ip4_address_set = 1; + } + if (mp->ip6_address_set) + { + ap->ip6_address = (ip6_address_t *) mp->ip6_address; + ap->ip6_mask_width = mp->ip6_mask_width; + ap->ip6_address_set = 1; + } + + rv = vnet_tap_connect_renumber (vm, ap); /* Add tag if supplied */ if (rv == 0 && mp->tag[0]) @@ -121,11 +140,19 @@ vl_api_tap_modify_t_handler (vl_api_tap_modify_t * mp) unix_shared_memory_queue_t *q; u32 sw_if_index = (u32) ~ 0; vlib_main_t *vm = vlib_get_main (); + vnet_tap_connect_args_t _a, *ap = &_a; + + memset (ap, 0, sizeof (*ap)); + + ap->orig_sw_if_index = ntohl (mp->sw_if_index); + ap->intfc_name = mp->tap_name; + if (!mp->use_random_mac) + ap->hwaddr_arg = mp->mac_address; + ap->sw_if_indexp = &sw_if_index; + ap->renumber = mp->renumber; + ap->custom_dev_instance = ntohl (mp->custom_dev_instance); - rv = vnet_tap_modify (vm, ntohl (mp->sw_if_index), mp->tap_name, - mp->use_random_mac ? 0 : mp->mac_address, - &sw_if_index, mp->renumber, - ntohl (mp->custom_dev_instance)); + rv = vnet_tap_modify (vm, ap); q = vl_api_client_index_to_input_queue (mp->client_index); if (!q) diff --git a/src/vnet/unix/tapcli.c b/src/vnet/unix/tapcli.c index 9862a2bd..2d3082cb 100644 --- a/src/vnet/unix/tapcli.c +++ b/src/vnet/unix/tapcli.c @@ -41,6 +41,7 @@ #include #include +#include #include static vnet_device_class_t tapcli_dev_class; @@ -780,19 +781,23 @@ static tapcli_interface_t *tapcli_get_new_tapif() return ti; } +typedef struct +{ + ip6_address_t addr; + u32 mask_width; + unsigned int ifindex; +} ip6_ifreq_t; + /** * @brief Connect a TAP interface * * @param vm - vlib_main_t - * @param intfc_name - u8 - * @param hwaddr_arg - u8 - * @param sw_if_indexp - u32 + * @param ap - vnet_tap_connect_args_t * * @return rc - int * */ -int vnet_tap_connect (vlib_main_t * vm, u8 * intfc_name, u8 *hwaddr_arg, - u32 * sw_if_indexp) +int vnet_tap_connect (vlib_main_t * vm, vnet_tap_connect_args_t *ap) { tapcli_main_t * tm = &tapcli_main; tapcli_interface_t * ti = NULL; @@ -815,7 +820,7 @@ int vnet_tap_connect (vlib_main_t * vm, u8 * intfc_name, u8 *hwaddr_arg, return VNET_API_ERROR_SYSCALL_ERROR_1; memset (&ifr, 0, sizeof (ifr)); - strncpy(ifr.ifr_name, (char *) intfc_name, sizeof (ifr.ifr_name)-1); + strncpy(ifr.ifr_name, (char *) ap->intfc_name, sizeof (ifr.ifr_name)-1); ifr.ifr_flags = flags; if (ioctl (dev_net_tun_fd, TUNSETIFF, (void *)&ifr) < 0) { @@ -837,7 +842,7 @@ int vnet_tap_connect (vlib_main_t * vm, u8 * intfc_name, u8 *hwaddr_arg, struct sockaddr_ll sll; memset (&ifr, 0, sizeof(ifr)); - strncpy (ifr.ifr_name, (char *) intfc_name, sizeof (ifr.ifr_name)-1); + strncpy (ifr.ifr_name, (char *) ap->intfc_name, sizeof (ifr.ifr_name)-1); if (ioctl (dev_tap_fd, SIOCGIFINDEX, &ifr) < 0 ) { rv = VNET_API_ERROR_SYSCALL_ERROR_4; @@ -888,11 +893,84 @@ int vnet_tap_connect (vlib_main_t * vm, u8 * intfc_name, u8 *hwaddr_arg, goto error; } + if (ap->ip4_address_set) + { + struct sockaddr_in sin; + /* ip4: mask defaults to /24 */ + u32 mask = clib_host_to_net_u32 (0xFFFFFF00); + + sin.sin_family = AF_INET; + sin.sin_port = 0; + sin.sin_addr.s_addr = ap->ip4_address->as_u32; + memcpy (&ifr.ifr_ifru.ifru_addr, &sin, sizeof (sin)); + + if (ioctl (dev_tap_fd, SIOCSIFADDR, &ifr) < 0) + { + rv = VNET_API_ERROR_SYSCALL_ERROR_10; + goto error; + } + + if (ap->ip4_mask_width > 0 && ap->ip4_mask_width < 33) + { + mask = ~0; + mask <<= (32 - ap->ip4_mask_width); + } + + mask = clib_host_to_net_u32(mask); + sin.sin_family = AF_INET; + sin.sin_port = 0; + sin.sin_addr.s_addr = mask; + memcpy (&ifr.ifr_ifru.ifru_addr, &sin, sizeof (sin)); + + if (ioctl (dev_tap_fd, SIOCSIFNETMASK, &ifr) < 0) + { + rv = VNET_API_ERROR_SYSCALL_ERROR_10; + goto error; + } + } + + if (ap->ip6_address_set) + { + struct ifreq ifr2; + ip6_ifreq_t ifr6; + int sockfd6; + + sockfd6 = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IP); + if (sockfd6 < 0) + { + rv = VNET_API_ERROR_SYSCALL_ERROR_10; + goto error; + } + + memset (&ifr2, 0, sizeof(ifr)); + strncpy (ifr2.ifr_name, (char *) ap->intfc_name, + sizeof (ifr2.ifr_name)-1); + if (ioctl (sockfd6, SIOCGIFINDEX, &ifr2) < 0 ) + { + close (sockfd6); + rv = VNET_API_ERROR_SYSCALL_ERROR_4; + goto error; + } + + memcpy (&ifr6.addr, ap->ip6_address, sizeof (ip6_address_t)); + ifr6.mask_width = ap->ip6_mask_width; + ifr6.ifindex = ifr2.ifr_ifindex; + + if (ioctl (sockfd6, SIOCSIFADDR, &ifr6) < 0) + { + close (sockfd6); + clib_unix_warning ("ifr6"); + rv = VNET_API_ERROR_SYSCALL_ERROR_10; + goto error; + } + close (sockfd6); + } + ti = tapcli_get_new_tapif(); ti->per_interface_next_index = ~0; - if (hwaddr_arg != 0) - clib_memcpy(hwaddr, hwaddr_arg, 6); + if (ap->hwaddr_arg != 0) + clib_memcpy(hwaddr, ap->hwaddr_arg, 6); else { f64 now = vlib_time_now(vm); @@ -937,8 +1015,8 @@ int vnet_tap_connect (vlib_main_t * vm, u8 * intfc_name, u8 *hwaddr_arg, hw->max_supported_packet_bytes = TAP_MTU_MAX; hw->max_l3_packet_bytes[VLIB_RX] = hw->max_l3_packet_bytes[VLIB_TX] = hw->max_supported_packet_bytes - sizeof(ethernet_header_t); ti->sw_if_index = hw->sw_if_index; - if (sw_if_indexp) - *sw_if_indexp = hw->sw_if_index; + if (ap->sw_if_indexp) + *(ap->sw_if_indexp) = hw->sw_if_index; } ti->active = 1; @@ -972,16 +1050,15 @@ int vnet_tap_connect (vlib_main_t * vm, u8 * intfc_name, u8 *hwaddr_arg, * @return rc - int * */ -int vnet_tap_connect_renumber (vlib_main_t * vm, u8 * intfc_name, - u8 *hwaddr_arg, u32 * sw_if_indexp, - u8 renumber, u32 custom_dev_instance) +int vnet_tap_connect_renumber (vlib_main_t * vm, + vnet_tap_connect_args_t *ap) { - int rv = vnet_tap_connect(vm, intfc_name, hwaddr_arg, sw_if_indexp); + int rv = vnet_tap_connect(vm, ap); - if (!rv && renumber) - vnet_interface_name_renumber (*sw_if_indexp, custom_dev_instance); + if (!rv && ap->renumber) + vnet_interface_name_renumber (*(ap->sw_if_indexp), ap->custom_dev_instance); - return rv; + return rv; } /** @@ -1118,18 +1195,14 @@ VLIB_CLI_COMMAND (tap_delete_command, static) = { * @return rc - int * */ -int vnet_tap_modify (vlib_main_t * vm, u32 orig_sw_if_index, - u8 * intfc_name, u8 *hwaddr_arg, - u32 * sw_if_indexp, - u8 renumber, u32 custom_dev_instance) +int vnet_tap_modify (vlib_main_t * vm, vnet_tap_connect_args_t *ap) { - int rv = vnet_tap_delete (vm, orig_sw_if_index); + int rv = vnet_tap_delete (vm, ap->orig_sw_if_index); if (rv) - return rv; + return rv; - rv = vnet_tap_connect_renumber(vm, intfc_name, hwaddr_arg, sw_if_indexp, - renumber, custom_dev_instance); + rv = vnet_tap_connect_renumber(vm, ap); return rv; } @@ -1155,6 +1228,7 @@ tap_modify_command_fn (vlib_main_t * vm, u32 new_sw_if_index = ~0; int user_hwaddr = 0; u8 hwaddr[6]; + vnet_tap_connect_args_t _a, *ap= &_a; if (tm->is_disabled) { @@ -1179,14 +1253,19 @@ tap_modify_command_fn (vlib_main_t * vm, user_hwaddr = 1; - int rc = vnet_tap_modify (vm, sw_if_index, intfc_name, - (user_hwaddr == 1 ? hwaddr : 0), - &new_sw_if_index, 0, 0); + memset (ap, 0, sizeof(*ap)); + ap->orig_sw_if_index = sw_if_index; + ap->intfc_name = intfc_name; + ap->sw_if_indexp = &new_sw_if_index; + if (user_hwaddr) + ap->hwaddr_arg = hwaddr; + + int rc = vnet_tap_modify (vm, ap); if (!rc) { vlib_cli_output (vm, "Modified %U for Linux tap '%s'", format_vnet_sw_if_index_name, tm->vnet_main, - new_sw_if_index, intfc_name); + *(ap->sw_if_indexp), ap->intfc_name); } else { vlib_cli_output (vm, "Error during modification of tap interface. (rc: %d)", rc); } @@ -1216,82 +1295,117 @@ tap_connect_command_fn (vlib_main_t * vm, vlib_cli_command_t * cmd) { u8 * intfc_name; + unformat_input_t _line_input, *line_input = &_line_input; + vnet_tap_connect_args_t _a, *ap= &_a; tapcli_main_t * tm = &tapcli_main; u8 hwaddr[6]; u8 *hwaddr_arg = 0; u32 sw_if_index; + ip4_address_t ip4_address; + int ip4_address_set = 0; + ip6_address_t ip6_address; + int ip6_address_set = 0; + u32 ip4_mask_width = 0; + u32 ip6_mask_width = 0; if (tm->is_disabled) + return clib_error_return (0, "device disabled..."); + + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { - return clib_error_return (0, "device disabled..."); + if (unformat(line_input, "hwaddr %U", unformat_ethernet_address, + &hwaddr)) + hwaddr_arg = hwaddr; + + /* It is here for backward compatibility */ + else if (unformat(line_input, "hwaddr random")) + ; + + else if (unformat (line_input, "address %U/%d", + unformat_ip4_address, &ip4_address, &ip4_mask_width)) + ip4_address_set = 1; + + else if (unformat (line_input, "address %U/%d", + unformat_ip6_address, &ip6_address, &ip6_mask_width)) + ip6_address_set = 1; + + else if (unformat (line_input, "%s", &intfc_name)) + ; + else + return clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); } - - if (unformat (input, "%s", &intfc_name)) - ; - else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); - if (unformat(input, "hwaddr %U", unformat_ethernet_address, - &hwaddr)) - hwaddr_arg = hwaddr; + memset (ap, 0, sizeof (*ap)); - /* It is here for backward compatibility */ - if (unformat(input, "hwaddr random")) - ; + ap->intfc_name = intfc_name; + ap->hwaddr_arg = hwaddr_arg; + if (ip4_address_set) + { + ap->ip4_address = &ip4_address; + ap->ip4_mask_width = ip4_mask_width; + ap->ip4_address_set = 1; + } + if (ip6_address_set) + { + ap->ip6_address = &ip6_address; + ap->ip6_mask_width = ip6_mask_width; + ap->ip6_address_set = 1; + } - int rv = vnet_tap_connect(vm, intfc_name, hwaddr_arg, &sw_if_index); - if (rv) { - switch (rv) { - case VNET_API_ERROR_SYSCALL_ERROR_1: - vlib_cli_output (vm, "Couldn't open /dev/net/tun"); - break; + ap->sw_if_indexp = &sw_if_index; + int rv = vnet_tap_connect(vm, ap); + + switch (rv) + { + case VNET_API_ERROR_SYSCALL_ERROR_1: + return clib_error_return (0, "Couldn't open /dev/net/tun"); + case VNET_API_ERROR_SYSCALL_ERROR_2: - vlib_cli_output (vm, "Error setting flags on '%s'", intfc_name); - break; + return clib_error_return (0, "Error setting flags on '%s'", intfc_name); case VNET_API_ERROR_SYSCALL_ERROR_3: - vlib_cli_output (vm, "Couldn't open provisioning socket"); - break; + return clib_error_return (0, "Couldn't open provisioning socket"); case VNET_API_ERROR_SYSCALL_ERROR_4: - vlib_cli_output (vm, "Couldn't get if_index"); - break; + return clib_error_return (0, "Couldn't get if_index"); case VNET_API_ERROR_SYSCALL_ERROR_5: - vlib_cli_output (vm, "Couldn't bind provisioning socket"); - break; + return clib_error_return (0, "Couldn't bind provisioning socket"); case VNET_API_ERROR_SYSCALL_ERROR_6: - vlib_cli_output (0, "Couldn't set device non-blocking flag"); - break; + return clib_error_return (0, "Couldn't set device non-blocking flag"); case VNET_API_ERROR_SYSCALL_ERROR_7: - vlib_cli_output (0, "Couldn't set device MTU"); - break; + return clib_error_return (0, "Couldn't set device MTU"); case VNET_API_ERROR_SYSCALL_ERROR_8: - vlib_cli_output (0, "Couldn't get interface flags"); - break; + return clib_error_return (0, "Couldn't get interface flags"); case VNET_API_ERROR_SYSCALL_ERROR_9: - vlib_cli_output (0, "Couldn't set intfc admin state up"); - break; + return clib_error_return (0, "Couldn't set intfc admin state up"); + + case VNET_API_ERROR_SYSCALL_ERROR_10: + return clib_error_return (0, "Couldn't set intfc address/mask"); case VNET_API_ERROR_INVALID_REGISTRATION: - vlib_cli_output (0, "Invalid registration"); + return clib_error_return (0, "Invalid registration"); + + case 0: break; + default: - vlib_cli_output (0, "Unknown error: %d", rv); - break; + return clib_error_return (0, "Unknown error: %d", rv); } - return 0; - } - vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); + 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) = { .path = "tap connect", diff --git a/src/vnet/unix/tuntap.h b/src/vnet/unix/tuntap.h index d7f96cae..7c2d5510 100644 --- a/src/vnet/unix/tuntap.h +++ b/src/vnet/unix/tuntap.h @@ -22,15 +22,48 @@ */ void register_tuntap_inject_node_name (char *name); -int vnet_tap_connect (vlib_main_t * vm, u8 * intfc_name, - u8 *hwaddr_arg, u32 * sw_if_indexp); -int vnet_tap_connect_renumber (vlib_main_t * vm, u8 * intfc_name, - u8 *hwaddr_arg, u32 * sw_if_indexp, - u8 renumber, u32 custom_dev_instance); +/** arguments structure for vnet_tap_connect, vnet_tap_connect_renumber, etc. + */ + +typedef struct +{ + /** Interface name */ + u8 *intfc_name; + /** Mac address */ + u8 *hwaddr_arg; + /** Please set the indicated ip4 address/mask on the interface */ + u8 ip4_address_set; + /** Please set the indicated ip4 address/mask on the interface */ + u8 ip6_address_set; + /** Renumber the (existing) interface */ + u8 renumber; + /** (optional) ip4 address to set */ + ip4_address_t *ip4_address; + /** (optional) ip4 mask width to set */ + u32 ip4_mask_width; + /** (optional) ip6 address to set */ + ip6_address_t *ip6_address; + /** (optional) ip6 mask width to set */ + u32 ip6_mask_width; + /** Output parameter: result sw_if_index */ + u32 *sw_if_indexp; + /** Custom device instance */ + u32 custom_dev_instance; + /** original sw_if_index (renumber) */ + u32 orig_sw_if_index; +} vnet_tap_connect_args_t; + +/** Connect a tap interface */ +int vnet_tap_connect (vlib_main_t * vm, vnet_tap_connect_args_t *args); +/** Connect / renumber a tap interface */ +int vnet_tap_connect_renumber (vlib_main_t * vm, + vnet_tap_connect_args_t *args); + +/** Modify a tap interface */ +int vnet_tap_modify (vlib_main_t * vm, vnet_tap_connect_args_t *args); + +/** delete a tap interface */ int vnet_tap_delete(vlib_main_t *vm, u32 sw_if_index); -int vnet_tap_modify (vlib_main_t * vm, u32 orig_sw_if_index, - u8 * intfc_name, u8 *hwaddr_arg, - u32 * sw_if_indexp, - u8 renumber, u32 custom_dev_instance); + diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c index 4cbb7082..8f59f5ee 100644 --- a/src/vpp/api/custom_dump.c +++ b/src/vpp/api/custom_dump.c @@ -438,7 +438,12 @@ static void *vl_api_tap_connect_t_print s = format (s, "tag %s ", mp->tag); if (memcmp (mp->mac_address, null_mac, 6)) s = format (s, "mac %U ", format_ethernet_address, mp->mac_address); - + if (mp->ip4_address_set) + s = format (s, "address %U/%d ", format_ip4_address, mp->ip4_address, + mp->ip4_mask_width); + if (mp->ip6_address_set) + s = format (s, "address %U/%d ", format_ip6_address, mp->ip6_address, + mp->ip6_mask_width); FINISH; } -- cgit 1.2.3-korg