base-files: preinit: also config switch when no port roles defined
authorChuanhong Guo <gch981213@gmail.com>
Fri, 10 Apr 2020 04:07:25 +0000 (12:07 +0800)
committerChuanhong Guo <gch981213@gmail.com>
Sun, 12 Apr 2020 14:29:02 +0000 (22:29 +0800)
current preinit code in base-files doesn't config switch when there are
no port roles defined. But this kind of configuration exists on single
port devices where switch vlan is simply disabled.
configure reset and enable_vlan property when a switch node exist.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
package/base-files/Makefile
package/base-files/files/lib/preinit/10_indicate_preinit

index 87c43fdc0c881df1d44865c95407d154bc3bdb92..f0085e56905c5854d13a0dd7f6a063b0ebdf5732 100644 (file)
@@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk
 include $(INCLUDE_DIR)/feeds.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=216
+PKG_RELEASE:=217
 PKG_FLAGS:=nonshared
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
index c3ec7bfdf77bc95d4881755a1ec59711da4448a3..423c425223ed0882b355f54eb471b06743f27669 100644 (file)
@@ -33,6 +33,11 @@ preinit_config_switch() {
 
        json_get_vars enable reset
 
+       if [ "$reset" -eq "1" ]; then
+               swconfig dev $name set reset
+       fi
+       swconfig dev $name set enable_vlan $enable
+
        if json_is_a roles array; then
                json_get_keys roles roles
                json_select roles
@@ -43,19 +48,15 @@ preinit_config_switch() {
                        json_select ..
 
                        if [ "$device" = "$lan_if" ]; then
-                               if [ "$reset" -eq "1" ]; then
-                                       swconfig dev $name set reset
-                               fi
-
-                               swconfig dev $name set enable_vlan $enable
                                swconfig dev $name vlan $role set ports "$ports"
-                               swconfig dev $name set apply
                        fi
                done
 
                json_select ..
        fi
 
+       swconfig dev $name set apply
+
        json_select ..
        json_select ..
 }