From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 8D6861FF133 for ; Mon, 11 May 2026 11:10:11 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0364AE58F; Mon, 11 May 2026 11:10:10 +0200 (CEST) Message-ID: <97ad2754-0db5-493c-94e3-2367ab5d539d@proxmox.com> Date: Mon, 11 May 2026 11:09:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH installer 3/8] gui: use run_env->{network} instead of old run_env->{ipconf} To: Christoph Heiss , pve-devel@lists.proxmox.com References: <20260508184546.113293-1-c.heiss@proxmox.com> <20260508184546.113293-4-c.heiss@proxmox.com> From: Hannes Laimer Content-Language: en-US In-Reply-To: <20260508184546.113293-4-c.heiss@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778490459625 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.081 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [net.pm] Message-ID-Hash: OH6SK4ZRW7WNB2OIDMP4CJRZFUQ3HORO X-Message-ID-Hash: OH6SK4ZRW7WNB2OIDMP4CJRZFUQ3HORO X-MailFrom: h.laimer@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: looks like this is missing an update to the `device_change_handler` closure in `sub create_ipconf_view` (proxinstall) On 2026-05-08 20:44, Christoph Heiss wrote: > The TUI started out with using the newer network configuration. That > information is parsed from the iproute2 JSON output, instead of the > human-readable output - making it more robust. > > Reworking the network address/gateway/DNS server selection also allows > for properly handling IPv4 and/or IPv6 setups, by always selecting the > correct IP address for the "active" network, based on the gateway. > > Signed-off-by: Christoph Heiss > --- > Proxmox/Sys/Net.pm | 6 +++++ > proxinstall | 66 ++++++++++++++++++++++++++++++---------------- > 2 files changed, 50 insertions(+), 22 deletions(-) > > diff --git a/Proxmox/Sys/Net.pm b/Proxmox/Sys/Net.pm > index 9571236..10144e0 100644 > --- a/Proxmox/Sys/Net.pm > +++ b/Proxmox/Sys/Net.pm > @@ -10,6 +10,7 @@ use JSON qw(from_json); > > use base qw(Exporter); > our @EXPORT_OK = qw( > + ip_get_version > parse_ip_address > parse_ip_mask > parse_fqdn > @@ -134,6 +135,11 @@ sub parse_ip_address { > return (undef, undef); > } > > +sub ip_get_version { > + my ($ip, $ver) = parse_ip_address($_[0]); > + return $ver; > +} > + > sub parse_ip_mask { > my ($text, $ip_version) = @_; > $text =~ s/^\s+//; > diff --git a/proxinstall b/proxinstall > index f5e1555..8291a46 100755 > --- a/proxinstall > +++ b/proxinstall > @@ -37,7 +37,9 @@ use Proxmox::Sys; > use Proxmox::Sys::Block qw(get_cached_disks); > use Proxmox::Sys::Command qw(syscmd); > use Proxmox::Sys::File qw(file_read_all file_write_all); > -use Proxmox::Sys::Net qw(parse_ip_address parse_ip_mask validate_link_pin_map DEFAULT_PIN_PREFIX); > +use Proxmox::Sys::Net qw( > + parse_ip_address ip_get_version parse_ip_mask validate_link_pin_map DEFAULT_PIN_PREFIX > +); > use Proxmox::UI; > > my $step_number = 0; # Init number for global function list > @@ -430,7 +432,21 @@ sub create_ipconf_view { > Proxmox::UI::display_html('ipconf.htm'); > > my $run_env = Proxmox::Install::RunEnv::get(); > - my $ipconf = $run_env->{ipconf}; > + my $network = $run_env->{network}; > + > + # prefer ipv4 gateway and fallback to ipv6 > + my $default_gateway = $network->{routes}->{gateway4} // $network->{routes}->{gateway6}; > + > + my $default_gateway_ipversion = ip_get_version($default_gateway->{gateway}) > + if defined($default_gateway->{gateway}); > + > + my $default_dns = undef; > + if (defined($default_gateway)) { > + # try to retrieve the first dns server matching the IP version of the gateway > + ($default_dns) = grep { > + ip_get_version($_) == $default_gateway_ipversion > + } @{ $network->{dns}->{dns} }; > + } > > my $grid = &$create_basic_grid(); > $grid->set_row_spacing(10); > @@ -463,20 +479,20 @@ sub create_ipconf_view { > > my $mapping = Proxmox::Install::Config::get_network_interface_pin_map(); > my $i = 0; > - for my $index (sort keys $ipconf->{ifaces}->%*) { > - my $iface = $ipconf->{ifaces}->{$index}; > + for my $name (sort keys $network->{interfaces}->%*) { > + my $iface = $network->{interfaces}->{$name}; > my $iter = $device_model->append(); > > my $symbol = "$iface->{state}" eq "UP" ? "\x{25CF}" : ' '; > - my $name = > + my $label = > $gtk_state->{network_pinning_enabled} && defined($mapping->{ $iface->{mac} }) > ? $mapping->{ $iface->{mac} } > - : $iface->{name}; > + : $name; > > $device_model->set( > $iter, > 0 => $symbol, > - 1 => "$name - $iface->{mac} ($iface->{driver})", > + 1 => "$label - $iface->{mac} ($iface->{driver})", > ); > $i++; > } > @@ -513,7 +529,7 @@ sub create_ipconf_view { > return if $current->get_active() == -1; > > my $new = $device_active_map->{ $current->get_active() }; > - my $iface = $ipconf->{ifaces}->{$new}; > + my $iface = $network->{interfaces}->{$new}; > > my $selected = Proxmox::Install::Config::get_mngmt_nic(); > return if defined($selected) && $iface->{name} eq $selected; > @@ -529,15 +545,22 @@ sub create_ipconf_view { > my ($initial_active_device_pos, $initial_addr, $initial_mask) = (0, undef, undef); > > my $i = 0; > - for my $index (sort keys $ipconf->{ifaces}->%*) { > - my $iface = $ipconf->{ifaces}->{$index}; > - $device_active_map->{$i} = $index; > - $device_active_reverse_map->{ $iface->{name} } = $i; > + for my $name (sort keys $network->{interfaces}->%*) { > + my $iface = $network->{interfaces}->{$name}; > + $device_active_map->{$i} = $name; > + $device_active_reverse_map->{$name} = $i; > > - if (defined($ipconf->{default}) && $index == $ipconf->{default}) { > + if (defined($default_gateway) && $name eq $default_gateway->{dev}) { > + # the chosen gateway is on this interface > $initial_active_device_pos = $i; > - $initial_addr = $iface->{inet}->{addr} || $iface->{inet6}->{addr}; > - $initial_mask = $iface->{inet}->{prefix} || $iface->{inet6}->{prefix}; > + > + # now find an address that matches the IP version of the gateway > + my ($addr) = grep { > + ip_get_version($_->{address}) == $default_gateway_ipversion > + } @{ $iface->{addresses} }; > + > + $initial_addr = $addr->{address}; > + $initial_mask = $addr->{prefix}; > } > $i++; > } > @@ -548,9 +571,8 @@ sub create_ipconf_view { > if (my $nic = Proxmox::Install::Config::get_mngmt_nic()) { > $initial_active_device_pos = $device_active_reverse_map->{$nic}; > } else { > - my $iface_id = $device_active_map->{$initial_active_device_pos}; > - my $iface = $ipconf->{ifaces}->{$iface_id}; > - Proxmox::Install::Config::set_mngmt_nic($iface->{name}); > + my $iface_name = $device_active_map->{$initial_active_device_pos}; > + Proxmox::Install::Config::set_mngmt_nic($iface_name); > } > > if (my $cidr = Proxmox::Install::Config::get_cidr()) { > @@ -574,7 +596,7 @@ sub create_ipconf_view { > > my $fqdn = Proxmox::Install::Config::get_fqdn(); > my $hostname = $run_env->{network}->{hostname} || $iso_env->{product}; > - my $domain = $ipconf->{domain} || "example.invalid"; > + my $domain = $network->{dns}->{domain} || "example.invalid"; > $fqdn //= "$hostname.$domain"; > > my ($host_label, $hostentry) = create_text_input($fqdn, 'Hostname (FQDN)'); > @@ -585,14 +607,14 @@ sub create_ipconf_view { > $grid->attach($cidr_box, 1, 2, 2, 1); > > my $cfg_gateway = Proxmox::Install::Config::get_gateway(); > - my $gateway = $cfg_gateway // $ipconf->{gateway} || '192.168.100.1'; > + my $gateway = $cfg_gateway // $default_gateway->{gateway} || '192.168.100.1'; > > my ($gw_label, $ipconf_entry_gw) = create_text_input($gateway, 'Gateway'); > $grid->attach($gw_label, 0, 3, 1, 1); > $grid->attach($ipconf_entry_gw, 1, 3, 2, 1); > > my $cfg_dns = Proxmox::Install::Config::get_dns(); > - my $dnsserver = $cfg_dns // $ipconf->{dnsserver} || $gateway; > + my $dnsserver = $cfg_dns // $default_dns || $gateway; > > my ($dns_label, $ipconf_entry_dns) = create_text_input($dnsserver, 'DNS Server'); > > @@ -1915,7 +1937,7 @@ my $initial_error = 0; > } > > my $run_env = Proxmox::Install::RunEnv::get(); > -if (!$initial_error && (scalar keys $run_env->{ipconf}->{ifaces}->%* == 0)) { > +if (!$initial_error && (scalar keys $run_env->{network}->{interfaces}->%* == 0)) { > print STDERR "no network interfaces found\n"; > $initial_error = 1; > Proxmox::UI::display_html("nonics.htm");