This repository was archived by the owner on Jan 15, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
server/src/com/cloud/network Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -568,6 +568,9 @@ public boolean isIP6AddressAvailableInNetwork(long networkId) {
568568 @ Override
569569 public boolean isIP6AddressAvailableInVlan (long vlanId ) {
570570 VlanVO vlan = _vlanDao .findById (vlanId );
571+ if (vlan .getIp6Range () == null ) {
572+ return false ;
573+ }
571574 long existedCount = _ipv6Dao .countExistedIpsInVlan (vlanId );
572575 BigInteger existedInt = BigInteger .valueOf (existedCount );
573576 BigInteger rangeInt = NetUtils .countIp6InRange (vlan .getIp6Range ());
Original file line number Diff line number Diff line change @@ -1192,6 +1192,9 @@ private static BigInteger convertIPv6AddressToBigInteger(IPv6Address addr) {
11921192
11931193 // Can cover 127 bits
11941194 public static BigInteger countIp6InRange (String ip6Range ) {
1195+ if (ip6Range == null ) {
1196+ return null ;
1197+ }
11951198 String [] ips = ip6Range .split ("-" );
11961199 String startIp = ips [0 ];
11971200 String endIp = ips [0 ];
@@ -1214,6 +1217,9 @@ public static BigInteger countIp6InRange(String ip6Range) {
12141217 }
12151218
12161219 public static boolean isIp6InRange (String ip6 , String ip6Range ) {
1220+ if (ip6Range == null ) {
1221+ return false ;
1222+ }
12171223 String [] ips = ip6Range .split ("-" );
12181224 String startIp = ips [0 ];
12191225 String endIp = null ;
Original file line number Diff line number Diff line change @@ -122,5 +122,10 @@ public void testIpv6() {
122122 assertTrue (NetUtils .isIp6InNetwork ("1234:5678::1" , "1234:5678::/64" ));
123123 assertTrue (NetUtils .isIp6InNetwork ("1234:5678::ffff:ffff:ffff:ffff" , "1234:5678::/64" ));
124124 assertTrue (NetUtils .isIp6InNetwork ("1234:5678::" , "1234:5678::/64" ));
125+ //Test isIp6InRange
126+ assertTrue (NetUtils .isIp6InRange ("1234:5678:abcd::1" , "1234:5678:abcd::1-1234:5678:abcd::1" ));
127+ assertFalse (NetUtils .isIp6InRange ("1234:5678:abcd::1" , "1234:5678:abcd::2-1234:5678:abcd::1" ));
128+ assertFalse (NetUtils .isIp6InRange ("1234:5678:abcd::1" , null ));
129+ assertTrue (NetUtils .isIp6InRange ("1234:5678:abcd::1" , "1234:5678::1-1234:5679::1" ));
125130 }
126131}
You can’t perform that action at this time.
0 commit comments