unc icon indicating copy to clipboard operation
unc copied to clipboard

Find a way to use pipe work for different namespace synchnization

Open HackToday opened this issue 8 years ago • 8 comments

Hi @LK4D4 , Thanks for blog, it helped me a lot to understand docker namespace magic. I like such hack learning.

I did not know you mail, so sorry to open a issue for one question :)

I have written C code like this: https://github.com/HackToday/Hackwork/blob/master/linux-namespace/netns.c

Also a simple go code (some reference your implementation, it is about MNT ns) https://github.com/HackToday/Hackwork/blob/master/go-container/gocontainer-4/main.go

I did read your blog about http://lk4d4.darth.io/ network namespace part, Right now, I want to use pipe to sychnization, as netns.c (I learn docker used this magic), instead of looping ways between parent and child network operation(interface ready and up etc)

Could you show me some hint how to achieve that ?

HackToday avatar Dec 29 '15 10:12 HackToday

ping @LK4D4 wish to get your insight. Thanks

HackToday avatar Dec 29 '15 10:12 HackToday

You can find simple pipe-sync trick in man user_namespace. It used for different task, but idea is the same.

LK4D4 avatar Dec 29 '15 20:12 LK4D4

hi @LK4D4 What's man user_namespace ? Seems linux not have such man page for that

$ man user_namespace No manual entry for user_namespace

HackToday avatar Dec 29 '15 23:12 HackToday

Sorry, it's user_namespaces

LK4D4 avatar Dec 30 '15 16:12 LK4D4

yes @LK4D4 I did read that article before, For C seems it is easy combine with pipe and clone call.

But for your GO program, it seems use magic like

    cmd := &exec.Cmd{
            Path: os.Args[0],
            Args: append([]string{"forkChild"}, args...),
    }

to simulate clone ways. which make me find diffcult to use such pipe ways.

Did you try Go ways for pipe like that?

HackToday avatar Dec 31 '15 01:12 HackToday

@HackToday I think any fork/clone actions is dangerous in Golang because of its runtime. Only safe way is to do fork-exec(exec.Cmd).

LK4D4 avatar Jan 01 '16 01:01 LK4D4

hello there! I dont know if you guys have fix that problem yet... I got the same error while writing my own container...

Joey777210 avatar Feb 23 '20 16:02 Joey777210

@Joey777210 Not sure which error you means. This issue is about using pipes for synchronization.

LK4D4 avatar Feb 24 '20 18:02 LK4D4