mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Honor enableIPv6 network flag on IP allocation
- 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>
This commit is contained in:
parent
dfc83a628f
commit
4b9dc647be
1 changed files with 11 additions and 3 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -1006,6 +1010,10 @@ func (n *network) ipamAllocate() error {
|
|||
}
|
||||
}()
|
||||
|
||||
if !n.enableIPv6 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return n.ipamAllocateVersion(6, ipam)
|
||||
}
|
||||
|
||||
|
@ -1126,7 +1134,7 @@ func (n *network) ipamReleaseVersion(ipVer int, ipam ipamapi.Ipam) {
|
|||
return
|
||||
}
|
||||
|
||||
if *infoList == nil {
|
||||
if len(*infoList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue