SG: Apply rules for both ipv4/ipv6 of VMs with associated account/SG (#11243)

This commit is contained in:
Wei Zhou 2025-08-29 11:39:50 +02:00 committed by GitHub
parent 05e7a257ca
commit ba7ec88650
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 0 deletions

View File

@ -50,6 +50,9 @@ public class SecurityGroupVMMapVO implements InternalIdentity {
@Column(name = "ip4_address", table = "nics", insertable = false, updatable = false)
private String guestIpAddress;
@Column(name = "ip6_address", table = "nics", insertable = false, updatable = false)
private String guestIpv6Address;
@Column(name = "state", table = "vm_instance", insertable = false, updatable = false)
private State vmState;
@ -77,6 +80,10 @@ public class SecurityGroupVMMapVO implements InternalIdentity {
return guestIpAddress;
}
public String getGuestIpv6Address() {
return guestIpv6Address;
}
public long getInstanceId() {
return instanceId;
}

View File

@ -354,6 +354,9 @@ public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGro
String cidr = defaultNic.getIPv4Address();
cidr = cidr + "/32";
cidrs.add(cidr);
if (defaultNic.getIPv6Address() != null) {
cidrs.add(defaultNic.getIPv6Address() + "/64");
}
}
}
} else if (rule.getAllowedSourceIpCidr() != null) {

View File

@ -250,6 +250,9 @@ public class SecurityGroupManagerImpl2 extends SecurityGroupManagerImpl {
//did a join with the nics table
String cidr = ngmapVO.getGuestIpAddress() + "/32";
cidrs.add(cidr);
if (ngmapVO.getGuestIpv6Address() != null) {
cidrs.add(ngmapVO.getGuestIpv6Address() + "/64");
}
}
} else if (rule.getAllowedSourceIpCidr() != null) {
cidrs.add(rule.getAllowedSourceIpCidr());