From bbca2594f5f60085ee5e14e27c65de6ff35be5ea Mon Sep 17 00:00:00 2001 From: Andrew Sy Kim Date: Mon, 7 Oct 2019 13:33:33 -0400 Subject: [PATCH] update github.com/docker/libnetwork to f0e46a7 - which bumps it's dependency to github.com/vishvananda/netlink to v1.0.0 Signed-off-by: Andrew Sy Kim Co-authored-by: Moriadry --- go.mod | 4 +- go.sum | 4 +- .../github.com/docker/libnetwork/ipvs/BUILD | 2 + .../docker/libnetwork/ipvs/constants.go | 20 ++++++ .../github.com/docker/libnetwork/ipvs/ipvs.go | 34 ++++++++--- .../docker/libnetwork/ipvs/netlink.go | 61 +++++++++++++++++++ vendor/modules.txt | 2 +- 7 files changed, 115 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 1392dd5b40a..2a9096fdcaa 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ require ( github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0 github.com/docker/go-connections v0.3.0 github.com/docker/go-units v0.3.3 - github.com/docker/libnetwork v0.0.0-20180830151422-a9cd636e3789 + github.com/docker/libnetwork v0.8.0-dev.2.0.20190624125649-f0e46a78ea34 github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e github.com/emicklei/go-restful v2.9.5+incompatible github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect @@ -244,7 +244,7 @@ replace ( github.com/docker/docker => github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0 github.com/docker/go-connections => github.com/docker/go-connections v0.3.0 github.com/docker/go-units => github.com/docker/go-units v0.3.3 - github.com/docker/libnetwork => github.com/docker/libnetwork v0.0.0-20180830151422-a9cd636e3789 + github.com/docker/libnetwork => github.com/docker/libnetwork v0.8.0-dev.2.0.20190624125649-f0e46a78ea34 github.com/docker/spdystream => github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 github.com/dustin/go-humanize => github.com/dustin/go-humanize v1.0.0 github.com/elazarl/goproxy => github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e diff --git a/go.sum b/go.sum index c07fed8d267..8e9ac77b150 100644 --- a/go.sum +++ b/go.sum @@ -135,8 +135,8 @@ github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/docker/libnetwork v0.0.0-20180830151422-a9cd636e3789 h1:8rOK787QQFFZJcOLXPiKKidY/ie2OQpblM5gEAaenPs= -github.com/docker/libnetwork v0.0.0-20180830151422-a9cd636e3789/go.mod h1:93m0aTqz6z+g32wla4l4WxTrdtvBRmVzYRkYvasA5Z8= +github.com/docker/libnetwork v0.8.0-dev.2.0.20190624125649-f0e46a78ea34 h1:8GFZB1KesbMy2X2zTiJyAuwCow+U1GT0ueD42p59y4k= +github.com/docker/libnetwork v0.8.0-dev.2.0.20190624125649-f0e46a78ea34/go.mod h1:93m0aTqz6z+g32wla4l4WxTrdtvBRmVzYRkYvasA5Z8= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 h1:cenwrSVm+Z7QLSV/BsnenAOcDXdX4cMv4wP0B/5QbPg= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= diff --git a/vendor/github.com/docker/libnetwork/ipvs/BUILD b/vendor/github.com/docker/libnetwork/ipvs/BUILD index f4bf1b785ea..0df884b9a46 100644 --- a/vendor/github.com/docker/libnetwork/ipvs/BUILD +++ b/vendor/github.com/docker/libnetwork/ipvs/BUILD @@ -15,11 +15,13 @@ go_library( "//vendor/github.com/sirupsen/logrus:go_default_library", "//vendor/github.com/vishvananda/netlink/nl:go_default_library", "//vendor/github.com/vishvananda/netns:go_default_library", + "//vendor/golang.org/x/sys/unix:go_default_library", ], "@io_bazel_rules_go//go/platform:linux": [ "//vendor/github.com/sirupsen/logrus:go_default_library", "//vendor/github.com/vishvananda/netlink/nl:go_default_library", "//vendor/github.com/vishvananda/netns:go_default_library", + "//vendor/golang.org/x/sys/unix:go_default_library", ], "//conditions:default": [], }), diff --git a/vendor/github.com/docker/libnetwork/ipvs/constants.go b/vendor/github.com/docker/libnetwork/ipvs/constants.go index d36bec0e800..b6b7f2bb5e3 100644 --- a/vendor/github.com/docker/libnetwork/ipvs/constants.go +++ b/vendor/github.com/docker/libnetwork/ipvs/constants.go @@ -145,3 +145,23 @@ const ( // addresses. SourceHashing = "sh" ) + +const ( + // ConnFwdMask is a mask for the fwd methods + ConnFwdMask = 0x0007 + + // ConnFwdMasq denotes forwarding via masquerading/NAT + ConnFwdMasq = 0x0000 + + // ConnFwdLocalNode denotes forwarding to a local node + ConnFwdLocalNode = 0x0001 + + // ConnFwdTunnel denotes forwarding via a tunnel + ConnFwdTunnel = 0x0002 + + // ConnFwdDirectRoute denotes forwarding via direct routing + ConnFwdDirectRoute = 0x0003 + + // ConnFwdBypass denotes forwarding while bypassing the cache + ConnFwdBypass = 0x0004 +) diff --git a/vendor/github.com/docker/libnetwork/ipvs/ipvs.go b/vendor/github.com/docker/libnetwork/ipvs/ipvs.go index ab10717089e..61b6f0a5e4e 100644 --- a/vendor/github.com/docker/libnetwork/ipvs/ipvs.go +++ b/vendor/github.com/docker/libnetwork/ipvs/ipvs.go @@ -3,14 +3,13 @@ package ipvs import ( - "net" - "syscall" - "time" - "fmt" + "net" + "time" "github.com/vishvananda/netlink/nl" "github.com/vishvananda/netns" + "golang.org/x/sys/unix" ) const ( @@ -62,6 +61,17 @@ type Destination struct { LowerThreshold uint32 ActiveConnections int InactiveConnections int + Stats DstStats +} + +// DstStats defines IPVS destination (real server) statistics +type DstStats SvcStats + +// Config defines IPVS timeout configuration +type Config struct { + TimeoutTCP time.Duration + TimeoutTCPFin time.Duration + TimeoutUDP time.Duration } // Handle provides a namespace specific ipvs handle to program ipvs @@ -87,16 +97,16 @@ func New(path string) (*Handle, error) { } defer n.Close() - sock, err := nl.GetNetlinkSocketAt(n, netns.None(), syscall.NETLINK_GENERIC) + sock, err := nl.GetNetlinkSocketAt(n, netns.None(), unix.NETLINK_GENERIC) if err != nil { return nil, err } // Add operation timeout to avoid deadlocks - tv := syscall.NsecToTimeval(netlinkSendSocketTimeout.Nanoseconds()) + tv := unix.NsecToTimeval(netlinkSendSocketTimeout.Nanoseconds()) if err := sock.SetSendTimeout(&tv); err != nil { return nil, err } - tv = syscall.NsecToTimeval(netlinkRecvSocketsTimeout.Nanoseconds()) + tv = unix.NsecToTimeval(netlinkRecvSocketsTimeout.Nanoseconds()) if err := sock.SetReceiveTimeout(&tv); err != nil { return nil, err } @@ -184,3 +194,13 @@ func (i *Handle) GetService(s *Service) (*Service, error) { return res[0], nil } + +// GetConfig returns the current timeout configuration +func (i *Handle) GetConfig() (*Config, error) { + return i.doGetConfigCmd() +} + +// SetConfig set the current timeout configuration. 0: no change +func (i *Handle) SetConfig(c *Config) error { + return i.doSetConfigCmd(c) +} diff --git a/vendor/github.com/docker/libnetwork/ipvs/netlink.go b/vendor/github.com/docker/libnetwork/ipvs/netlink.go index 3c7b1a562ae..083909ae050 100644 --- a/vendor/github.com/docker/libnetwork/ipvs/netlink.go +++ b/vendor/github.com/docker/libnetwork/ipvs/netlink.go @@ -12,6 +12,7 @@ import ( "sync" "sync/atomic" "syscall" + "time" "unsafe" "github.com/sirupsen/logrus" @@ -443,6 +444,12 @@ func assembleDestination(attrs []syscall.NetlinkRouteAttr) (*Destination, error) d.ActiveConnections = int(native.Uint16(attr.Value)) case ipvsDestAttrInactiveConnections: d.InactiveConnections = int(native.Uint16(attr.Value)) + case ipvsSvcAttrStats: + stats, err := assembleStats(attr.Value) + if err != nil { + return nil, err + } + d.Stats = DstStats(stats) } } return &d, nil @@ -497,6 +504,60 @@ func (i *Handle) doGetDestinationsCmd(s *Service, d *Destination) ([]*Destinatio return res, nil } +// parseConfig given a ipvs netlink response this function will respond with a valid config entry, an error otherwise +func (i *Handle) parseConfig(msg []byte) (*Config, error) { + var c Config + + //Remove General header for this message + hdr := deserializeGenlMsg(msg) + attrs, err := nl.ParseRouteAttr(msg[hdr.Len():]) + if err != nil { + return nil, err + } + + for _, attr := range attrs { + attrType := int(attr.Attr.Type) + switch attrType { + case ipvsCmdAttrTimeoutTCP: + c.TimeoutTCP = time.Duration(native.Uint32(attr.Value)) * time.Second + case ipvsCmdAttrTimeoutTCPFin: + c.TimeoutTCPFin = time.Duration(native.Uint32(attr.Value)) * time.Second + case ipvsCmdAttrTimeoutUDP: + c.TimeoutUDP = time.Duration(native.Uint32(attr.Value)) * time.Second + } + } + + return &c, nil +} + +// doGetConfigCmd a wrapper function to be used by GetConfig +func (i *Handle) doGetConfigCmd() (*Config, error) { + msg, err := i.doCmdWithoutAttr(ipvsCmdGetConfig) + if err != nil { + return nil, err + } + + res, err := i.parseConfig(msg[0]) + if err != nil { + return res, err + } + return res, nil +} + +// doSetConfigCmd a wrapper function to be used by SetConfig +func (i *Handle) doSetConfigCmd(c *Config) error { + req := newIPVSRequest(ipvsCmdSetConfig) + req.Seq = atomic.AddUint32(&i.seq, 1) + + req.AddData(nl.NewRtAttr(ipvsCmdAttrTimeoutTCP, nl.Uint32Attr(uint32(c.TimeoutTCP.Seconds())))) + req.AddData(nl.NewRtAttr(ipvsCmdAttrTimeoutTCPFin, nl.Uint32Attr(uint32(c.TimeoutTCPFin.Seconds())))) + req.AddData(nl.NewRtAttr(ipvsCmdAttrTimeoutUDP, nl.Uint32Attr(uint32(c.TimeoutUDP.Seconds())))) + + _, err := execute(i.sock, req, 0) + + return err +} + // IPVS related netlink message format explained /* EACH NETLINK MSG is of the below format, this is what we will receive from execute() api. diff --git a/vendor/modules.txt b/vendor/modules.txt index 4f8d132c34d..f89fc276a13 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -238,7 +238,7 @@ github.com/docker/go-connections/sockets github.com/docker/go-connections/tlsconfig # github.com/docker/go-units v0.3.3 => github.com/docker/go-units v0.3.3 github.com/docker/go-units -# github.com/docker/libnetwork v0.0.0-20180830151422-a9cd636e3789 => github.com/docker/libnetwork v0.0.0-20180830151422-a9cd636e3789 +# github.com/docker/libnetwork v0.8.0-dev.2.0.20190624125649-f0e46a78ea34 => github.com/docker/libnetwork v0.8.0-dev.2.0.20190624125649-f0e46a78ea34 github.com/docker/libnetwork/ipvs # github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 => github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 github.com/docker/spdystream