mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-1668: Fix IP conflict in VPC tier
Currently, allPossibleIps return the Ip lists which include the gateway, so we need to remove gateway ip from this list. Now, for non-VPC network it works, because NetUtils.getAllIpsFromCidr return the Ip lists which do not include the first IP of the network (like 192.168.0.1). We need too add the first IP into the returned Ip list, because it can be used for VM if it is not the gateway IP (for example, VPC networks). The corresponding patch for 4.0.1 has been posted on https://reviews.apache.org/r/9923/ Signed-off-by: Chip Childers <chip.childers@gmail.com>
This commit is contained in:
parent
2bebb124cc
commit
86a2a75046
|
|
@ -1644,6 +1644,11 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
|||
if (usedIps.size() != 0) {
|
||||
allPossibleIps.removeAll(usedIps);
|
||||
}
|
||||
|
||||
String gateway = network.getGateway();
|
||||
if ((gateway != null) && (allPossibleIps.contains(NetUtils.ip2Long(gateway))))
|
||||
allPossibleIps.remove(NetUtils.ip2Long(gateway));
|
||||
|
||||
return allPossibleIps;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2046,6 +2046,11 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
if (usedIps.size() != 0) {
|
||||
allPossibleIps.removeAll(usedIps);
|
||||
}
|
||||
|
||||
String gateway = network.getGateway();
|
||||
if ((gateway != null) && (allPossibleIps.contains(NetUtils.ip2Long(gateway))))
|
||||
allPossibleIps.remove(NetUtils.ip2Long(gateway));
|
||||
|
||||
return allPossibleIps;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -632,7 +632,7 @@ public class NetUtils {
|
|||
Set<Long> result = new TreeSet<Long>();
|
||||
long ip = ip2Long(cidr);
|
||||
long startNetMask = ip2Long(getCidrNetmask(size));
|
||||
long start = (ip & startNetMask) + 2;
|
||||
long start = (ip & startNetMask) + 1;
|
||||
long end = start;
|
||||
|
||||
end = end >> (32 - size);
|
||||
|
|
|
|||
Loading…
Reference in New Issue