libremesh / lime-packages

LibreMesh packages configuring OpenWrt for wireless mesh networking
https://libremesh.org/
GNU Affero General Public License v3.0
276 stars 95 forks source link

lime.network.scandevices: fix finding intefaces on dsa devices #1033

Closed pony1k closed 11 months ago

pony1k commented 12 months ago

On devices that have only a single lan port, like D-Link DAP-X1860 A1, with DSA, the lan port is just called lan, not lan1 as one might expect. This changes a regex ^lan%d+$ to ^lan%d*$, so that the lan interface is correctly recognized and configured. Instead of just scraping eth0, eth1, ... from /sys/class/net/, the second commit adds scraping of lan, lan1, lan2, ... aswell. Without this, lanx-interaces are not configured if they do not appear in the configuration.

codecov-commenter commented 12 months ago

Codecov Report

Merging #1033 (63d6012) into master (06053e3) will decrease coverage by 0.01%. The diff coverage is 100.00%.

:exclamation: Current head 63d6012 differs from pull request most recent head a1a6e3e. Consider uploading reports for the commit a1a6e3e to get more accurate results

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master    #1033      +/-   ##
==========================================
- Coverage   79.27%   79.26%   -0.01%     
==========================================
  Files          53       53              
  Lines        4444     4447       +3     
==========================================
+ Hits         3523     3525       +2     
- Misses        921      922       +1     
Impacted Files Coverage Δ
...ges/lime-system/files/usr/lib/lua/lime/network.lua 78.39% <100.00%> (+0.20%) :arrow_up:

... and 1 file with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

ilario commented 12 months ago

Looks good for me, both commits! @spiccinini @G10h4ck

ilario commented 12 months ago

Did you check on another device, one that has more than one LAN port, if the generated /etc/config/network is different before and after these edits?

pony1k commented 11 months ago

It is used in production on devices with multiple ports with and without dsa (Linksys E8450 (UBI), TP-LINK TD-W8970, AVM FRITZ!Box 4040, TP-Link TL-WDR3600 v1). I did not do a direct comparison before and after, but the configuration looks good and it is working normally. I checked that there is nothing called lan in the devices that have lan1, lan2, ... in /sys/class/net/ and lan is the only additional string that the regex matches, so it should be fine.