From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox-firewall 11/14] firewall: put guest traffic of zone VRFs into their conntrack zone
Date: Thu, 19 Nov 2026 20:45:43 +0100 [thread overview]
Message-ID: <20261119194547.674512-12-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20261119194547.674512-1-s.hanreich@proxmox.com>
Bridge conntrack tracks the connections of guests as soon as the guest
table uses conntrack, and routed packets keep that entry in the inet
hooks. The conntrack zones set by the sdn-ct-zones command therefore
come too late for guest traffic.
Set the conntrack zone of the VRF for the traffic of its vnets in a
chain of the guest table that runs before bridge conntrack. As the
chain is part of the guest table, it exists exactly when bridge
conntrack is in use. The conntrack zones are taken from the SDN running
config.
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
.../resources/proxmox-firewall.nft | 13 ++++++++
proxmox-firewall/src/config.rs | 8 +++++
proxmox-firewall/src/firewall.rs | 30 +++++++++++++++++++
.../tests/input/.running-config.json | 4 ++-
.../integration_tests__firewall.snap | 24 +++++++++++++++
5 files changed, 78 insertions(+), 1 deletion(-)
diff --git a/proxmox-firewall/resources/proxmox-firewall.nft b/proxmox-firewall/resources/proxmox-firewall.nft
index 2675727..af69248 100644
--- a/proxmox-firewall/resources/proxmox-firewall.nft
+++ b/proxmox-firewall/resources/proxmox-firewall.nft
@@ -44,6 +44,7 @@ add chain bridge proxmox-firewall-guests pre-vm-in
add chain bridge proxmox-firewall-guests vm-in {type filter hook postrouting priority 0; policy accept;}
add chain bridge proxmox-firewall-guests before-bridge
add chain bridge proxmox-firewall-guests forward {type filter hook forward priority 0; policy accept;}
+add chain bridge proxmox-firewall-guests sdn-ct-zone {type filter hook prerouting priority -310; policy accept;}
flush chain inet proxmox-firewall do-reject
flush chain inet proxmox-firewall accept-management
@@ -84,6 +85,7 @@ flush chain bridge proxmox-firewall-guests pre-vm-in
flush chain bridge proxmox-firewall-guests vm-in
flush chain bridge proxmox-firewall-guests before-bridge
flush chain bridge proxmox-firewall-guests forward
+flush chain bridge proxmox-firewall-guests sdn-ct-zone
table inet proxmox-firewall {
chain do-reject {
@@ -296,6 +298,17 @@ table bridge proxmox-firewall-guests {
typeof iifname : verdict
}
+ map sdn-ct-zones {
+ typeof meta ibrname : ct zone
+ }
+
+ # Bridge conntrack tracks the connections of the guests, and routed packets keep the entry in
+ # the inet hooks, so the conntrack zone of their VRF has to be set before it (priority -200).
+ chain sdn-ct-zone {
+ type filter hook prerouting priority -310; policy accept;
+ ct zone set meta ibrname map @sdn-ct-zones
+ }
+
chain allow-dhcp-in {
udp sport . udp dport { 67 . 68, 547 . 546 } accept
}
diff --git a/proxmox-firewall/src/config.rs b/proxmox-firewall/src/config.rs
index 7e055c0..cf82bc6 100644
--- a/proxmox-firewall/src/config.rs
+++ b/proxmox-firewall/src/config.rs
@@ -26,6 +26,7 @@ use proxmox_nftables::types::ListChain;
use proxmox_ve_config::sdn::{
VnetName,
config::{RunningConfig, SdnConfig},
+ conntrack::VrfCtZone,
ipam::{Ipam, IpamJson},
};
@@ -319,6 +320,13 @@ impl FirewallSdnConfig {
&self.config
}
+ /// The vnets of zones with a dedicated VRF, together with the conntrack zone of the VRF.
+ pub fn vnet_ct_zones(&self) -> impl Iterator<Item = (&VnetName, VrfCtZone)> + '_ {
+ self.config
+ .vnets()
+ .filter_map(|(zone, vnet)| Some((vnet.name(), zone.ct_zone()?)))
+ }
+
pub fn ipsets(&self) -> &BTreeMap<String, Ipset> {
&self.ipsets
}
diff --git a/proxmox-firewall/src/firewall.rs b/proxmox-firewall/src/firewall.rs
index d620a2e..d80a463 100644
--- a/proxmox-firewall/src/firewall.rs
+++ b/proxmox-firewall/src/firewall.rs
@@ -82,6 +82,10 @@ impl Firewall {
SetName::new(Self::guest_table(), format!("vm-map-{dir}"))
}
+ fn sdn_ct_zone_map() -> SetName {
+ SetName::new(Self::guest_table(), "sdn-ct-zones")
+ }
+
fn cluster_chain(dir: Direction) -> ChainPart {
ChainPart::new(Self::cluster_table(), format!("cluster-{dir}"))
}
@@ -156,6 +160,7 @@ impl Firewall {
Flush::map(Self::guest_vmap(Direction::Out)),
Flush::map(Self::bridge_vmap(Self::guest_table())),
Flush::map(Self::bridge_vmap(Self::host_table())),
+ Flush::map(Self::sdn_ct_zone_map()),
Flush::chain(Self::host_conntrack_chain()),
Flush::chain(Self::synflood_limit_chain()),
Flush::chain(Self::log_invalid_tcp_chain()),
@@ -331,6 +336,7 @@ impl Firewall {
if !(enabled_guests.is_empty() && enabled_bridges.is_empty()) {
log::info!("creating guest configuration");
+ self.create_sdn_ct_zones(&mut commands);
self.create_management_ipset(&mut commands, &guest_table)?;
self.create_ipsets(
@@ -455,6 +461,30 @@ impl Firewall {
Ok(())
}
+ /// Puts the traffic of vnets in zones with a dedicated VRF into the conntrack zone of the VRF.
+ fn create_sdn_ct_zones(&self, commands: &mut Commands) {
+ let Some(sdn) = self.config.sdn() else {
+ return;
+ };
+
+ let elements: Vec<(Expression, MapValue)> = sdn
+ .vnet_ct_zones()
+ .map(|(vnet, ct_zone)| {
+ (
+ Expression::from(vnet.as_ref()),
+ MapValue::from(Expression::from(ct_zone.id())),
+ )
+ })
+ .collect();
+
+ if !elements.is_empty() {
+ commands.push(Add::element(AddElement::map_from_expressions(
+ Self::sdn_ct_zone_map(),
+ elements,
+ )));
+ }
+ }
+
fn handle_host_options(&self, commands: &mut Commands) -> Result<(), Error> {
log::info!("setting host options");
diff --git a/proxmox-firewall/tests/input/.running-config.json b/proxmox-firewall/tests/input/.running-config.json
index a4511f0..c674352 100644
--- a/proxmox-firewall/tests/input/.running-config.json
+++ b/proxmox-firewall/tests/input/.running-config.json
@@ -35,7 +35,9 @@
"test": {
"dhcp": "dnsmasq",
"ipam": "pve",
- "type": "simple"
+ "type": "simple",
+ "dedicated-vrf": 1,
+ "ct-zone": 16384
}
}
},
diff --git a/proxmox-firewall/tests/snapshots/integration_tests__firewall.snap b/proxmox-firewall/tests/snapshots/integration_tests__firewall.snap
index 69fb10a..a434586 100644
--- a/proxmox-firewall/tests/snapshots/integration_tests__firewall.snap
+++ b/proxmox-firewall/tests/snapshots/integration_tests__firewall.snap
@@ -148,6 +148,15 @@ expression: "firewall.full_host_fw().expect(\"firewall can be generated\")"
}
}
},
+ {
+ "flush": {
+ "map": {
+ "family": "bridge",
+ "table": "proxmox-firewall-guests",
+ "name": "sdn-ct-zones"
+ }
+ }
+ },
{
"flush": {
"chain": {
@@ -4366,6 +4375,21 @@ expression: "firewall.full_host_fw().expect(\"firewall can be generated\")"
}
}
},
+ {
+ "add": {
+ "element": {
+ "family": "bridge",
+ "table": "proxmox-firewall-guests",
+ "name": "sdn-ct-zones",
+ "elem": [
+ [
+ "public",
+ 16384
+ ]
+ ]
+ }
+ }
+ },
{
"add": {
"set": {
--
2.47.3
next prev parent reply other threads:[~2026-11-19 19:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 19:45 [PATCH docs/manager/network/proxmox{,-ve-rs,-firewall} 00/14] sdn: conntrack zones and SNAT for simple zones with a dedicated VRF Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox 01/14] network-api: expose the master device of a link Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-ve-rs 02/14] sdn: config: read the conntrack zone of zones with a dedicated VRF Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-ve-rs 03/14] sdn: conntrack: map the interfaces of zone VRFs to their conntrack zone Stefan Hanreich
2026-11-19 19:45 ` [PATCH pve-network 04/14] sdn: simple: SNAT via the uplinks of zone VRFs Stefan Hanreich
2026-11-19 19:45 ` [PATCH pve-network 05/14] sdn: zones: assign a conntrack zone to zones with a dedicated VRF Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-firewall 06/14] firewall: apply vnet rules to host traffic from vnets in a VRF Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-firewall 07/14] nftables: expression: add a constructor for map lookups Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-firewall 08/14] nftables: statement: add a helper for setting the conntrack zone Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-firewall 09/14] nftables: expression: convert the conntrack zones of zone VRFs Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-firewall 10/14] firewall: add a command applying " Stefan Hanreich
2026-11-19 19:45 ` Stefan Hanreich [this message]
2026-11-19 19:45 ` [PATCH pve-manager 12/14] network: apply " Stefan Hanreich
2026-11-19 19:45 ` [PATCH pve-manager 13/14] network: warn if pve-firewall cannot isolate guests in " Stefan Hanreich
2026-11-19 19:45 ` [PATCH pve-docs 14/14] pvesdn: simple zones: document dedicated VRFs Stefan Hanreich
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=20261119194547.674512-12-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.