Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
Security Level: Public (Anyone can view this level - this is the default.)
-
None
Description
example
1. create a network with cidr = 10.1.1.32/28
2. edit the network and change guest vm cidr to 10.1.1.32/27
according to server/src/com/cloud/network/NetworkServiceImpl.java
if (networkCidr != null) { if (!NetUtils.isNetworkAWithinNetworkB(guestVmCidr, networkCidr)) { throw new InvalidParameterValueException("Invalid value of Guest VM CIDR. For IP Reservation, Guest VM CIDR should be a subset of network CIDR : " + networkCidr); } } else { if (!NetUtils.isNetworkAWithinNetworkB(guestVmCidr, network.getCidr())) { throw new InvalidParameterValueException("Invalid value of Guest VM CIDR. For IP Reservation, Guest VM CIDR should be a subset of network CIDR : " + network.getCidr()); } }
this should throw an exception, however it does not.
I added some unit test in utils/src/test/java/com/cloud/utils/net/NetUtilsTest.java
@Test public void testIsNetworkAWithinNetworkB() { assertTrue(NetUtils.isNetworkAWithinNetworkB("192.168.30.0/24", "192.168.30.0/23")); assertTrue(NetUtils.isNetworkAWithinNetworkB("192.168.30.0/24", "192.168.30.0/22")); assertFalse(NetUtils.isNetworkAWithinNetworkB("192.168.30.0/23", "192.168.30.0/24")); assertFalse(NetUtils.isNetworkAWithinNetworkB("192.168.30.0/22", "192.168.30.0/24")); assertTrue(NetUtils.isNetworkAWithinNetworkB("192.168.28.0/24", "192.168.28.0/23")); assertTrue(NetUtils.isNetworkAWithinNetworkB("192.168.28.0/24", "192.168.28.0/22")); assertFalse(NetUtils.isNetworkAWithinNetworkB("192.168.28.0/23", "192.168.28.0/24")); assertFalse(NetUtils.isNetworkAWithinNetworkB("192.168.28.0/22", "192.168.28.0/24")); assertTrue(NetUtils.isNetworkAWithinNetworkB("192.168.30.0/24", "192.168.28.0/22")); }
the test fails at
assertFalse(NetUtils.isNetworkAWithinNetworkB("192.168.30.0/23", "192.168.30.0/24"));
Attachments
Issue Links
- links to