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 48F5B1FF144 for ; Tue, 24 Feb 2026 16:27:10 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4AED6FC40; Tue, 24 Feb 2026 16:28:03 +0100 (CET) From: Maximiliano Sandoval To: Moayad Almalat Subject: Re: [PATCH proxmox-widget-toolkit v2] fix #2685: ui: allow 4-bit mac_prefix suffix In-Reply-To: <20260224120536.141228-1-m.almalat@proxmox.com> (Moayad Almalat's message of "Tue, 24 Feb 2026 13:05:36 +0100") References: <20260224120536.141228-1-m.almalat@proxmox.com> User-Agent: mu4e 1.12.9; emacs 30.1 Date: Tue, 24 Feb 2026 16:27:28 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1771946833538 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.976 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 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. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 5F6P7STR62NHSBCVZCPUGAUK4A7UH6HE X-Message-ID-Hash: 5F6P7STR62NHSBCVZCPUGAUK4A7UH6HE X-MailFrom: m.sandoval@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 CC: pve-devel@lists.proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Moayad Almalat writes: > Signed-off-by: Moayad Almalat > --- > src/Toolkit.js | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/Toolkit.js b/src/Toolkit.js > index d4e579b..39513b8 100644 > --- a/src/Toolkit.js > +++ b/src/Toolkit.js > @@ -72,7 +72,7 @@ Ext.apply(Ext.form.field.VTypes, { > MacAddressText: gettext('Example') + ': 01:23:45:67:89:ab', > > MacPrefix: function (v) { > - return /^[a-f0-9][02468ace](?::[a-f0-9]{2}){0,2}:?$/i.test(v); > + return /^(?:[a-f0-9][02468ace](?::[a-f0-9]{2}){0,2}:?|[a-f0-9][02468ace](?::[a-f0-9]{2}){2}:[a-f0-9])$/i.test(v); > }, > MacPrefixMask: /[a-fA-F0-9:]/, > MacPrefixText: I had the following stashed locally: ``` modified 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: new file 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(); ``` Perhaps this can be added here either in a followup or in v3. This is pre-existing issue, but at the moment we only allow for 8bit, 16bit or 24bit suffixes, e.g. 00:00:0 is not allowed. The test above will test any possible prefix lenght from 00 to 00:00:00:0. -- Maximiliano