Skip to content

debiface: merge an inet6 stanza into the inet stanza of the same iface - #223

Open
luxend0 wants to merge 1 commit into
cloudbase:masterfrom
luxend0:fix/debiface-inet6-same-iface
Open

luxend0 wants to merge 1 commit into
cloudbase:masterfrom
luxend0:fix/debiface-inet6-same-iface

Conversation

@luxend0

@luxend0 luxend0 commented Nov 16, 2026

Copy link
Copy Markdown

Problem

Proxmox VE configdrive2 writes the IPv6 settings of an interface as a separate stanza after the IPv4 one (configdrive2_network):

auto eth0
iface eth0 inet static
        address 192.0.2.10
        netmask 255.255.255.0
        gateway 192.0.2.1
iface eth0 inet6 static
        address 2001:db8:10::10
        netmask 64
        gateway 2001:db8:10::1

With both ip= and ip6= set on a VM, Windows guests only get the IPv6 address. IPv4 is never configured.

Cause

  • debiface.py#L80-L87: every iface line starts a new block. crt_lines = lines6 is overwritten by crt_lines = lines a few lines later, so the inet6 stanza becomes a second NetworkDetails named eth0 with the IPv6 data in the IPv4 fields.
  • networkconfig.py#L131-L134: both entries resolve to the same MAC and macnics[nic.mac] keeps only the last one, so the IPv4 settings are dropped.

Fix

When an inet6 stanza has the same name as the current static inet stanza, its lines go into the v6 half of that block. V6_PROXY already maps address, netmask and gateway to address6, netmask6 and gateway6.

Everything else works as before. That covers inet6 stanzas of other interfaces (the existing eth2 fixture) and inet6 stanzas that follow a non-static inet stanza (ip=dhcp,ip6=...). Merging those would make _preprocess_nics derive a truncated IPv4 address from the IPv6 one.

Tests

  • New test_parse_inet6_stanza_same_iface in cloudbaseinit/tests/utils/test_debiface.py, using a sample in the exact shape of the Proxmox generator: lo with dns_nameservers/dns_search, eth0 inet + inet6 static, eth1 inet dhcp + inet6 static. It fails on master (two eth0 entries) and passes with this change.
  • test_debiface, test_networkconfig, test_baseopenstackservice and test_nocloudservice all pass, and flake8 with hacking 6.1.0 is clean.
  • Running NetworkConfigPlugin with mocked osutils on the sample: master calls set_static_network_config for eth0 only with the IPv6 address. With this change it is called with the IPv4 address and then with the IPv6 address.
  • We hit this in production on Proxmox VE with Windows Server 2022/2025 templates (cloudbase-init 1.1.6). The same change, patched into the image, fixed it.

Proxmox VE (configdrive2) writes the IPv6 settings of an interface as a
separate stanza after the IPv4 one:

    iface eth0 inet static
        address 192.0.2.10
        ...
    iface eth0 inet6 static
        address 2001:db8:10::10
        ...

_get_iface_blocks() starts a new block on every iface line, so this
yields two NetworkDetails named eth0. Both resolve to the same MAC and
NetworkConfigPlugin keeps only the last one per MAC, so the IPv4
address, netmask and gateway are never configured.

When an inet6 stanza has the same name as the current static inet
stanza, feed its lines into the v6 half of that block, where V6_PROXY
already maps address, netmask and gateway to their v6 fields. inet6
stanzas of other interfaces (or after a non static inet stanza) still
start their own block, as before.

Signed-off-by: luxend <luxend@instantnode.eu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant