From 67984daedbc8a2602eb1345855cac748553086b0 Mon Sep 17 00:00:00 2001 From: Karsten Hoehn Date: Sun, 5 Apr 2026 16:04:20 +1000 Subject: [PATCH] luci-mod-status: add dynamic ethernet devices Extend port status view to include dynamically detected ethernet interfaces (e.g. USB adapters). Devices are merged into the existing port list if not already present. Loopback interfaces are excluded. Filter against /sys/class/net to avoid stale entries after device removal. Tested on: - GL.iNet GL-MT6000 - OpenWrt 25.12.1 - Apple USB ethernet adapters (100 Mbps and 2.5 Gbps) Verified link state changes and hotplug (add/remove). Signed-off-by: Karsten Hoehn --- .../resources/view/status/include/29_ports.js | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js index 9ff30bb473d4..0a201f3f4beb 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js @@ -412,13 +412,18 @@ return baseclass.extend({ }); }); - return Promise.all(psePromises).then((pseResults) => { + return Promise.all([ + Promise.all(psePromises), + L.resolveDefault(fs.list('/sys/class/net'), []) + ]).then(([pseResults, devs]) => { const pseMap = {}; pseResults.forEach((r) => { if (r.pse) pseMap[r.name] = r.pse; }); - data.push(pseMap); + const present = (devs || []).map(d => d.name || d); + data.push(pseMap); + data.push(present); return data; }); }); @@ -462,6 +467,23 @@ return baseclass.extend({ } } + const presentDevices = new Set(data[6] || []); + for (const dev in port_map) { + if (dev === 'lo') + continue; + + if (!presentDevices.has(dev)) + continue; + + if (!known_ports.find(p => p.device === dev)) { + known_ports.push({ + role: 'extra', + device: dev, + netdev: network.instantiateDevice(dev) + }); + } + } + known_ports.sort(function(a, b) { return L.naturalCompare(a.device, b.device); });