From 4822efab3133ae7c1f053dd0584d392158c9532e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 26 Jan 2018 16:39:26 -0800 Subject: [PATCH] bump libnetwork to 0ef1f8c94fa85acacf88b9be75ae07de91d0b2a5 Signed-off-by: Sebastiaan van Stijn --- components/engine/vendor.conf | 2 +- .../libnetwork/drivers/overlay/ov_network.go | 57 ++++++++++--------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/components/engine/vendor.conf b/components/engine/vendor.conf index 49d6cf6524..5325744582 100644 --- a/components/engine/vendor.conf +++ b/components/engine/vendor.conf @@ -30,7 +30,7 @@ github.com/moby/buildkit aaff9d591ef128560018433fe61beb802e149de8 github.com/tonistiigi/fsutil dea3a0da73aee887fc02142d995be764106ac5e2 #get libnetwork packages -github.com/docker/libnetwork cb462375d91926adfce98bd8a1f47a325ed6f8f2 +github.com/docker/libnetwork 0ef1f8c94fa85acacf88b9be75ae07de91d0b2a5 github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec diff --git a/components/engine/vendor/github.com/docker/libnetwork/drivers/overlay/ov_network.go b/components/engine/vendor/github.com/docker/libnetwork/drivers/overlay/ov_network.go index 11314170b1..d33939beeb 100644 --- a/components/engine/vendor/github.com/docker/libnetwork/drivers/overlay/ov_network.go +++ b/components/engine/vendor/github.com/docker/libnetwork/drivers/overlay/ov_network.go @@ -13,7 +13,6 @@ import ( "strings" "sync" "syscall" - "time" "github.com/docker/docker/pkg/reexec" "github.com/docker/libnetwork/datastore" @@ -693,6 +692,12 @@ func (n *network) initSandbox(restore bool) error { n.driver.initSandboxPeerDB(n.id) } + // If we are in swarm mode, we don't need anymore the watchMiss routine. + // This will save 1 thread and 1 netlink socket per network + if !n.driver.isSerfAlive() { + return nil + } + var nlSock *nl.NetlinkSocket sbox.InvokeFunc(func() { nlSock, err = nl.Subscribe(syscall.NETLINK_ROUTE, syscall.RTNLGRP_NEIGH) @@ -706,7 +711,7 @@ func (n *network) initSandbox(restore bool) error { n.setNetlinkSocket(nlSock) if err == nil { - go n.watchMiss(nlSock) + go n.watchMiss(nlSock, key) } else { logrus.Errorf("failed to subscribe to neighbor group netlink messages for overlay network %s in sbox %s: %v", n.id, sbox.Key(), err) @@ -715,8 +720,23 @@ func (n *network) initSandbox(restore bool) error { return nil } -func (n *network) watchMiss(nlSock *nl.NetlinkSocket) { - t := time.Now() +func (n *network) watchMiss(nlSock *nl.NetlinkSocket, nsPath string) { + // With the new version of the netlink library the deserialize function makes + // requests about the interface of the netlink message. This can succeed only + // if this go routine is in the target namespace. For this reason following we + // lock the thread on that namespace + runtime.LockOSThread() + defer runtime.UnlockOSThread() + newNs, err := netns.GetFromPath(nsPath) + if err != nil { + logrus.WithError(err).Errorf("failed to get the namespace %s", nsPath) + return + } + defer newNs.Close() + if err = netns.Set(newNs); err != nil { + logrus.WithError(err).Errorf("failed to enter the namespace %s", nsPath) + return + } for { msgs, err := nlSock.Receive() if err != nil { @@ -772,30 +792,13 @@ func (n *network) watchMiss(nlSock *nl.NetlinkSocket) { continue } - if n.driver.isSerfAlive() { - logrus.Debugf("miss notification: dest IP %v, dest MAC %v", ip, mac) - mac, IPmask, vtep, err := n.driver.resolvePeer(n.id, ip) - if err != nil { - logrus.Errorf("could not resolve peer %q: %v", ip, err) - continue - } - n.driver.peerAdd(n.id, "dummy", ip, IPmask, mac, vtep, l2Miss, l3Miss, false) - } else if l3Miss && time.Since(t) > time.Second { - // All the local peers will trigger a miss notification but this one is expected and the local container will reply - // autonomously to the ARP request - // In case the gc_thresh3 values is low kernel might reject new entries during peerAdd. This will trigger the following - // extra logs that will inform of the possible issue. - // Entries created would not be deleted see documentation http://man7.org/linux/man-pages/man7/arp.7.html: - // Entries which are marked as permanent are never deleted by the garbage-collector. - // The time limit here is to guarantee that the dbSearch is not - // done too frequently causing a stall of the peerDB operations. - pKey, pEntry, err := n.driver.peerDbSearch(n.id, ip) - if err == nil && !pEntry.isLocal { - t = time.Now() - logrus.Warnf("miss notification for peer:%+v l3Miss:%t l2Miss:%t, if the problem persist check the gc_thresh on the host pKey:%+v pEntry:%+v err:%v", - neigh, l3Miss, l2Miss, *pKey, *pEntry, err) - } + logrus.Debugf("miss notification: dest IP %v, dest MAC %v", ip, mac) + mac, IPmask, vtep, err := n.driver.resolvePeer(n.id, ip) + if err != nil { + logrus.Errorf("could not resolve peer %q: %v", ip, err) + continue } + n.driver.peerAdd(n.id, "dummy", ip, IPmask, mac, vtep, l2Miss, l3Miss, false) } } }