lib/config/legacy: treat single eth0 as wan port

This commit is contained in:
Astro 2021-11-06 03:36:55 +01:00
parent e975d78504
commit 7834d64e27
1 changed files with 16 additions and 4 deletions

View File

@ -443,11 +443,23 @@ in
in
if model ? ports
then
lib.optionalAttrs (builtins.length wanTargets > 0) {
"${builtins.head wanTargets}".ports = getPorts "wan";
} // lib.optionalAttrs (ap ? lan-access) {
"${ap.lan-access}".ports = getPorts "lan.*";
if model.ports == [ {
interface = "eth0";
port = "lan";
type = "phys";
} ] && builtins.length wanTargets > 0
then {
# Only 1 Ethernet port, treat as uplink
"${builtins.head wanTargets}".ports = [ "eth0" ];
}
else
lib.optionalAttrs (builtins.length wanTargets > 0) {
"${builtins.head wanTargets}".ports = getPorts "wan";
} // lib.optionalAttrs (ap ? lan-access) {
"${ap.lan-access}".ports = self.lib.unique (
getPorts "lan.*"
);
}
else
builtins.trace "No known ports for OpenWRT model ${ap.model}"
{};