From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 1EB6A1FF066 for ; Tue, 24 Nov 2026 18:58:04 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 45F2E21733; Tue, 24 Nov 2026 18:57:32 +0100 (CET) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH pve-firewall 7/7] firewall: do not generate MAC addresses for guest network devices Date: Tue, 24 Nov 2026 18:57:17 +0100 Message-ID: <20261124175718.512428-8-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261124175718.512428-1-s.hanreich@proxmox.com> References: <20261124175718.512428-1-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795543047060 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.176 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 7MJHYG2OV5V5Y2GQS6X34QZYSRZHAPXA X-Message-ID-Hash: 7MJHYG2OV5V5Y2GQS6X34QZYSRZHAPXA X-MailFrom: s.hanreich@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: The parsers of qemu-server and pve-container generate a random MAC address for a network device without one, so each compilation built the MAC filter and the IP filter from a different address. The filters dropped the traffic of the device anyway, as the address never matched the one the guest uses, but the ruleset changed on every compilation, so it was applied again each time. Parse the devices without generating a MAC address, so that such a device has none, and the filters drop its traffic consistently. pve-container only supports this from the version that fixes starting containers with such a device. With an older version, a random MAC address is generated as before. Signed-off-by: Stefan Hanreich --- src/PVE/Firewall.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm index 053b289..369d8d8 100644 --- a/src/PVE/Firewall.pm +++ b/src/PVE/Firewall.pm @@ -4659,7 +4659,7 @@ sub compile_iptables_filter { foreach my $netid (sort keys %$conf) { next if $netid !~ m/^net(\d+)$/; - my $net = PVE::QemuServer::Network::parse_net($conf->{$netid}); + my $net = PVE::QemuServer::Network::parse_net($conf->{$netid}, 1); next if !$net->{firewall}; my $iface = "tap${vmid}i$1"; @@ -4709,7 +4709,7 @@ sub compile_iptables_filter { foreach my $netid (sort keys %$conf) { next if $netid !~ m/^net(\d+)$/; - my $net = PVE::LXC::Config->parse_lxc_network($conf->{$netid}); + my $net = PVE::LXC::Config->parse_lxc_network($conf->{$netid}, 1); next if !$net->{firewall}; my $iface = "veth${vmid}i$1"; @@ -4810,7 +4810,7 @@ sub compile_ipsets { my $device_ips = {}; foreach my $netid (keys %$conf) { next if $netid !~ m/^net(\d+)$/; - my $net = PVE::QemuServer::Network::parse_net($conf->{$netid}); + my $net = PVE::QemuServer::Network::parse_net($conf->{$netid}, 1); next if !$net->{firewall}; if ($vmfw_conf->{options}->{ipfilter} && !$ipsets->{"ipfilter-$netid"}) { @@ -4863,7 +4863,7 @@ sub compile_ipsets { my $device_ips = {}; foreach my $netid (keys %$conf) { next if $netid !~ m/^net(\d+)$/; - my $net = PVE::LXC::Config->parse_lxc_network($conf->{$netid}); + my $net = PVE::LXC::Config->parse_lxc_network($conf->{$netid}, 1); next if !$net->{firewall}; if ($vmfw_conf->{options}->{ipfilter} && !$ipsets->{"ipfilter-$netid"}) { @@ -4974,7 +4974,7 @@ sub compile_ebtables_filter { foreach my $netid (sort keys %$conf) { next if $netid !~ m/^net(\d+)$/; - my $net = PVE::QemuServer::Network::parse_net($conf->{$netid}); + my $net = PVE::QemuServer::Network::parse_net($conf->{$netid}, 1); next if !$net->{firewall}; my $iface = "tap${vmid}i$1"; next if !valid_interface_name($iface); @@ -5005,7 +5005,7 @@ sub compile_ebtables_filter { foreach my $netid (sort keys %$conf) { next if $netid !~ m/^net(\d+)$/; - my $net = PVE::LXC::Config->parse_lxc_network($conf->{$netid}); + my $net = PVE::LXC::Config->parse_lxc_network($conf->{$netid}, 1); next if !$net->{firewall}; my $iface = "veth${vmid}i$1"; next if !valid_interface_name($iface); -- 2.47.3