luci-mod-network: fix loading ra_mtu and ra_hoplimit options
authorJo-Philipp Wich <jo@mein.io>
Wed, 1 Dec 2021 22:08:19 +0000 (23:08 +0100)
committerJo-Philipp Wich <jo@mein.io>
Wed, 1 Dec 2021 22:20:27 +0000 (23:20 +0100)
Fixes: #5565
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit d19d717de241fccb655cb9651f3b10e998dd62c3)

modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js

index 86075c1a8fe2a895dfe16e48eb82c21f85338cf6..a730dc4d718aff9c7365e20006ecaa976525e20a 100644 (file)
@@ -835,15 +835,17 @@ return view.extend({
                                        so.depends('ra', 'server');
                                        so.depends({ ra: 'hybrid', master: '0' });
                                        so.load = function(section_id) {
-                                               var dev = ifc.getL3Device();
+                                               var dev = ifc.getL3Device(),
+                                                   path = dev ? "/proc/sys/net/ipv6/conf/%s/mtu".format(dev.getName()) : null;
 
-                                               if (dev) {
-                                                       var path = "/proc/sys/net/ipv6/conf/%s/mtu".format(dev.getName());
+                                               return Promise.all([
+                                                       dev ? L.resolveDefault(fs.read(path), dev.getMTU()) : null,
+                                                       this.super('load', [section_id])
+                                               ]).then(L.bind(function(res) {
+                                                       this.placeholder = +res[0];
 
-                                                       return L.resolveDefault(fs.read(path), dev.getMTU()).then(L.bind(function(data) {
-                                                               this.placeholder = data;
-                                                       }, this));
-                                               }
+                                                       return res[1];
+                                               }, this));
                                        };
 
                                        so = ss.taboption('ipv6-ra', form.Value, 'ra_hoplimit', _('<abbr title="Router Advertisement">RA</abbr> Hop Limit'), _('The maximum hops  to be published in <abbr title="Router Advertisement">RA</abbr> messages. Maximum is 255 hops.'));
@@ -852,15 +854,17 @@ return view.extend({
                                        so.depends('ra', 'server');
                                        so.depends({ ra: 'hybrid', master: '0' });
                                        so.load = function(section_id) {
-                                               var dev = ifc.getL3Device();
+                                               var dev = ifc.getL3Device(),
+                                                   path = dev ? "/proc/sys/net/ipv6/conf/%s/hop_limit".format(dev.getName()) : null;
 
-                                               if (dev) {
-                                                       var path = "/proc/sys/net/ipv6/conf/%s/hop_limit".format(dev.getName());
+                                               return Promise.all([
+                                                       dev ? L.resolveDefault(fs.read(path), 64) : null,
+                                                       this.super('load', [section_id])
+                                               ]).then(L.bind(function(res) {
+                                                       this.placeholder = +res[0];
 
-                                                       return L.resolveDefault(fs.read(path), 64).then(L.bind(function(data) {
-                                                               this.placeholder = data;
-                                                       }, this));
-                                               }
+                                                       return res[1];
+                                               }, this));
                                        };