if (args->host_namespace)
{
int fd;
+ int rc;
old_netns_fd = open ("/proc/self/ns/net", O_RDONLY);
if ((fd = open_netns_fd ((char *) args->host_namespace)) == -1)
{
args->rv = VNET_API_ERROR_NETLINK_ERROR;
goto error;
}
- if (setns (fd, CLONE_NEWNET) == -1)
+ rc = setns (fd, CLONE_NEWNET);
+ close (fd);
+ if (rc == -1)
{
args->rv = VNET_API_ERROR_SYSCALL_ERROR_3;
args->error = clib_error_return_unix (0, "setns '%s'",
args->host_namespace);
goto error;
}
- close (fd);
if ((vif->ifindex = if_nametoindex ((char *) args->host_if_name)) == 0)
{
args->rv = VNET_API_ERROR_SYSCALL_ERROR_3;