Skip to content

Commit b8b3ab0

Browse files
committed
SG: Apply rules for both ipv4/ipv6 of VMs with associated account/SG
1 parent 06c80cd commit b8b3ab0

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
@@ -354,6 +354,9 @@ protected Map<PortAndProto, Set<String>> generateRulesForVM(Long userVmId, Secur
354354
String cidr = defaultNic.getIPv4Address();
355355
cidr = cidr + "/32";
356356
cidrs.add(cidr);
357+
if (defaultNic.getIPv6Address() != null) {
358+
cidrs.add(defaultNic.getIPv6Address() + "/64");
359+
}
357360
}
358361
}
359362
} 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
@@ -250,6 +250,9 @@ protected Map<PortAndProto, Set<String>> generateRulesForVM(Long userVmId, Secur
250250
//did a join with the nics table
251251
String cidr = ngmapVO.getGuestIpAddress() + "/32";
252252
cidrs.add(cidr);
253+
if (ngmapVO.getGuestIpv6Address() != null) {
254+
cidrs.add(ngmapVO.getGuestIpv6Address() + "/64");
255+
}
253256
}
254257
} else if (rule.getAllowedSourceIpCidr() != null) {
255258
cidrs.add(rule.getAllowedSourceIpCidr());

0 commit comments

Comments
 (0)