Repository navigation
Set WiFi regulatory domain from the system timezone - #428
Conversation
Some WiFi interfaces, such as the Raspberry Pi 400 (brcmfmac43456) do not have region-aware firmware feature, so cfg80211 stays in the world domain (00) until a country code is set. That leaves some 5GHz channels disabled. Add a small helper that derives the country code from the timezone and applies it with `iw reg set`: - set-regdom: POSIX sh script (works with dash, bash and zsh). Gets the timezone from timedatectl, maps it to a country code using /usr/share/zoneinfo/zone.tab, and only calls `iw reg set` if the result is two uppercase letters. - set-regdom.service: oneshot unit that runs the script at boot. - watch-regdom.path: re-runs the script when the timezone changes. 'timedatectl set-timezone' atomically replaces the /etc/localtime symlink, so an inotify watch on the file itself is lost. Watch the parent directory /etc instead. - watch-regdom.service: triggered by the path unit. Since /etc changes often, ExecCondition only lets it proceed if /etc/localtime was modified within the last 10 seconds. https://phabricator.endlessm.com/T33993
The set-regdom will use iw and the timezone information from tzdata. So, add them as dependencies. https://phabricator.endlessm.com/T33993
wjt
left a comment
There was a problem hiding this comment.
Red Hat-derived systems have a script called setregdomain which is a longer but IMO clearer implementation of your set-regdom script. They have a udev rule that runs this script when an ieee80211 device is created. https://src.fedoraproject.org/rpms/wireless-regdb/tree/rawhide
I found this thread about importing this script & udev rule into Debian where the former is done but the maintainer disagrees with it being automatic. https://lists.debian.org/debian-kernel/2026/02/msg00264.html
The "watch /etc but then check if /etc/localtime changed recently" approach seems hacky but I admit that I can't see any better way! You could monitor the org.freedesktop.timedated1 Timezone property for changes but that would involve having a daemon running continuously just to do that.
|
Thanks! Trying fedora's script. |
|
Have another PR #429 |
Some WiFi interfaces, such as the Raspberry Pi 400 (brcmfmac43456) do not have region-aware firmware feature, so cfg80211 stays in the world domain (00) until a country code is set. That leaves some 5GHz channels disabled.
Add a small helper that derives the country code from the timezone and applies it with
iw reg set:iw reg setif the result is two uppercase letters.https://phabricator.endlessm.com/T33993