1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

return an error on overlay subnet is overlapped with hosts

Signed-off-by: realityone <realityone@me.com>
This commit is contained in:
realityone 2016-10-24 15:52:48 +08:00
parent f2f0212cab
commit d94be29ec5

View file

@ -402,7 +402,7 @@ func (n *network) getBridgeNamePrefix(s *subnet) string {
return "ov-" + fmt.Sprintf("%06x", n.vxlanID(s))
}
func isOverlap(nw *net.IPNet) bool {
func checkOverlap(nw *net.IPNet) error {
var nameservers []string
if rc, err := resolvconf.Get(); err == nil {
@ -410,14 +410,14 @@ func isOverlap(nw *net.IPNet) bool {
}
if err := netutils.CheckNameserverOverlaps(nameservers, nw); err != nil {
return true
return fmt.Errorf("overlay subnet %s failed check with nameserver: %v: %v", nw.String(), nameservers, err)
}
if err := netutils.CheckRouteOverlaps(nw); err != nil {
return true
return fmt.Errorf("overlay subnet %s failed check with host route table: %v", nw.String(), err)
}
return false
return nil
}
func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) error {
@ -456,8 +456,8 @@ func (n *network) setupSubnetSandbox(s *subnet, brName, vxlanName string) error
// Try to delete the vxlan interface by vni if already present
deleteVxlanByVNI("", n.vxlanID(s))
if isOverlap(s.subnetIP) {
return fmt.Errorf("overlay subnet %s has conflicts in the host while running in host mode", s.subnetIP.String())
if err := checkOverlap(s.subnetIP); err != nil {
return err
}
}