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 2399B1FF15E for ; Mon, 1 Sep 2025 18:28:35 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 86FB032A04; Mon, 1 Sep 2025 18:28:46 +0200 (CEST) To: pve-devel@lists.proxmox.com Date: Mon, 1 Sep 2025 18:20:34 +0200 In-Reply-To: <20250901162036.2651-1-09couplet.bitmap@icloud.com> References: <20250901162036.2651-1-09couplet.bitmap@icloud.com> MIME-Version: 1.0 Message-ID: List-Id: Proxmox VE development discussion List-Post: From: Guillaume via pve-devel Precedence: list Cc: Guillaume <09couplet.bitmap@icloud.com> X-Mailman-Version: 2.1.29 X-BeenThere: pve-devel@lists.proxmox.com List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Proxmox VE development discussion List-Help: Subject: [pve-devel] [PATCH container v2 2/4] setup: add support of el10 and implementing NetworkManager instead fo network-scripts Content-Type: multipart/mixed; boundary="===============0518483335967806726==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============0518483335967806726== Content-Type: message/rfc822 Content-Disposition: inline Return-Path: <09couplet.bitmap@icloud.com> X-Original-To: pve-devel@lists.proxmox.com Delivered-To: pve-devel@lists.proxmox.com Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 92704D1DDC for ; Mon, 1 Sep 2025 18:28:45 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6B7C232961 for ; Mon, 1 Sep 2025 18:28:15 +0200 (CEST) Received: from 7.mo584.mail-out.ovh.net (7.mo584.mail-out.ovh.net [178.33.253.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 1 Sep 2025 18:28:14 +0200 (CEST) Received: from director4.ghost.mail-out.ovh.net (unknown [10.110.43.142]) by mo584.mail-out.ovh.net (Postfix) with ESMTP id 4cFvJr5mpdz8Gxx for ; Mon, 1 Sep 2025 16:21:48 +0000 (UTC) Received: from ghost-submission-5b5ff79f4f-gqwhg (unknown [10.108.54.199]) by director4.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 5129DC28AB; Mon, 1 Sep 2025 16:21:48 +0000 (UTC) Received: from cours.cloud ([37.59.142.111]) by ghost-submission-5b5ff79f4f-gqwhg with ESMTPSA id mNA4FwHItWi54wAAq4irsw:T3 (envelope-from <09couplet.bitmap@icloud.com>); Mon, 01 Sep 2025 16:21:48 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-111S00541ca0e11-2889-4f21-9c99-eb96fc3c4b98, 626740C7795EBEF0A24945DD74755F9321337A95) smtp.auth=guillaume@cours.cloud X-OVh-ClientIp: 90.50.10.13 From: Guillaume <09couplet.bitmap@icloud.com> To: pve-devel@lists.proxmox.com Cc: Guillaume <09couplet.bitmap@icloud.com> Subject: [PATCH container v2 2/4] setup: add support of el10 and implementing NetworkManager instead fo network-scripts Date: Mon, 1 Sep 2025 18:20:34 +0200 Message-ID: <20250901162036.2651-3-09couplet.bitmap@icloud.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250901162036.2651-1-09couplet.bitmap@icloud.com> References: <20250901162036.2651-1-09couplet.bitmap@icloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 14419400108048218232 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduledviedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefiuhhilhhlrghumhgvuceotdeltghouhhplhgvthdrsghithhmrghpsehitghlohhuugdrtghomheqnecuggftrfgrthhtvghrnhepuefftdduudetteefleeujeetleekgfetieduhfegudehhfehueeikedugfegveeknecukfhppeduvdejrddtrddtrddupdeltddrhedtrddutddrudefpdefjedrheelrddugedvrdduuddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpedtlegtohhuphhlvghtrdgsihhtmhgrphesihgtlhhouhgurdgtohhmpdhnsggprhgtphhtthhopedupdhrtghpthhtohepphhvvgdquggvvhgvlheslhhishhtshdrphhrohigmhhogidrtghomhdpoffvtefjohhsthepmhhoheekgegmpdhmohguvgepshhmthhpohhuth X-SPAM-LEVEL: Spam detection results: 2 AWL 0.099 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_QUAR 0.1 DMARC quarantine policy FREEMAIL_FROM 0.001 Sender email is commonly abused enduser mail provider KAM_DMARC_QUARANTINE 4 DKIM has Failed or SPF has failed on the message and the domain has a DMARC quarantine policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust RCVD_IN_MSPIKE_H3 -0.01 Good reputation (+3) RCVD_IN_MSPIKE_WL -0.01 Mailspike good senders RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_SOFTFAIL 0.665 SPF: sender does not match SPF record (softfail) Red Hat remove support for network configuration files in the ifcfg format until version 10. Signed-off-by: Guillaume <09couplet.bitmap@icloud.com> --- src/PVE/LXC/Setup/CentOS.pm | 108 +++++++++++++++++++++++++++++++++--- 1 file changed, 101 insertions(+), 7 deletions(-) diff --git a/src/PVE/LXC/Setup/CentOS.pm b/src/PVE/LXC/Setup/CentOS.pm index 446b49b..06b4dac 100644 --- a/src/PVE/LXC/Setup/CentOS.pm +++ b/src/PVE/LXC/Setup/CentOS.pm @@ -4,6 +4,7 @@ use strict; use warnings; use UUID; +use Net::IP; use PVE::Tools; use PVE::Network; @@ -19,16 +20,13 @@ sub new { my $release = PVE::Tools::file_read_firstline("$rootdir/etc/redhat-release"); die "unable to read version info\n" if !defined($release); - my $version; + my $version = get_centos_version($release); - if (($release =~ m/release\s+(\d+\.\d+)(\.\d+)?/) || ($release =~ m/release\s+(\d+)/)) { - if ($1 >= 5 && $1 < 10) { - $version = $1; - } + # check compatibility + if (!($version >= 5 && $version < 11)) { + die "unsupported centos version '$version'\n"; } - die "unsupported centos release '$release'\n" if !$version; - my $self = { conf => $conf, rootdir => $rootdir, version => $version }; $conf->{ostype} = "centos"; @@ -36,6 +34,16 @@ sub new { return bless $self, $class; } +sub get_centos_version { + my ($release) = @_; + + if (($release =~ m/release\s+(\d+\.\d+)(\.\d+)?/) || ($release =~ m/release\s+(\d+)/)) { + return $1; + } + + die "unable to parse centos version '$release'\n"; +} + my $tty_conf = <<__EOD__; # tty - getty # @@ -182,6 +190,92 @@ sub set_hostname { sub setup_network { my ($self, $conf) = @_; + my $release = $self->ct_file_get_contents('/etc/redhat-release'); + my $version = get_centos_version($release); + + if ($version >= 10) { + # Use NetworkManager files + setup_netork_with_networkmanager($self, $conf) + } else { + # Use network-scripts files + setup_netork_with_network_scripts($self, $conf) + } +} + +sub setup_netork_with_networkmanager { + my ($self, $conf) = @_; + + $self->ct_make_path('/etc/NetworkManager/system-connections'); + + foreach my $k (keys %$conf) { + next if $k !~ m/^net(\d+)$/; + my $d = PVE::LXC::Config->parse_lxc_network($conf->{$k}); + next if !$d->{name}; + + my $filename = "/etc/NetworkManager/system-connections/$d->{name}.nmconnection"; + + my ($searchdomains, $nameserver) = $self->lookup_dns_conf($conf); + my @nameservers = PVE::Tools::split_list($nameserver); + my @nameserversv4 = grep { + my $ip = Net::IP->new($_); + $ip && $ip->version == 4; + } @nameservers; + my @nameserversv6 = grep { + my $ip = Net::IP->new($_); + $ip && $ip->version == 6; + } @nameservers; + + + my $header = "[connection]\nid=$d->{name}\nuuid=" . UUID::uuid() . "\ntype=ethernet\ninterface-name=$d->{name}\n"; + my $data = ''; + + if ($d->{ip} && $d->{ip} ne 'manual') { + $data .= "[ipv4]\n"; + if ($d->{ip} eq 'dhcp') { + $data .= "method=auto\n"; + } else { + $data .= "method=manual\n"; + $data .= "addresses=$d->{ip}\n"; + if (defined($d->{gw})) { + $data .= "gateway=$d->{gw}\n"; + if (!PVE::Network::is_ip_in_cidr($d->{gw}, $d->{ip}, 4)) { + $data .= "routes=$d->{gw}\n"; + } + } + } + $data .= "dns=" . join(',', @nameserversv4) . "\n" if @nameserversv4; + $data .= "dns-search=" . join(' ', PVE::Tools::split_list($searchdomains)) . "\n" if @nameserversv4 && $searchdomains; + } + + if ($d->{ip6} && $d->{ip6} ne 'manual') { + $data .= "[ipv6]\n"; + if ($d->{ip6} eq 'auto' || $d->{ip6} eq 'dhcp') { + $data .= "method=auto\n"; + } else { + $data .= "method=manual\naddress=$d->{ip6}\n"; + if (defined($d->{gw6})) { + if ( + !PVE::Network::is_ip_in_cidr($d->{gw6}, $d->{ip6}, 6) + && !PVE::Network::is_ip_in_cidr($d->{gw6}, 'fe80::/10', 6) + ) { + $data .= "routes=$d->{gw6}\n"; + } else { + $data .= "gateway=$d->{gw6}\n"; + } + } + } + $data .= "dns=" . join(',', @nameserversv6) . "\n" if @nameserversv6; + $data .= "dns-search=" . join(' ', PVE::Tools::split_list($searchdomains)) . "\n" if @nameserversv6 && $searchdomains; + } + + next unless $data; + $self->ct_file_set_contents($filename, $header . $data, 0600); + } +} + +sub setup_netork_with_network_scripts { + my ($self, $conf) = @_; + my ($gw, $gw6); $self->ct_make_path('/etc/sysconfig/network-scripts'); -- 2.47.2 --===============0518483335967806726== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel --===============0518483335967806726==--