mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
bump github.com/vishvananda/netns 13995c7128ccc8e51e9a6bd2b551020a27180abd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
d152888722
commit
e9e18d993c
11 changed files with 57 additions and 51 deletions
|
@ -42,7 +42,7 @@ github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374
|
|||
github.com/sirupsen/logrus f006c2ac4710855cf0f916dd6b77acf6b048dc6e # v1.0.3
|
||||
github.com/ugorji/go b4c50a2b199d93b13dc15e78929cfb23bfdf21ab # v1.1.1
|
||||
github.com/vishvananda/netlink a2ad57a690f3caf3015351d2d6e1c0b95c349752 # v1.0.0
|
||||
github.com/vishvananda/netns 604eaf189ee867d8c147fafc28def2394e878d25
|
||||
github.com/vishvananda/netns 13995c7128ccc8e51e9a6bd2b551020a27180abd
|
||||
golang.org/x/crypto b7391e95e576cacdcdd422573063bc057239113d
|
||||
golang.org/x/net a680a1efc54dd51c040b3b5ce4939ea3cf2ea0d1
|
||||
golang.org/x/sys d455e41777fca6e8a5a79e34a14b8368bc11d9ba
|
||||
|
|
6
libnetwork/vendor/github.com/vishvananda/netns/README.md
generated
vendored
6
libnetwork/vendor/github.com/vishvananda/netns/README.md
generated
vendored
|
@ -20,9 +20,10 @@ Testing (requires root):
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"runtime"
|
||||
"github.com/vishvananada/netns"
|
||||
"github.com/vishvananda/netns"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -36,9 +37,10 @@ func main() {
|
|||
|
||||
// Create a new network namespace
|
||||
newns, _ := netns.New()
|
||||
netns.Set(newns)
|
||||
defer newns.Close()
|
||||
|
||||
// Do something with tne network namespace
|
||||
// Do something with the network namespace
|
||||
ifaces, _ := net.Interfaces()
|
||||
fmt.Printf("Interfaces: %v\n", ifaces)
|
||||
|
||||
|
|
17
libnetwork/vendor/github.com/vishvananda/netns/netns.go
generated
vendored
17
libnetwork/vendor/github.com/vishvananda/netns/netns.go
generated
vendored
|
@ -19,7 +19,7 @@ type NsHandle int
|
|||
|
||||
// Equal determines if two network handles refer to the same network
|
||||
// namespace. This is done by comparing the device and inode that the
|
||||
// file descripors point to.
|
||||
// file descriptors point to.
|
||||
func (ns NsHandle) Equal(other NsHandle) bool {
|
||||
if ns == other {
|
||||
return true
|
||||
|
@ -46,6 +46,19 @@ func (ns NsHandle) String() string {
|
|||
return fmt.Sprintf("NS(%d: %d, %d)", ns, s.Dev, s.Ino)
|
||||
}
|
||||
|
||||
// UniqueId returns a string which uniquely identifies the namespace
|
||||
// associated with the network handle.
|
||||
func (ns NsHandle) UniqueId() string {
|
||||
var s syscall.Stat_t
|
||||
if ns == -1 {
|
||||
return "NS(none)"
|
||||
}
|
||||
if err := syscall.Fstat(int(ns), &s); err != nil {
|
||||
return "NS(unknown)"
|
||||
}
|
||||
return fmt.Sprintf("NS(%d:%d)", s.Dev, s.Ino)
|
||||
}
|
||||
|
||||
// IsOpen returns true if Close() has not been called.
|
||||
func (ns NsHandle) IsOpen() bool {
|
||||
return ns != -1
|
||||
|
@ -61,7 +74,7 @@ func (ns *NsHandle) Close() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Get an empty (closed) NsHandle
|
||||
// None gets an empty (closed) NsHandle.
|
||||
func None() NsHandle {
|
||||
return NsHandle(-1)
|
||||
}
|
||||
|
|
33
libnetwork/vendor/github.com/vishvananda/netns/netns_linux.go
generated
vendored
33
libnetwork/vendor/github.com/vishvananda/netns/netns_linux.go
generated
vendored
|
@ -7,14 +7,27 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// SYS_SETNS syscall allows changing the namespace of the current process.
|
||||
var SYS_SETNS = map[string]uintptr{
|
||||
"386": 346,
|
||||
"amd64": 308,
|
||||
"arm64": 268,
|
||||
"arm": 375,
|
||||
"mips": 4344,
|
||||
"mipsle": 4344,
|
||||
"ppc64": 350,
|
||||
"ppc64le": 350,
|
||||
"s390x": 339,
|
||||
}[runtime.GOARCH]
|
||||
|
||||
// Deprecated: use syscall pkg instead (go >= 1.5 needed).
|
||||
const (
|
||||
// These constants belong in the syscall library but have not been
|
||||
// added yet.
|
||||
CLONE_NEWUTS = 0x04000000 /* New utsname group? */
|
||||
CLONE_NEWIPC = 0x08000000 /* New ipcs */
|
||||
CLONE_NEWUSER = 0x10000000 /* New user namespace */
|
||||
|
@ -125,7 +138,9 @@ func getThisCgroup(cgroupType string) (string, error) {
|
|||
return "", fmt.Errorf("docker pid not found in /var/run/docker.pid")
|
||||
}
|
||||
pid, err := strconv.Atoi(result[0])
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
output, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -167,8 +182,18 @@ func getPidForContainer(id string) (int, error) {
|
|||
filepath.Join(cgroupRoot, cgroupThis, id, "tasks"),
|
||||
// With more recent lxc versions use, cgroup will be in lxc/
|
||||
filepath.Join(cgroupRoot, cgroupThis, "lxc", id, "tasks"),
|
||||
// With more recent dockee, cgroup will be in docker/
|
||||
// With more recent docker, cgroup will be in docker/
|
||||
filepath.Join(cgroupRoot, cgroupThis, "docker", id, "tasks"),
|
||||
// Even more recent docker versions under systemd use docker-<id>.scope/
|
||||
filepath.Join(cgroupRoot, "system.slice", "docker-"+id+".scope", "tasks"),
|
||||
// Even more recent docker versions under cgroup/systemd/docker/<id>/
|
||||
filepath.Join(cgroupRoot, "..", "systemd", "docker", id, "tasks"),
|
||||
// Kubernetes with docker and CNI is even more different
|
||||
filepath.Join(cgroupRoot, "..", "systemd", "kubepods", "*", "pod*", id, "tasks"),
|
||||
// Another flavor of containers location in recent kubernetes 1.11+
|
||||
filepath.Join(cgroupRoot, cgroupThis, "kubepods.slice", "kubepods-besteffort.slice", "*", "docker-"+id+".scope", "tasks"),
|
||||
// When runs inside of a container with recent kubernetes 1.11+
|
||||
filepath.Join(cgroupRoot, "kubepods.slice", "kubepods-besteffort.slice", "*", "docker-"+id+".scope", "tasks"),
|
||||
}
|
||||
|
||||
var filename string
|
||||
|
|
7
libnetwork/vendor/github.com/vishvananda/netns/netns_linux_386.go
generated
vendored
7
libnetwork/vendor/github.com/vishvananda/netns/netns_linux_386.go
generated
vendored
|
@ -1,7 +0,0 @@
|
|||
// +build linux,386
|
||||
|
||||
package netns
|
||||
|
||||
const (
|
||||
SYS_SETNS = 346
|
||||
)
|
7
libnetwork/vendor/github.com/vishvananda/netns/netns_linux_amd64.go
generated
vendored
7
libnetwork/vendor/github.com/vishvananda/netns/netns_linux_amd64.go
generated
vendored
|
@ -1,7 +0,0 @@
|
|||
// +build linux,amd64
|
||||
|
||||
package netns
|
||||
|
||||
const (
|
||||
SYS_SETNS = 308
|
||||
)
|
7
libnetwork/vendor/github.com/vishvananda/netns/netns_linux_arm.go
generated
vendored
7
libnetwork/vendor/github.com/vishvananda/netns/netns_linux_arm.go
generated
vendored
|
@ -1,7 +0,0 @@
|
|||
// +build linux,arm
|
||||
|
||||
package netns
|
||||
|
||||
const (
|
||||
SYS_SETNS = 375
|
||||
)
|
7
libnetwork/vendor/github.com/vishvananda/netns/netns_linux_arm64.go
generated
vendored
7
libnetwork/vendor/github.com/vishvananda/netns/netns_linux_arm64.go
generated
vendored
|
@ -1,7 +0,0 @@
|
|||
// +build linux,arm64
|
||||
|
||||
package netns
|
||||
|
||||
const (
|
||||
SYS_SETNS = 268
|
||||
)
|
7
libnetwork/vendor/github.com/vishvananda/netns/netns_linux_ppc64le.go
generated
vendored
7
libnetwork/vendor/github.com/vishvananda/netns/netns_linux_ppc64le.go
generated
vendored
|
@ -1,7 +0,0 @@
|
|||
// +build linux,ppc64le
|
||||
|
||||
package netns
|
||||
|
||||
const (
|
||||
SYS_SETNS = 350
|
||||
)
|
7
libnetwork/vendor/github.com/vishvananda/netns/netns_linux_s390x.go
generated
vendored
7
libnetwork/vendor/github.com/vishvananda/netns/netns_linux_s390x.go
generated
vendored
|
@ -1,7 +0,0 @@
|
|||
// +build linux,s390x
|
||||
|
||||
package netns
|
||||
|
||||
const (
|
||||
SYS_SETNS = 339
|
||||
)
|
8
libnetwork/vendor/github.com/vishvananda/netns/netns_unspecified.go
generated
vendored
8
libnetwork/vendor/github.com/vishvananda/netns/netns_unspecified.go
generated
vendored
|
@ -22,6 +22,10 @@ func Get() (NsHandle, error) {
|
|||
return -1, ErrNotImplemented
|
||||
}
|
||||
|
||||
func GetFromPath(path string) (NsHandle, error) {
|
||||
return -1, ErrNotImplemented
|
||||
}
|
||||
|
||||
func GetFromName(name string) (NsHandle, error) {
|
||||
return -1, ErrNotImplemented
|
||||
}
|
||||
|
@ -30,6 +34,10 @@ func GetFromPid(pid int) (NsHandle, error) {
|
|||
return -1, ErrNotImplemented
|
||||
}
|
||||
|
||||
func GetFromThread(pid, tid int) (NsHandle, error) {
|
||||
return -1, ErrNotImplemented
|
||||
}
|
||||
|
||||
func GetFromDocker(id string) (NsHandle, error) {
|
||||
return -1, ErrNotImplemented
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue