Skip to content

Set WiFi regulatory domain from the system timezone - #428

Merged
starnight merged 2 commits into
eos6.0from
T33993-set-wifi-regulation-region-eos6.0
Oct 14, 2026
Merged

starnight merged 2 commits into
eos6.0from
T33993-set-wifi-regulation-region-eos6.0

Conversation

@starnight

Copy link
Copy Markdown
Contributor

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

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
@starnight
starnight merged commit 66f86f6 into eos6.0 Oct 14, 2026
2 checks passed
@starnight
starnight deleted the T33993-set-wifi-regulation-region-eos6.0 branch October 14, 2026 08:20

@wjt wjt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@starnight

Copy link
Copy Markdown
Contributor Author

Thanks! Trying fedora's script.

@starnight

Copy link
Copy Markdown
Contributor Author

Have another PR #429

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