vendor: github.com/vishvananda/netns v0.0.2
full diff: https://github.com/vishvananda/netns/compare/v0.0.1...v0.0.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit f53feeea8b
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
ebedb1c496
commit
13a31b67de
9 changed files with 79 additions and 26 deletions
|
@ -79,7 +79,7 @@ require (
|
|||
github.com/tonistiigi/go-archvariant v1.0.0
|
||||
github.com/vbatts/tar-split v0.11.2
|
||||
github.com/vishvananda/netlink v1.2.1-beta.2
|
||||
github.com/vishvananda/netns v0.0.1
|
||||
github.com/vishvananda/netns v0.0.2
|
||||
go.etcd.io/bbolt v1.3.6
|
||||
golang.org/x/net v0.4.0
|
||||
golang.org/x/sync v0.1.0
|
||||
|
|
|
@ -1071,8 +1071,8 @@ github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmF
|
|||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
|
||||
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
||||
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
||||
github.com/vishvananda/netns v0.0.1 h1:JDkWS7Axy5ziNM3svylLhpSgqjPDb+BgVUbXoDo+iPw=
|
||||
github.com/vishvananda/netns v0.0.1/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
||||
github.com/vishvananda/netns v0.0.2 h1:Cn05BRLm+iRP/DZxyVSsfVyrzgjDbwHwkVt38qvXnNI=
|
||||
github.com/vishvananda/netns v0.0.2/go.mod h1:yitZXdAVI+yPFSb4QUe+VW3vOVl4PZPNcBgbPxAtJxw=
|
||||
github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||
github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||
|
@ -1473,6 +1473,7 @@ golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
|
|
1
vendor/github.com/vishvananda/netns/README.md
generated
vendored
1
vendor/github.com/vishvananda/netns/README.md
generated
vendored
|
@ -23,6 +23,7 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
"runtime"
|
||||
|
||||
"github.com/vishvananda/netns"
|
||||
)
|
||||
|
||||
|
|
9
vendor/github.com/vishvananda/netns/doc.go
generated
vendored
Normal file
9
vendor/github.com/vishvananda/netns/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Package netns allows ultra-simple network namespace handling. NsHandles
|
||||
// can be retrieved and set. Note that the current namespace is thread
|
||||
// local so actions that set and reset namespaces should use LockOSThread
|
||||
// to make sure the namespace doesn't change due to a goroutine switch.
|
||||
// It is best to close NsHandles when you are done with them. This can be
|
||||
// accomplished via a `defer ns.Close()` on the handle. Changing namespaces
|
||||
// requires elevated privileges, so in most cases this code needs to be run
|
||||
// as root.
|
||||
package netns
|
26
vendor/github.com/vishvananda/netns/netns_linux.go
generated
vendored
26
vendor/github.com/vishvananda/netns/netns_linux.go
generated
vendored
|
@ -1,6 +1,3 @@
|
|||
//go:build linux && go1.10
|
||||
// +build linux,go1.10
|
||||
|
||||
package netns
|
||||
|
||||
import (
|
||||
|
@ -17,15 +14,16 @@ import (
|
|||
|
||||
// Deprecated: use golang.org/x/sys/unix pkg instead.
|
||||
const (
|
||||
CLONE_NEWUTS = 0x04000000 /* New utsname group? */
|
||||
CLONE_NEWIPC = 0x08000000 /* New ipcs */
|
||||
CLONE_NEWUSER = 0x10000000 /* New user namespace */
|
||||
CLONE_NEWPID = 0x20000000 /* New pid namespace */
|
||||
CLONE_NEWNET = 0x40000000 /* New network namespace */
|
||||
CLONE_IO = 0x80000000 /* Get io context */
|
||||
bindMountPath = "/run/netns" /* Bind mount path for named netns */
|
||||
CLONE_NEWUTS = unix.CLONE_NEWUTS /* New utsname group? */
|
||||
CLONE_NEWIPC = unix.CLONE_NEWIPC /* New ipcs */
|
||||
CLONE_NEWUSER = unix.CLONE_NEWUSER /* New user namespace */
|
||||
CLONE_NEWPID = unix.CLONE_NEWPID /* New pid namespace */
|
||||
CLONE_NEWNET = unix.CLONE_NEWNET /* New network namespace */
|
||||
CLONE_IO = unix.CLONE_IO /* Get io context */
|
||||
)
|
||||
|
||||
const bindMountPath = "/run/netns" /* Bind mount path for named netns */
|
||||
|
||||
// Setns sets namespace using golang.org/x/sys/unix.Setns.
|
||||
//
|
||||
// Deprecated: Use golang.org/x/sys/unix.Setns instead.
|
||||
|
@ -36,13 +34,13 @@ func Setns(ns NsHandle, nstype int) (err error) {
|
|||
// Set sets the current network namespace to the namespace represented
|
||||
// by NsHandle.
|
||||
func Set(ns NsHandle) (err error) {
|
||||
return Setns(ns, CLONE_NEWNET)
|
||||
return unix.Setns(int(ns), unix.CLONE_NEWNET)
|
||||
}
|
||||
|
||||
// New creates a new network namespace, sets it as current and returns
|
||||
// a handle to it.
|
||||
func New() (ns NsHandle, err error) {
|
||||
if err := unix.Unshare(CLONE_NEWNET); err != nil {
|
||||
if err := unix.Unshare(unix.CLONE_NEWNET); err != nil {
|
||||
return -1, err
|
||||
}
|
||||
return Get()
|
||||
|
@ -67,6 +65,7 @@ func NewNamed(name string) (NsHandle, error) {
|
|||
|
||||
f, err := os.OpenFile(namedPath, os.O_CREATE|os.O_EXCL, 0444)
|
||||
if err != nil {
|
||||
newNs.Close()
|
||||
return None(), err
|
||||
}
|
||||
f.Close()
|
||||
|
@ -74,6 +73,7 @@ func NewNamed(name string) (NsHandle, error) {
|
|||
nsPath := fmt.Sprintf("/proc/%d/task/%d/ns/net", os.Getpid(), unix.Gettid())
|
||||
err = unix.Mount(nsPath, namedPath, "bind", unix.MS_BIND, "")
|
||||
if err != nil {
|
||||
newNs.Close()
|
||||
return None(), err
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,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.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
//go:build !linux
|
||||
// +build !linux
|
||||
|
||||
package netns
|
||||
|
@ -10,6 +11,10 @@ var (
|
|||
ErrNotImplemented = errors.New("not implemented")
|
||||
)
|
||||
|
||||
// Setns sets namespace using golang.org/x/sys/unix.Setns on Linux. It
|
||||
// is not implemented on other platforms.
|
||||
//
|
||||
// Deprecated: Use golang.org/x/sys/unix.Setns instead.
|
||||
func Setns(ns NsHandle, nstype int) (err error) {
|
||||
return ErrNotImplemented
|
||||
}
|
|
@ -1,11 +1,3 @@
|
|||
// Package netns allows ultra-simple network namespace handling. NsHandles
|
||||
// can be retrieved and set. Note that the current namespace is thread
|
||||
// local so actions that set and reset namespaces should use LockOSThread
|
||||
// to make sure the namespace doesn't change due to a goroutine switch.
|
||||
// It is best to close NsHandles when you are done with them. This can be
|
||||
// accomplished via a `defer ns.Close()` on the handle. Changing namespaces
|
||||
// requires elevated privileges, so in most cases this code needs to be run
|
||||
// as root.
|
||||
package netns
|
||||
|
||||
import (
|
||||
|
@ -71,7 +63,7 @@ func (ns *NsHandle) Close() error {
|
|||
if err := unix.Close(int(*ns)); err != nil {
|
||||
return err
|
||||
}
|
||||
(*ns) = -1
|
||||
*ns = -1
|
||||
return nil
|
||||
}
|
||||
|
45
vendor/github.com/vishvananda/netns/nshandle_others.go
generated
vendored
Normal file
45
vendor/github.com/vishvananda/netns/nshandle_others.go
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
//go:build !linux
|
||||
// +build !linux
|
||||
|
||||
package netns
|
||||
|
||||
// NsHandle is a handle to a network namespace. It can only be used on Linux,
|
||||
// but provides stub methods on other platforms.
|
||||
type NsHandle int
|
||||
|
||||
// Equal determines if two network handles refer to the same network
|
||||
// namespace. It is only implemented on Linux.
|
||||
func (ns NsHandle) Equal(_ NsHandle) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// String shows the file descriptor number and its dev and inode.
|
||||
// It is only implemented on Linux, and returns "NS(none)" on other
|
||||
// platforms.
|
||||
func (ns NsHandle) String() string {
|
||||
return "NS(None)"
|
||||
}
|
||||
|
||||
// UniqueId returns a string which uniquely identifies the namespace
|
||||
// associated with the network handle. It is only implemented on Linux,
|
||||
// and returns "NS(none)" on other platforms.
|
||||
func (ns NsHandle) UniqueId() string {
|
||||
return "NS(none)"
|
||||
}
|
||||
|
||||
// IsOpen returns true if Close() has not been called. It is only implemented
|
||||
// on Linux and always returns false on other platforms.
|
||||
func (ns NsHandle) IsOpen() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Close closes the NsHandle and resets its file descriptor to -1.
|
||||
// It is only implemented on Linux.
|
||||
func (ns *NsHandle) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// None gets an empty (closed) NsHandle.
|
||||
func None() NsHandle {
|
||||
return NsHandle(-1)
|
||||
}
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -797,7 +797,7 @@ github.com/vbatts/tar-split/tar/storage
|
|||
## explicit; go 1.12
|
||||
github.com/vishvananda/netlink
|
||||
github.com/vishvananda/netlink/nl
|
||||
# github.com/vishvananda/netns v0.0.1
|
||||
# github.com/vishvananda/netns v0.0.2
|
||||
## explicit; go 1.12
|
||||
github.com/vishvananda/netns
|
||||
# go.etcd.io/bbolt v1.3.6
|
||||
|
|
Loading…
Reference in a new issue