From cacdd39761c41e4364669b9f3c9da2112d599ca6 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Thu, 25 Jun 2015 12:30:27 -0700 Subject: [PATCH] netns: Update to latest for arm64 Signed-off-by: Geoff Levand --- libnetwork/Godeps/Godeps.json | 2 +- .../vishvananda/netns/netns_linux.go | 27 +++++++++---------- .../vishvananda/netns/netns_linux_arm64.go | 7 +++++ 3 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 libnetwork/Godeps/_workspace/src/github.com/vishvananda/netns/netns_linux_arm64.go diff --git a/libnetwork/Godeps/Godeps.json b/libnetwork/Godeps/Godeps.json index 64c40ccc97..c38b6f8e26 100644 --- a/libnetwork/Godeps/Godeps.json +++ b/libnetwork/Godeps/Godeps.json @@ -131,7 +131,7 @@ }, { "ImportPath": "github.com/vishvananda/netns", - "Rev": "5478c060110032f972e86a1f844fdb9a2f008f2c" + "Rev": "b7a04d6db3dce92b370e6d5b6ab9e2361a3c53e1" } ] } diff --git a/libnetwork/Godeps/_workspace/src/github.com/vishvananda/netns/netns_linux.go b/libnetwork/Godeps/_workspace/src/github.com/vishvananda/netns/netns_linux.go index c9170d6426..abdc308290 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/vishvananda/netns/netns_linux.go +++ b/libnetwork/Godeps/_workspace/src/github.com/vishvananda/netns/netns_linux.go @@ -52,33 +52,30 @@ func Get() (NsHandle, error) { return GetFromThread(os.Getpid(), syscall.Gettid()) } -// GetFromName gets a handle to a named network namespace such as one -// created by `ip netns add`. -func GetFromName(name string) (NsHandle, error) { - fd, err := syscall.Open(fmt.Sprintf("/var/run/netns/%s", name), syscall.O_RDONLY, 0) +// GetFromPath gets a handle to a network namespace +// identified by the path +func GetFromPath(path string) (NsHandle, error) { + fd, err := syscall.Open(path, syscall.O_RDONLY, 0) if err != nil { return -1, err } return NsHandle(fd), nil } +// 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)) +} + // GetFromPid gets a handle to the network namespace of a given pid. func GetFromPid(pid int) (NsHandle, error) { - fd, err := syscall.Open(fmt.Sprintf("/proc/%d/ns/net", pid), syscall.O_RDONLY, 0) - if err != nil { - return -1, err - } - return NsHandle(fd), nil + return GetFromPath(fmt.Sprintf("/proc/%d/ns/net", pid)) } // GetFromThread gets a handle to the network namespace of a given pid and tid. func GetFromThread(pid, tid int) (NsHandle, error) { - name := fmt.Sprintf("/proc/%d/task/%d/ns/net", pid, tid) - fd, err := syscall.Open(name, syscall.O_RDONLY, 0) - if err != nil { - return -1, err - } - return NsHandle(fd), nil + return GetFromPath(fmt.Sprintf("/proc/%d/task/%d/ns/net", pid, tid)) } // GetFromDocker gets a handle to the network namespace of a docker container. diff --git a/libnetwork/Godeps/_workspace/src/github.com/vishvananda/netns/netns_linux_arm64.go b/libnetwork/Godeps/_workspace/src/github.com/vishvananda/netns/netns_linux_arm64.go new file mode 100644 index 0000000000..741a30207a --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/vishvananda/netns/netns_linux_arm64.go @@ -0,0 +1,7 @@ +// +build linux,arm64 + +package netns + +const ( + SYS_SETNS = 268 +)