mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Avoids panic when checking for conflicts against an uninitalized network
A network is added to the `d.networks` map before it's fully initialized. That is, it's possible for a network in `d.networks` to exist without having `bridgeIPv4` populated yet. If multiple networks are spun up close to the same time, a panic can occur. Example: ``` panic(0x1a75d20, 0xc82000e090) /usr/local/go/src/runtime/panic.go:443 +0x4e9 net.networkNumberAndMask(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0) /usr/local/go/src/net/ip.go:433 +0x42 net.(*IPNet).Contains(0x0, 0xc82084dbd0, 0x4, 0x4, 0xc820010200) /usr/local/go/src/net/ip.go:457 +0x25 github.com/docker/libnetwork/drivers/bridge.(*networkConfiguration).conflictsWithNetworks(0xc822249360, 0xc822761380, 0x40, 0xc820866a60, 0x4, 0x4, 0x0, 0x0) /root/rpmbuild/BUILD/docker-engine/vendor/src/github.com/docker/libnetwork/drivers/bridge/bridge.go:334 +0x40b ``` Signed-off-by: Andy Lindeman <alindeman@salesforce.com>
This commit is contained in:
parent
630e106529
commit
f2ae8467e3
1 changed files with 1 additions and 1 deletions
|
@ -330,7 +330,7 @@ func (c *networkConfiguration) conflictsWithNetworks(id string, others []*bridge
|
|||
// bridges. This could not be completely caught by the config conflict
|
||||
// check, because networks which config does not specify the AddressIPv4
|
||||
// get their address and subnet selected by the driver (see electBridgeIPv4())
|
||||
if c.AddressIPv4 != nil {
|
||||
if c.AddressIPv4 != nil && nwBridge.bridgeIPv4 != nil {
|
||||
if nwBridge.bridgeIPv4.Contains(c.AddressIPv4.IP) ||
|
||||
c.AddressIPv4.Contains(nwBridge.bridgeIPv4.IP) {
|
||||
return types.ForbiddenErrorf("conflicts with network %s (%s) by ip network", nwID, nwConfig.BridgeName)
|
||||
|
|
Loading…
Reference in a new issue