From f48c8e59868bd995d8ea0f76e6cf26d2a1c6eb11 Mon Sep 17 00:00:00 2001 From: Findlay Feng Date: Tue, 27 Feb 2024 15:30:05 +0800 Subject: [PATCH] luci-proto-bonding: Modify ipaddr as optional Signed-off-by: Findlay Feng --- .../luci-static/resources/protocol/bonding.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/protocols/luci-proto-bonding/htdocs/luci-static/resources/protocol/bonding.js b/protocols/luci-proto-bonding/htdocs/luci-static/resources/protocol/bonding.js index 4c774290f0..5309931a2a 100644 --- a/protocols/luci-proto-bonding/htdocs/luci-static/resources/protocol/bonding.js +++ b/protocols/luci-proto-bonding/htdocs/luci-static/resources/protocol/bonding.js @@ -42,8 +42,11 @@ function getSelectableSlaves(section_id) { }); } -function validateEmpty(section, value) { - if (value) { +function validate_netmask_empty(section, value) { + var opt = this.map.lookupOption('ipaddr', section); + var ipaddr = opt[0].formvalue(section); + + if (!ipaddr || value) { return true; } else { @@ -164,13 +167,15 @@ return network.registerProtocol('bonding', { _('IPv4 address'), _('The local IPv4 address')); o.datatype = 'ip4addr'; + o.optional = true; o.rmempty = false; o = s.taboption('general', form.Value, 'netmask', _('IPv4 netmask'), _('The local IPv4 netmask')); o.datatype = 'ip4addr'; - o.validate = validateEmpty; + o.optional = true; + o.validate = validate_netmask_empty; o.rmempty = false; o.value("255.255.255.0"); o.value("255.255.0.0"); @@ -196,7 +201,7 @@ return network.registerProtocol('bonding', { }; o.validate = updatePrimaries; o.rmempty = false; - + o = s.taboption('advanced', form.ListValue, 'bonding_policy', _('Bonding Policy'), _('Specifies the mode to be used for this bonding interface')); -- 2.30.2