[CRIU] [PATCH 3/4] join-ns: skip prepare_net_ns when join net ns flag set

Pavel Emelyanov xemul at virtuozzo.com
Mon Apr 4 04:23:07 PDT 2016


On 04/04/2016 09:41 AM, Dengguangxing wrote:
> 
> modify switch_ns error message
> 
> Signed-off-by: Deng Guangxing <dengguangxing at huawei.com>
> ---
>  criu/namespaces.c | 2 +-
>  criu/net.c        | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/criu/namespaces.c b/criu/namespaces.c
> index c7a5572..5981030 100644
> --- a/criu/namespaces.c
> +++ b/criu/namespaces.c
> @@ -222,7 +222,7 @@ int switch_ns(int pid, struct ns_desc *nd, int *rst)
> 
>  	nsfd = open_proc(pid, "ns/%s", nd->str);
>  	if (nsfd < 0) {
> -		pr_perror("Can't open ipcns file");
> +		pr_perror("Can't open ns file");
>  		goto err_ns;
>  	}
> 
> diff --git a/criu/net.c b/criu/net.c
> index faed2bd..860f1a3 100644
> --- a/criu/net.c
> +++ b/criu/net.c
> @@ -1095,7 +1095,8 @@ int prepare_net_ns(int pid)
>  	int ret = 0;
>  	NetnsEntry *netns = NULL;
> 
> -	if (!(opts.empty_ns & CLONE_NEWNET)) {
> +	if (!(opts.empty_ns & CLONE_NEWNET) &&
> +			!(join_ns_flags & CLONE_NEWNET)) {

We only get to this whole function if the global ns mask containes
CLONE_NEWNET, but in this case join_ns_flags cannot contain one,
so this check is always true. Thus -- not required.

>  		ret = restore_netns_conf(pid, &netns);
>  		if (!ret)
>  			ret = restore_links(pid, &netns);
> 



More information about the CRIU mailing list