Update vendoring (#1105)

* Update vendor github.com/sirupsen/logrus@v1.1.1
* Update vendor github.com/coreos/go-systemd/dbus@v17
* Update vendor github.com/golang/protobuf/proto@v1.2.0
* Update vendor github.com/konsorten/go-windows-terminal-sequences@v1.0.1
* Update vendor github.com/mdlayher/...
* Update vendor github.com/prometheus/procfs/...
* Update vendor golang.org/x/...

Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Ben Kochie 2018-10-11 18:41:41 +02:00 committed by GitHub
commit 9cf508e673
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
279 changed files with 54502 additions and 15108 deletions

View file

@ -50,8 +50,10 @@ func dial(family int, config *Config) (*conn, uint32, error) {
config = &Config{}
}
lockThread := !config.NoLockThread
sock := newSysSocket(lockThread)
sock, err := newSysSocket(config)
if err != nil {
return nil, 0, err
}
if err := sock.Socket(family); err != nil {
return nil, 0, err
@ -260,6 +262,32 @@ func (c *conn) SetOption(option ConnOption, enable bool) error {
)
}
// SetReadBuffer sets the size of the operating system's receive buffer
// associated with the Conn.
func (c *conn) SetReadBuffer(bytes int) error {
v := uint32(bytes)
return c.s.SetSockopt(
unix.SOL_SOCKET,
unix.SO_RCVBUF,
unsafe.Pointer(&v),
uint32(unsafe.Sizeof(v)),
)
}
// SetReadBuffer sets the size of the operating system's transmit buffer
// associated with the Conn.
func (c *conn) SetWriteBuffer(bytes int) error {
v := uint32(bytes)
return c.s.SetSockopt(
unix.SOL_SOCKET,
unix.SO_SNDBUF,
unsafe.Pointer(&v),
uint32(unsafe.Sizeof(v)),
)
}
// linuxOption converts a ConnOption to its Linux value.
func linuxOption(o ConnOption) (int, bool) {
switch o {
@ -299,11 +327,16 @@ type sysSocket struct {
wg *sync.WaitGroup
funcC chan<- func()
mu sync.RWMutex
done bool
doneC chan<- bool
}
// newSysSocket creates a sysSocket that optionally locks its internal goroutine
// to a single thread.
func newSysSocket(lockThread bool) *sysSocket {
func newSysSocket(config *Config) (*sysSocket, error) {
var wg sync.WaitGroup
wg.Add(1)
@ -312,52 +345,98 @@ func newSysSocket(lockThread bool) *sysSocket {
// Gophers Slack for providing this useful link.
funcC := make(chan func())
doneC := make(chan bool)
errC := make(chan error)
go func() {
// It is important to lock this goroutine to its OS thread for the duration
// of the netlink socket being used, or else the kernel may end up routing
// messages to the wrong places.
// See: http://lists.infradead.org/pipermail/libnl/2017-February/002293.html.
//
// But since this is very experimental, we'll leave it as a configurable at
// this point.
if lockThread {
// The intent is to never unlock the OS thread, so that the thread
// will terminate when the goroutine exits starting in Go 1.10:
// https://go-review.googlesource.com/c/go/+/46038.
//
// However, due to recent instability and a potential bad interaction
// with the Go runtime for threads which are not unlocked, we have
// elected to temporarily unlock the thread:
// https://github.com/golang/go/issues/25128#issuecomment-410764489.
//
// If we ever allow a Conn to set its own network namespace, we must
// either ensure that the namespace is restored on exit here or that
// the thread is properly terminated at some point in the future.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
}
// The intent is to never unlock the OS thread, so that the thread
// will terminate when the goroutine exits starting in Go 1.10:
// https://go-review.googlesource.com/c/go/+/46038.
//
// However, due to recent instability and a potential bad interaction
// with the Go runtime for threads which are not unlocked, we have
// elected to temporarily unlock the thread when the goroutine terminates:
// https://github.com/golang/go/issues/25128#issuecomment-410764489.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
defer wg.Done()
for f := range funcC {
f()
// The user requested the Conn to operate in a non-default network namespace.
if config.NetNS != 0 {
// Get the current namespace of the thread the goroutine is locked to.
origNetNS, err := getThreadNetNS()
if err != nil {
errC <- err
return
}
// Set the network namespace of the current thread using
// the file descriptor provided by the user.
err = setThreadNetNS(config.NetNS)
if err != nil {
errC <- err
return
}
// Once the thread's namespace has been successfully manipulated,
// make sure we change it back when the goroutine returns.
defer setThreadNetNS(origNetNS)
}
// Signal to caller that initialization was successful.
errC <- nil
for {
select {
case <-doneC:
return
case f := <-funcC:
f()
}
}
}()
// Wait for the goroutine to return err or nil.
if err := <-errC; err != nil {
return nil, err
}
return &sysSocket{
wg: &wg,
funcC: funcC,
}
doneC: doneC,
}, nil
}
// do runs f in a worker goroutine which can be locked to one thread.
func (s *sysSocket) do(f func()) {
func (s *sysSocket) do(f func()) error {
done := make(chan bool, 1)
// All operations handled by this function are assumed to only
// read from s.done.
s.mu.RLock()
if s.done {
s.mu.RUnlock()
return syscall.EBADF
}
s.funcC <- func() {
f()
done <- true
}
<-done
s.mu.RUnlock()
return nil
}
func (s *sysSocket) Socket(family int) error {
@ -366,13 +445,16 @@ func (s *sysSocket) Socket(family int) error {
err error
)
s.do(func() {
doErr := s.do(func() {
fd, err = unix.Socket(
unix.AF_NETLINK,
unix.SOCK_RAW,
family,
)
})
if doErr != nil {
return doErr
}
if err != nil {
return err
}
@ -383,21 +465,35 @@ func (s *sysSocket) Socket(family int) error {
func (s *sysSocket) Bind(sa unix.Sockaddr) error {
var err error
s.do(func() {
doErr := s.do(func() {
err = unix.Bind(s.fd, sa)
})
if doErr != nil {
return doErr
}
return err
}
func (s *sysSocket) Close() error {
var err error
s.do(func() {
err = unix.Close(s.fd)
})
close(s.funcC)
// Be sure to acquire a write lock because we need to stop any other
// goroutines from sending system call requests after close.
// Any invocation of do() after this write lock unlocks is guaranteed
// to find s.done being true.
s.mu.Lock()
defer s.mu.Unlock()
// Close the socket from the main thread, this operation has no risk
// of routing data to the wrong socket.
err := unix.Close(s.fd)
s.done = true
// Signal the syscall worker to exit, wait for the WaitGroup to join,
// and close the job channel only when the worker is guaranteed to have stopped.
close(s.doneC)
s.wg.Wait()
close(s.funcC)
return err
}
@ -410,12 +506,16 @@ func (s *sysSocket) Getsockname() (unix.Sockaddr, error) {
err error
)
s.do(func() {
doErr := s.do(func() {
sa, err = unix.Getsockname(s.fd)
})
if doErr != nil {
return nil, doErr
}
return sa, err
}
func (s *sysSocket) Recvmsg(p, oob []byte, flags int) (int, int, int, unix.Sockaddr, error) {
var (
n, oobn, recvflags int
@ -423,27 +523,36 @@ func (s *sysSocket) Recvmsg(p, oob []byte, flags int) (int, int, int, unix.Socka
err error
)
s.do(func() {
doErr := s.do(func() {
n, oobn, recvflags, from, err = unix.Recvmsg(s.fd, p, oob, flags)
})
if doErr != nil {
return 0, 0, 0, nil, doErr
}
return n, oobn, recvflags, from, err
}
func (s *sysSocket) Sendmsg(p, oob []byte, to unix.Sockaddr, flags int) error {
var err error
s.do(func() {
doErr := s.do(func() {
err = unix.Sendmsg(s.fd, p, oob, to, flags)
})
if doErr != nil {
return doErr
}
return err
}
func (s *sysSocket) SetSockopt(level, name int, v unsafe.Pointer, l uint32) error {
var err error
s.do(func() {
doErr := s.do(func() {
err = setsockopt(s.fd, level, name, v, l)
})
if doErr != nil {
return doErr
}
return err
}