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

ffac-ssid-changer: rewrite in lua, use wifi reconf #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maurerle
Copy link
Member

@maurerle maurerle commented Nov 3, 2024

This is a lua rewrite of the ffac-ssid-changer, which uses uci set wireless.$network.ssid and wifi reconf instead of the hostapd reload approach.

As we then can use uci revert and reconf, this is much lighter to handle and does only reload the radios for which a change is requested.

OWE radios are turned off when offline.

The other parts should stay the same.
This is not yet thoroughly tested, but works fine in first functionality tests by copying the script onto a gluon node and going offline and online again.

@maurerle
Copy link
Member Author

maurerle commented Nov 3, 2024

@blocktrron mentioned on IRC that the upcoming openwrt 24.x will have a way to do a dynamic wifi reconf without teardown of a reconfigured interface.
For now, clients are disconnected as the SSID changes.

I tried various things like
ubus call hostapd config_set '{"phy": "phy1", "config": "/var/run/hostapd-phy1.conf.new"}' to set a new config, which did set the config in hostapd (as Set new config for phy phy1: /var/run/hostapd-phy1.conf.new is logged).
However this change is not applied and ubus call hostapd.client0 reload did then reload the config from the /var/run again, so I don't know how config_set can work.

The most easiest way which works similar to the former behavior of reloading the hostapd with a changed config, can be done using:

uci set wireless.client_radio1.ssid='OfflineSSID'
wifi reconf

# now offline ssid exists

uci revert wireless
wifi reconf

# online ssid is used again

The rewrite does basically exactly this.

@citronalco
Copy link

Did some tests on a single band device with an additional private wifi, and on a dual band device with owe transition mode on 5 GHz band (see https://git.bingo-ev.de/freifunk/ffin-site) without private wifi.

It works, all SSIDs get changed.

I noted that when going offline, the OWE SSID disappears, and it comes back again after going online - that's nice!
Honestly, I would like to see some log entries when switching between online and offline. Currently there's nothing.
And I see some errors/warnings in the log:

# Online -> Offline:
Thu Feb 13 21:52:34 2025 kern.info kernel: [ 1628.695694] device client0 left promiscuous mode
Thu Feb 13 21:52:34 2025 kern.info kernel: [ 1628.700664] br-client: port 5(client0) entered disabled state
Thu Feb 13 21:52:34 2025 kern.info kernel: [ 1628.714139] device client1 left promiscuous mode
Thu Feb 13 21:52:34 2025 kern.info kernel: [ 1628.719331] br-client: port 4(client1) entered disabled state
Thu Feb 13 21:52:34 2025 kern.info kernel: [ 1628.739870] device owe0 left promiscuous mode
Thu Feb 13 21:52:34 2025 kern.info kernel: [ 1628.744651] br-client: port 3(owe0) entered disabled state
Thu Feb 13 21:52:36 2025 daemon.notice hostapd: Set new config for phy phy0: /var/run/hostapd-phy0.conf
Thu Feb 13 21:52:36 2025 daemon.notice hostapd: Remove bss 'owe0' on phy 'phy0'
Thu Feb 13 21:52:36 2025 daemon.notice hostapd: owe0: AP-DISABLED
Thu Feb 13 21:52:36 2025 daemon.notice hostapd: owe0: CTRL-EVENT-TERMINATING
Thu Feb 13 21:52:36 2025 daemon.err hostapd: rmdir[ctrl_interface=/var/run/hostapd]: Permission denied
Thu Feb 13 21:52:36 2025 daemon.notice netifd: radio1 (9147): ./mac80211.sh: eval: line 975: wpa_supplicant: not found
Thu Feb 13 21:52:36 2025 daemon.notice hostapd: nl80211: Failed to remove interface owe0 from bridge br-client: No such device
Thu Feb 13 21:52:36 2025 daemon.notice hostapd: Reload config for bss 'client0' on phy 'phy0'
Thu Feb 13 21:52:36 2025 daemon.notice hostapd: Reloaded settings for phy phy0
Thu Feb 13 21:52:36 2025 daemon.notice hostapd: Set new config for phy phy1: /var/run/hostapd-phy1.conf
Thu Feb 13 21:52:36 2025 daemon.notice hostapd: Reload config for bss 'client1' on phy 'phy1'
Thu Feb 13 21:52:36 2025 daemon.notice hostapd: Reloaded settings for phy phy1
Thu Feb 13 21:52:37 2025 daemon.notice netifd: Wireless device 'radio0' is now up
Thu Feb 13 21:52:37 2025 daemon.notice netifd: Network device 'client0' link is up
Thu Feb 13 21:52:37 2025 kern.info kernel: [ 1631.373877] br-client: port 3(client0) entered blocking state
Thu Feb 13 21:52:37 2025 kern.info kernel: [ 1631.379997] br-client: port 3(client0) entered disabled state
Thu Feb 13 21:52:37 2025 kern.info kernel: [ 1631.386510] device client0 entered promiscuous mode
Thu Feb 13 21:52:37 2025 kern.info kernel: [ 1631.391829] br-client: port 3(client0) entered blocking state
Thu Feb 13 21:52:37 2025 kern.info kernel: [ 1631.397832] br-client: port 3(client0) entered forwarding state
Thu Feb 13 21:52:37 2025 daemon.notice netifd: Wireless device 'radio1' is now up
Thu Feb 13 21:52:37 2025 daemon.notice netifd: Network device 'client1' link is up
Thu Feb 13 21:52:37 2025 kern.info kernel: [ 1631.593214] br-client: port 4(client1) entered blocking state
Thu Feb 13 21:52:37 2025 kern.info kernel: [ 1631.599246] br-client: port 4(client1) entered disabled state
Thu Feb 13 21:52:37 2025 kern.info kernel: [ 1631.605756] device client1 entered promiscuous mode
Thu Feb 13 21:52:37 2025 kern.info kernel: [ 1631.611235] br-client: port 4(client1) entered blocking state
Thu Feb 13 21:52:37 2025 kern.info kernel: [ 1631.617205] br-client: port 4(client1) entered forwarding state

# Offline -> Online:
Thu Feb 13 21:53:19 2025 kern.info kernel: [ 1674.200419] device client0 left promiscuous mode
Thu Feb 13 21:53:19 2025 kern.info kernel: [ 1674.205367] br-client: port 3(client0) entered disabled state
Thu Feb 13 21:53:19 2025 kern.info kernel: [ 1674.229949] device client1 left promiscuous mode
Thu Feb 13 21:53:19 2025 kern.info kernel: [ 1674.235497] br-client: port 4(client1) entered disabled state
Thu Feb 13 21:53:22 2025 daemon.notice netifd: radio1 (9372): ./mac80211.sh: eval: line 975: wpa_supplicant: not found
Thu Feb 13 21:53:22 2025 daemon.notice hostapd: Set new config for phy phy1: /var/run/hostapd-phy1.conf
Thu Feb 13 21:53:22 2025 daemon.notice hostapd: Reload config for bss 'client1' on phy 'phy1'
Thu Feb 13 21:53:22 2025 daemon.notice hostapd: Reloaded settings for phy phy1
Thu Feb 13 21:53:22 2025 daemon.notice hostapd: Set new config for phy phy0: /var/run/hostapd-phy0.conf
Thu Feb 13 21:53:22 2025 daemon.notice hostapd: Add bss owe0 on phy phy0
Thu Feb 13 21:53:22 2025 kern.info kernel: [ 1676.949045] br-client: port 3(owe0) entered blocking state
Thu Feb 13 21:53:22 2025 kern.info kernel: [ 1676.955032] br-client: port 3(owe0) entered disabled state
Thu Feb 13 21:53:22 2025 kern.info kernel: [ 1676.961119] device owe0 entered promiscuous mode
Thu Feb 13 21:53:22 2025 kern.info kernel: [ 1676.985458] br-client: port 3(owe0) entered blocking state
Thu Feb 13 21:53:22 2025 kern.info kernel: [ 1676.991200] br-client: port 3(owe0) entered forwarding state
Thu Feb 13 21:53:22 2025 daemon.notice netifd: Network device 'owe0' link is up
Thu Feb 13 21:53:22 2025 kern.info kernel: [ 1677.088530] IPv6: ADDRCONF(NETDEV_CHANGE): owe0: link becomes ready
Thu Feb 13 21:53:22 2025 daemon.notice hostapd: Reload config for bss 'client0' on phy 'phy0'
Thu Feb 13 21:53:22 2025 daemon.notice hostapd: Reloaded settings for phy phy0
Thu Feb 13 21:53:23 2025 daemon.notice netifd: Wireless device 'radio1' is now up
Thu Feb 13 21:53:23 2025 daemon.notice netifd: Network device 'client1' link is up
Thu Feb 13 21:53:23 2025 kern.info kernel: [ 1677.412596] br-client: port 4(client1) entered blocking state
Thu Feb 13 21:53:23 2025 kern.info kernel: [ 1677.418885] br-client: port 4(client1) entered disabled state
Thu Feb 13 21:53:23 2025 kern.info kernel: [ 1677.425153] device client1 entered promiscuous mode
Thu Feb 13 21:53:23 2025 kern.info kernel: [ 1677.430390] br-client: port 4(client1) entered blocking state
Thu Feb 13 21:53:23 2025 kern.info kernel: [ 1677.436361] br-client: port 4(client1) entered forwarding state
Thu Feb 13 21:53:23 2025 daemon.notice netifd: Wireless device 'radio0' is now up
Thu Feb 13 21:53:23 2025 daemon.notice netifd: Network device 'client0' link is up
Thu Feb 13 21:53:23 2025 kern.info kernel: [ 1677.643829] br-client: port 5(client0) entered blocking state
Thu Feb 13 21:53:23 2025 kern.info kernel: [ 1677.649830] br-client: port 5(client0) entered disabled state
Thu Feb 13 21:53:23 2025 kern.info kernel: [ 1677.656389] device client0 entered promiscuous mode
Thu Feb 13 21:53:23 2025 kern.info kernel: [ 1677.661708] br-client: port 5(client0) entered blocking state
Thu Feb 13 21:53:23 2025 kern.info kernel: [ 1677.667710] br-client: port 5(client0) entered forwarding state

@maurerle
Copy link
Member Author

Thanks! @citronalco
you can add this using:
uci set ssid-changer.settings.debug_log_enabled = 1

Though this also adds a log entry for the minutely checks.
Eventually we should always log when changes occur.

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.

2 participants