Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

pony1k
Copy link
Contributor

@pony1k pony1k commented Feb 11, 2024

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.

Do not assume that an interface that is called "wan" or "lan" has a
link to a lower interface in /sys/class/net. It is not always the case.
@codecov-commenter
Copy link

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%.

❗ 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 ⚠️

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

Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ilario ilario requested review from spiccinini and G10h4ck February 12, 2024 09:25
@ilario
Copy link
Member

ilario commented Feb 12, 2024

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
Copy link
Contributor Author

pony1k commented Feb 12, 2024

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
Copy link
Member

ilario commented Feb 12, 2024

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
Copy link
Member

G10h4ck commented Feb 12, 2024

Looks good to me too, thanks @pony1k

@G10h4ck G10h4ck merged commit 8b577bf into libremesh:master Feb 12, 2024
1 check passed
@ilario
Copy link
Member

ilario commented Sep 15, 2024

Sorry for not testing before.
In your case, @pony1k, did this work for activating the dhcp for the wan entry in the /etc/config/network file?
I tried with a YouHua WR1200JS and the dhcp is indicated in /etc/config/lime-autogen but not in /etc/config/network.

So I think we should run devices[dev] = {} even if lower_if does not exist:

devices[dev] = {}
if lower_if then                                                               
  devices[lower_if] = { nobridge = true }                                
  utils.log( "network.scandevices.dev_parser found WAN port %s " ..      
  "and marking %s as nobridge", dev, lower_if )               
else                                                                           
  utils.log( "network.scandevices.dev_parser found WAN port %s", dev)    
end

@pony1k
Copy link
Contributor Author

pony1k commented Sep 17, 2024

You're right. If I had tried activating dhcp for the wan entry, it would probably have failed.

What you are proposing looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants