From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-network v2 2/4] sdn: add full-range CIDR JSON schema formats
Date: Wed, 13 May 2026 10:34:21 +0200 [thread overview]
Message-ID: <20260513083430.63529-3-g.goller@proxmox.com> (raw)
In-Reply-To: <20260513083430.63529-1-g.goller@proxmox.com>
Add IPv4, IPv6, and generic CIDR validators that allow the full
prefix range, including /0. Don't change the existing CIDR validators.
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
src/PVE/Network/SDN/PrefixLists.pm | 40 ++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/src/PVE/Network/SDN/PrefixLists.pm b/src/PVE/Network/SDN/PrefixLists.pm
index 19d752d245f0..9bb7174878f7 100644
--- a/src/PVE/Network/SDN/PrefixLists.pm
+++ b/src/PVE/Network/SDN/PrefixLists.pm
@@ -5,6 +5,7 @@ use warnings;
use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_lock_file cfs_write_file);
use PVE::JSONSchema qw(get_standard_option);
+use PVE::Tools;
use PVE::INotify;
use PVE::Network::SDN;
use PVE::Network::SDN::RouteMaps;
@@ -39,6 +40,45 @@ PVE::JSONSchema::register_standard_option(
},
);
+PVE::JSONSchema::register_format('FullRangeCIDRv6', \&pve_verify_fullrangecidrv6);
+
+sub pve_verify_fullrangecidrv6 {
+ my ($cidr, $noerr) = @_;
+
+ if ($cidr =~ m!^(?:$PVE::Tools::IPV6RE)(?:/(\d+))$! && ($1 >= 0) && ($1 <= 128)) {
+ return $cidr;
+ }
+
+ return undef if $noerr;
+ die "value does not look like a valid IPv6 CIDR network\n";
+}
+
+PVE::JSONSchema::register_format('FullRangeCIDRv4', \&pve_verify_fullrangecidrv4);
+
+sub pve_verify_fullrangecidrv4 {
+ my ($cidr, $noerr) = @_;
+
+ if ($cidr =~ m!^(?:$PVE::Tools::IPV4RE)(?:/(\d+))$! && ($1 >= 0) && ($1 <= 32)) {
+ return $cidr;
+ }
+
+ return undef if $noerr;
+ die "value does not look like a valid IPv4 CIDR network\n";
+}
+
+PVE::JSONSchema::register_format('FullRangeCIDR', \&pve_verify_fullrangecidr);
+
+sub pve_verify_fullrangecidr {
+ my ($cidr, $noerr) = @_;
+
+ if (!(pve_verify_fullrangecidrv4($cidr, 1) || pve_verify_fullrangecidrv6($cidr, 1))) {
+ return undef if $noerr;
+ die "value does not look like a valid CIDR network\n";
+ }
+
+ return $cidr;
+}
+
cfs_register_file(
'sdn/prefix-lists.cfg', \&parse_prefix_lists_config, \&write_prefix_lists_config,
);
--
2.47.3
next prev parent reply other threads:[~2026-05-13 8:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 8:34 [PATCH manager/network v2 0/4] Extend prefix-list CIDR range Gabriel Goller
2026-05-13 8:34 ` [PATCH pve-network v2 1/4] sdn: prefix-list: allow full prefix " Gabriel Goller
2026-05-13 8:34 ` Gabriel Goller [this message]
2026-05-13 8:34 ` [PATCH pve-manager v2 3/4] sdn: prefix-lists: change prefix format to allow bigger subnets Gabriel Goller
2026-05-13 8:34 ` [PATCH pve-manager v2 4/4] toolkit: Add IP/CIDR validator with full prefix range checks Gabriel Goller
2026-05-15 5:02 ` applied: [PATCH manager/network v2 0/4] Extend prefix-list CIDR range Thomas Lamprecht
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=20260513083430.63529-3-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