[PATCH] base-files: generate "device" UCI type section for bridge

Rafał Miłecki zajec5 at gmail.com
Sat May 15 12:12:40 PDT 2021


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

This switches from the old way of defining bridges in an "interface" UCI
section type (that should be used for layer 3 only). From now a defualt
board switch will have its own "device" UCI section type. It's a new &
preferred way of defining L2 devices.

Before:

config interface 'lan'
        option type 'bridge'
        option ifname 'lan1 lan2 lan3 lan4'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'

After:

config device
        option name 'lan'
        option type 'bridge'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'

config interface 'lan'
        option ifname 'lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 package/base-files/files/bin/config_generate | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate
index 56f6c4423b..0f6f280cf0 100755
--- a/package/base-files/files/bin/config_generate
+++ b/package/base-files/files/bin/config_generate
@@ -110,8 +110,14 @@ generate_network() {
 	}
 
 	[ -n "$ports" ] && {
-		type="bridge"
-		ifname="$ports"
+		uci -q batch <<-EOF
+			add network device
+			set network. at device[-1].name='$1'
+			set network. at device[-1].type='bridge'
+		EOF
+		for port in $ports; do uci add_list network. at device[-1].ports="$port"; done
+		ifname=$1
+		type=
 	}
 
 	[ -n "$bridge" ] && {
-- 
2.26.2




More information about the openwrt-devel mailing list