libremesh / lime-packages

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

Fix lime-config fail when there is no lower iface #1080

Closed pony1k closed 4 months ago

pony1k commented 4 months ago

On a mercusys mr70x, lime-config does not work. It throws the following error:

network.scandevices.owrt_network_interface_parser found ifname wan
ls: /sys/class/net/wan/lower*: No such file or directory
/usr/lib/lua/lime/network.lua:223: attempt to index field '?' (a nil value)
stack traceback:
        /usr/lib/lua/lime/config.lua:221: in function </usr/lib/lua/lime/config.lua:221>
        [C]: in function 'foreach'
        /usr/lib/lua/lime/network.lua:339: in function 'scandevices'
        /usr/lib/lua/lime/network.lua:373: in function </usr/lib/lua/lime/network.lua:364>
        [C]: in function 'xpcall'
        /usr/lib/lua/lime/config.lua:221: in function 'main'
        /usr/bin/lime-config:55: in main chunk
        [C]: ?

It seems that an interface that is called "wan" does not always have link to a lower interface in /sys/class/net. This is how I would like to fix it. I've tested it already on a mercusys mr70x and it is working fine.

codecov-commenter commented 4 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (0c8a915) 79.56% compared to head (38e3e7f) 79.53%.

:exclamation: Current head 38e3e7f differs from pull request most recent head d5befee. Consider uploading reports for the commit d5befee to get more accurate results

Files Patch % Lines
...ges/lime-system/files/usr/lib/lua/lime/network.lua 83.33% 2 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1080 +/- ## ========================================== - Coverage 79.56% 79.53% -0.04% ========================================== Files 53 53 Lines 4561 4564 +3 ========================================== + Hits 3629 3630 +1 - Misses 932 934 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ilario commented 4 months ago

Uh... Unexpected. Do you have idea if this is a new thing of OpenWrt 23? Anyway, the code looks good to me. After this change, does the WAN work?

pony1k commented 4 months ago

I believe this is because wan is not a switch port, but connected directly to the CPU. See here for mr70x: https://github.com/openwrt/openwrt/blob/6497cdba09d6faa04a4f74465ed95ae21e2ff1ff/target/linux/ramips/dts/mt7621_mercusys_mr70x-v1.dts#L134-L171 While for the archer-c6 as an example: https://github.com/openwrt/openwrt/blob/6497cdba09d6faa04a4f74465ed95ae21e2ff1ff/target/linux/ramips/dts/mt7621_tplink_archer-x6-v3.dtsi#L182-L218

The wan port works. I checked.

ilario commented 4 months ago

Anyway it is something new... I didn't see such messages when using OpenWrt 19.07 (cannot remember if I used also OpenWrt 22) on YouHua WR1200JS that has a very similar DTS... Mah...

G10h4ck commented 4 months ago

Looks good to me too, thanks @pony1k