[PATCH] luci-mod-network: Fix migration overwriting device attribute

Hauke Mehrtens hauke at hauke-m.de
Sat May 29 05:31:24 PDT 2021


Without this patch we first migrate the configuration to the br-lan
device entry and change the device option of the network interface to
point to the newly created device. In the next step all device options
will be overwritten with the ifname entry, this partly reverted the
change from the previous migration.

The configuration we work on is not changed between these steps, so the
functions all work on the same initial configuration.

This patch changes the order to first migrate all ifname options to
device or ports and do the migration of the bridges as the last step.
This way the bridge migration is not overwritten any more.

Without this patch this configuration:
-------------------------------------------------------------
config interface 'lan'
    option type 'bridge'
    option ifname 'lan0 lan1'
    option proto 'static'
    option ipaddr '192.168.1.1'
    option netmask '255.255.255.0'
    option ip6assign '60'
-------------------------------------------------------------

Is migrated to this broken configuration:
-------------------------------------------------------------
config interface 'lan'
    option proto 'static'
    option ipaddr '192.168.1.1'
    option netmask '255.255.255.0'
    option ip6assign '60'
    option device 'lan0 lan1'

config device
    option name 'br-lan'
    option type 'bridge'
    list ports 'lan0'
    list ports 'lan1'
-------------------------------------------------------------

Fixes: 74be304e541f ("treewide: use "device" option in UCI "interface" sections")
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 .../resources/view/network/interfaces.js      | 28 +++++++++----------
 1 file changed, 14 insertions(+), 14 deletions(-)

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 6f8fd614b1..38f4b7e60c 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
@@ -321,18 +321,10 @@ return view.extend({
 		var interfaces = this.interfaceBridgeWithIfnameSections();
 		var tasks = [];
 
-		interfaces.forEach(function(ns) {
-			var device_name = 'br-' + ns['.name'];
-
-			tasks.push(uci.callAdd('network', 'device', null, {
-				'name': device_name,
-				'type': 'bridge',
-				'ports': L.toArray(ns.ifname)
-			}));
-
+		this.interfaceWithIfnameSections().forEach(function(ns) {
 			tasks.push(uci.callSet('network', ns['.name'], {
-				'type': '',
-				'device': device_name
+				'ifname': '',
+				'device': ns.ifname
 			}));
 		});
 
@@ -343,10 +335,18 @@ return view.extend({
 			}));
 		});
 
-		this.interfaceWithIfnameSections().forEach(function(ns) {
+		interfaces.forEach(function(ns) {
+			var device_name = 'br-' + ns['.name'];
+
+			tasks.push(uci.callAdd('network', 'device', null, {
+				'name': device_name,
+				'type': 'bridge',
+				'ports': L.toArray(ns.ifname)
+			}));
+
 			tasks.push(uci.callSet('network', ns['.name'], {
-				'ifname': '',
-				'device': ns.ifname
+				'type': '',
+				'device': device_name
 			}));
 		});
 
-- 
2.30.2




More information about the openwrt-devel mailing list