mirror of https://github.com/docker/docs.git
Merge pull request #21780 from sanimej/libn-v0.7rc2
Vendor Libnetwork v0.7.0-rc.3
This commit is contained in:
commit
a79e79c58e
|
@ -29,7 +29,7 @@ clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837
|
||||||
clone git github.com/imdario/mergo 0.2.1
|
clone git github.com/imdario/mergo 0.2.1
|
||||||
|
|
||||||
#get libnetwork packages
|
#get libnetwork packages
|
||||||
clone git github.com/docker/libnetwork v0.7.0-rc.1
|
clone git github.com/docker/libnetwork v0.7.0-rc.3
|
||||||
clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
|
clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
|
||||||
clone git github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b
|
clone git github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b
|
||||||
clone git github.com/hashicorp/memberlist 9a1e242e454d2443df330bdd51a436d5a9058fc4
|
clone git github.com/hashicorp/memberlist 9a1e242e454d2443df330bdd51a436d5a9058fc4
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.7.0-rc.3 (2016-04-05)
|
||||||
|
- Revert fix for default gateway endoint join/leave. Needs to be reworked.
|
||||||
|
- Persist the network internal mode for bridge networks
|
||||||
|
|
||||||
|
## 0.7.0-rc.2 (2016-04-05)
|
||||||
|
- Fixes https://github.com/docker/libnetwork/issues/1070
|
||||||
|
- Move IPAM resource initialization out of init()
|
||||||
|
- Initialize overlay driver before network delete
|
||||||
|
- Fix the handling for default gateway Endpoint join/lean
|
||||||
|
|
||||||
## 0.7.0-rc.1 (2016-03-30)
|
## 0.7.0-rc.1 (2016-03-30)
|
||||||
- Fixes https://github.com/docker/libnetwork/issues/985
|
- Fixes https://github.com/docker/libnetwork/issues/985
|
||||||
- Fixes https://github.com/docker/libnetwork/issues/945
|
- Fixes https://github.com/docker/libnetwork/issues/945
|
||||||
|
|
|
@ -95,6 +95,7 @@ func (ncfg *networkConfiguration) MarshalJSON() ([]byte, error) {
|
||||||
nMap["EnableIPMasquerade"] = ncfg.EnableIPMasquerade
|
nMap["EnableIPMasquerade"] = ncfg.EnableIPMasquerade
|
||||||
nMap["EnableICC"] = ncfg.EnableICC
|
nMap["EnableICC"] = ncfg.EnableICC
|
||||||
nMap["Mtu"] = ncfg.Mtu
|
nMap["Mtu"] = ncfg.Mtu
|
||||||
|
nMap["Internal"] = ncfg.Internal
|
||||||
nMap["DefaultBridge"] = ncfg.DefaultBridge
|
nMap["DefaultBridge"] = ncfg.DefaultBridge
|
||||||
nMap["DefaultBindingIP"] = ncfg.DefaultBindingIP.String()
|
nMap["DefaultBindingIP"] = ncfg.DefaultBindingIP.String()
|
||||||
nMap["DefaultGatewayIPv4"] = ncfg.DefaultGatewayIPv4.String()
|
nMap["DefaultGatewayIPv4"] = ncfg.DefaultGatewayIPv4.String()
|
||||||
|
@ -143,6 +144,9 @@ func (ncfg *networkConfiguration) UnmarshalJSON(b []byte) error {
|
||||||
ncfg.EnableIPMasquerade = nMap["EnableIPMasquerade"].(bool)
|
ncfg.EnableIPMasquerade = nMap["EnableIPMasquerade"].(bool)
|
||||||
ncfg.EnableICC = nMap["EnableICC"].(bool)
|
ncfg.EnableICC = nMap["EnableICC"].(bool)
|
||||||
ncfg.Mtu = int(nMap["Mtu"].(float64))
|
ncfg.Mtu = int(nMap["Mtu"].(float64))
|
||||||
|
if v, ok := nMap["Internal"]; ok {
|
||||||
|
ncfg.Internal = v.(bool)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,11 @@ func (d *driver) DeleteNetwork(nid string) error {
|
||||||
return fmt.Errorf("invalid network id")
|
return fmt.Errorf("invalid network id")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure driver resources are initialized before proceeding
|
||||||
|
if err := d.configure(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
n := d.network(nid)
|
n := d.network(nid)
|
||||||
if n == nil {
|
if n == nil {
|
||||||
return fmt.Errorf("could not find network with id %s", nid)
|
return fmt.Errorf("could not find network with id %s", nid)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/docker/libnetwork/datastore"
|
"github.com/docker/libnetwork/datastore"
|
||||||
"github.com/docker/libnetwork/ipam"
|
"github.com/docker/libnetwork/ipam"
|
||||||
"github.com/docker/libnetwork/ipamapi"
|
"github.com/docker/libnetwork/ipamapi"
|
||||||
|
"github.com/docker/libnetwork/ipamutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Init registers the built-in ipam service with libnetwork
|
// Init registers the built-in ipam service with libnetwork
|
||||||
|
@ -28,6 +29,9 @@ func Init(ic ipamapi.Callback, l, g interface{}) error {
|
||||||
return fmt.Errorf("incorrect global datastore passed to built-in ipam init")
|
return fmt.Errorf("incorrect global datastore passed to built-in ipam init")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ipamutils.InitNetworks()
|
||||||
|
|
||||||
a, err := ipam.NewAllocator(localDs, globalDs)
|
a, err := ipam.NewAllocator(localDs, globalDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
// Package ipamutils provides utililty functions for ipam management
|
// Package ipamutils provides utililty functions for ipam management
|
||||||
package ipamutils
|
package ipamutils
|
||||||
|
|
||||||
import "net"
|
import (
|
||||||
|
"net"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// PredefinedBroadNetworks contains a list of 31 IPv4 private networks with host size 16 and 12
|
// PredefinedBroadNetworks contains a list of 31 IPv4 private networks with host size 16 and 12
|
||||||
|
@ -10,11 +13,16 @@ var (
|
||||||
// PredefinedGranularNetworks contains a list of 64K IPv4 private networks with host size 8
|
// PredefinedGranularNetworks contains a list of 64K IPv4 private networks with host size 8
|
||||||
// (10.x.x.x/24) which do not overlap with the networks in `PredefinedBroadNetworks`
|
// (10.x.x.x/24) which do not overlap with the networks in `PredefinedBroadNetworks`
|
||||||
PredefinedGranularNetworks []*net.IPNet
|
PredefinedGranularNetworks []*net.IPNet
|
||||||
|
|
||||||
|
initNetworksOnce sync.Once
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
// InitNetworks initializes the pre-defined networks used by the built-in IP allocator
|
||||||
PredefinedBroadNetworks = initBroadPredefinedNetworks()
|
func InitNetworks() {
|
||||||
PredefinedGranularNetworks = initGranularPredefinedNetworks()
|
initNetworksOnce.Do(func() {
|
||||||
|
PredefinedBroadNetworks = initBroadPredefinedNetworks()
|
||||||
|
PredefinedGranularNetworks = initGranularPredefinedNetworks()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func initBroadPredefinedNetworks() []*net.IPNet {
|
func initBroadPredefinedNetworks() []*net.IPNet {
|
||||||
|
|
|
@ -22,6 +22,8 @@ func ElectInterfaceAddresses(name string) (*net.IPNet, []*net.IPNet, error) {
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
InitNetworks()
|
||||||
|
|
||||||
defer osl.InitOSContext()()
|
defer osl.InitOSContext()()
|
||||||
|
|
||||||
link, _ := netlink.LinkByName(name)
|
link, _ := netlink.LinkByName(name)
|
||||||
|
|
|
@ -49,8 +49,14 @@ const (
|
||||||
defaultRespSize = 512
|
defaultRespSize = 512
|
||||||
maxConcurrent = 50
|
maxConcurrent = 50
|
||||||
logInterval = 2 * time.Second
|
logInterval = 2 * time.Second
|
||||||
|
maxDNSID = 65536
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type clientConn struct {
|
||||||
|
dnsID uint16
|
||||||
|
respWriter dns.ResponseWriter
|
||||||
|
}
|
||||||
|
|
||||||
type extDNSEntry struct {
|
type extDNSEntry struct {
|
||||||
ipStr string
|
ipStr string
|
||||||
extConn net.Conn
|
extConn net.Conn
|
||||||
|
@ -69,6 +75,7 @@ type resolver struct {
|
||||||
count int32
|
count int32
|
||||||
tStamp time.Time
|
tStamp time.Time
|
||||||
queryLock sync.Mutex
|
queryLock sync.Mutex
|
||||||
|
client map[uint16]clientConn
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -78,8 +85,9 @@ func init() {
|
||||||
// NewResolver creates a new instance of the Resolver
|
// NewResolver creates a new instance of the Resolver
|
||||||
func NewResolver(sb *sandbox) Resolver {
|
func NewResolver(sb *sandbox) Resolver {
|
||||||
return &resolver{
|
return &resolver{
|
||||||
sb: sb,
|
sb: sb,
|
||||||
err: fmt.Errorf("setup not done yet"),
|
err: fmt.Errorf("setup not done yet"),
|
||||||
|
client: make(map[uint16]clientConn),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +383,9 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) {
|
||||||
extConn.SetDeadline(time.Now().Add(extIOTimeout))
|
extConn.SetDeadline(time.Now().Add(extIOTimeout))
|
||||||
co := &dns.Conn{Conn: extConn}
|
co := &dns.Conn{Conn: extConn}
|
||||||
|
|
||||||
if r.concurrentQueryInc() == false {
|
// forwardQueryStart stores required context to mux multiple client queries over
|
||||||
|
// one connection; and limits the number of outstanding concurrent queries.
|
||||||
|
if r.forwardQueryStart(w, query) == false {
|
||||||
old := r.tStamp
|
old := r.tStamp
|
||||||
r.tStamp = time.Now()
|
r.tStamp = time.Now()
|
||||||
if r.tStamp.Sub(old) > logInterval {
|
if r.tStamp.Sub(old) > logInterval {
|
||||||
|
@ -391,18 +401,25 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) {
|
||||||
}()
|
}()
|
||||||
err = co.WriteMsg(query)
|
err = co.WriteMsg(query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.concurrentQueryDec()
|
r.forwardQueryEnd(w, query)
|
||||||
log.Debugf("Send to DNS server failed, %s", err)
|
log.Debugf("Send to DNS server failed, %s", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err = co.ReadMsg()
|
resp, err = co.ReadMsg()
|
||||||
r.concurrentQueryDec()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
r.forwardQueryEnd(w, query)
|
||||||
log.Debugf("Read from DNS server failed, %s", err)
|
log.Debugf("Read from DNS server failed, %s", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieves the context for the forwarded query and returns the client connection
|
||||||
|
// to send the reply to
|
||||||
|
w = r.forwardQueryEnd(w, resp)
|
||||||
|
if w == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
resp.Compress = true
|
resp.Compress = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -418,22 +435,71 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *resolver) concurrentQueryInc() bool {
|
func (r *resolver) forwardQueryStart(w dns.ResponseWriter, msg *dns.Msg) bool {
|
||||||
|
proto := w.LocalAddr().Network()
|
||||||
|
dnsID := uint16(rand.Intn(maxDNSID))
|
||||||
|
|
||||||
|
cc := clientConn{
|
||||||
|
dnsID: msg.Id,
|
||||||
|
respWriter: w,
|
||||||
|
}
|
||||||
|
|
||||||
r.queryLock.Lock()
|
r.queryLock.Lock()
|
||||||
defer r.queryLock.Unlock()
|
defer r.queryLock.Unlock()
|
||||||
|
|
||||||
if r.count == maxConcurrent {
|
if r.count == maxConcurrent {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
r.count++
|
r.count++
|
||||||
|
|
||||||
|
switch proto {
|
||||||
|
case "tcp":
|
||||||
|
break
|
||||||
|
case "udp":
|
||||||
|
for ok := true; ok == true; dnsID = uint16(rand.Intn(maxDNSID)) {
|
||||||
|
_, ok = r.client[dnsID]
|
||||||
|
}
|
||||||
|
log.Debugf("client dns id %v, changed id %v", msg.Id, dnsID)
|
||||||
|
r.client[dnsID] = cc
|
||||||
|
msg.Id = dnsID
|
||||||
|
default:
|
||||||
|
log.Errorf("Invalid protocol..")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *resolver) concurrentQueryDec() bool {
|
func (r *resolver) forwardQueryEnd(w dns.ResponseWriter, msg *dns.Msg) dns.ResponseWriter {
|
||||||
|
var (
|
||||||
|
cc clientConn
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
proto := w.LocalAddr().Network()
|
||||||
|
|
||||||
r.queryLock.Lock()
|
r.queryLock.Lock()
|
||||||
defer r.queryLock.Unlock()
|
defer r.queryLock.Unlock()
|
||||||
|
|
||||||
if r.count == 0 {
|
if r.count == 0 {
|
||||||
return false
|
log.Errorf("Invalid concurrent query count")
|
||||||
|
} else {
|
||||||
|
r.count--
|
||||||
}
|
}
|
||||||
r.count--
|
|
||||||
return true
|
switch proto {
|
||||||
|
case "tcp":
|
||||||
|
break
|
||||||
|
case "udp":
|
||||||
|
if cc, ok = r.client[msg.Id]; ok == false {
|
||||||
|
log.Debugf("Can't retrieve client context for dns id %v", msg.Id)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
delete(r.client, msg.Id)
|
||||||
|
msg.Id = cc.dnsID
|
||||||
|
w = cc.respWriter
|
||||||
|
default:
|
||||||
|
log.Errorf("Invalid protocol")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return w
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue