public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Hanreich <s.hanreich@proxmox.com>
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	[thread overview]
Message-ID: <20261124175718.512428-8-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20261124175718.512428-1-s.hanreich@proxmox.com>

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 <s.hanreich@proxmox.com>
---
 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





  parent reply	other threads:[~2026-11-24 17:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 17:57 [PATCH firewall/proxmox{-ve-rs,-firewall} 0/7] firewall: handle guest network devices without a MAC address Stefan Hanreich
2026-11-24 17:57 ` [PATCH proxmox-ve-rs 1/7] ve-config: guest: require the name of container network devices Stefan Hanreich
2026-11-24 17:57 ` [PATCH proxmox-ve-rs 2/7] ve-config: guest: default the type of container network devices to veth Stefan Hanreich
2026-11-24 17:57 ` [PATCH proxmox-ve-rs 3/7] ve-config: guest: accept network devices without a MAC address Stefan Hanreich
2026-11-24 17:57 ` [PATCH proxmox-firewall 4/7] firewall: guest: handle " Stefan Hanreich
2026-11-25  7:28   ` Arthur Bied-Charreton
2026-11-24 17:57 ` [PATCH proxmox-firewall 5/7] tests: add network devices without " Stefan Hanreich
2026-11-24 17:57 ` [PATCH pve-firewall 6/7] firewall: drop the traffic of guest " Stefan Hanreich
2026-11-24 17:57 ` Stefan Hanreich [this message]
2026-11-25  7:14 ` [PATCH firewall/proxmox{-ve-rs,-firewall} 0/7] firewall: handle guest network devices without a " Arthur Bied-Charreton

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=20261124175718.512428-8-s.hanreich@proxmox.com \
    --to=s.hanreich@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal