X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fdevices%2Ftap%2Ftap.c;h=e6a7ba518a665313bee7566609bd5e909421fa6b;hb=7866c4595b65f54f491ffc4e92b1f8cf94d6f142;hp=4f76321071c2a45bc94261559dbf0ccdadfff96a;hpb=4e671d20c8bc6a45ff703625d78f6703c62094b7;p=vpp.git diff --git a/src/vnet/devices/tap/tap.c b/src/vnet/devices/tap/tap.c index 4f76321071c..e6a7ba518a6 100644 --- a/src/vnet/devices/tap/tap.c +++ b/src/vnet/devices/tap/tap.c @@ -292,6 +292,26 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args) goto error; } + if (args->host_ip4_gw_set) + { + args->error = vnet_netlink_add_ip4_route (0, 0, &args->host_ip4_gw); + if (args->error) + { + args->rv = VNET_API_ERROR_NETLINK_ERROR; + goto error; + } + } + + if (args->host_ip6_gw_set) + { + args->error = vnet_netlink_add_ip6_route (0, 0, &args->host_ip6_gw); + if (args->error) + { + args->rv = VNET_API_ERROR_NETLINK_ERROR; + goto error; + } + } + /* switch back to old net namespace */ if (args->host_namespace) { @@ -335,10 +355,22 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args) args->mac_addr[0] = 2; args->mac_addr[1] = 0xfe; } + vif->rx_ring_sz = args->rx_ring_sz != 0 ? args->rx_ring_sz : 256; + vif->tx_ring_sz = args->tx_ring_sz != 0 ? args->tx_ring_sz : 256; vif->host_if_name = args->host_if_name; args->host_if_name = 0; vif->net_ns = args->host_namespace; args->host_namespace = 0; + vif->host_bridge = args->host_bridge; + args->host_bridge = 0; + clib_memcpy (vif->host_mac_addr, args->host_mac_addr, 6); + vif->host_ip4_prefix_len = args->host_ip4_prefix_len; + vif->host_ip6_prefix_len = args->host_ip6_prefix_len; + if (args->host_ip4_prefix_len) + clib_memcpy (&vif->host_ip4_addr, &args->host_ip4_addr, 4); + if (args->host_ip6_prefix_len) + clib_memcpy (&vif->host_ip6_addr, &args->host_ip6_addr, 16); + args->error = ethernet_register_interface (vnm, virtio_device_class.index, vif->dev_instance, args->mac_addr, @@ -378,7 +410,7 @@ error: close (vif->tap_fd); if (vif->fd != -1) close (vif->fd); - vec_foreach_index (i, vif->vrings) virtio_vring_free (vif, i); + vec_foreach_index (i, vif->vrings) virtio_vring_free (vm, vif, i); memset (vif, 0, sizeof (virtio_if_t)); pool_put (vim->interfaces, vif); @@ -417,7 +449,7 @@ tap_delete_if (vlib_main_t * vm, u32 sw_if_index) if (vif->fd != -1) close (vif->fd); - vec_foreach_index (i, vif->vrings) virtio_vring_free (vif, i); + vec_foreach_index (i, vif->vrings) virtio_vring_free (vm, vif, i); vec_free (vif->vrings); hash_unset (tm->dev_instance_by_interface_id, vif->id); @@ -441,11 +473,39 @@ tap_dump_ifs (tap_interface_details_t ** out_tapids) pool_foreach (vif, mm->interfaces, vec_add2(r_tapids, tapid, 1); memset (tapid, 0, sizeof (*tapid)); + tapid->id = vif->id; tapid->sw_if_index = vif->sw_if_index; hi = vnet_get_hw_interface (vnm, vif->hw_if_index); clib_memcpy(tapid->dev_name, hi->name, - MIN (ARRAY_LEN (tapid->dev_name) - 1, - strlen ((const char *) hi->name))); + MIN (ARRAY_LEN (tapid->dev_name) - 1, + strlen ((const char *) hi->name))); + tapid->rx_ring_sz = vif->rx_ring_sz; + tapid->tx_ring_sz = vif->tx_ring_sz; + clib_memcpy(tapid->host_mac_addr, vif->host_mac_addr, 6); + if (vif->host_if_name) + { + clib_memcpy(tapid->host_if_name, vif->host_if_name, + MIN (ARRAY_LEN (tapid->host_if_name) - 1, + strlen ((const char *) vif->host_if_name))); + } + if (vif->net_ns) + { + clib_memcpy(tapid->host_namespace, vif->net_ns, + MIN (ARRAY_LEN (tapid->host_namespace) - 1, + strlen ((const char *) vif->net_ns))); + } + if (vif->host_bridge) + { + clib_memcpy(tapid->host_bridge, vif->host_bridge, + MIN (ARRAY_LEN (tapid->host_bridge) - 1, + strlen ((const char *) vif->host_bridge))); + } + if (vif->host_ip4_prefix_len) + clib_memcpy(tapid->host_ip4_addr, &vif->host_ip4_addr, 4); + tapid->host_ip4_prefix_len = vif->host_ip4_prefix_len; + if (vif->host_ip6_prefix_len) + clib_memcpy(tapid->host_ip6_addr, &vif->host_ip6_addr, 16); + tapid->host_ip6_prefix_len = vif->host_ip6_prefix_len; ); /* *INDENT-ON* */