diff options
author | Felix Fietkau <nbd@nbd.name> | 2020-11-05 12:00:12 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2020-11-05 12:03:49 +0100 |
commit | ed11f0c0ffe4fdacfe3f8223049ef8a61d9c53e9 (patch) | |
tree | 1b072c4f5eb31e63e442670acff913629e5859ab /config.c | |
parent | 3a2b21001c3c93dbe8502a8df465e415f18a84b1 (diff) |
When VLAN filtering is enabled, but no vlans are defined, the implicit
VLANs should stay, so that forwarding between ports still works.
This is useful for setups where VLANs are assigned by external scripts
instead of being configured via netifd
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -76,18 +76,15 @@ config_bridge_has_vlans(const char *br_name) } static void -config_fixup_bridge_vlan_filtering(struct uci_section *s, const char *name) +config_fixup_bridge_var(struct uci_section *s, const char *name, const char *val) { struct uci_ptr ptr = { .p = s->package, .s = s, - .option = "vlan_filtering", - .value = "1", + .option = name, + .value = val, }; - if (!config_bridge_has_vlans(name)) - return; - uci_lookup_ptr(uci_ctx, &ptr, NULL, false); if (ptr.o) return; @@ -95,6 +92,19 @@ config_fixup_bridge_vlan_filtering(struct uci_section *s, const char *name) uci_set(uci_ctx, &ptr); } +static void +config_fixup_bridge_vlan_filtering(struct uci_section *s, const char *name) +{ + bool has_vlans = config_bridge_has_vlans(name); + + config_fixup_bridge_var(s, "__has_vlans", has_vlans ? "1" : "0"); + + if (!has_vlans) + return; + + config_fixup_bridge_var(s, "vlan_filtering", "1"); +} + static int config_parse_bridge_interface(struct uci_section *s, struct device_type *devtype) { |