From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 603671FF144 for ; Tue, 24 Feb 2026 17:14:01 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D6F1D111C1; Tue, 24 Feb 2026 17:14:54 +0100 (CET) From: Moayad Almalat To: pve-devel@lists.proxmox.com Subject: [PATCH pve-cluster v3] fix #2685: datacenter: allow 4-bit suffix in mac_prefix Date: Tue, 24 Feb 2026 17:14:18 +0100 Message-ID: <20260224161418.320892-1-m.almalat@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -0.931 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 1.179 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.717 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.236 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: OLH5DCGEBFTVUGP4DF2SPI4RAAY3XF6V X-Message-ID-Hash: OLH5DCGEBFTVUGP4DF2SPI4RAAY3XF6V X-MailFrom: moayad@sara.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --- src/PVE/DataCenterConfig.pm | 2 +- src/test/Makefile | 9 ++++++++- src/test/test_mac_prefix.pl | 24 ++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/test/test_mac_prefix.pl diff --git a/src/PVE/DataCenterConfig.pm b/src/PVE/DataCenterConfig.pm index 514c867..d88b167 100644 --- a/src/PVE/DataCenterConfig.pm +++ b/src/PVE/DataCenterConfig.pm @@ -224,7 +224,7 @@ PVE::JSONSchema::register_format('mac-prefix', \&pve_verify_mac_prefix); sub pve_verify_mac_prefix { my ($mac_prefix, $noerr) = @_; - if ($mac_prefix !~ m/^[a-f0-9][02468ace](?::[a-f0-9]{2}){0,2}:?$/i) { + if ($mac_prefix !~ m/^[a-f0-9][02468ace](?::[a-f0-9]{2}){0,2}(?::[a-f0-9]?)?$/i) { return undef if $noerr; die "value is not a valid unicast MAC address prefix\n"; } diff --git a/src/test/Makefile b/src/test/Makefile index 757f35f..cdd37d0 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -4,8 +4,15 @@ cpgtest: cpgtest.c gcc -Wall cpgtest.c $(shell pkg-config --cflags --libs libcpg libqb) -o cpgtest .PHONY: check install clean distclean -check: +check: corosync-parser-test test-mac-prefix + +.PHONY: corosync-parser-test +corosync-parser-test: ./corosync_parser_test.pl +.PHONY: test-mac-prefix +test-mac-prefix: + perl test_mac_prefix.pl + distclean: clean clean: diff --git a/src/test/test_mac_prefix.pl b/src/test/test_mac_prefix.pl new file mode 100644 index 0000000..631874c --- /dev/null +++ b/src/test/test_mac_prefix.pl @@ -0,0 +1,24 @@ +use strict; +use warnings; + +use Test::More; + +use lib ('.', '..'); + +use PVE::DataCenterConfig; + +my $longest_prefix_len = 10; +my $prefix = "00:00:00:00:00:00"; + +# test that all sub-strings of $prefix longer than "00" and strictly shorter than +# "00:00:00:00" are OK +for (my $i = 0; $i <= length($prefix); $i++) { + my $sub_prefix = substr($prefix, 0, $i); + if (2 <= $i && $i <= $longest_prefix_len) { + ok(PVE::DataCenterConfig::pve_verify_mac_prefix($sub_prefix), "$sub_prefix is a valid mac prefix"); + } else { + is(PVE::DataCenterConfig::pve_verify_mac_prefix($sub_prefix, 1), undef, "$sub_prefix is not valid mac prefix"); + } +} + +done_testing(); -- 2.47.3