From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox-firewall 09/14] nftables: expression: convert the conntrack zones of zone VRFs
Date: Thu, 19 Nov 2026 20:45:41 +0100 [thread overview]
Message-ID: <20261119194547.674512-10-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20261119194547.674512-1-s.hanreich@proxmox.com>
The interfaces of zone VRFs need to be mapped to the conntrack zone of
their VRF. Convert them into the data of an anonymous map, so that a
rule can set the conntrack zone with a map lookup of the interface name.
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
proxmox-nftables/src/expression.rs | 53 ++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/proxmox-nftables/src/expression.rs b/proxmox-nftables/src/expression.rs
index 010c0c6..cfd6a97 100644
--- a/proxmox-nftables/src/expression.rs
+++ b/proxmox-nftables/src/expression.rs
@@ -14,6 +14,8 @@ use proxmox_ve_config::firewall::types::rule_match::{IcmpCode, IcmpType, Icmpv6C
use proxmox_ve_config::guest::types::Vmid;
#[cfg(feature = "config-ext")]
use proxmox_ve_config::host::types::BridgeName;
+#[cfg(feature = "config-ext")]
+use proxmox_ve_config::sdn::conntrack::VrfCtZones;
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
@@ -276,6 +278,16 @@ impl From<Vmid> for Expression {
}
}
+/// The interfaces of the zone VRFs with their conntrack zone, for use as data of a map lookup.
+#[cfg(feature = "config-ext")]
+impl From<&VrfCtZones> for Expression {
+ fn from(value: &VrfCtZones) -> Self {
+ Expression::set(value.interfaces().map(|(interface, ct_zone)| {
+ Expression::List(vec![interface.into(), ct_zone.id().into()])
+ }))
+ }
+}
+
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Meta {
key: String,
@@ -432,3 +444,44 @@ pub struct Element {
config: ElemConfig,
val: Expression,
}
+
+#[cfg(all(test, feature = "config-ext"))]
+mod tests {
+ use std::str::FromStr;
+
+ use proxmox_ve_config::sdn::ZoneName;
+ use proxmox_ve_config::sdn::config::{ZoneConfig, ZoneType};
+ use proxmox_ve_config::sdn::conntrack::VrfCtZone;
+ use serde_json::json;
+
+ use super::*;
+
+ #[test]
+ fn vrf_ct_zones_map_data() {
+ let mut ct_zones = VrfCtZones::default();
+
+ assert_eq!(
+ serde_json::to_value(Expression::from(&ct_zones)).unwrap(),
+ json!({ "set": [] })
+ );
+
+ for (name, ct_zone) in [("red", 16384), ("blue", 16389)] {
+ let mut zone = ZoneConfig::new(ZoneName::from_str(name).unwrap(), ZoneType::Simple);
+ zone.set_ct_zone(VrfCtZone::new(ct_zone));
+ ct_zones.add_zone(&zone);
+ }
+
+ ct_zones.add_interface("vrf_red", "vnetr1");
+ ct_zones.add_interface("vrf_blue", "vnetb");
+
+ assert_eq!(
+ serde_json::to_value(Expression::from(&ct_zones)).unwrap(),
+ json!({ "set": [
+ ["vrf_blue", 16389],
+ ["vnetb", 16389],
+ ["vrf_red", 16384],
+ ["vnetr1", 16384],
+ ]})
+ );
+ }
+}
--
2.47.3
next prev parent reply other threads:[~2026-11-19 19:47 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 ` Stefan Hanreich [this message]
2026-11-19 19:45 ` [PATCH proxmox-firewall 10/14] firewall: add a command applying the conntrack zones of zone VRFs Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-firewall 11/14] firewall: put guest traffic of zone VRFs into their conntrack zone Stefan Hanreich
2026-11-19 19:45 ` [PATCH pve-manager 12/14] network: apply the conntrack zones of zone VRFs 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-10-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