-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Named namespaces #26
Comments
We do this manually right now, here's the code:
Should probably clean this up and submit a PR; maintainers, would you be interested in this? |
"self/ns/net" may refer to another thread. You should access namespace
bound to your task id. I'll send full example later
…On Sun, 5 Aug 2018, 13:44 Alexander Schittler ***@***.***> wrote:
We do this manually right now, here's the code:
if err := syscall.Unshare(syscall.CLONE_NEWNET); err != nil {
panic(err)
}
p := path.Join("/var/run/netns/", netname)
f, err := os.OpenFile(p, os.O_CREATE | os.O_EXCL, 0444)
if err != nil {
panic(err)
}
f.Close()
if err := syscall.Mount(fmt.Sprintf("/proc/self/ns/net"), p, "bind", syscall.MS_BIND, ""); err != nil {
panic(err)
}
Should probably clean this up and submit a PR; maintainers, would you be
interested in this?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#26 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHKZxs4z8je-uHlzAPy0rECB93DMybFcks5uNtqDgaJpZM4U-e_u>
.
|
I create a named one like this: newNsPath := "/var/run/netns"
nsPath := fmt.Sprintf("/proc/%d/task/%d/ns/net", os.Getpid(), syscall.Gettid())
err = syscall.Mount(nsPath, newNsPath, "", syscall.MS_BIND|syscall.MS_REC, "") |
Ah, that's good to know, we spawned a new process to avoid this (also because it "burns" an OS thread available to the runtime) |
I think this can be closed as fixed? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
is there a way to create a named network namespace? I mean the one that I can see in
ip netns
.The text was updated successfully, but these errors were encountered: