mirror of
https://github.com/clearlinux/libnetwork.git
synced 2026-09-05 13:21:30 +00:00
Misc fixes to ip allocation in bridge driver
Two changes were missing: - On allocation of bridge ip was not passing canonical subnet - Canonical subnet has to be passed on ip release as well, otherwise ipallocator will attempt ip release from a non registered nw Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
@@ -947,8 +947,7 @@ func (d *driver) CreateEndpoint(nid, eid types.UUID, epInfo driverapi.EndpointIn
|
||||
}
|
||||
|
||||
// v4 address for the sandbox side pipe interface
|
||||
sub := types.GetIPNetCopy(n.bridge.bridgeIPv4)
|
||||
sub.IP = sub.IP.Mask(sub.Mask)
|
||||
sub := types.GetIPNetCanonical(n.bridge.bridgeIPv4)
|
||||
ip4, err := ipAllocator.RequestIP(sub, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1075,7 +1074,8 @@ func (d *driver) DeleteEndpoint(nid, eid types.UUID) error {
|
||||
n.releasePorts(ep)
|
||||
|
||||
// Release the v4 address allocated to this endpoint's sandbox interface
|
||||
err = ipAllocator.ReleaseIP(n.bridge.bridgeIPv4, ep.addr.IP)
|
||||
sub := types.GetIPNetCanonical(n.bridge.bridgeIPv4)
|
||||
err = ipAllocator.ReleaseIP(sub, ep.addr.IP)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -76,7 +76,8 @@ func setupBridgeIPv4(config *networkConfiguration, i *bridgeInterface) error {
|
||||
}
|
||||
|
||||
func allocateBridgeIP(config *networkConfiguration, i *bridgeInterface) error {
|
||||
ipAllocator.RequestIP(i.bridgeIPv4, i.bridgeIPv4.IP)
|
||||
sub := types.GetIPNetCanonical(i.bridgeIPv4)
|
||||
ipAllocator.RequestIP(sub, i.bridgeIPv4.IP)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -112,8 +113,7 @@ func setupGatewayIPv4(config *networkConfiguration, i *bridgeInterface) error {
|
||||
}
|
||||
|
||||
// Pass the real network subnet to ip allocator (no host bits set)
|
||||
sub := types.GetIPNetCopy(i.bridgeIPv4)
|
||||
sub.IP = sub.IP.Mask(sub.Mask)
|
||||
sub := types.GetIPNetCanonical(i.bridgeIPv4)
|
||||
if _, err := ipAllocator.RequestIP(sub, config.DefaultGatewayIPv4); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user