Skip to content

systemvm: enable IPv6 link-local on the control network - #13795

Open
wido wants to merge 2 commits into
apache:mainfrom
wido:systemvm-control-ipv6
Open

systemvm: enable IPv6 link-local on the control network#13795
wido wants to merge 2 commits into
apache:mainfrom
wido:systemvm-control-ipv6

Conversation

@wido

@wido wido commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

This PR enables IPv6 link-local addressing on the control (link-local) network of system VMs, alongside the existing 169.254.0.0/16 IPv4 addressing. With IPv6 explicitly enabled on the control network we can move our SSH commands (on at least KVM) to link local IPv6 and remove the 169.254.0.0/16 addressing in the future. That can significantly reduce the code-base inside CloudStack. That's not part of this PR yet.

The existing issue #9957 talks about this and this PR should be groundwork for that to be done in the future.

System VM (common.sh):

  • The control NIC gets an IPv6 link-local address generated with EUI-64 (addr_gen_mode=0), so the address is deterministic and can be calculated from the NIC's MAC address
  • Router Advertisements and SLAAC are disabled on the interface (accept_ra=0, autoconf=0); only the link-local address is configured
  • setup_sshd() waits for Duplicate Address Detection to complete and adds a ListenAddress fe80::...%ethX entry to sshd_config, so sshd listens on both the IPv4 and IPv6 link-local addresses. The sed expressions are idempotent across reboots
  • This works for all system VM types, as setup_sshd() is always handed the control interface (eth0 for CPVM/SSVM on KVM, eth1 for routers)

Management Server / API:

  • listSystemVms now returns linklocalip6: the EUI-64 IPv6 link-local address calculated from the control NIC's MAC address using the existing (unit-tested) NetUtils.ipv6LinkLocal(). This performs the same U/L-bit flip + ff:fe expansion the kernel does, so the reported address always matches what the system VM configures
  • New response field on SystemVmResponse (since 4.23.0)

KVM agent:

  • When the control network is set up, the agent now enables IPv6 (link-local only, no RA/SLAAC) on the control bridge (cloud0) via a shared enableBridgeIpv6LinkLocal() helper in VifDriverBase, called from BridgeVifDriver, OvsVifDriver and IvsVifDriver
  • This runs unconditionally on agent start, so hosts with a pre-existing cloud0 bridge also get IPv6 enabled on it
  • With this, the host can reach system VMs over the control network with e.g. ssh -6 -p 3922 fe80::...%cloud0

UI:

  • The System VMs list and detail views show the new "Link-local/Control IPv6 address" field

This is a first step towards using IPv6 link-local instead of 169.254.0.0/16 on the control network. The Management Server still provisions system VMs over IPv4; nothing changes for existing deployments.

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

How Has This Been Tested?

  • api, server and plugins/hypervisors/kvm compile cleanly
  • bash -n on common.sh
  • NetUtils.ipv6LinkLocal() is covered by existing unit tests in NetUtilsTest (testIpv6LinkLocal), verifying the EUI-64 calculation matches the kernel's

Bring up an EUI-64 based IPv6 link-local address on the control NIC
of system VMs and make sshd listen on it, in addition to the
existing 169.254.0.0/16 IPv4 address.

Since the address is generated with EUI-64 it can be calculated from
the MAC address of the control NIC. listSystemVms now returns it as
'linklocalip6', calculated by the Management Server using
NetUtils.ipv6LinkLocal(), and the UI shows it in the System VMs view.

On KVM the agent enables IPv6 (link-local only, no RA/SLAAC) on the
control bridge (cloud0) when setting up the control network, so the
host can reach system VMs over IPv6 once this is used.
The nftables ip6_firewall and ip6_acl tables created on VRs with
IPv6 networking have an input hook chain with policy drop, which
applies to all interfaces including the control NIC. Accept TCP 3922
between link-local addresses so sshd remains reachable on the IPv6
link-local address of the control interface. Restricting both saddr
and daddr to fe80::/10 ensures no global address can reach sshd.
@boring-cyborg boring-cyborg Bot added the Python Warning... Python code Ahead! label Aug 5, 2026
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.65%. Comparing base (4f11707) to head (137b3da).

Files with missing lines Patch % Lines
...ache/cloudstack/api/response/SystemVmResponse.java 0.00% 6 Missing ⚠️
...m/cloud/hypervisor/kvm/resource/VifDriverBase.java 0.00% 4 Missing ⚠️
...src/main/java/com/cloud/api/ApiResponseHelper.java 0.00% 2 Missing ⚠️
...cloud/hypervisor/kvm/resource/BridgeVifDriver.java 0.00% 1 Missing ⚠️
...om/cloud/hypervisor/kvm/resource/IvsVifDriver.java 0.00% 1 Missing ⚠️
...om/cloud/hypervisor/kvm/resource/OvsVifDriver.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main   #13795   +/-   ##
=========================================
  Coverage     19.65%   19.65%           
  Complexity    19792    19792           
=========================================
  Files          6368     6368           
  Lines        574881   574896   +15     
  Branches      70351    70352    +1     
=========================================
+ Hits         112970   112975    +5     
- Misses       449639   449648    +9     
- Partials      12272    12273    +1     
Flag Coverage Δ
uitests 3.41% <ø> (ø)
unittests 20.92% <0.00%> (+<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.

@wido
wido requested a review from weizhouapache August 5, 2026 06:10
@DaanHoogland DaanHoogland linked an issue Aug 5, 2026 that may be closed by this pull request
@DaanHoogland DaanHoogland added this to the 4.24.0 milestone Aug 5, 2026
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.

Replace control cidr for SSVM by IPv6 Link-Local

2 participants