+ if (args->tap_flags & TAP_FLAG_ATTACH)
+ {
+ if (args->host_if_name != NULL)
+ {
+ host_if_name = (char *) args->host_if_name;
+ clib_memcpy (ifr.ifr_name, host_if_name,
+ clib_min (IFNAMSIZ, strlen (host_if_name)));
+ }
+ else
+ {
+ args->rv = VNET_API_ERROR_NO_MATCHING_INTERFACE;
+ err = clib_error_return (0, "host_if_name is not provided");
+ goto error;
+ }
+ if (args->host_namespace)
+ {
+ old_netns_fd = open ("/proc/self/ns/net", O_RDONLY);
+ if ((nfd = open_netns_fd ((char *) args->host_namespace)) == -1)
+ {
+ args->rv = VNET_API_ERROR_SYSCALL_ERROR_2;
+ args->error = clib_error_return_unix (0, "open_netns_fd '%s'",
+ args->host_namespace);
+ goto error;
+ }
+ if (setns (nfd, CLONE_NEWNET) == -1)
+ {
+ args->rv = VNET_API_ERROR_SYSCALL_ERROR_3;
+ args->error = clib_error_return_unix (0, "setns '%s'",
+ args->host_namespace);
+ goto error;
+ }
+ }
+ }