diff options
author | Rafał Miłecki <rafal@milecki.pl> | 2022-04-05 08:49:58 +0200 |
---|---|---|
committer | Rafał Miłecki <rafal@milecki.pl> | 2022-06-15 10:44:32 +0200 |
commit | d75bb744eaa1edd613612af0399f318fae841ae6 (patch) | |
tree | 22741d014179cfd1d6344b5f359b270456b3bf1b /package/network | |
parent | c4b499bc03ab0e2eea643c46d1d781ab64e78931 (diff) | |
download | upstream-d75bb744eaa1edd613612af0399f318fae841ae6.tar.gz upstream-d75bb744eaa1edd613612af0399f318fae841ae6.tar.bz2 upstream-d75bb744eaa1edd613612af0399f318fae841ae6.zip |
swconfig: parse "switch_vlan" before "switch_port"
Before this change UCI sections of both types were parsed in order as
specified in UCI. That didn't work well with all drivers (e.g. b53).
It seems that VLAN setup can reset / overwrite previously set ports
parameters. It resulted in "switch_port" options defined above
"switch_vlan"s being silently ignored.
Ideally swconfig & all drivers should be improved to handle that
properly but it'd be a waste of time at this point as DSA replaces
swconfig. Use this minor parsing change as a quick fix.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'package/network')
-rw-r--r-- | package/network/config/swconfig/src/uci.c | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/package/network/config/swconfig/src/uci.c b/package/network/config/swconfig/src/uci.c index f99583b483..200069f94f 100644 --- a/package/network/config/swconfig/src/uci.c +++ b/package/network/config/swconfig/src/uci.c @@ -164,32 +164,7 @@ found: struct uci_element *os; s = uci_to_section(e); - if (!strcmp(s->type, "switch_port")) { - char *devn = NULL, *port = NULL, *port_err = NULL; - int port_n; - - uci_foreach_element(&s->options, os) { - o = uci_to_option(os); - if (o->type != UCI_TYPE_STRING) - continue; - - if (!strcmp(os->name, "device")) { - devn = o->v.string; - if (!swlib_match_name(dev, devn)) - devn = NULL; - } else if (!strcmp(os->name, "port")) { - port = o->v.string; - } - } - if (!devn || !port || !port[0]) - continue; - - port_n = strtoul(port, &port_err, 0); - if (port_err && port_err[0]) - continue; - - swlib_map_settings(dev, SWLIB_ATTR_GROUP_PORT, port_n, s); - } else if (!strcmp(s->type, "switch_vlan")) { + if (!strcmp(s->type, "switch_vlan")) { char *devn = NULL, *vlan = NULL, *vlan_err = NULL; int vlan_n; @@ -216,6 +191,38 @@ found: swlib_map_settings(dev, SWLIB_ATTR_GROUP_VLAN, vlan_n, s); } } + uci_foreach_element(&p->sections, e) { + struct uci_element *os; + char *devn = NULL, *port = NULL, *port_err = NULL; + int port_n; + + s = uci_to_section(e); + + if (strcmp(s->type, "switch_port")) + continue; + + uci_foreach_element(&s->options, os) { + o = uci_to_option(os); + if (o->type != UCI_TYPE_STRING) + continue; + + if (!strcmp(os->name, "device")) { + devn = o->v.string; + if (!swlib_match_name(dev, devn)) + devn = NULL; + } else if (!strcmp(os->name, "port")) { + port = o->v.string; + } + } + if (!devn || !port || !port[0]) + continue; + + port_n = strtoul(port, &port_err, 0); + if (port_err && port_err[0]) + continue; + + swlib_map_settings(dev, SWLIB_ATTR_GROUP_PORT, port_n, s); + } for (i = 0; i < ARRAY_SIZE(early_settings); i++) { struct swlib_setting *st = &early_settings[i]; |