Visitar URL original
Fix External-DHCP APIPA/Link-local address on L2 networks by nvazquez · Pull Request #14333 · apache/cloudstack · GitHub
Skip to content

Fix External-DHCP APIPA/Link-local address on L2 networks - #14333

Open
nvazquez wants to merge 1 commit into
apache:4.22from
shapeblue:l2-external-dchp-ip-fix
Open

nvazquez wants to merge 1 commit into
apache:4.22from
shapeblue:l2-external-dchp-ip-fix

Conversation

@nvazquez

@nvazquez nvazquez commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Description

This PR an issue observed on L2 Networks with external DHCP server:

On an L2 guest network with an external DHCP server, CloudStack learns a Windows VM's IP address as the self-assigned (APIPA / link-local) address 169.254.149.120. It recorded that as the NIC's IP and never refreshed it. More than 30 minutes later, listVirtualMachines still reports 169.254.149.120, while the guest really has 172.25.16.236 (DHCP). The QEMU guest agent reports 172.25.16.236, and SSH on 172.25.16.236:22 is reachable.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@nvazquez

nvazquez commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.02%. Comparing base (2974af8) to head (3c97325).

Files with missing lines Patch % Lines
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 0.00% 7 Missing ⚠️
...ls/src/main/java/com/cloud/utils/net/NetUtils.java 85.71% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #14333      +/-   ##
============================================
- Coverage     18.02%   18.02%   -0.01%     
- Complexity    16250    16262      +12     
============================================
  Files          5936     5936              
  Lines        535823   535847      +24     
  Branches      65612    65617       +5     
============================================
+ Hits          96582    96586       +4     
- Misses       428242   428263      +21     
+ Partials      10999    10998       -1     
Flag Coverage Δ
uitests 4.04% <ø> (ø)
unittests 19.09% <66.66%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@weizhouapache weizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

code lgtm

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19442

@nvazquez

nvazquez commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Legacy APIPA values can remain exposed, and malformed IPv6 zone input can throw unexpectedly.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Fixes stale APIPA/link-local addresses reported for externally DHCP-managed L2 VM NICs.

Changes:

  • Adds IPv4/IPv6 link-local detection utilities.
  • Filters link-local addresses from KVM guest-agent results.
  • Retries NICs containing previously recorded APIPA addresses.
File Description
NetUtils.java Adds link-local address helpers.
NetUtilsTest.java Tests link-local detection.
UserVmManagerImpl.java Handles and retries APIPA NIC addresses.
LibvirtGetVmIpAddressCommandWrapper.java Ignores link-local guest addresses.
LibvirtGetVmIpAddressCommandWrapperTest.java Tests APIPA and DHCP parsing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

for (NicVO nic : nics) {
if (nic.getIPv4Address() == null) {
// also retry NICs holding a link-local (APIPA) address recorded before the guest obtained its DHCP lease
if (nic.getIPv4Address() == null || NetUtils.isLinkLocalIp4(nic.getIPv4Address())) {
if (ip == null) {
return false;
}
final String address = ip.split("%")[0];
@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-17089)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 49968 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr14333-t17089-kvm-ol8.zip
Smoke tests completed. 149 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants