mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #128390 from aroradaman/netlink-bump
bump: github.com/vishvananda/netlink
This commit is contained in:
commit
78fed9dbcd
2
go.mod
2
go.mod
@ -60,7 +60,7 @@ require (
|
|||||||
github.com/spf13/cobra v1.8.1
|
github.com/spf13/cobra v1.8.1
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
github.com/vishvananda/netlink v1.3.0
|
github.com/vishvananda/netlink v1.3.1-0.20240905180732-b1ce50cfa9be
|
||||||
github.com/vishvananda/netns v0.0.4
|
github.com/vishvananda/netns v0.0.4
|
||||||
go.etcd.io/etcd/api/v3 v3.5.16
|
go.etcd.io/etcd/api/v3 v3.5.16
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.16
|
go.etcd.io/etcd/client/pkg/v3 v3.5.16
|
||||||
|
4
go.sum
4
go.sum
@ -497,8 +497,8 @@ github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG
|
|||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE=
|
||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75/go.mod h1:KO6IkyS8Y3j8OdNO85qEYBsRPuteD+YciPomcXdrMnk=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75/go.mod h1:KO6IkyS8Y3j8OdNO85qEYBsRPuteD+YciPomcXdrMnk=
|
||||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||||
github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQdrZk=
|
github.com/vishvananda/netlink v1.3.1-0.20240905180732-b1ce50cfa9be h1:xdCMvyhnKzaepIUgVpUmTJo/+H1AQ7HuFYn1hv7/Neo=
|
||||||
github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs=
|
github.com/vishvananda/netlink v1.3.1-0.20240905180732-b1ce50cfa9be/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs=
|
||||||
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
|
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
|
||||||
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
|
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
|
||||||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||||
|
18
vendor/github.com/vishvananda/netlink/conntrack_linux.go
generated
vendored
18
vendor/github.com/vishvananda/netlink/conntrack_linux.go
generated
vendored
@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/vishvananda/netlink/nl"
|
"github.com/vishvananda/netlink/nl"
|
||||||
@ -70,7 +71,7 @@ func ConntrackUpdate(table ConntrackTableType, family InetFamily, flow *Conntrac
|
|||||||
// ConntrackDeleteFilter deletes entries on the specified table on the base of the filter
|
// ConntrackDeleteFilter deletes entries on the specified table on the base of the filter
|
||||||
// conntrack -D [table] parameters Delete conntrack or expectation
|
// conntrack -D [table] parameters Delete conntrack or expectation
|
||||||
//
|
//
|
||||||
// Deprecated: use [ConntrackDeleteFilter] instead.
|
// Deprecated: use [ConntrackDeleteFilters] instead.
|
||||||
func ConntrackDeleteFilter(table ConntrackTableType, family InetFamily, filter CustomConntrackFilter) (uint, error) {
|
func ConntrackDeleteFilter(table ConntrackTableType, family InetFamily, filter CustomConntrackFilter) (uint, error) {
|
||||||
return pkgHandle.ConntrackDeleteFilters(table, family, filter)
|
return pkgHandle.ConntrackDeleteFilters(table, family, filter)
|
||||||
}
|
}
|
||||||
@ -158,6 +159,7 @@ func (h *Handle) ConntrackDeleteFilters(table ConntrackTableType, family InetFam
|
|||||||
}
|
}
|
||||||
|
|
||||||
var matched uint
|
var matched uint
|
||||||
|
var errMsgs []string
|
||||||
for _, dataRaw := range res {
|
for _, dataRaw := range res {
|
||||||
flow := parseRawData(dataRaw)
|
flow := parseRawData(dataRaw)
|
||||||
for _, filter := range filters {
|
for _, filter := range filters {
|
||||||
@ -165,14 +167,18 @@ func (h *Handle) ConntrackDeleteFilters(table ConntrackTableType, family InetFam
|
|||||||
req2 := h.newConntrackRequest(table, family, nl.IPCTNL_MSG_CT_DELETE, unix.NLM_F_ACK)
|
req2 := h.newConntrackRequest(table, family, nl.IPCTNL_MSG_CT_DELETE, unix.NLM_F_ACK)
|
||||||
// skip the first 4 byte that are the netfilter header, the newConntrackRequest is adding it already
|
// skip the first 4 byte that are the netfilter header, the newConntrackRequest is adding it already
|
||||||
req2.AddRawData(dataRaw[4:])
|
req2.AddRawData(dataRaw[4:])
|
||||||
req2.Execute(unix.NETLINK_NETFILTER, 0)
|
if _, err = req2.Execute(unix.NETLINK_NETFILTER, 0); err == nil {
|
||||||
matched++
|
matched++
|
||||||
// flow is already deleted, no need to match on other filters and continue to the next flow.
|
// flow is already deleted, no need to match on other filters and continue to the next flow.
|
||||||
break
|
break
|
||||||
|
}
|
||||||
|
errMsgs = append(errMsgs, fmt.Sprintf("failed to delete conntrack flow '%s': %s", flow.String(), err.Error()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(errMsgs) > 0 {
|
||||||
|
return matched, fmt.Errorf(strings.Join(errMsgs, "; "))
|
||||||
|
}
|
||||||
return matched, nil
|
return matched, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
vendor/github.com/vishvananda/netlink/conntrack_unspecified.go
generated
vendored
2
vendor/github.com/vishvananda/netlink/conntrack_unspecified.go
generated
vendored
@ -33,7 +33,7 @@ func ConntrackTableFlush(table ConntrackTableType) error {
|
|||||||
// ConntrackDeleteFilter deletes entries on the specified table on the base of the filter
|
// ConntrackDeleteFilter deletes entries on the specified table on the base of the filter
|
||||||
// conntrack -D [table] parameters Delete conntrack or expectation
|
// conntrack -D [table] parameters Delete conntrack or expectation
|
||||||
//
|
//
|
||||||
// Deprecated: use [ConntrackDeleteFilter] instead.
|
// Deprecated: use [ConntrackDeleteFilters] instead.
|
||||||
func ConntrackDeleteFilter(table ConntrackTableType, family InetFamily, filter *ConntrackFilter) (uint, error) {
|
func ConntrackDeleteFilter(table ConntrackTableType, family InetFamily, filter *ConntrackFilter) (uint, error) {
|
||||||
return 0, ErrNotImplemented
|
return 0, ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
8
vendor/github.com/vishvananda/netlink/filter_linux.go
generated
vendored
8
vendor/github.com/vishvananda/netlink/filter_linux.go
generated
vendored
@ -920,9 +920,11 @@ func parseActions(tables []syscall.NetlinkRouteAttr) ([]Action, error) {
|
|||||||
actionnStatistic = (*ActionStatistic)(s)
|
actionnStatistic = (*ActionStatistic)(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
action.Attrs().Statistics = actionnStatistic
|
if action != nil {
|
||||||
action.Attrs().Timestamp = actionTimestamp
|
action.Attrs().Statistics = actionnStatistic
|
||||||
actions = append(actions, action)
|
action.Attrs().Timestamp = actionTimestamp
|
||||||
|
actions = append(actions, action)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return actions, nil
|
return actions, nil
|
||||||
}
|
}
|
||||||
|
73
vendor/github.com/vishvananda/netlink/nl/nl_linux.go
generated
vendored
73
vendor/github.com/vishvananda/netlink/nl/nl_linux.go
generated
vendored
@ -4,6 +4,7 @@ package nl
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
@ -11,6 +12,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/vishvananda/netns"
|
"github.com/vishvananda/netns"
|
||||||
@ -656,9 +658,11 @@ func NewNetlinkRequest(proto, flags int) *NetlinkRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type NetlinkSocket struct {
|
type NetlinkSocket struct {
|
||||||
fd int32
|
fd int32
|
||||||
file *os.File
|
file *os.File
|
||||||
lsa unix.SockaddrNetlink
|
lsa unix.SockaddrNetlink
|
||||||
|
sendTimeout int64 // Access using atomic.Load/StoreInt64
|
||||||
|
receiveTimeout int64 // Access using atomic.Load/StoreInt64
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -802,8 +806,44 @@ func (s *NetlinkSocket) GetFd() int {
|
|||||||
return int(s.fd)
|
return int(s.fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *NetlinkSocket) GetTimeouts() (send, receive time.Duration) {
|
||||||
|
return time.Duration(atomic.LoadInt64(&s.sendTimeout)),
|
||||||
|
time.Duration(atomic.LoadInt64(&s.receiveTimeout))
|
||||||
|
}
|
||||||
|
|
||||||
func (s *NetlinkSocket) Send(request *NetlinkRequest) error {
|
func (s *NetlinkSocket) Send(request *NetlinkRequest) error {
|
||||||
return unix.Sendto(int(s.fd), request.Serialize(), 0, &s.lsa)
|
rawConn, err := s.file.SyscallConn()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var (
|
||||||
|
deadline time.Time
|
||||||
|
innerErr error
|
||||||
|
)
|
||||||
|
sendTimeout := atomic.LoadInt64(&s.sendTimeout)
|
||||||
|
if sendTimeout != 0 {
|
||||||
|
deadline = time.Now().Add(time.Duration(sendTimeout))
|
||||||
|
}
|
||||||
|
if err := s.file.SetWriteDeadline(deadline); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
serializedReq := request.Serialize()
|
||||||
|
err = rawConn.Write(func(fd uintptr) (done bool) {
|
||||||
|
innerErr = unix.Sendto(int(s.fd), serializedReq, 0, &s.lsa)
|
||||||
|
return innerErr != unix.EWOULDBLOCK
|
||||||
|
})
|
||||||
|
if innerErr != nil {
|
||||||
|
return innerErr
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
// The timeout was previously implemented using SO_SNDTIMEO on a blocking
|
||||||
|
// socket. So, continue to return EAGAIN when the timeout is reached.
|
||||||
|
if errors.Is(err, os.ErrDeadlineExceeded) {
|
||||||
|
return unix.EAGAIN
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, *unix.SockaddrNetlink, error) {
|
func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, *unix.SockaddrNetlink, error) {
|
||||||
@ -812,20 +852,33 @@ func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, *unix.SockaddrNetli
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
|
deadline time.Time
|
||||||
fromAddr *unix.SockaddrNetlink
|
fromAddr *unix.SockaddrNetlink
|
||||||
rb [RECEIVE_BUFFER_SIZE]byte
|
rb [RECEIVE_BUFFER_SIZE]byte
|
||||||
nr int
|
nr int
|
||||||
from unix.Sockaddr
|
from unix.Sockaddr
|
||||||
innerErr error
|
innerErr error
|
||||||
)
|
)
|
||||||
|
receiveTimeout := atomic.LoadInt64(&s.receiveTimeout)
|
||||||
|
if receiveTimeout != 0 {
|
||||||
|
deadline = time.Now().Add(time.Duration(receiveTimeout))
|
||||||
|
}
|
||||||
|
if err := s.file.SetReadDeadline(deadline); err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
err = rawConn.Read(func(fd uintptr) (done bool) {
|
err = rawConn.Read(func(fd uintptr) (done bool) {
|
||||||
nr, from, innerErr = unix.Recvfrom(int(fd), rb[:], 0)
|
nr, from, innerErr = unix.Recvfrom(int(fd), rb[:], 0)
|
||||||
return innerErr != unix.EWOULDBLOCK
|
return innerErr != unix.EWOULDBLOCK
|
||||||
})
|
})
|
||||||
if innerErr != nil {
|
if innerErr != nil {
|
||||||
err = innerErr
|
return nil, nil, innerErr
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// The timeout was previously implemented using SO_RCVTIMEO on a blocking
|
||||||
|
// socket. So, continue to return EAGAIN when the timeout is reached.
|
||||||
|
if errors.Is(err, os.ErrDeadlineExceeded) {
|
||||||
|
return nil, nil, unix.EAGAIN
|
||||||
|
}
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
fromAddr, ok := from.(*unix.SockaddrNetlink)
|
fromAddr, ok := from.(*unix.SockaddrNetlink)
|
||||||
@ -847,16 +900,14 @@ func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, *unix.SockaddrNetli
|
|||||||
|
|
||||||
// SetSendTimeout allows to set a send timeout on the socket
|
// SetSendTimeout allows to set a send timeout on the socket
|
||||||
func (s *NetlinkSocket) SetSendTimeout(timeout *unix.Timeval) error {
|
func (s *NetlinkSocket) SetSendTimeout(timeout *unix.Timeval) error {
|
||||||
// Set a send timeout of SOCKET_SEND_TIMEOUT, this will allow the Send to periodically unblock and avoid that a routine
|
atomic.StoreInt64(&s.sendTimeout, timeout.Nano())
|
||||||
// remains stuck on a send on a closed fd
|
return nil
|
||||||
return unix.SetsockoptTimeval(int(s.fd), unix.SOL_SOCKET, unix.SO_SNDTIMEO, timeout)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetReceiveTimeout allows to set a receive timeout on the socket
|
// SetReceiveTimeout allows to set a receive timeout on the socket
|
||||||
func (s *NetlinkSocket) SetReceiveTimeout(timeout *unix.Timeval) error {
|
func (s *NetlinkSocket) SetReceiveTimeout(timeout *unix.Timeval) error {
|
||||||
// Set a read timeout of SOCKET_READ_TIMEOUT, this will allow the Read to periodically unblock and avoid that a routine
|
atomic.StoreInt64(&s.receiveTimeout, timeout.Nano())
|
||||||
// remains stuck on a recvmsg on a closed fd
|
return nil
|
||||||
return unix.SetsockoptTimeval(int(s.fd), unix.SOL_SOCKET, unix.SO_RCVTIMEO, timeout)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetReceiveBufferSize allows to set a receive buffer size on the socket
|
// SetReceiveBufferSize allows to set a receive buffer size on the socket
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -597,7 +597,7 @@ github.com/syndtr/gocapability/capability
|
|||||||
# github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75
|
# github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75
|
||||||
## explicit; go 1.15
|
## explicit; go 1.15
|
||||||
github.com/tmc/grpc-websocket-proxy/wsproxy
|
github.com/tmc/grpc-websocket-proxy/wsproxy
|
||||||
# github.com/vishvananda/netlink v1.3.0
|
# github.com/vishvananda/netlink v1.3.1-0.20240905180732-b1ce50cfa9be
|
||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
github.com/vishvananda/netlink
|
github.com/vishvananda/netlink
|
||||||
github.com/vishvananda/netlink/nl
|
github.com/vishvananda/netlink/nl
|
||||||
|
Loading…
Reference in New Issue
Block a user