-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Prevent deploying IPv6 network if Zone has no IPv6 DNS configured #4177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ce658ac
e060158
1898b2f
b66843e
c90e1e2
c52730d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -726,10 +726,10 @@ public NicSecondaryIp allocateSecondaryGuestIP(final long nicId, IpAddresses req | |
| String ip6addr = null; | ||
| //Isolated network can exist in Basic zone only, so no need to verify the zone type | ||
| if (network.getGuestType() == Network.GuestType.Isolated) { | ||
| if ((ipv4Address != null || NetUtils.isIpv4(network.getGateway()) && org.apache.commons.lang3.StringUtils.isBlank(ipv6Address))) { | ||
| if ((ipv4Address != null || NetUtils.isIpv4(network.getGateway()) && isBlank(ipv6Address))) { | ||
| ipaddr = _ipAddrMgr.allocateGuestIP(network, ipv4Address); | ||
| } | ||
| if (ipv6Address != null) { | ||
| if (isNotBlank(ipv6Address)) { | ||
| ip6addr = ipv6AddrMgr.allocateGuestIpv6(network, ipv6Address); | ||
| } | ||
| } else if (network.getGuestType() == Network.GuestType.Shared) { | ||
|
|
@@ -763,7 +763,7 @@ public NicSecondaryIp allocateSecondaryGuestIP(final long nicId, IpAddresses req | |
| return null; | ||
| } | ||
|
|
||
| if (ipaddr != null || ip6addr != null) { | ||
| if (isNotBlank(ipaddr) || isNotBlank(ip6addr)) { | ||
| // we got the ip addr so up the nics table and secodary ip | ||
| final String ip4AddrFinal = ipaddr; | ||
| final String ip6AddrFinal = ip6addr; | ||
|
|
@@ -1195,7 +1195,7 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac | |
| if (startIP != null) { | ||
| ipv4 = true; | ||
| } | ||
| if (startIPv6 != null) { | ||
| if (isNotBlank(ip6Cidr) && isNotBlank(ip6Gateway)) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Due to SLAAC implementation, an IPv6 network needs CIDR and Gateway. With the refactored code a network is "marked" as ipv6 if IPv6 CIDR and Gateway are not null. |
||
| ipv6 = true; | ||
| } | ||
|
|
||
|
|
@@ -1273,6 +1273,10 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac | |
| if (zone.getNetworkType() != NetworkType.Advanced || ntwkOff.getGuestType() != Network.GuestType.Shared) { | ||
| throw new InvalidParameterValueException("Can only support create IPv6 network with advance shared network!"); | ||
| } | ||
|
|
||
| if(isBlank(zone.getIp6Dns1()) && isBlank(zone.getIp6Dns2())) { | ||
| throw new InvalidParameterValueException("Can only create IPv6 network if the zone has IPv6 DNS! Please configure the zone IPv6 DNS1 and/or IPv6 DNS2."); | ||
| } | ||
| } | ||
|
|
||
| if (isNotBlank(isolatedPvlan) && (zone.getNetworkType() != NetworkType.Advanced || ntwkOff.getGuestType() == GuestType.Isolated)) { | ||
|
|
@@ -2759,7 +2763,7 @@ private void verifyAlreadyMigratedTiers(long migratedVpcId, long vpcOfferingId, | |
| for (Network tier : migratedTiers) { | ||
| String tierNetworkOfferingUuid = networkToOffering.get(tier.getUuid()); | ||
|
|
||
| if (!StringUtils.isNotBlank(tierNetworkOfferingUuid)) { | ||
| if (!isNotBlank(tierNetworkOfferingUuid)) { | ||
| throwInvalidIdException("Failed to resume migrating VPC as the specified tierNetworkOfferings is not complete", String.valueOf(tier.getUuid()), "networkUuid"); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| import com.cloud.dc.DataCenter; | ||
| import com.cloud.dc.DataCenterVO; | ||
| import com.cloud.dc.dao.DataCenterDao; | ||
| import com.cloud.exception.InvalidParameterValueException; | ||
| import com.cloud.network.dao.PhysicalNetworkDao; | ||
| import com.cloud.network.dao.PhysicalNetworkServiceProviderDao; | ||
| import com.cloud.network.dao.PhysicalNetworkServiceProviderVO; | ||
|
|
@@ -90,6 +91,11 @@ public class NetworkModelTest { | |
| private static final long PHYSICAL_NETWORK_1_ID = 1L; | ||
| private static final long PHYSICAL_NETWORK_2_ID = 2L; | ||
|
|
||
| private static final String IPV6_CIDR = "fd59:16ba:559b:243d::/64"; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nowadays IPv6 networking support only |
||
| private static final String IPV6_GATEWAY = "fd59:16ba:559b:243d::1"; | ||
| private static final String START_IPV6 = "fd59:16ba:559b:243d:0:0:0:2"; | ||
| private static final String END_IPV6 = "fd59:16ba:559b:243d:ffff:ffff:ffff:ffff"; | ||
|
|
||
| @Before | ||
| public void setUp() { | ||
| MockitoAnnotations.initMocks(this); | ||
|
|
@@ -194,4 +200,67 @@ public void testAddDisabledConfigDriveEntriesOnZoneAdvancedZoneNonExistingConfig | |
| addProviderToPhysicalNetwork(anyLong(), eq(Provider.ConfigDrive.getName()), isNull(Long.class), isNull(List.class)); | ||
| } | ||
|
|
||
| @Test | ||
| public void checkIp6ParametersTestAllGood() { | ||
| networkModel.checkIp6Parameters(START_IPV6, END_IPV6, IPV6_GATEWAY,IPV6_CIDR); | ||
| } | ||
|
|
||
| @Test(expected = InvalidParameterValueException.class) | ||
| public void checkIp6ParametersTestCidr32() { | ||
| String ipv6cidr = "fd59:16ba:559b:243d::/32"; | ||
| String endipv6 = "fd59:16ba:ffff:ffff:ffff:ffff:ffff:ffff"; | ||
| networkModel.checkIp6Parameters(START_IPV6, endipv6, IPV6_GATEWAY,ipv6cidr); | ||
| } | ||
|
|
||
| @Test(expected = InvalidParameterValueException.class) | ||
| public void checkIp6ParametersTestCidr63() { | ||
| String ipv6cidr = "fd59:16ba:559b:243d::/63"; | ||
| String endipv6 = "fd59:16ba:559b:243d:ffff:ffff:ffff:ffff"; | ||
| networkModel.checkIp6Parameters(START_IPV6, endipv6, IPV6_GATEWAY,ipv6cidr); | ||
| } | ||
|
|
||
| @Test(expected = InvalidParameterValueException.class) | ||
| public void checkIp6ParametersTestCidr65() { | ||
| String ipv6cidr = "fd59:16ba:559b:243d::/65"; | ||
| String endipv6 = "fd59:16ba:559b:243d:7fff:ffff:ffff:ffff"; | ||
| networkModel.checkIp6Parameters(START_IPV6, endipv6, IPV6_GATEWAY,ipv6cidr); | ||
| } | ||
|
|
||
| @Test(expected = InvalidParameterValueException.class) | ||
| public void checkIp6ParametersTestCidr120() { | ||
| String ipv6cidr = "fd59:16ba:559b:243d::/120"; | ||
| String endipv6 = "fd59:16ba:559b:243d:0:0:0:ff"; | ||
| networkModel.checkIp6Parameters(START_IPV6, endipv6, IPV6_GATEWAY,ipv6cidr); | ||
| } | ||
|
|
||
| @Test(expected = InvalidParameterValueException.class) | ||
| public void checkIp6ParametersTestNullGateway() { | ||
| networkModel.checkIp6Parameters(START_IPV6, END_IPV6, null,IPV6_CIDR); | ||
| } | ||
|
|
||
| @Test(expected = InvalidParameterValueException.class) | ||
| public void checkIp6ParametersTestNullCidr() { | ||
| networkModel.checkIp6Parameters(START_IPV6, END_IPV6, IPV6_GATEWAY,null); | ||
| } | ||
|
|
||
| @Test(expected = InvalidParameterValueException.class) | ||
| public void checkIp6ParametersTestNullCidrAndNulGateway() { | ||
| networkModel.checkIp6Parameters(START_IPV6, END_IPV6, null,null); | ||
| } | ||
|
|
||
| @Test | ||
| public void checkIp6ParametersTestNullStartIpv6() { | ||
| networkModel.checkIp6Parameters(null, END_IPV6, IPV6_GATEWAY,IPV6_CIDR); | ||
| } | ||
|
|
||
| @Test | ||
| public void checkIp6ParametersTestNullEndIpv6() { | ||
| networkModel.checkIp6Parameters(START_IPV6, null, IPV6_GATEWAY,IPV6_CIDR); | ||
| } | ||
|
|
||
| @Test | ||
| public void checkIp6ParametersTestNullStartAndEndIpv6() { | ||
| networkModel.checkIp6Parameters(null, null, IPV6_GATEWAY,IPV6_CIDR); | ||
| } | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CloudStack uses SLAAC for managing IPv6 ranges, therefore it is not necessary to have a start/end IPv6 address; on the other hand, IPv6 CIDR is mandatory for IPv6 networks.
That is why I changed this and other pieces of code that had start/end ipv6 address as mandatory.