clib_file_t t = { 0 };
clib_error_t *err = 0;
int fd = -1;
+ char *host_if_name = 0;
if (args->id != ~0)
{
vif->ifindex = if_nametoindex (ifr.ifr_ifrn.ifrn_name);
if (!args->host_if_name)
- args->host_if_name = (void *) ifr.ifr_ifrn.ifrn_name;
+ host_if_name = ifr.ifr_ifrn.ifrn_name;
+ else
+ host_if_name = (char *) args->host_if_name;
unsigned int offload = 0;
hdrsz = sizeof (struct virtio_net_hdr_v1);
goto error;
}
args->error = vnet_netlink_set_link_netns (vif->ifindex, fd,
- (char *) args->host_if_name);
+ host_if_name);
if (args->error)
{
args->rv = VNET_API_ERROR_NETLINK_ERROR;
args->host_namespace);
goto error;
}
- if ((vif->ifindex = if_nametoindex ((char *) args->host_if_name)) == 0)
+ if ((vif->ifindex = if_nametoindex (host_if_name)) == 0)
{
args->rv = VNET_API_ERROR_SYSCALL_ERROR_3;
args->error = clib_error_return_unix (0, "if_nametoindex '%s'",
- args->host_if_name);
+ host_if_name);
goto error;
}
}
else
{
- if (args->host_if_name)
+ if (host_if_name)
{
args->error = vnet_netlink_set_link_name (vif->ifindex,
- (char *)
- args->host_if_name);
+ host_if_name);
if (args->error)
{
args->rv = VNET_API_ERROR_NETLINK_ERROR;
clib_memcpy (vif->mac_addr, args->mac_addr, 6);
- vif->host_if_name = format (0, "%s%c", args->host_if_name, 0);
+ vif->host_if_name = format (0, "%s%c", host_if_name, 0);
vif->net_ns = format (0, "%s%c", args->host_namespace, 0);
vif->host_bridge = format (0, "%s%c", args->host_bridge, 0);
vif->host_mtu_size = args->host_mtu_size;
sw = vnet_get_hw_sw_interface (vnm, vif->hw_if_index);
vif->sw_if_index = sw->sw_if_index;
args->sw_if_index = vif->sw_if_index;
+ args->rv = 0;
hw = vnet_get_hw_interface (vnm, vif->hw_if_index);
hw->flags |= VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE;
if (args->tap_flags & TAP_FLAG_GSO)
virtio_if_t *vif;
vnet_hw_interface_t *hw;
- hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
+ hw = vnet_get_sup_hw_interface_api_visible_or_null (vnm, sw_if_index);
if (hw == NULL || virtio_device_class.index != hw->dev_class_index)
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
vnet_main_t *vnm = vnet_get_main ();
virtio_main_t *mm = &virtio_main;
virtio_if_t *vif;
- vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
+ vnet_hw_interface_t *hw;
clib_error_t *err = 0;
+ hw = vnet_get_sup_hw_interface_api_visible_or_null (vnm, sw_if_index);
+
if (hw == NULL || virtio_device_class.index != hw->dev_class_index)
return VNET_API_ERROR_INVALID_SW_IF_INDEX;