From 7834d64e2717a7a7aa13886db30dd8fb334f6b65 Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 6 Nov 2021 03:36:55 +0100 Subject: [PATCH] lib/config/legacy: treat single eth0 as wan port --- nix/lib/config/legacy.nix | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/nix/lib/config/legacy.nix b/nix/lib/config/legacy.nix index be81165..84e2b6f 100644 --- a/nix/lib/config/legacy.nix +++ b/nix/lib/config/legacy.nix @@ -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}" {};