Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,10 @@ public boolean equals(Object obj) {
return true;
}

return NetUtils.isNetworkAWithinNetworkB(cidr, that.cidr);
final String normalizedCidr = com.cloud.utils.StringUtils.getFirstValueFromCommaSeparatedString(cidr);
Comment thread
DaanHoogland marked this conversation as resolved.
Outdated
final String normalizedThatCidr = com.cloud.utils.StringUtils.getFirstValueFromCommaSeparatedString(that.cidr);

return NetUtils.isNetworkAWithinNetworkB(normalizedCidr, normalizedThatCidr);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5425,7 +5425,7 @@ public Vlan createVlanAndPublicIpRange(final long zoneId, final long networkId,
final VlanVO vlan = commitVlanAndIpRange(zoneId, networkId, physicalNetworkId, podId, startIP, endIP, vlanGateway, vlanNetmask, vlanId, domain, vlanOwner, vlanIp6Gateway, vlanIp6Cidr,
ipv4, zone, vlanType, ipv6Range, ipRange, forSystemVms, provider);

if (vlan != null) {
if (vlan != null && network.getTrafficType() != TrafficType.Public) {
if (ipv4) {
addCidrAndGatewayForIpv4(networkId, vlanGateway, vlanNetmask);
} else if (ipv6) {
Expand Down Expand Up @@ -6504,11 +6504,14 @@ private boolean deleteAndPublishVlanAndPublicIpRange(final long userId, final lo
final boolean ipv4 = deletedVlan.getVlanGateway() != null;
final boolean ipv6 = deletedVlan.getIp6Gateway() != null;
final long networkId = deletedVlan.getNetworkId();
final NetworkVO networkVO = _networkDao.findById(networkId);

if (ipv4) {
removeCidrAndGatewayForIpv4(networkId, deletedVlan);
} else if (ipv6) {
removeCidrAndGatewayForIpv6(networkId, deletedVlan);
if (networkVO != null && networkVO.getTrafficType() != TrafficType.Public) {
if (ipv4) {
removeCidrAndGatewayForIpv4(networkId, deletedVlan);
Comment on lines +6510 to +6514
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

networkVO is fetched here to check traffic type, but removeCidrAndGatewayForIpv4/Ipv6 immediately re-fetch the same NetworkVO again. To avoid the extra DB hit (and keep the code easier to follow), consider passing the already-fetched NetworkVO into the remove* helpers or moving the traffic-type guard into those helpers.

Copilot uses AI. Check for mistakes.
} else if (ipv6) {
removeCidrAndGatewayForIpv6(networkId, deletedVlan);
}
}

messageBus.publish(_name, MESSAGE_DELETE_VLAN_IP_RANGE_EVENT, PublishScope.LOCAL, deletedVlan);
Expand Down
Loading