From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-common 1/4] jsonschema: add full-range CIDR JSON schema formats
Date: Tue, 12 May 2026 13:21:20 +0200 [thread overview]
Message-ID: <20260512112129.224619-2-g.goller@proxmox.com> (raw)
In-Reply-To: <20260512112129.224619-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/JSONSchema.pm | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 1997c703d725..58b86874b0d6 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -590,6 +590,45 @@ sub pve_verify_cidr {
return $cidr;
}
+register_format('FullRangeCIDRv6', \&pve_verify_fullrangecidrv6);
+
+sub pve_verify_fullrangecidrv6 {
+ my ($cidr, $noerr) = @_;
+
+ if ($cidr =~ m!^(?:$IPV6RE)(?:/(\d+))$! && ($1 >= 0) && ($1 <= 128)) {
+ return $cidr;
+ }
+
+ return undef if $noerr;
+ die "value does not look like a valid IPv6 CIDR network\n";
+}
+
+register_format('FullRangeCIDRv4', \&pve_verify_fullrangecidrv4);
+
+sub pve_verify_fullrangecidrv4 {
+ my ($cidr, $noerr) = @_;
+
+ if ($cidr =~ m!^(?:$IPV4RE)(?:/(\d+))$! && ($1 >= 0) && ($1 <= 32)) {
+ return $cidr;
+ }
+
+ return undef if $noerr;
+ die "value does not look like a valid IPv4 CIDR network\n";
+}
+
+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;
+}
+
register_format('pve-ipv4-config', \&pve_verify_ipv4_config);
sub pve_verify_ipv4_config {
--
2.47.3
next prev parent reply other threads:[~2026-05-12 11:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 11:21 [PATCH common/manager/network/proxmox-widget-toolkit 0/4] Extend prefix-list CIDR range Gabriel Goller
2026-05-12 11:21 ` Gabriel Goller [this message]
2026-05-12 11:21 ` [PATCH pve-network 2/4] sdn: prefix-list: allow full prefix " Gabriel Goller
2026-05-12 11:21 ` [PATCH proxmox-widget-toolkit 3/4] toolkit: Add IP/CIDR validator with full prefix range checks Gabriel Goller
2026-05-12 11:21 ` [PATCH pve-manager 4/4] sdn: prefix-lists: change prefix format to allow bigger subnets Gabriel Goller
2026-05-12 22:09 ` [PATCH common/manager/network/proxmox-widget-toolkit 0/4] Extend prefix-list CIDR range Thomas Lamprecht
2026-05-13 8:35 ` 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=20260512112129.224619-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 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.