Skip to content

Commit

Permalink
Honor enableIPv6 network flag on IP allocation
Browse files Browse the repository at this point in the history
- If the flag is not set, do not query IPAM driver for
  IPv6 pool/addresses even if they are passed

Signed-off-by: Alessandro Boch <aboch@docker.com>
  • Loading branch information
aboch committed Mar 18, 2016
1 parent b89fd5a commit 10d6abc
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions network.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ func (n *network) UnmarshalJSON(b []byte) (err error) {
if v, ok := netMap["inDelete"]; ok {
n.inDelete = v.(bool)
}
// Reconcile old networks with the recently added `--ipv6` flag
if !n.enableIPv6 {
n.enableIPv6 = len(n.ipamV6Info) > 0
}
return nil
}

Expand Down Expand Up @@ -752,7 +756,7 @@ func (n *network) CreateEndpoint(name string, options ...EndpointOption) (Endpoi
ep.ipamOptions[netlabel.MacAddress] = ep.iface.mac.String()
}

if err = ep.assignAddress(ipam.driver, true, !n.postIPv6); err != nil {
if err = ep.assignAddress(ipam.driver, true, n.enableIPv6 && !n.postIPv6); err != nil {
return nil, err
}
defer func() {
Expand All @@ -772,7 +776,7 @@ func (n *network) CreateEndpoint(name string, options ...EndpointOption) (Endpoi
}
}()

if err = ep.assignAddress(ipam.driver, false, n.postIPv6); err != nil {
if err = ep.assignAddress(ipam.driver, false, n.enableIPv6 && n.postIPv6); err != nil {
return nil, err
}

Expand Down Expand Up @@ -1006,6 +1010,10 @@ func (n *network) ipamAllocate() error {
}
}()

if !n.enableIPv6 {
return nil
}

return n.ipamAllocateVersion(6, ipam)
}

Expand Down Expand Up @@ -1126,7 +1134,7 @@ func (n *network) ipamReleaseVersion(ipVer int, ipam ipamapi.Ipam) {
return
}

if *infoList == nil {
if len(*infoList) == 0 {
return
}

Expand Down

0 comments on commit 10d6abc

Please sign in to comment.