mirror of
https://github.com/vishvananda/netns
synced 2025-01-05 05:49:44 +00:00
GetFromName: use /run/netns instead of /var/run/netns
The GetFromName() function looked for network namespaces in "/var/run", whereas DeleteNamed() and NewNamed() used the "bindMountPath" const (which points to "/run/netns"). While "/var/run" should be symlink to "/run" on most distros, this is not a guarantee, so use the same paths so that at least the code is consistently using this path. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
e6c3e222e7
commit
a21f45a794
@ -108,7 +108,7 @@ func GetFromPath(path string) (NsHandle, error) {
|
||||
// GetFromName gets a handle to a named network namespace such as one
|
||||
// created by `ip netns add`.
|
||||
func GetFromName(name string) (NsHandle, error) {
|
||||
return GetFromPath(fmt.Sprintf("/var/run/netns/%s", name))
|
||||
return GetFromPath(filepath.Join(bindMountPath, name))
|
||||
}
|
||||
|
||||
// GetFromPid gets a handle to the network namespace of a given pid.
|
||||
|
Loading…
Reference in New Issue
Block a user