From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox-firewall 4/7] firewall: guest: handle network devices without a MAC address
Date: Tue, 24 Nov 2026 18:57:14 +0100 [thread overview]
Message-ID: <20261124175718.512428-5-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20261124175718.512428-1-s.hanreich@proxmox.com>
A guest network device can lack a MAC address, for example after a
manual edit of the config. qemu-server and pve-container then use a
random one, which the firewall cannot know. Such a guest failed the
parsing of its network config, and with it the whole firewall update.
Leave the device out of the MAC filter, so that the filter drops its
traffic, like it drops the traffic from any other unknown MAC address.
If none of the devices of a guest has a MAC address, there is no set
to match against, so drop all traffic of the guest instead of skipping
the filter. Likewise, leave the link-local address out of the default
IP filter, which then drops traffic from link-local addresses of the
device.
pve-firewall effectively behaves the same, as it builds the filters
from a random MAC address that does not match the one of the guest.
This requires the version of proxmox-ve-config in which the MAC address
of a network device is optional.
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
proxmox-firewall/src/firewall.rs | 38 +++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/proxmox-firewall/src/firewall.rs b/proxmox-firewall/src/firewall.rs
index 5689bdd..1fe35a2 100644
--- a/proxmox-firewall/src/firewall.rs
+++ b/proxmox-firewall/src/firewall.rs
@@ -671,16 +671,28 @@ impl Firewall {
if config.macfilter() {
log::debug!("setting macfilter for guest #{vmid}");
- let mac_address_set: Vec<Expression> = config
+ let firewall_devices: Vec<_> = config
.network_config()
.network_devices()
.iter()
.filter(|(_, device)| device.has_firewall())
- .map(|(index, device)| {
- Expression::concat([
- Expression::from(config.iface_name_by_index(*index)),
- Expression::from(device.mac_address().to_string()),
- ])
+ .collect();
+
+ let mac_address_set: Vec<Expression> = firewall_devices
+ .iter()
+ .filter_map(|(index, device)| {
+ let Some(mac_address) = device.mac_address() else {
+ log::warn!(
+ "guest #{vmid}: net{index} has no MAC address, the MAC filter drops \
+ its traffic"
+ );
+ return None;
+ };
+
+ Some(Expression::concat([
+ Expression::from(config.iface_name_by_index(**index)),
+ Expression::from(mac_address.to_string()),
+ ]))
})
.collect();
@@ -717,6 +729,11 @@ impl Firewall {
commands.push(Add::rule(macfilter_rule));
commands.push(Add::rule(macfilter_arp_rule));
+ } else if !firewall_devices.is_empty() {
+ commands.push(Add::rule(AddRule::from_statement(
+ chain_out.clone(),
+ Statement::make_drop(),
+ )));
}
}
@@ -885,10 +902,11 @@ impl Firewall {
let ipset_name = IpsetName::new(IpsetScope::Guest, ipfilter_name);
let mut ipset = Ipset::new(ipset_name);
- let cidr =
- Ipv6Cidr::from(network_device.mac_address().eui64_link_local_address());
-
- ipset.push(IpsetEntry::from(Cidr::from(cidr)));
+ // without a MAC address, the filter drops traffic from link-local addresses
+ if let Some(mac_address) = network_device.mac_address() {
+ let cidr = Ipv6Cidr::from(mac_address.eui64_link_local_address());
+ ipset.push(IpsetEntry::from(Cidr::from(cidr)));
+ }
if let Some(ip_address) = network_device.ip() {
ipset.push(IpsetEntry::from(Cidr::from(Ipv4Cidr::from(
--
2.47.3
next prev 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 ` Stefan Hanreich [this message]
2026-11-25 7:28 ` [PATCH proxmox-firewall 4/7] firewall: guest: handle " 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 ` [PATCH pve-firewall 7/7] firewall: do not generate MAC addresses for guest network devices Stefan Hanreich
2026-11-25 7:14 ` [PATCH firewall/proxmox{-ve-rs,-firewall} 0/7] firewall: handle guest network devices without a MAC address 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-5-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 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.