-
Notifications
You must be signed in to change notification settings - Fork 110
Add unique mac for each AP-UP interface asociated with batman #1200
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
base: master
Are you sure you want to change the base?
Conversation
G10h4ck
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my inline comments
| --! | ||
| --! ATM work around the problem configuring IP addresses via ip command | ||
|
|
||
| utils.unsafe_shell("ip link set dev "..ifaceConf.ifname.." address "..ifaceConf.macaddr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU vMacaddr is calculated at lines 554-570 but it seems it is never assiged to ifaceConf.macaddr am I wrong? Also being this a specific batman-adv requirement I would not enforce it on the general network.createStatic function, as it would enforce this behaviour that might be not desiderable with other routing protocols too. I'd try to do this when the numbered batman-adv vlan is created, so it apply only on batman-adv case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes!, you are write !
- batadv: clarify log message to show when VLAN interfaces are created - limed: improve logging; add device existence checks - network: introduce device_exists function for interface validation and tests
b0d6e74 to
e64b5ba
Compare
|
Thanks for the feedback! now only batman interfaces change its macs, I added a small script whit instructions to manually verify how it is working. And fixed some unexpected behaviors of helper functions. |
G10h4ck
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See inline comments
| end | ||
| if string == nil or string == '' then | ||
| return ret | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAK, empty separator should be treated as error, the function should fail in that case because calling it without separator is symptomatic of something wrong in the caller.
| local _, macaddr = next(network.get_own_macs(ifname)) | ||
| --! this is to avoid the error: | ||
| --! ...ackages/lime-system/files/usr/lib/lua/lime/utils.lua:53: attempt to index local 'string' (a nil value) | ||
| if macaddr == nil then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAK, I think it is better to fail ASAP if the MAC address for a non-existent device is requested, instead of propagating a nil value upstream in the call stack, because requesting the MAC address of a non-existent device is indicative of an already pathological situation.
| it('test get_mac for ethernet', function() | ||
| assert.is_nil (network.get_mac('nonexistent-interface')) | ||
| end) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAK
|
|
||
| --! ...e-proto-olsr6/files/usr/lib/lua/lime/proto/olsr6.lua:55: attempt to index global 'ipv6' (a nil value) | ||
| local _, ipv6 = network.primary_address() | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated, please move to another PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I see that this is needed for unit testing. No idea when this got broken. I agree with @G10h4ck, this deserves its own pull request. @javierbrk can you open another PR with this fix? Otherwise I can do it copying and pasting your fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes ! let me do it!
| --! [2025-07-31 20:06:11] [limed] ifname = wlan1-peer2 | ||
| --! [2025-07-31 20:06:12] [limed] ip: can't find device 'wlan1-peer2' | ||
| --! [2025-07-31 20:06:12] [ubus] { "ubus.object.add": | ||
| --{"id":-1478746778,"path":"network.interface.lm_net_wlan1-peer2_batadv"} } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
! missing
| --! [2025-07-31 20:06:12] [ubus] { "ubus.object.add": | ||
| --{"id":-1478746778,"path":"network.interface.lm_net_wlan1-peer2_batadv"} } | ||
| if not network.device_exists(nData.ifname) then | ||
| utils.log("Device does not exist, skipping:", nData.ifname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this condition something that may happen in normal situation, or should it be reported as an error? It is not clear to me from the log message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition arises when using commands WiFi down WiFi up. It seems that apup interfaces do not go down with all the others and some times the daemon is notified about interfaces that do not exist. I created a script to make it easy to check this situation.
I will create an issue with more details later this week.
In this case I made a defensive approach that checks the existence of the interface before trying to add it. If it fails and the daemon breaks some notifications might not be handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can reproduce the problem using tree devices.
This happens in this sequence.
LR2_a is running the test script from the pull request.
LR2_b and LR1 are turned on
Everything works as expected:
- They both get registered
- iwinfo shows wlan1-peer1 wlan1-peer2 and wlan1-apup
After using "wifi down" command in LR2_a, wlan1-apup goes down but wlan1-peer1 and wlan1-peer2 will still be displayed.
Then I do "wifi up"
And only wlan1-peer2 works as expected but wlan1-peer1 no,
limed is notified about a new interface but no interface was created
wlan1-peer1 is no longer available.
after some time the other peer finally appears they both get notified and every thing works as expected.
This is the log of the run.
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
LibreRouterOs 24.10.1, r28597-0425664679
-----------------------------------------------------
___ __ __ _______ __
| |_|__| |--.----.-----.| | |-----.-----| |--.
| | | _ | _| -__|| | -__|__ --| |
|_____|__|_____|__| |_____||__|_|__|_____|_____|__|__|
------------------------------------------------------
%LIME_DESCRIPTION%
------------------------------------------------------
https://libremesh.org
------------------------------------------------------
=== System Notes =================================================
= edit via http://thisnode.info/app/#/notes or /etc/banner.notes =
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
[0/4] Killing any running limed processes...
killall: limed: no process killed
[1/4] Bringing Wi-Fi down...
[2/4] Starting limed and ubus listen ...
------------------------------------------
[2025-07-31 19:03:26] [limed] 'hostapd' namespace exists...
[2025-07-31 19:03:26] [ubus] { "ubus.object.remove": {"id":-88125505,"path":"wpa_supplicant.wlan0-sta"} }
[2025-07-31 19:03:26] [ubus] { "ubus.object.remove": {"id":-559228225,"path":"hostapd.wlan1-apup"} }
------------------------------------------
------------------------------------------
[3/4] Bringing Wi-Fi up...
[4/4] Now you should be able to see new connections. Press Ctrl+C to stop.
[2025-07-31 19:03:33] [ubus] { "ubus.object.add": {"id":363302232,"path":"wpa_supplicant.wlan0-sta"} }
[2025-07-31 19:03:34] [ubus] { "ubus.object.add": {"id":-1452635026,"path":"hostapd.wlan1-apup"} }
---
two new devices are turned on
---
[2025-07-31 19:04:41] [limed] Subscribing:
[2025-07-31 19:04:41] [limed] peerSubscriber:
[2025-07-31 19:04:41] [ubus] { "ubus.object.add": {"id":-199291730,"path":"network.interface.lm_net_lm_net_wlan1_peer1_static"} }
[2025-07-31 19:04:41] [limed] lime.network.runProtocols(wlan1-peer1, ...)
[2025-07-31 19:04:41] [limed] lime.proto.batadv.runOnDevice(wlan1-peer1, ...)
[2025-07-31 19:04:41] [limed] lime.network.createVlan(wlan1-peer1, ...)
[2025-07-31 19:04:41] [limed] vid = 29
[2025-07-31 19:04:41] [limed] type = 8021ad
[2025-07-31 19:04:41] [limed] name = wlan1-peer1_29
[2025-07-31 19:04:41] [ubus] { "ubus.object.add": {"id":1943448621,"path":"network.interface.lm_net_wlan1-peer1_batadv"} }
[2025-07-31 19:04:41] [limed] ifname = wlan1-peer1
[2025-07-31 19:04:41] [ubus] { "network.interface": {"action":"ifup","interface":"lm_net_lm_net_wlan1_peer1_29_static"} }
[2025-07-31 19:04:41] [ubus] { "ubus.object.add": {"id":-650912589,"path":"network.interface.lm_net_lm_net_wlan1_peer1_29_static"} }
[2025-07-31 19:04:41] [ubus] { "network.interface": {"action":"ifup","interface":"lm_net_wlan1-peer1_batadv"} }
[2025-07-31 19:04:41] [limed] batadv createdwlan1-peer1_29 with address:02:58:11:c1:00:59 and static lm_net_lm_net_wlan1_peer1_29_static
[2025-07-31 19:04:41] [limed] lime.proto.babeld.runOnDevice(wlan1-peer1, ...)
[2025-07-31 19:04:41] [limed] lime.network.createVlan(wlan1-peer1, ...)
[2025-07-31 19:04:41] [limed] vid = 17
[2025-07-31 19:04:41] [limed] type = 8021ad
[2025-07-31 19:04:41] [limed] name = wlan1-peer1_17
[2025-07-31 19:04:41] [limed] ifname = wlan1-peer1
[2025-07-31 19:04:42] [ubus] { "network.interface": {"action":"ifup","interface":"lm_net_lm_net_wlan1_peer1_17_static"} }
[2025-07-31 19:04:42] [ubus] { "ubus.object.add": {"id":187664330,"path":"network.interface.lm_net_lm_net_wlan1_peer1_17_static"} }
[2025-07-31 19:05:17] [limed] peerSubscriber:
[2025-07-31 19:05:17] [ubus] { "ubus.object.add": {"id":838939608,"path":"network.interface.lm_net_lm_net_wlan1_peer2_static"} }
[2025-07-31 19:05:17] [limed] lime.network.runProtocols(wlan1-peer2, ...)
[2025-07-31 19:05:17] [limed] lime.proto.batadv.runOnDevice(wlan1-peer2, ...)
[2025-07-31 19:05:17] [limed] lime.network.createVlan(wlan1-peer2, ...)
[2025-07-31 19:05:17] [limed] vid = 29
[2025-07-31 19:05:17] [limed] type = 8021ad
[2025-07-31 19:05:17] [limed] name = wlan1-peer2_29
[2025-07-31 19:05:17] [limed] ifname = wlan1-peer2
[2025-07-31 19:05:17] [ubus] { "ubus.object.add": {"id":-876835113,"path":"network.interface.lm_net_wlan1-peer2_batadv"} }
[2025-07-31 19:05:17] [ubus] { "network.interface": {"action":"ifup","interface":"lm_net_lm_net_wlan1_peer2_29_static"} }
[2025-07-31 19:05:17] [ubus] { "ubus.object.add": {"id":1735019273,"path":"network.interface.lm_net_lm_net_wlan1_peer2_29_static"} }
[2025-07-31 19:05:17] [limed] batadv createdwlan1-peer2_29 with address:02:f4:ce:c1:00:59 and static lm_net_lm_net_wlan1_peer2_29_static
[2025-07-31 19:05:17] [ubus] { "network.interface": {"action":"ifup","interface":"lm_net_wlan1-peer2_batadv"} }
[2025-07-31 19:05:17] [limed] lime.proto.babeld.runOnDevice(wlan1-peer2, ...)
[2025-07-31 19:05:17] [limed] lime.network.createVlan(wlan1-peer2, ...)
[2025-07-31 19:05:17] [limed] vid = 17
[2025-07-31 19:05:17] [limed] type = 8021ad
[2025-07-31 19:05:17] [limed] name = wlan1-peer2_17
[2025-07-31 19:05:17] [limed] ifname = wlan1-peer2
[2025-07-31 19:05:17] [ubus] { "network.interface": {"action":"ifup","interface":"lm_net_lm_net_wlan1_peer2_17_static"} }
[2025-07-31 19:05:17] [ubus] { "ubus.object.add": {"id":-942311592,"path":"network.interface.lm_net_lm_net_wlan1_peer2_17_static"} }
---
on another terminal of the device LR2_a (running the script) issue "wifi down" coomand.
---
[2025-07-31 19:07:16] [ubus] { "ubus.object.remove": {"id":-1452635026,"path":"hostapd.wlan1-apup"} }
[2025-07-31 19:07:17] [ubus] { "network.interface": {"action":"ifdown","interface":"lm_net_wlan1-peer2_batadv"} }
[2025-07-31 19:07:17] [ubus] { "ubus.object.remove": {"id":-876835113,"path":"network.interface.lm_net_wlan1-peer2_batadv"} }
[2025-07-31 19:07:17] [ubus] { "network.interface": {"action":"ifdown","interface":"lm_net_wlan1-peer1_batadv"} }
[2025-07-31 19:07:17] [ubus] { "ubus.object.remove": {"id":1943448621,"path":"network.interface.lm_net_wlan1-peer1_batadv"} }
[2025-07-31 19:07:17] [ubus] { "ubus.object.remove": {"id":363302232,"path":"wpa_supplicant.wlan0-sta"} }
[2025-07-31 19:08:53] [ubus] { "ubus.object.add": {"id":-1976344305,"path":"wpa_supplicant.wlan0-sta"} }
[2025-07-31 19:08:53] [ubus] { "ubus.object.add": {"id":-562794743,"path":"hostapd.wlan1-apup"} }
[2025-07-31 19:08:54] [ubus] { "network.interface": {"action":"ifdown","interface":"lm_net_lm_net_wlan1_peer2_17_static"} }
[2025-07-31 19:08:54] [ubus] { "network.interface": {"action":"ifdown","interface":"lm_net_lm_net_wlan1_peer2_17_static"} }
[2025-07-31 19:08:54] [limed] Subscribing:
[2025-07-31 19:08:54] [limed] peerSubscriber:
[2025-07-31 19:08:54] [ubus] { "ubus.object.remove": {"id":-942311592,"path":"network.interface.lm_net_lm_net_wlan1_peer2_17_static"} }
[2025-07-31 19:08:54] [ubus] { "network.interface": {"action":"ifdown","interface":"lm_net_lm_net_wlan1_peer2_29_static"} }
[2025-07-31 19:08:54] [ubus] { "network.interface": {"action":"ifdown","interface":"lm_net_lm_net_wlan1_peer2_29_static"} }
[2025-07-31 19:08:54] [ubus] { "ubus.object.remove": {"id":1735019273,"path":"network.interface.lm_net_lm_net_wlan1_peer2_29_static"} }
[2025-07-31 19:08:54] [ubus] { "network.interface": {"action":"ifdown","interface":"lm_net_lm_net_wlan1_peer1_17_static"} }
[2025-07-31 19:08:54] [ubus] { "network.interface": {"action":"ifdown","interface":"lm_net_lm_net_wlan1_peer1_17_static"} }
[2025-07-31 19:08:55] [ubus] { "ubus.object.remove": {"id":187664330,"path":"network.interface.lm_net_lm_net_wlan1_peer1_17_static"} }
[2025-07-31 19:08:55] [ubus] { "network.interface": {"action":"ifdown","interface":"lm_net_lm_net_wlan1_peer1_29_static"} }
[2025-07-31 19:08:55] [ubus] { "network.interface": {"action":"ifdown","interface":"lm_net_lm_net_wlan1_peer1_29_static"} }
[2025-07-31 19:08:55] [ubus] { "ubus.object.remove": {"id":-650912589,"path":"network.interface.lm_net_lm_net_wlan1_peer1_29_static"} }
---
after "wifi up"
---
[2025-07-31 19:08:55] [limed] Cannot find device "wlan1-peer1"
[2025-07-31 19:08:55] [limed] Cannot find device "wlan1-peer1"
[2025-07-31 19:08:55] [limed] lime.network.runProtocols(wlan1-peer1, ...)
[2025-07-31 19:08:55] [limed] lime.proto.batadv.runOnDevice(wlan1-peer1, ...)
[2025-07-31 19:08:55] [limed] lime.network.createVlan(wlan1-peer1, ...)
[2025-07-31 19:08:55] [limed] vid = 29
[2025-07-31 19:08:55] [limed] type = 8021ad
[2025-07-31 19:08:55] [limed] name = wlan1-peer1_29
[2025-07-31 19:08:55] [limed] ifname = wlan1-peer1
[2025-07-31 19:08:55] [limed] Cannot find device "wlan1-peer1"
[2025-07-31 19:08:56] [ubus] { "ubus.object.add": {"id":-1148713626,"path":"network.interface.lm_net_wlan1-peer1_batadv"} }
[2025-07-31 19:08:56] [limed] /usr/lib/lua/lime/utils.lua:53: attempt to index local 'string' (a nil value)
[2025-07-31 19:08:56] [limed] stack traceback:
[2025-07-31 19:08:56] [limed] /usr/lib/lua/lime/network.lua:631: in function </usr/lib/lua/lime/network.lua:631>
[2025-07-31 19:08:56] [limed] /usr/lib/lua/lime/utils.lua:53: in function </usr/lib/lua/lime/utils.lua:51>
[2025-07-31 19:08:56] [limed] (tail call): ?
[2025-07-31 19:08:56] [limed] /usr/lib/lua/lime/proto/batadv.lua:137: in function 'runOnDevice'
[2025-07-31 19:08:56] [limed] /usr/lib/lua/lime/network.lua:630: in function </usr/lib/lua/lime/network.lua:630>
[2025-07-31 19:08:56] [limed] [C]: in function 'xpcall'
[2025-07-31 19:08:56] [limed] /usr/lib/lua/lime/network.lua:630: in function 'runProtocols'
[2025-07-31 19:08:56] [limed] /usr/bin/limed:51: in function </usr/bin/limed:46>
[2025-07-31 19:08:56] [limed] [C]: in function 'run'
[2025-07-31 19:08:56] [limed] /usr/bin/limed:91: in main chunk
[2025-07-31 19:08:56] [limed] [C]: ?
[2025-07-31 19:08:56] [limed] lime.proto.babeld.runOnDevice(wlan1-peer1, ...)
[2025-07-31 19:08:56] [limed] lime.network.createVlan(wlan1-peer1, ...)
[2025-07-31 19:08:56] [limed] vid = 17
[2025-07-31 19:08:56] [limed] type = 8021ad
[2025-07-31 19:08:56] [limed] name = wlan1-peer1_17
[2025-07-31 19:08:56] [limed] ifname = wlan1-peer1
[2025-07-31 19:08:56] [limed] Cannot find device "wlan1-peer1"
[2025-07-31 19:08:56] [ubus] { "ubus.object.add": {"id":1783125576,"path":"network.interface.lm_net_lm_net_wlan1_peer1_17_static"} }
[2025-07-31 19:08:56] [limed] Cannot find device "wlan1-peer1_17"
[2025-07-31 19:08:56] [limed] Cannot find device "wlan1-peer1_17"
[2025-07-31 19:08:57] [limed] peerSubscriber:
[2025-07-31 19:08:57] [limed] lime.network.runProtocols(wlan1-peer2, ...)
[2025-07-31 19:08:57] [limed] lime.proto.batadv.runOnDevice(wlan1-peer2, ...)
[2025-07-31 19:08:57] [limed] lime.network.createVlan(wlan1-peer2, ...)
[2025-07-31 19:08:57] [limed] vid = 29
[2025-07-31 19:08:57] [limed] type = 8021ad
[2025-07-31 19:08:57] [limed] name = wlan1-peer2_29
[2025-07-31 19:08:57] [limed] ifname = wlan1-peer2
[2025-07-31 19:08:57] [ubus] { "ubus.object.add": {"id":-1829193661,"path":"network.interface.lm_net_wlan1-peer2_batadv"} }
[2025-07-31 19:08:57] [ubus] { "network.interface": {"action":"ifup","interface":"lm_net_lm_net_wlan1_peer2_29_static"} }
[2025-07-31 19:08:57] [ubus] { "ubus.object.add": {"id":-1080074008,"path":"network.interface.lm_net_lm_net_wlan1_peer2_29_static"} }
[2025-07-31 19:08:57] [ubus] { "network.interface": {"action":"ifup","interface":"lm_net_wlan1-peer2_batadv"} }
[2025-07-31 19:08:57] [limed] batadv createdwlan1-peer2_29 with address:02:f4:ce:c1:00:59 and static lm_net_lm_net_wlan1_peer2_29_static
[2025-07-31 19:08:57] [limed] lime.proto.babeld.runOnDevice(wlan1-peer2, ...)
[2025-07-31 19:08:57] [limed] lime.network.createVlan(wlan1-peer2, ...)
[2025-07-31 19:08:57] [limed] vid = 17
[2025-07-31 19:08:57] [limed] type = 8021ad
[2025-07-31 19:08:57] [limed] name = wlan1-peer2_17
[2025-07-31 19:08:57] [limed] ifname = wlan1-peer2
[2025-07-31 19:08:57] [ubus] { "network.interface": {"action":"ifup","interface":"lm_net_lm_net_wlan1_peer2_17_static"} }
[2025-07-31 19:08:57] [ubus] { "ubus.object.add": {"id":-1692506623,"path":"network.interface.lm_net_lm_net_wlan1_peer2_17_static"} }
---
after some minutes the device associates again and every thing is fine
---
[2025-07-31 19:13:55] [limed] peerSubscriber:
[2025-07-31 19:13:55] [limed] lime.network.runProtocols(wlan1-peer1, ...)
[2025-07-31 19:13:55] [limed] lime.proto.batadv.runOnDevice(wlan1-peer1, ...)
[2025-07-31 19:13:55] [limed] lime.network.createVlan(wlan1-peer1, ...)
[2025-07-31 19:13:55] [limed] vid = 29
[2025-07-31 19:13:55] [limed] type = 8021ad
[2025-07-31 19:13:55] [limed] name = wlan1-peer1_29
[2025-07-31 19:13:55] [limed] ifname = wlan1-peer1
[2025-07-31 19:13:55] [ubus] { "network.interface": {"action":"ifup","interface":"lm_net_lm_net_wlan1_peer1_29_static"} }
[2025-07-31 19:13:55] [ubus] { "ubus.object.add": {"id":1069843693,"path":"network.interface.lm_net_lm_net_wlan1_peer1_29_static"} }
[2025-07-31 19:13:55] [limed] batadv createdwlan1-peer1_29 with address:02:58:11:c1:00:59 and static lm_net_lm_net_wlan1_peer1_29_static
[2025-07-31 19:13:55] [limed] lime.proto.babeld.runOnDevice(wlan1-peer1, ...)
[2025-07-31 19:13:55] [limed] lime.network.createVlan(wlan1-peer1, ...)
[2025-07-31 19:13:55] [limed] vid = 17
[2025-07-31 19:13:55] [ubus] { "network.interface": {"action":"ifup","interface":"lm_net_lm_net_wlan1_peer1_17_static"} }
[2025-07-31 19:13:55] [ubus] { "network.interface": {"action":"ifup","interface":"lm_net_wlan1-peer1_batadv"} }
[2025-07-31 19:13:55] [limed] type = 8021ad
[2025-07-31 19:13:55] [limed] name = wlan1-peer1_17
[2025-07-31 19:13:55] [limed] ifname = wlan1-peer1
APuP creates an interface for each radio named "wlanX-apup" then for each peer Y in that radio creates a new interface called wlanX-peerY. This interface is then associated to a new device called wlanX-peerY_WZ were WZ are numbers associated with protocols. In my particular case 29 is associated with batman and derived from the network name.
Each time a new peer appears the device linked with the peer WiFi interface has the same mac address and batman requires that all the interfaces have different macs. So this pull request adds the new mac feature to the each interface.