From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH installer 7/8] common: options: rework network address setup to handle ipv6-only
Date: Fri, 8 May 2026 20:44:10 +0200 [thread overview]
Message-ID: <20260508184546.113293-8-c.heiss@proxmox.com> (raw)
In-Reply-To: <20260508184546.113293-1-c.heiss@proxmox.com>
With this, IPv6-only setups are now handled properly. Previously it
would fail to actually select IPv6 addresses for the interface and DNS
on such setups, instead falling back to the default IPv4 addresses set
above.
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
proxmox-installer-common/src/options.rs | 89 ++++++++++++-------------
1 file changed, 44 insertions(+), 45 deletions(-)
diff --git a/proxmox-installer-common/src/options.rs b/proxmox-installer-common/src/options.rs
index ed00b4b..8929bd4 100644
--- a/proxmox-installer-common/src/options.rs
+++ b/proxmox-installer-common/src/options.rs
@@ -425,59 +425,58 @@ impl NetworkOptions {
pinning_opts: pinning_opts.cloned(),
};
- if let Some(ip) = network.dns.dns.first() {
- this.dns_server = *ip;
- }
-
- if let Some(routes) = &network.routes
- && let Some(gw) = &routes.gateway4
- && let Some(iface) = network.interfaces.get(&gw.dev)
- {
- // we got some ipv4 connectivity, so use that
-
- if let Some(opts) = pinning_opts
- && let Some(pinned) = iface.to_pinned(opts)
- {
- this.ifname.clone_from(&pinned.name);
- } else {
- this.ifname.clone_from(&iface.name);
- }
-
- if let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv4()) {
- this.gateway = gw.gateway;
- this.address = *addr;
- } else if let Some(gw) = &routes.gateway6
+ let iface = if let Some(routes) = &network.routes {
+ if let Some(gw) = &routes.gateway4
&& let Some(iface) = network.interfaces.get(&gw.dev)
- && let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv6())
{
- // no ipv4, but ipv6 connectivity
- if let Some(opts) = pinning_opts
- && let Some(pinned) = iface.to_pinned(opts)
- {
- this.ifname.clone_from(&pinned.name);
- } else {
- this.ifname.clone_from(&iface.name);
+ this.gateway = gw.gateway;
+
+ if let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv4()) {
+ this.address = *addr;
}
- this.gateway = gw.gateway;
- this.address = *addr;
- }
- }
+ if let Some(addr) = network.dns.dns.iter().find(|addr| addr.is_ipv4()) {
+ this.dns_server = *addr;
+ }
- // In case no there are no routes defined at all (e.g. no DHCP lease),
- // try to set the interface name to *some* valid values. At least one
- // NIC should always be present here, as the installation will abort
- // earlier in that case, so use the first one enumerated.
- if this.ifname.is_empty()
- && let Some(iface) = network.interfaces.values().min_by_key(|v| v.index)
- {
- if let Some(opts) = pinning_opts
- && let Some(pinned) = iface.to_pinned(opts)
+ Some(iface)
+ } else if let Some(gw) = &routes.gateway6
+ && let Some(iface) = network.interfaces.get(&gw.dev)
{
- this.ifname.clone_from(&pinned.name);
+ this.gateway = gw.gateway;
+
+ if let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv6()) {
+ this.address = *addr;
+ }
+
+ if let Some(addr) = network.dns.dns.iter().find(|addr| addr.is_ipv6()) {
+ this.dns_server = *addr;
+ }
+
+ Some(iface)
} else {
- this.ifname.clone_from(&iface.name);
+ None
}
+ } else {
+ None
+ }
+ .unwrap_or_else(|| {
+ // Safety: In case no there are no routes defined at all (e.g. no DHCP lease), try to
+ // set the interface name to *some* valid values. At least one NIC must always be
+ // present here, as the installation will abort earlier otherwise, so use the first one
+ // enumerated.
+ network
+ .interfaces
+ .values()
+ .min_by_key(|v| v.index)
+ .expect("at least one NIC must be present")
+ });
+
+ // Use pinned network interface name, if enabled
+ if let Some(pinned) = pinning_opts.and_then(|opts| iface.to_pinned(opts)) {
+ this.ifname.clone_from(&pinned.name);
+ } else {
+ this.ifname.clone_from(&iface.name);
}
if let Some(ref mut opts) = this.pinning_opts {
--
2.53.0
next prev parent reply other threads:[~2026-05-08 18:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 18:44 [PATCH installer 0/8] add IPv6 SLAAC and v6-only support Christoph Heiss
2026-05-08 18:44 ` [PATCH installer 1/8] install: drop trivial fromjs() wrapper and use JSON::from_json() Christoph Heiss
2026-05-08 18:44 ` [PATCH installer 2/8] install: move network subroutines to Proxmox::Sys::Net Christoph Heiss
2026-05-08 18:44 ` [PATCH installer 3/8] gui: use run_env->{network} instead of old run_env->{ipconf} Christoph Heiss
2026-05-08 18:44 ` [PATCH installer 4/8] sys: net: drop the now-unused `ipconf` runtime environment configuration Christoph Heiss
2026-05-08 18:44 ` [PATCH installer 5/8] sys: net: allow up to /128 netmask for IPv6 Christoph Heiss
2026-05-08 18:44 ` [PATCH RFC installer 6/8] sys: net: ignore ipv6 nameservers with zone identifiers Christoph Heiss
2026-05-08 18:44 ` Christoph Heiss [this message]
2026-05-08 18:44 ` [PATCH installer 8/8] unconfigured: try to retrieve IPv6 SLAAC addresses on startup Christoph Heiss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260508184546.113293-8-c.heiss@proxmox.com \
--to=c.heiss@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.