1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Libnetwork vendoring

- lock OS thread in overlay driver operation

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
This commit is contained in:
Flavio Crisciani 2017-08-16 09:48:12 -07:00
parent 2afb3efaa6
commit 8570687647
No known key found for this signature in database
GPG key ID: 28CAFCE754CF3A48
6 changed files with 22 additions and 24 deletions

View file

@ -27,7 +27,7 @@ github.com/imdario/mergo 0.2.1
golang.org/x/sync de49d9dcd27d4f764488181bea099dfe6179bcf0 golang.org/x/sync de49d9dcd27d4f764488181bea099dfe6179bcf0
#get libnetwork packages #get libnetwork packages
github.com/docker/libnetwork 2719c60fbd40d894a9cdabf95d2facbd14d2ba75 github.com/docker/libnetwork 5b28c0ec98236c489e39ae6a9e1aeb802e071681
github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9
github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec

View file

@ -120,7 +120,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
} }
} }
d.peerAdd(nid, eid, ep.addr.IP, ep.addr.Mask, ep.mac, net.ParseIP(d.advertiseAddress), true, false, false, true) d.peerAdd(nid, eid, ep.addr.IP, ep.addr.Mask, ep.mac, net.ParseIP(d.advertiseAddress), false, false, true)
if err := d.checkEncryption(nid, nil, n.vxlanID(s), true, true); err != nil { if err := d.checkEncryption(nid, nil, n.vxlanID(s), true, true); err != nil {
logrus.Warn(err) logrus.Warn(err)
@ -200,11 +200,11 @@ func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key stri
} }
if etype == driverapi.Delete { if etype == driverapi.Delete {
d.peerDelete(nid, eid, addr.IP, addr.Mask, mac, vtep, true) d.peerDelete(nid, eid, addr.IP, addr.Mask, mac, vtep)
return return
} }
d.peerAdd(nid, eid, addr.IP, addr.Mask, mac, vtep, true, false, false, false) d.peerAdd(nid, eid, addr.IP, addr.Mask, mac, vtep, false, false, false)
} }
// Leave method is invoked when a Sandbox detaches from an endpoint. // Leave method is invoked when a Sandbox detaches from an endpoint.

View file

@ -8,6 +8,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"runtime"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@ -81,6 +82,10 @@ func setDefaultVlan() {
logrus.Error("insufficient number of arguments") logrus.Error("insufficient number of arguments")
os.Exit(1) os.Exit(1)
} }
runtime.LockOSThread()
defer runtime.UnlockOSThread()
nsPath := os.Args[1] nsPath := os.Args[1]
ns, err := netns.GetFromPath(nsPath) ns, err := netns.GetFromPath(nsPath)
if err != nil { if err != nil {
@ -767,7 +772,7 @@ func (n *network) watchMiss(nlSock *nl.NetlinkSocket) {
logrus.Errorf("could not resolve peer %q: %v", ip, err) logrus.Errorf("could not resolve peer %q: %v", ip, err)
continue continue
} }
n.driver.peerAdd(n.id, "dummy", ip, IPmask, mac, vtep, true, l2Miss, l3Miss, false) n.driver.peerAdd(n.id, "dummy", ip, IPmask, mac, vtep, l2Miss, l3Miss, false)
} else { } else {
// If the gc_thresh values are lower kernel might knock off the neighor entries. // If the gc_thresh values are lower kernel might knock off the neighor entries.
// When we get a L3 miss check if its a valid peer and reprogram the neighbor // When we get a L3 miss check if its a valid peer and reprogram the neighbor

View file

@ -120,10 +120,9 @@ func (d *driver) processEvent(u serf.UserEvent) {
switch action { switch action {
case "join": case "join":
d.peerAdd(nid, eid, net.ParseIP(ipStr), net.IPMask(net.ParseIP(maskStr).To4()), mac, net.ParseIP(vtepStr), d.peerAdd(nid, eid, net.ParseIP(ipStr), net.IPMask(net.ParseIP(maskStr).To4()), mac, net.ParseIP(vtepStr), false, false, false)
true, false, false, false)
case "leave": case "leave":
d.peerDelete(nid, eid, net.ParseIP(ipStr), net.IPMask(net.ParseIP(maskStr).To4()), mac, net.ParseIP(vtepStr), true) d.peerDelete(nid, eid, net.ParseIP(ipStr), net.IPMask(net.ParseIP(maskStr).To4()), mac, net.ParseIP(vtepStr))
} }
} }

View file

@ -170,7 +170,7 @@ func (d *driver) restoreEndpoints() error {
} }
n.incEndpointCount() n.incEndpointCount()
d.peerAdd(ep.nid, ep.id, ep.addr.IP, ep.addr.Mask, ep.mac, net.ParseIP(d.advertiseAddress), true, false, false, true) d.peerAdd(ep.nid, ep.id, ep.addr.IP, ep.addr.Mask, ep.mac, net.ParseIP(d.advertiseAddress), false, false, true)
} }
return nil return nil
} }

View file

@ -234,7 +234,6 @@ type peerOperation struct {
peerIPMask net.IPMask peerIPMask net.IPMask
peerMac net.HardwareAddr peerMac net.HardwareAddr
vtepIP net.IP vtepIP net.IP
updateDB bool
l2Miss bool l2Miss bool
l3Miss bool l3Miss bool
localPeer bool localPeer bool
@ -252,9 +251,9 @@ func (d *driver) peerOpRoutine(ctx context.Context, ch chan *peerOperation) {
case peerOperationINIT: case peerOperationINIT:
err = d.peerInitOp(op.networkID) err = d.peerInitOp(op.networkID)
case peerOperationADD: case peerOperationADD:
err = d.peerAddOp(op.networkID, op.endpointID, op.peerIP, op.peerIPMask, op.peerMac, op.vtepIP, op.updateDB, op.l2Miss, op.l3Miss, op.localPeer) err = d.peerAddOp(op.networkID, op.endpointID, op.peerIP, op.peerIPMask, op.peerMac, op.vtepIP, op.l2Miss, op.l3Miss, true, op.localPeer)
case peerOperationDELETE: case peerOperationDELETE:
err = d.peerDeleteOp(op.networkID, op.endpointID, op.peerIP, op.peerIPMask, op.peerMac, op.vtepIP, op.updateDB) err = d.peerDeleteOp(op.networkID, op.endpointID, op.peerIP, op.peerIPMask, op.peerMac, op.vtepIP)
} }
if err != nil { if err != nil {
logrus.Warnf("Peer operation failed:%s op:%v", err, op) logrus.Warnf("Peer operation failed:%s op:%v", err, op)
@ -279,14 +278,14 @@ func (d *driver) peerInitOp(nid string) error {
return false return false
} }
d.peerAddOp(nid, pEntry.eid, pKey.peerIP, pEntry.peerIPMask, pKey.peerMac, pEntry.vtep, false, false, false, false) d.peerAddOp(nid, pEntry.eid, pKey.peerIP, pEntry.peerIPMask, pKey.peerMac, pEntry.vtep, false, false, false, pEntry.isLocal)
// return false to loop on all entries // return false to loop on all entries
return false return false
}) })
} }
func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
peerMac net.HardwareAddr, vtep net.IP, updateDb, l2Miss, l3Miss, localPeer bool) { peerMac net.HardwareAddr, vtep net.IP, l2Miss, l3Miss, localPeer bool) {
callerName := common.CallerName(1) callerName := common.CallerName(1)
d.peerOpCh <- &peerOperation{ d.peerOpCh <- &peerOperation{
opType: peerOperationADD, opType: peerOperationADD,
@ -296,7 +295,6 @@ func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
peerIPMask: peerIPMask, peerIPMask: peerIPMask,
peerMac: peerMac, peerMac: peerMac,
vtepIP: vtep, vtepIP: vtep,
updateDB: updateDb,
l2Miss: l2Miss, l2Miss: l2Miss,
l3Miss: l3Miss, l3Miss: l3Miss,
localPeer: localPeer, localPeer: localPeer,
@ -305,13 +303,13 @@ func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
} }
func (d *driver) peerAddOp(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, func (d *driver) peerAddOp(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
peerMac net.HardwareAddr, vtep net.IP, updateDb, l2Miss, l3Miss, updateOnlyDB bool) error { peerMac net.HardwareAddr, vtep net.IP, l2Miss, l3Miss, updateDB, updateOnlyDB bool) error {
if err := validateID(nid, eid); err != nil { if err := validateID(nid, eid); err != nil {
return err return err
} }
if updateDb { if updateDB {
d.peerDbAdd(nid, eid, peerIP, peerIPMask, peerMac, vtep, false) d.peerDbAdd(nid, eid, peerIP, peerIPMask, peerMac, vtep, false)
if updateOnlyDB { if updateOnlyDB {
return nil return nil
@ -368,7 +366,7 @@ func (d *driver) peerAddOp(nid, eid string, peerIP net.IP, peerIPMask net.IPMask
} }
func (d *driver) peerDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, func (d *driver) peerDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
peerMac net.HardwareAddr, vtep net.IP, updateDb bool) { peerMac net.HardwareAddr, vtep net.IP) {
callerName := common.CallerName(1) callerName := common.CallerName(1)
d.peerOpCh <- &peerOperation{ d.peerOpCh <- &peerOperation{
opType: peerOperationDELETE, opType: peerOperationDELETE,
@ -378,22 +376,18 @@ func (d *driver) peerDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMas
peerIPMask: peerIPMask, peerIPMask: peerIPMask,
peerMac: peerMac, peerMac: peerMac,
vtepIP: vtep, vtepIP: vtep,
updateDB: updateDb,
callerName: callerName, callerName: callerName,
} }
} }
func (d *driver) peerDeleteOp(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, func (d *driver) peerDeleteOp(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
peerMac net.HardwareAddr, vtep net.IP, updateDb bool) error { peerMac net.HardwareAddr, vtep net.IP) error {
if err := validateID(nid, eid); err != nil { if err := validateID(nid, eid); err != nil {
return err return err
} }
var pEntry peerEntry pEntry := d.peerDbDelete(nid, eid, peerIP, peerIPMask, peerMac, vtep)
if updateDb {
pEntry = d.peerDbDelete(nid, eid, peerIP, peerIPMask, peerMac, vtep)
}
n := d.network(nid) n := d.network(nid)
if n == nil { if n == nil {