luci-proto-vxlan: fix tos write and load handlers
authorPaul Donald <newtwen+github@gmail.com>
Thu, 7 Nov 2024 00:45:41 +0000 (01:45 +0100)
committerPaul Donald <newtwen+github@gmail.com>
Thu, 7 Nov 2024 00:46:57 +0000 (01:46 +0100)
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
(cherry picked from commit 1de73e16f525a5edc80954afda50db88b3cf96da)

protocols/luci-proto-vxlan/htdocs/luci-static/resources/protocol/vxlan.js
protocols/luci-proto-vxlan/htdocs/luci-static/resources/protocol/vxlan6.js

index 3997bc6277854261622e24562a20143ec357c382..358f1da2cb78ff5a3edf25c45abc014ec49a7cc4 100644 (file)
@@ -157,10 +157,13 @@ return network.registerProtocol('vxlan', {
                        return false;
                };
                o.write = function(section_id, value) {
-                       return uci.set('network', section_id, 'tos', parseInt(value).toString(16).padStart(2, '0'));
+                       if (!value) return
+                       value = value === 'inherit' ? value : parseInt(value).toString(16).padStart(2, '0');
+                       return uci.set('network', section_id, 'tos', value);
                };
                o.load = function(section_id) {
-                       return parseInt(uci.get('network', section_id, 'tos'), 16).toString();
+                       const value = uci.get('network', section_id, 'tos');
+                       return value ? (value === 'inherit' ? value : parseInt(value, 16).toString()) : null;
                };
 
                o = s.taboption('advanced', form.Flag, 'rxcsum', _('Enable rx checksum'));
index 9f54d4c1b8234f1999c9202d7351d571bb21b9cf..3bf6a50c6ac511d40eff5509cfb98f163dbb0c01 100644 (file)
@@ -157,10 +157,13 @@ return network.registerProtocol('vxlan6', {
                        return false;
                };
                o.write = function(section_id, value) {
-                       return uci.set('network', section_id, 'tos', parseInt(value).toString(16).padStart(2, '0'));
+                       if (!value) return
+                       value = value === 'inherit' ? value : parseInt(value).toString(16).padStart(2, '0');
+                       return uci.set('network', section_id, 'tos', value);
                };
                o.load = function(section_id) {
-                       return parseInt(uci.get('network', section_id, 'tos'), 16).toString();
+                       const value = uci.get('network', section_id, 'tos');
+                       return value ? (value === 'inherit' ? value : parseInt(value, 16).toString()) : null;
                };
 
                o = s.taboption('advanced', form.Flag, 'rxcsum', _('Enable rx checksum'));