mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #989 from msabansal/IPFix
Fixed IP information not displayed properly in docker network inspect on Windows
This commit is contained in:
commit
86e2b0243f
4 changed files with 20 additions and 7 deletions
|
@ -186,8 +186,11 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Dat
|
|||
|
||||
for _, ipData := range ipV4Data {
|
||||
subnet := hcsshim.Subnet{
|
||||
AddressPrefix: ipData.Pool.String(),
|
||||
GatewayAddress: ipData.Gateway.IP.String(),
|
||||
AddressPrefix: ipData.Pool.String(),
|
||||
}
|
||||
|
||||
if ipData.Gateway != nil {
|
||||
subnet.GatewayAddress = ipData.Gateway.IP.String()
|
||||
}
|
||||
|
||||
subnets = append(subnets, subnet)
|
||||
|
|
|
@ -957,9 +957,13 @@ func (ep *endpoint) releaseAddress() {
|
|||
log.Warnf("Failed to retrieve ipam driver to release interface address on delete of endpoint %s (%s): %v", ep.Name(), ep.ID(), err)
|
||||
return
|
||||
}
|
||||
if err := ipam.ReleaseAddress(ep.iface.v4PoolID, ep.iface.addr.IP); err != nil {
|
||||
log.Warnf("Failed to release ip address %s on delete of endpoint %s (%s): %v", ep.iface.addr.IP, ep.Name(), ep.ID(), err)
|
||||
|
||||
if ep.iface.addr != nil {
|
||||
if err := ipam.ReleaseAddress(ep.iface.v4PoolID, ep.iface.addr.IP); err != nil {
|
||||
log.Warnf("Failed to release ip address %s on delete of endpoint %s (%s): %v", ep.iface.addr.IP, ep.Name(), ep.ID(), err)
|
||||
}
|
||||
}
|
||||
|
||||
if ep.iface.addrv6 != nil && ep.iface.addrv6.IP.IsGlobalUnicast() {
|
||||
if err := ipam.ReleaseAddress(ep.iface.v6PoolID, ep.iface.addrv6.IP); err != nil {
|
||||
log.Warnf("Failed to release ip address %s on delete of endpoint %s (%s): %v", ep.iface.addrv6.IP, ep.Name(), ep.ID(), err)
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/docker/libnetwork/discoverapi"
|
||||
"github.com/docker/libnetwork/ipamapi"
|
||||
"github.com/docker/libnetwork/netlabel"
|
||||
"github.com/docker/libnetwork/types"
|
||||
)
|
||||
|
||||
|
@ -64,14 +65,19 @@ func (a *allocator) ReleasePool(poolID string) error {
|
|||
// RequestAddress returns an address from the specified pool ID.
|
||||
// Always allocate the 0.0.0.0/32 ip if no preferred address was specified
|
||||
func (a *allocator) RequestAddress(poolID string, prefAddress net.IP, opts map[string]string) (*net.IPNet, map[string]string, error) {
|
||||
log.Debugf("RequestAddress(%s, %v, %v) %s", poolID, prefAddress, opts, opts["RequestAddressType"])
|
||||
log.Debugf("RequestAddress(%s, %v, %v)", poolID, prefAddress, opts)
|
||||
_, ipNet, err := net.ParseCIDR(poolID)
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if prefAddress == nil {
|
||||
|
||||
// TODO Windows: Remove this once the bug in docker daemon is fixed
|
||||
// that causes it to throw an exception on nil gateway
|
||||
if opts[ipamapi.RequestAddressType] == netlabel.Gateway {
|
||||
return ipNet, nil, nil
|
||||
} else if prefAddress == nil {
|
||||
return nil, nil, nil
|
||||
}
|
||||
return &net.IPNet{IP: prefAddress, Mask: ipNet.Mask}, nil, nil
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ func TestWindowsIPAM(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !types.CompareIPNet(ip, requestPool) {
|
||||
if ip != nil {
|
||||
t.Fatalf("Unexpected data returned. Expected %v . Got: %v ", requestPool, ip)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue