Skip to content

Commit 655b065

Browse files
weizhouapachedhslove
authored andcommitted
SG: Apply rules for both ipv4/ipv6 of VMs with associated account/SG (apache#11243)
1 parent 8f39af2 commit 655b065

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

engine/schema/src/main/java/com/cloud/network/security/SecurityGroupVMMapVO.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public class SecurityGroupVMMapVO implements InternalIdentity {
5050
@Column(name = "ip4_address", table = "nics", insertable = false, updatable = false)
5151
private String guestIpAddress;
5252

53+
@Column(name = "ip6_address", table = "nics", insertable = false, updatable = false)
54+
private String guestIpv6Address;
55+
5356
@Column(name = "state", table = "vm_instance", insertable = false, updatable = false)
5457
private State vmState;
5558

@@ -77,6 +80,10 @@ public String getGuestIpAddress() {
7780
return guestIpAddress;
7881
}
7982

83+
public String getGuestIpv6Address() {
84+
return guestIpv6Address;
85+
}
86+
8087
public long getInstanceId() {
8188
return instanceId;
8289
}

server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ protected Map<PortAndProto, Set<String>> generateRulesForVM(Long userVmId, Secur
355355
String cidr = defaultNic.getIPv4Address();
356356
cidr = cidr + "/32";
357357
cidrs.add(cidr);
358+
if (defaultNic.getIPv6Address() != null) {
359+
cidrs.add(defaultNic.getIPv6Address() + "/64");
360+
}
358361
}
359362
}
360363
} else if (rule.getAllowedSourceIpCidr() != null) {

server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl2.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ protected Map<PortAndProto, Set<String>> generateRulesForVM(Long userVmId, Secur
249249
//did a join with the nics table
250250
String cidr = ngmapVO.getGuestIpAddress() + "/32";
251251
cidrs.add(cidr);
252+
if (ngmapVO.getGuestIpv6Address() != null) {
253+
cidrs.add(ngmapVO.getGuestIpv6Address() + "/64");
254+
}
252255
}
253256
} else if (rule.getAllowedSourceIpCidr() != null) {
254257
cidrs.add(rule.getAllowedSourceIpCidr());

0 commit comments

Comments
 (0)