[PATCH] base-files: migrate old UCI network bridge ports syntax

Rafał Miłecki zajec5 at gmail.com
Sat May 18 04:41:01 PDT 2024


From: Rafał Miłecki <rafal at milecki.pl>

netifd supports more accurate "ports" option (instead of "ifname") for
years now. Relevant changes were even backported to OpenWrt 21.02. Add
uci-defaults script that translates config files using deprecated
syntax.

Identical commit f716c30241d5 ended up reverted back in 2021 by
80be798d4a4f due to breaking downgrades. With 19.07 support ended it
should no longer be an issue.

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 .../uci-defaults/11_network-migrate-bridges   | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 package/base-files/files/etc/uci-defaults/11_network-migrate-bridges

diff --git a/package/base-files/files/etc/uci-defaults/11_network-migrate-bridges b/package/base-files/files/etc/uci-defaults/11_network-migrate-bridges
new file mode 100644
index 0000000000..745648531f
--- /dev/null
+++ b/package/base-files/files/etc/uci-defaults/11_network-migrate-bridges
@@ -0,0 +1,23 @@
+. /lib/functions.sh
+
+migrate_ports() {
+	local config="$1"
+	local type ports ifname
+
+	config_get type "$config" type
+	[ "$type" != "bridge" ] && return
+
+	config_get ports "$config" ports
+	[ -n "$ports" ] && return
+
+	config_get ifname "$config" ifname
+	[ -z "$ifname" ] && return
+
+	for port in $ifname; do uci add_list network.$config.ports="$port"; done
+	uci delete network.$config.ifname
+}
+
+config_load network
+config_foreach migrate_ports device
+
+exit 1
-- 
2.35.3




More information about the openwrt-devel mailing list