From 300961bb1ba7d71b50288b97c0fdeae0c71253e7 Mon Sep 17 00:00:00 2001 From: Daniel Nilsson Date: Sat, 21 Sep 2024 19:38:49 +0200 Subject: luci-mod-network: split interface name and protocol validation The previous implementation of binding the protocol validation to the name validation caused problems when creating a new interface where an already existing interface had the new one's protocol as its name, as the protocol would be used when validating if an interface of that name already existed. Consider the following case: 1. Interface 'gre' with protocol PPPoE is created 2. Interface 'foo' with protocol GRE tunnel over IPv4 (which resolves to 'gre') tries to be created Creating interface 'foo' would error out during protocol validation as 'gre' would be passed to the name validation, which in turn would check if an interface with name 'gre' already exists, which it does. Instead of reusing the validation logic, simply trigger the name validation manually as the protocol changes to properly pass the name of the interface instead of the protocol. This also gives the benefit of keeping all error states related to the name contained in the appropriate UI element. Fixes #7146 Tested-by: Tiago Gaspar Signed-off-by: Daniel Nilsson --- .../htdocs/luci-static/resources/view/network/interfaces.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'modules/luci-mod-network') diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js index db3bb8eaff..112f9436ae 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js @@ -1237,7 +1237,10 @@ return view.extend({ }; proto = s2.option(form.ListValue, 'proto', _('Protocol')); - proto.validate = name.validate; + proto.onchange = function(ev, section_id, value) { + var elem = name.getUIElement(section_id); + elem.triggerValidation(); + }; device = s2.option(widgets.DeviceSelect, 'device', _('Device')); device.noaliases = false; -- cgit v1.2.3