Simplify NetworkOverlaps function

- Doing a lot of unnecessary things.

Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
Alessandro Boch 2015-08-06 10:04:01 -07:00
parent f7d4913ab9
commit 26ac09e004
1 changed files with 1 additions and 11 deletions

View File

@ -59,17 +59,7 @@ func CheckRouteOverlaps(toCheck *net.IPNet) error {
// NetworkOverlaps detects overlap between one IPNet and another
func NetworkOverlaps(netX *net.IPNet, netY *net.IPNet) bool {
// Check if both netX and netY are ipv4 or ipv6
if (netX.IP.To4() != nil && netY.IP.To4() != nil) ||
(netX.IP.To4() == nil && netY.IP.To4() == nil) {
if firstIP, _ := NetworkRange(netX); netY.Contains(firstIP) {
return true
}
if firstIP, _ := NetworkRange(netY); netX.Contains(firstIP) {
return true
}
}
return false
return netX.Contains(netY.IP) || netY.Contains(netX.IP)
}
// NetworkRange calculates the first and last IP addresses in an IPNet