From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 6311B1FF0AF for ; Fri, 20 Nov 2026 17:01:18 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 0C0D221817; Fri, 20 Nov 2026 17:00:40 +0100 (CET) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH pve-manager 05/10] ui: sdn: fabrics: wireguard: block saving invalid interface values Date: Fri, 20 Nov 2026 17:00:20 +0100 Message-ID: <20261120160026.512565-6-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261120160026.512565-1-s.hanreich@proxmox.com> References: <20261120160026.512565-1-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795190433259 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.205 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: 7OCJSMJ7TZVMOCCYLZKTKWE7NWJ42D5P X-Message-ID-Hash: 7OCJSMJ7TZVMOCCYLZKTKWE7NWJ42D5P X-MailFrom: s.hanreich@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: ExtJS fields only publish valid values to their binding, so entering an out-of-range MTU or listen port left the previous value in the interface record. Since the interface panel never reported itself as invalid, the edit window allowed saving and submitted that previous value. Publish invalid values to the interface record as well and validate all interfaces in the panel, so saving stays blocked while any interface has an invalid value, even after selecting another one. Signed-off-by: Stefan Hanreich --- .../sdn/fabrics/wireguard/InterfacePanel.js | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/www/manager6/sdn/fabrics/wireguard/InterfacePanel.js b/www/manager6/sdn/fabrics/wireguard/InterfacePanel.js index 1a90c09d..8c5def67 100644 --- a/www/manager6/sdn/fabrics/wireguard/InterfacePanel.js +++ b/www/manager6/sdn/fabrics/wireguard/InterfacePanel.js @@ -353,6 +353,13 @@ Ext.define('PVE.sdn.Fabric.WireGuard.InterfacePanel', { minValue: 1, maxValue: 65535, isFormField: false, + // publish invalid values too, so the interface does not silently keep its + // previous value; the panel validates the interfaces instead + publishValue: function () { + if (this.rendered) { + this.publishState('value', this.getValue()); + } + }, }, { fieldLabel: gettext('IPv4 Address'), @@ -375,6 +382,13 @@ Ext.define('PVE.sdn.Fabric.WireGuard.InterfacePanel', { minValue: 1280, maxValue: 65535, isFormField: false, + // publish invalid values too, so the interface does not silently keep its + // previous value; the panel validates the interfaces instead + publishValue: function () { + if (this.rendered) { + this.publishState('value', this.getValue()); + } + }, }, { xtype: 'pveSDNWireGuardPeerSelector', @@ -393,6 +407,7 @@ Ext.define('PVE.sdn.Fabric.WireGuard.InterfacePanel', { ], previousDirty: false, + previousValid: true, controller: { xclass: 'Ext.app.ViewController', @@ -518,6 +533,35 @@ Ext.define('PVE.sdn.Fabric.WireGuard.InterfacePanel', { ); }, + isInterfaceValid: function (iface) { + let { listen_port: listenPort, mtu } = iface.data; + + // values parsed from the configuration are strings, entered values are numbers + let isUnsetOrInRange = (value, min, max) => { + if (value === null || value === undefined || value === '') { + return true; + } + let number = Number(value); + return Number.isInteger(number) && number >= min && number <= max; + }; + + return isUnsetOrInRange(listenPort, 1, 65535) && isUnsetOrInRange(mtu, 1280, 65535); + }, + + isValid: function () { + let me = this; + + if (me.isDisabled()) { + return true; + } + + return me + .getViewModel() + .getStore('interfaces') + .getData() + .items.every((iface) => me.isInterfaceValid(iface)); + }, + initComponent: function () { let me = this; @@ -534,6 +578,12 @@ Ext.define('PVE.sdn.Fabric.WireGuard.InterfacePanel', { me.previousDirty = dirtyStatus; me.fireEvent('dirtychange'); } + + let validStatus = me.isValid(); + if (validStatus !== me.previousValid) { + me.previousValid = validStatus; + me.fireEvent('validitychange', me, validStatus); + } }; me.lookupReference('peerSelector').on({ -- 2.47.3