[PATCH] base-files: migrate old UCI network sections defining bridges

Rafał Miłecki zajec5 at gmail.com
Sat May 15 14:11:09 PDT 2021


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

Old "interface" sections for bridges were mixing layer 2 and layer 3.
Migrate them to the new styles that has:
1. "device" UCI section for L2 bridge
2. "interface" UCI section for L3 interface

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

diff --git a/package/base-files/files/etc/uci-defaults/11_network-bridge b/package/base-files/files/etc/uci-defaults/11_network-bridge
new file mode 100644
index 0000000000..7a53e8e355
--- /dev/null
+++ b/package/base-files/files/etc/uci-defaults/11_network-bridge
@@ -0,0 +1,29 @@
+. /lib/functions.sh
+
+migrate_bridge() {
+	local config="$1"
+	local type ifname
+
+	config_get type "$config" type
+	[ "$type" != "bridge" ] && return
+
+	config_get ifname "$config" ifname
+
+	uci -q batch <<-EOF
+		add network device
+		set network. at device[-1].name='br-$1'
+		set network. at device[-1].type='bridge'
+	EOF
+	for port in $ifname; do uci add_list network. at device[-1].ports="$port"; done
+
+	uci -q batch <<-EOF
+		delete network.$1.type
+		set network.$1.ifname='br-$1'
+	EOF
+}
+
+config_load network
+config_foreach migrate_bridge interface
+uci commit network
+
+exit 0
-- 
2.26.2




More information about the openwrt-devel mailing list