base-files: migrate old UCI network sections defining bridges
authorRafał Miłecki <rafal@milecki.pl>
Tue, 18 May 2021 21:41:33 +0000 (23:41 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Wed, 19 Jun 2024 10:47:58 +0000 (12:47 +0200)
Old "interface" sections for bridges were mixing layer 2 and layer 3.
That syntax got deprecated and UCI section "device" is used for bridge
configuration now.

Backward compatibility may be dropped from netifd soon now so migrate
old configs using uci-defaults script.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
package/base-files/files/etc/uci-defaults/11_network-migrate-bridges

index ad13d1a353542049705ec6908422e066151d8009..a9dece418d6817a6ded7f2e743dbe648ece68a91 100644 (file)
@@ -19,5 +19,31 @@ migrate_ports() {
        uci delete network.$config.ifname
 }
 
+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.@device[-1].name='br-$config'
+               set network.@device[-1].type='bridge'
+       EOF
+       for port in $ifname; do
+               uci add_list network.@device[-1].ports="$port"
+       done
+
+       uci -q batch <<-EOF
+               delete network.$config.type
+               delete network.$config.ifname
+               set network.$config.device='br-$config'
+       EOF
+}
+
 config_load network
 config_foreach migrate_ports device
+config_foreach migrate_bridge interface