From 5bdb5fd6972d021c2317378ab69496cc87b5633f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 1 Jun 2021 14:35:31 +0200 Subject: [PATCH] luci-mod-network: don't accidentally reset macvlan device names Fixes: #5081 Signed-off-by: Jo-Philipp Wich (cherry picked from commit 671c94b034db9d7470d5f1e681b919158de205f6) --- .../luci-static/resources/tools/network.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/tools/network.js b/modules/luci-mod-network/htdocs/luci-static/resources/tools/network.js index 199cd0f152..80b4b2b343 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/tools/network.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/tools/network.js @@ -423,17 +423,19 @@ return baseclass.extend({ o.default = (dev ? dev.getName() : '').match(/^.+\.\d+$/) ? dev.getName().replace(/\.\d+$/, '') : ''; o.ucioption = 'ifname'; o.validate = function(section_id, value) { - var type = this.section.formvalue(section_id, 'type'), - name = this.section.getUIElement(section_id, 'name_complex'); + if (isNew) { + var type = this.section.formvalue(section_id, 'type'), + name = this.section.getUIElement(section_id, 'name_complex'); - if (type == 'macvlan' && value && name && !name.isChanged()) { - var i = 0; + if (type == 'macvlan' && value && name && !name.isChanged()) { + var i = 0; - while (deviceSectionExists(section_id, '%smac%d'.format(value, i))) - i++; + while (deviceSectionExists(section_id, '%smac%d'.format(value, i))) + i++; - name.setValue('%smac%d'.format(value, i)); - name.triggerValidation(); + name.setValue('%smac%d'.format(value, i)); + name.triggerValidation(); + } } return true; -- 2.30.2