Skip to content

network-legacy: Change ip=any to mean dual stack DHCP - #2628

Open
chewi wants to merge 1 commit into
dracut-ng:mainfrom
chewi:network-legacy-dual-stack
Open

network-legacy: Change ip=any to mean dual stack DHCP#2628
chewi wants to merge 1 commit into
dracut-ng:mainfrom
chewi:network-legacy-dual-stack

Conversation

@chewi

@chewi chewi commented Aug 20, 2026

Copy link
Copy Markdown
Member

systemd-network-generator tries to support the same IP configuration syntax as Dracut. One difference is that Dracut supports multiple comma-separated autoconf values (e.g. dhcp,dhcp6) whereas systemd only permits one. Fixing this in systemd may not be straightforward.

This matters because Afterburn can emit dhcp,dhcp6 for KubeVirt, and it is now being adapted to support systemd-network-generator as well as Dracut's network-legacy module.

Even if systemd-network-generator did support multiple values, the behaviour would not be the same. Both systemd-networkd and NetworkManager always try both IPv4 and IPv6, normally requiring just one of them to work, whereas network-legacy will not even try IPv6 if IPv4 works, or vice-versa depending on the order given. It is not currently possible to make network-legacy always try both.

To workaround the lack of multi-value support in systemd and to mirror how systemd and NetworkManager behave, I am changing ip=any to always try both protocols, requiring just one to work. They are tried in parallel to avoid the cost of a double timeout. Despite the name, this is currently treated by network-legacy as IPv4-only. The history of ifup.sh reveals that any was supported before IPv6 was, and that IPv6 was initially added with "preliminary" support. Perhaps the author didn't want to change the behaviour of any until that support was better established and then forgot, or perhaps it was merely an oversight.

systemd-network-generator also treats ip=on as dual stack, but that would be a more controversial change. Users may not expect IPv6 alone to be considered successful. NetworkManager even treats ip=dhcp as dual stack, but I feel that is wrong. With ip=any, the intent is clearer, and this at least gives us one option where the behaviour is consistent.

Much of this change is adjusting the dhclient PID and lease paths to be protocol-specific so that IPv4 and IPv6 instances can be run simultaneously.

There were no tests for explicit IP configuration at all, but I felt it was important to have this covered, so some have been added. To avoid unnecessary overhead, this spins up just one VM with several differently configured interfaces.

The module changes were mostly written by me with a little help from AI. The tests were entirely written by AI.

Checklist

  • I have tested it locally
  • I have reviewed and updated any documentation if relevant
  • I am providing new code and test(s) for it

@chewi
chewi requested a review from a team as a code owner August 20, 2026 16:26
@github-actions github-actions Bot added docs github Issues related to .github man modules Issue tracker for all modules net-lib network-legacy Issues related to the network-legacy module test Issues related to testing labels Aug 20, 2026
@chewi

chewi commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

CC @dracut-ng/gentoo-maint @dracut-ng/opensuse-maint

systemd-network-generator tries to support the same IP configuration
syntax as Dracut. One difference is that Dracut supports multiple
comma-separated autoconf values (e.g. `dhcp,dhcp6`) whereas systemd only
permits one. Fixing this in systemd may not be straightforward.

This matters because Afterburn can emit `dhcp,dhcp6` for KubeVirt, and
it is now being adapted to support systemd-network-generator as well as
Dracut's network-legacy module.

Even if systemd-network-generator did support multiple values, the
behaviour would not be the same. Both systemd-networkd and
NetworkManager always try both IPv4 and IPv6, normally requiring just
one of them to work, whereas network-legacy will not even try IPv6 if
IPv4 works, or vice-versa depending on the order given. It is not
currently possible to make network-legacy always try both.

To workaround the lack of multi-value support in systemd and to mirror
how systemd and NetworkManager behave, I am changing `ip=any` to always
try both protocols, requiring just one to work. They are tried in
parallel to avoid the cost of a double timeout. Despite the name, this
is currently treated by network-legacy as IPv4-only. The history of
ifup.sh reveals that `any` was supported before IPv6 was, and that IPv6
was initially added with "preliminary" support. Perhaps the author
didn't want to change the behaviour of `any` until that support was
better established and then forgot, or perhaps it was merely an
oversight.

systemd-network-generator also treats `ip=on` as dual stack, but that
would be a more controversial change. Users may not expect IPv6 alone to
be considered successful. NetworkManager even treats `ip=dhcp` as dual
stack, but I feel that is wrong. With `ip=any`, the intent is clearer,
and this at least gives us one option where the behaviour is consistent.

Much of this change is adjusting the dhclient PID and lease paths to be
protocol-specific so that IPv4 and IPv6 instances can be run
simultaneously.

There were no tests for explicit IP configuration at all, but I felt it
was important to have this covered, so some have been added. To avoid
unnecessary overhead, this spins up just one VM with several differently
configured interfaces.

The module changes were mostly written by me with a little help from AI.
The tests were entirely written by AI.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
@chewi
chewi force-pushed the network-legacy-dual-stack branch from e5cdf6b to 73830a0 Compare August 20, 2026 16:32
@chewi

chewi commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

I was a little slow to join the dots and realise that Fedora CoreOS now uses NetworkManager rather than network-legacy. With Flatcar migrating to systemd-network-generator, I could probably change this in Afterburn without impacting anybody. Still, I think the fix makes sense for those still using network-legacy in other contexts.

@aafeijoo-suse

Copy link
Copy Markdown
Contributor

I was a little slow to join the dots and realise that Fedora CoreOS now uses NetworkManager rather than network-legacy.

Same in openSUSE, the default is NetworkManager for some years now, and some people use systemd-networkd. The legacy network module is only still alive (for now) to facilitate maintenance, but I'd not add anything new to it.

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

Labels

docs github Issues related to .github man modules Issue tracker for all modules net-lib network-legacy Issues related to the network-legacy module test Issues related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants