mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Set a timeout on the netlink handle sockets
Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
c3e00a2611
commit
763f0fa1da
4 changed files with 28 additions and 0 deletions
|
@ -320,6 +320,11 @@ func populateVNITbl() {
|
|||
}
|
||||
defer nlh.Delete()
|
||||
|
||||
err = nlh.SetSocketTimeout(soTimeout)
|
||||
if err != nil {
|
||||
logrus.Warnf("Failed to set the timeout on the netlink handle sockets for vni table population: %v", err)
|
||||
}
|
||||
|
||||
links, err := nlh.LinkList()
|
||||
if err != nil {
|
||||
logrus.Errorf("Failed to list interfaces during vni population for ns %s: %v", path, err)
|
||||
|
|
|
@ -13,6 +13,8 @@ import (
|
|||
"github.com/vishvananda/netns"
|
||||
)
|
||||
|
||||
var soTimeout = ns.NetlinkSocketsTimeout
|
||||
|
||||
func validateID(nid, eid string) error {
|
||||
if nid == "" {
|
||||
return fmt.Errorf("invalid network id")
|
||||
|
@ -134,6 +136,10 @@ func deleteVxlanByVNI(path string, vni uint32) error {
|
|||
return fmt.Errorf("failed to get netlink handle for ns %s: %v", path, err)
|
||||
}
|
||||
defer nlh.Delete()
|
||||
err = nlh.SetSocketTimeout(soTimeout)
|
||||
if err != nil {
|
||||
logrus.Warnf("Failed to set the timeout on the netlink handle sockets for vxlan deletion: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
links, err := nlh.LinkList()
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/vishvananda/netlink"
|
||||
|
@ -17,6 +18,8 @@ var (
|
|||
initNs netns.NsHandle
|
||||
initNl *netlink.Handle
|
||||
initOnce sync.Once
|
||||
// NetlinkSocketsTimeout represents the default timeout duration for the sockets
|
||||
NetlinkSocketsTimeout = 3 * time.Second
|
||||
)
|
||||
|
||||
// Init initializes a new network namespace
|
||||
|
@ -30,6 +33,10 @@ func Init() {
|
|||
if err != nil {
|
||||
logrus.Errorf("could not create netlink handle on initial namespace: %v", err)
|
||||
}
|
||||
err = initNl.SetSocketTimeout(NetlinkSocketsTimeout)
|
||||
if err != nil {
|
||||
logrus.Warnf("Failed to set the timeout on the default netlink handle sockets: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// SetNamespace sets the initial namespace handler
|
||||
|
|
|
@ -211,6 +211,11 @@ func NewSandbox(key string, osCreate, isRestore bool) (Sandbox, error) {
|
|||
return nil, fmt.Errorf("failed to create a netlink handle: %v", err)
|
||||
}
|
||||
|
||||
err = n.nlHandle.SetSocketTimeout(ns.NetlinkSocketsTimeout)
|
||||
if err != nil {
|
||||
logrus.Warnf("Failed to set the timeout on the sandbox netlink handle sockets: %v", err)
|
||||
}
|
||||
|
||||
if err = n.loopbackUp(); err != nil {
|
||||
n.nlHandle.Delete()
|
||||
return nil, err
|
||||
|
@ -253,6 +258,11 @@ func GetSandboxForExternalKey(basePath string, key string) (Sandbox, error) {
|
|||
return nil, fmt.Errorf("failed to create a netlink handle: %v", err)
|
||||
}
|
||||
|
||||
err = n.nlHandle.SetSocketTimeout(ns.NetlinkSocketsTimeout)
|
||||
if err != nil {
|
||||
logrus.Warnf("Failed to set the timeout on the sandbox netlink handle sockets: %v", err)
|
||||
}
|
||||
|
||||
if err = n.loopbackUp(); err != nil {
|
||||
n.nlHandle.Delete()
|
||||
return nil, err
|
||||
|
|
Loading…
Add table
Reference in a new issue