config: initialize bridge and bridge vlans before other devices
authorFelix Fietkau <nbd@nbd.name>
Wed, 18 Nov 2020 14:15:01 +0000 (15:15 +0100)
committerFelix Fietkau <nbd@nbd.name>
Wed, 18 Nov 2020 14:36:49 +0000 (15:36 +0100)
This allows vlan devices to access bridge vlan data safely, regardless
of the order in which sections appear in the config

Signed-off-by: Felix Fietkau <nbd@nbd.name>
config.c

index 8122a955a5f388604d57631498e1812fbe1b38e5..563dedc4a8b722d3ca4aa2ca967b3d50dbca8629 100644 (file)
--- a/config.c
+++ b/config.c
@@ -221,7 +221,7 @@ config_parse_rule(struct uci_section *s, bool v6)
 }
 
 static void
-config_init_devices(void)
+config_init_devices(bool bridge)
 {
        struct uci_element *e;
 
@@ -243,6 +243,9 @@ config_init_devices(void)
                if (type)
                        devtype = device_type_get(type);
 
+               if (bridge != (devtype && devtype->bridge_capability))
+                       continue;
+
                if (devtype)
                        params = devtype->config_params;
                if (!params)
@@ -672,9 +675,10 @@ config_init_all(void)
        device_lock();
 
        device_reset_config();
-       config_init_devices();
-       config_init_interfaces();
+       config_init_devices(true);
        config_init_vlans();
+       config_init_devices(false);
+       config_init_interfaces();
        config_init_ip();
        config_init_rules();
        config_init_globals();