Skip to content

Commit f049f54

Browse files
authored
server: fix dualstack ipv6 networks for vxlan (#7933)
Fixes #7926 Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 126dd5f commit f049f54

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

plugins/network-elements/vxlan/src/main/java/com/cloud/network/guru/VxlanGuestNetworkGuru.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,16 @@ protected boolean canHandle(NetworkOffering offering, final NetworkType networkT
6969

7070
@Override
7171
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
72-
7372
NetworkVO network = (NetworkVO)super.design(offering, plan, userSpecified, owner);
7473
if (network == null) {
7574
return null;
7675
}
77-
7876
if (offering.getGuestType() == GuestType.L2 && network.getBroadcastUri() != null) {
7977
String vxlan = BroadcastDomainType.getValue(network.getBroadcastUri());
8078
network.setBroadcastUri(BroadcastDomainType.Vxlan.toUri(vxlan));
8179
}
8280
network.setBroadcastDomainType(BroadcastDomainType.Vxlan);
83-
84-
return network;
81+
return updateNetworkDesignForIPv6IfNeeded(network, userSpecified);
8582
}
8683

8784
@Override

server/src/main/java/com/cloud/network/guru/ExternalGuestNetworkGuru.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import com.cloud.event.EventVO;
3737
import com.cloud.exception.InsufficientAddressCapacityException;
3838
import com.cloud.exception.InsufficientVirtualNetworkCapacityException;
39-
import com.cloud.exception.InvalidParameterValueException;
4039
import com.cloud.network.IpAddressManager;
4140
import com.cloud.network.Network;
4241
import com.cloud.network.Network.GuestType;
@@ -124,22 +123,7 @@ public Network design(NetworkOffering offering, DeploymentPlan plan, Network use
124123
/* In order to revert userSpecified network setup */
125124
config.setState(State.Allocated);
126125
}
127-
if (userSpecified == null) {
128-
return config;
129-
}
130-
if ((userSpecified.getIp6Cidr() == null && userSpecified.getIp6Gateway() != null) ||
131-
(userSpecified.getIp6Cidr() != null && userSpecified.getIp6Gateway() == null)) {
132-
throw new InvalidParameterValueException("ip6gateway and ip6cidr must be specified together.");
133-
}
134-
if (userSpecified.getIp6Cidr() != null) {
135-
config.setIp6Cidr(userSpecified.getIp6Cidr());
136-
config.setIp6Gateway(userSpecified.getIp6Gateway());
137-
}
138-
if (userSpecified.getRouterIpv6() != null) {
139-
config.setRouterIpv6(userSpecified.getRouterIpv6());
140-
}
141-
142-
return config;
126+
return updateNetworkDesignForIPv6IfNeeded(config, userSpecified);
143127
}
144128

145129
@Override

server/src/main/java/com/cloud/network/guru/GuestNetworkGuru.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,4 +545,22 @@ public String getConfigComponentName() {
545545
public ConfigKey<?>[] getConfigKeys() {
546546
return new ConfigKey<?>[]{UseSystemGuestVlans};
547547
}
548+
549+
public Network updateNetworkDesignForIPv6IfNeeded(NetworkVO network, Network userSpecified) {
550+
if (userSpecified == null) {
551+
return network;
552+
}
553+
if ((userSpecified.getIp6Cidr() == null && userSpecified.getIp6Gateway() != null) ||
554+
(userSpecified.getIp6Cidr() != null && userSpecified.getIp6Gateway() == null)) {
555+
throw new InvalidParameterValueException("ip6gateway and ip6cidr must be specified together.");
556+
}
557+
if (userSpecified.getIp6Cidr() != null) {
558+
network.setIp6Cidr(userSpecified.getIp6Cidr());
559+
network.setIp6Gateway(userSpecified.getIp6Gateway());
560+
}
561+
if (userSpecified.getRouterIpv6() != null) {
562+
network.setRouterIpv6(userSpecified.getRouterIpv6());
563+
}
564+
return network;
565+
}
548566
}

0 commit comments

Comments
 (0)