vendor folder bump.
This commit is contained in:
51
vendor/github.com/vishvananda/netlink/handle_linux.go
generated
vendored
51
vendor/github.com/vishvananda/netlink/handle_linux.go
generated
vendored
@ -2,11 +2,11 @@ package netlink
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/vishvananda/netns"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// Empty handle used by the netlink package methods
|
||||
@ -43,14 +43,29 @@ func (h *Handle) SetSocketTimeout(to time.Duration) error {
|
||||
if to < time.Microsecond {
|
||||
return fmt.Errorf("invalid timeout, minimul value is %s", time.Microsecond)
|
||||
}
|
||||
tv := syscall.NsecToTimeval(to.Nanoseconds())
|
||||
tv := unix.NsecToTimeval(to.Nanoseconds())
|
||||
for _, sh := range h.sockets {
|
||||
fd := sh.Socket.GetFd()
|
||||
err := syscall.SetsockoptTimeval(fd, syscall.SOL_SOCKET, syscall.SO_RCVTIMEO, &tv)
|
||||
if err != nil {
|
||||
if err := sh.Socket.SetSendTimeout(&tv); err != nil {
|
||||
return err
|
||||
}
|
||||
err = syscall.SetsockoptTimeval(fd, syscall.SOL_SOCKET, syscall.SO_SNDTIMEO, &tv)
|
||||
if err := sh.Socket.SetReceiveTimeout(&tv); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetSocketReceiveBufferSize sets the receive buffer size for each
|
||||
// socket in the netlink handle. The maximum value is capped by
|
||||
// /proc/sys/net/core/rmem_max.
|
||||
func (h *Handle) SetSocketReceiveBufferSize(size int, force bool) error {
|
||||
opt := unix.SO_RCVBUF
|
||||
if force {
|
||||
opt = unix.SO_RCVBUFFORCE
|
||||
}
|
||||
for _, sh := range h.sockets {
|
||||
fd := sh.Socket.GetFd()
|
||||
err := unix.SetsockoptInt(fd, unix.SOL_SOCKET, opt, size)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -58,6 +73,24 @@ func (h *Handle) SetSocketTimeout(to time.Duration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSocketReceiveBufferSize gets the receiver buffer size for each
|
||||
// socket in the netlink handle. The retrieved value should be the
|
||||
// double to the one set for SetSocketReceiveBufferSize.
|
||||
func (h *Handle) GetSocketReceiveBufferSize() ([]int, error) {
|
||||
results := make([]int, len(h.sockets))
|
||||
i := 0
|
||||
for _, sh := range h.sockets {
|
||||
fd := sh.Socket.GetFd()
|
||||
size, err := unix.GetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_RCVBUF)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
results[i] = size
|
||||
i++
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
||||
// NewHandle returns a netlink handle on the network namespace
|
||||
// specified by ns. If ns=netns.None(), current network namespace
|
||||
// will be assumed
|
||||
@ -101,10 +134,10 @@ func (h *Handle) newNetlinkRequest(proto, flags int) *nl.NetlinkRequest {
|
||||
return nl.NewNetlinkRequest(proto, flags)
|
||||
}
|
||||
return &nl.NetlinkRequest{
|
||||
NlMsghdr: syscall.NlMsghdr{
|
||||
Len: uint32(syscall.SizeofNlMsghdr),
|
||||
NlMsghdr: unix.NlMsghdr{
|
||||
Len: uint32(unix.SizeofNlMsghdr),
|
||||
Type: uint16(proto),
|
||||
Flags: syscall.NLM_F_REQUEST | uint16(flags),
|
||||
Flags: unix.NLM_F_REQUEST | uint16(flags),
|
||||
},
|
||||
Sockets: h.sockets,
|
||||
}
|
||||
|
Reference in New Issue
Block a user