Damans227 commented on code in PR #14333:
URL: https://github.com/apache/cloudstack/pull/14333#discussion_r4336753746
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmIpAddressCommandWrapper.java:
##########
@@ -130,12 +139,29 @@ private Pair<String, String> getIpAddresses(String
output, String macAddress) {
found = true;
String ipFamily = parts[parts.length - 2];
String ipPart = parts[parts.length - 1].split("/")[0];
+ // Skip link-local IPv4 addresses (e.g. Windows APIPA
169.254.0.0/16 before a DHCP lease is obtained),
+ // they are not routable and must not be reported as the instance
IP
if (ipFamily.equals("ipv4")) {
- ipv4 = ipPart;
+ if (NetUtils.isLinkLocalIp4(ipPart)) {
+ logger.debug(String.format("Ignoring link-local ipv4 %s
with mac address %s", ipPart, macAddress));
+ } else {
+ ipv4 = ipPart;
+ }
} else if (ipFamily.equals("ipv6")) {
- ipv6 = ipPart;
+ // keep the first global address, and the first link-local one
as a fallback
+ if (NetUtils.isLinkLocalIp6(ipPart)) {
+ if (linkLocalIpv6 == null) {
+ int zoneIndex = ipPart.indexOf('%');
+ linkLocalIpv6 = zoneIndex >= 0 ? ipPart.substring(0,
zoneIndex) : ipPart;
+ }
+ } else if (ipv6 == null) {
+ ipv6 = ipPart;
+ }
}
}
+ if (ipv6 == null) {
+ ipv6 = linkLocalIpv6;
Review Comment:
@weizhouapache couldnt find one either. the closest is #13635 and it doesnt
fetch again. here the checks stop once an ipv6 is saved, so a link-local one
would stay on the nic
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]