External network namespaces

Submitted by Andrey Vagin on Sept. 17, 2018, 10:52 p.m.

Details

Message ID 20180917225241.GB31595@outlook.office365.com
State New
Series "External network namespaces"
Headers show

Commit Message

Andrey Vagin Sept. 17, 2018, 10:52 p.m.
On Fri, Sep 14, 2018 at 08:26:55AM +0200, Adrian Reber wrote:
> On Thu, Sep 13, 2018 at 11:33:17AM +0200, Adrian Reber wrote:
> > when we initially talked about external network namespace and how RPC
> > can get those FDs you mentioned FD clashes.
> > 
> > I am now hitting such a FD clash:
> > 
> > (00.197735)      1: Inherit fd extRootNetNS -> 4 has been reused
> > (00.197738)      1: Error (criu/util.c:251): fd 4 already in use (called at criu/files.c:1102)
> > (00.197743)      1: Error (criu/files.c:1205): Unable to open fd=4 id=0x7d
> > 
> > I understand it in such a way that CRIU gets the network namespace via
> > FD 4, but the restored process also uses FD 4 and cannot use the
> > information from inherit FD. Any idea how to solve this? Thanks.
> 
> So if I just 'dup2(4, 99);' then it works. What is the right way in CRIU
> to move an FD out of the way. There are so many FD related functions and
> I am not sure which one is the right for this use case.

Could you try out the next patch:


> 
> 		Adrian

Patch hide | download patch | download mbox

diff --git a/criu/net.c b/criu/net.c
index 0431b62f9..0331dffb8 100644
--- a/criu/net.c
+++ b/criu/net.c
@@ -2210,7 +2210,6 @@  int net_set_ext(struct ns_id *ns)
        }
 
        ret = switch_ns_by_fd(fd, &net_ns_desc, NULL);
-       close(fd);
 
        return ret;
 }

Comments

Adrian Reber Sept. 18, 2018, 5:35 a.m.
On Mon, Sep 17, 2018 at 10:52:49PM +0000, Andrey Vagin wrote:
> On Fri, Sep 14, 2018 at 08:26:55AM +0200, Adrian Reber wrote:
> > On Thu, Sep 13, 2018 at 11:33:17AM +0200, Adrian Reber wrote:
> > > when we initially talked about external network namespace and how RPC
> > > can get those FDs you mentioned FD clashes.
> > > 
> > > I am now hitting such a FD clash:
> > > 
> > > (00.197735)      1: Inherit fd extRootNetNS -> 4 has been reused
> > > (00.197738)      1: Error (criu/util.c:251): fd 4 already in use (called at criu/files.c:1102)
> > > (00.197743)      1: Error (criu/files.c:1205): Unable to open fd=4 id=0x7d
> > > 
> > > I understand it in such a way that CRIU gets the network namespace via
> > > FD 4, but the restored process also uses FD 4 and cannot use the
> > > information from inherit FD. Any idea how to solve this? Thanks.
> > 
> > So if I just 'dup2(4, 99);' then it works. What is the right way in CRIU
> > to move an FD out of the way. There are so many FD related functions and
> > I am not sure which one is the right for this use case.
> 
> Could you try out the next patch:
> 
> diff --git a/criu/net.c b/criu/net.c
> index 0431b62f9..0331dffb8 100644
> --- a/criu/net.c
> +++ b/criu/net.c
> @@ -2210,7 +2210,6 @@ int net_set_ext(struct ns_id *ns)
>         }
>  
>         ret = switch_ns_by_fd(fd, &net_ns_desc, NULL);
> -       close(fd);
>  
>         return ret;
>  }

That works. Thanks!

		Adrian