From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH ve-rs 1/2] fix: firewall: introduce iptables to nftables mapping for icmpv6-types
Date: Tue, 16 Sep 2025 11:31:10 +0200 [thread overview]
Message-ID: <20250916093116.114942-2-g.goller@proxmox.com> (raw)
In-Reply-To: <20250916093116.114942-1-g.goller@proxmox.com>
nftables changed the names of the icmpv6-types and they don't overlap
completely with the old iptables names. Introduce a mapping that
converts old names into the new ones. A few of these are not supported,
see here for more info:
https://wiki.nftables.org/wiki-nftables/index.php/Supported_features_compared_to_xtables#icmp6
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
.../src/firewall/types/rule_match.rs | 33 +++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/proxmox-ve-config/src/firewall/types/rule_match.rs b/proxmox-ve-config/src/firewall/types/rule_match.rs
index 7fcd35c80d86..8202cda57895 100644
--- a/proxmox-ve-config/src/firewall/types/rule_match.rs
+++ b/proxmox-ve-config/src/firewall/types/rule_match.rs
@@ -697,6 +697,31 @@ const ICMPV6_TYPES: [(&str, u8); 19] = sorted!([
("time-exceeded", 3),
]);
+/// Some icmp_types are not supported by nftables. See:
+/// https://wiki.nftables.org/wiki-nftables/index.php/Supported_features_compared_to_xtables#icmp6
+#[sortable]
+const IPTABLES_ICMP_TYPES_MAPPING: [(&str, Option<&str>); 19] = sorted!([
+ ("no-route", None),
+ ("communication-prohibited", None),
+ ("beyond-scope", None),
+ ("address-unreachable", None),
+ ("port-unreachable", None),
+ ("failed-policy", None),
+ ("reject-route'", None),
+ ("ttl-zero-during-transit", None),
+ ("ttl-zero-during-reassembly", None),
+ ("bad-header", None),
+ ("unknown-header-type", None),
+ ("unknown-option", None),
+ ("router-solicitation", Some("nd-router-solicit")),
+ ("router-advertisement", Some("nd-router-advert")),
+ ("neighbor-solicitation", Some("nd-neighbor-solicit")),
+ ("neighbour-solicitation", Some("nd-neighbor-solicit")),
+ ("neighbor-advertisement", Some("nd-neighbor-advert")),
+ ("neighbour-advertisement", Some("nd-neighbor-advert")),
+ ("redirect", Some("nd-redirect")),
+]);
+
impl std::str::FromStr for Icmpv6Type {
type Err = Error;
@@ -713,6 +738,14 @@ impl std::str::FromStr for Icmpv6Type {
return Ok(Self::Named(ICMPV6_TYPES[index].0));
}
+ if let Ok(index) = IPTABLES_ICMP_TYPES_MAPPING.binary_search_by(|v| v.0.cmp(s)) {
+ if let Some(mapped_nftables_type) = IPTABLES_ICMP_TYPES_MAPPING[index].1 {
+ return Ok(Self::Named(mapped_nftables_type));
+ } else {
+ bail!("icmp_type {s:?} is unsupported in nftables");
+ }
+ }
+
bail!("{s:?} is not a valid icmpv6 type");
}
}
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-09-16 9:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 9:31 [pve-devel] [PATCH proxmox-firewall/ve-rs 0/3] Fix ICMPv6 types in nftables Gabriel Goller
2025-09-16 9:31 ` Gabriel Goller [this message]
2025-09-16 9:31 ` [pve-devel] [PATCH ve-rs 2/2] firewall: correctly return errors when parsing icmpv6 types and codes Gabriel Goller
2025-09-16 9:31 ` [pve-devel] [PATCH proxmox-firewall 1/1] tests: add icmpv6 type mapping test Gabriel Goller
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=20250916093116.114942-2-g.goller@proxmox.com \
--to=g.goller@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