Skip to content

sysinfo.sh: MLO sta count via hostapd_cli + ifname-in-config fallback#5

Open
perceival wants to merge 2 commits into
Rafciq:masterfrom
perceival:pr/sysinfo-hostapd-ifname
Open

sysinfo.sh: MLO sta count via hostapd_cli + ifname-in-config fallback#5
perceival wants to merge 2 commits into
Rafciq:masterfrom
perceival:pr/sysinfo-hostapd-ifname

Conversation

@perceival

@perceival perceival commented May 12, 2026

Copy link
Copy Markdown

Summary

Two real fixes for misc/sysinfo.sh on modern OpenWrt / GL.iNet builds, plus some
header cleanup. Tested on GL.iNet BE9300 (Flint 3) running OpenWrt 23.05-SNAPSHOT
with MLO across wlan02 / wlan12 / wlan22, and on two older APs
(Netgear R7800 and Linksys E8450) running vanilla OpenWrt.

1. ubus network.wireless status schema move — ifname now lives inside config

On newer OpenWrt, ubus call network.wireless status no longer exposes
ifname at the per-interface object level — it has moved into the inner
config object. The current code only reads the top-level value, so
$RadioIface ends up empty, the per-iface code path is skipped, and the
output silently degrades to conn: Down for every radio.

Fix: read the top-level first (back-compat with older builds), then fall
back to config.ifname if it's empty.

2. iw dev <ifname> station dump misses MLO/MLD-bound stations

On Wi-Fi 7 hardware with MLO enabled, clients associated through an MLD
do not show up in iw dev <radio> station dump — the kernel reports
them per-link only via hostapd's control socket. As a result, the
station counter shows 0 / wrong values on Flint 3 etc.

Added get_sta_count() helper that prefers hostapd_cli ... status and
sums num_sta[*] across BSS slots:

  1. hostapd_cli -p /var/run/hostapd -i $iface status (single-dir layout, stock OpenWrt)
  2. hostapd_cli -p /var/run/hostapd-$iface -i $iface status (per-instance dir layout)
  3. fallback: original iw dev $iface station dump | grep -c '^Station'

Counts now match hostapd_cli status num_sta and the LuCI overview.

3. Header cleanup (commit 2)

  • Restored the original Polish revision-log entries from upstream and
    kept English translations side-by-side (PL / EN per line). The file
    is now valid UTF-8 — the original had mixed ISO-8859-2 / CP1250 bytes
    so ś rendered as / œ depending on terminal.
  • Updated # Destination hint from /sbin/sysinfo.sh to
    /etc/profile.d/99-sysinfo.sh, which is where the script naturally
    fires on modern OpenWrt (runs on each shell login, survives sysupgrade
    when listed in /etc/sysupgrade.conf).

Other changes already in perceival:master

Two smaller pre-existing changes from my fork's master also flow into this PR
because they sit on the same path; flagging them so they aren't lost in review:

  • clean_output() filter that strips literal e[0;31m / e[0m strings that
    some logread outputs leak when not on a TTY (applied via
    print_error | clean_output).
  • print_lan() now skips zones that have no DHCP pool configured
    (uci get dhcp.$Device.start empty) — previously they printed an empty
    dhcp: n/a row. Also references dhcp.$Device.{start,limit} directly
    instead of the dhcp.@dhcp[*].interface=$Device lookup, since the latter
    doesn't match named DHCP sections on current OpenWrt configs.

Happy to split these out into a separate PR if you'd prefer.

Test plan

  • Flint 3 / BE9300, OpenWrt 23.05-SNAPSHOT, MLO across 2.4/5/6 GHz —
    conn: now matches hostapd_cli status num_sta and LuCI client count
  • Older GL.iNet APs (no MLO) — conn: still matches iw dev fallback
  • sh -n misc/sysinfo.sh clean
  • HTML mode (REQUEST_METHOD=GET sysinfo.sh) still renders
  • (Maintainer) Verify on stock OpenWrt 23.05 / 24.10 reference image

🤖 Generated with Claude Code

perceival and others added 2 commits May 8, 2026 11:22
Two fixes for newer OpenWrt / GL.iNet builds where the previous
station-count logic silently produced "Down":

1. ifname schema move: ubus call network.wireless status now puts
   ifname inside the per-iface "config" object instead of at the
   iface-object level. Added a fallback read from config.ifname so
   RadioIface gets populated and the per-iface code path runs at all.

2. New get_sta_count() helper: prefers hostapd_cli on /var/run/hostapd
   (single-dir layout) and /var/run/hostapd-<iface>/<iface>
   (per-instance dir layout). Sums num_sta[*] across all BSS slots,
   so MLO/MLD-bound clients are counted (iw dev station dump misses
   them on Flint 3 / BE9300 type setups). Falls back to the original
   iw dev station dump if hostapd_cli isn't available.

Tested on GL.iNet BE9300 (Flint 3) running OpenWrt 23.05-SNAPSHOT
with MLO across wlan02/wlan12/wlan22 — counts now match
hostapd_cli status num_sta values.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…on path

- Bring back the original Polish revision-log entries from the upstream
  header and keep the English translations side-by-side (one line per
  revision, `PL / EN`, with overflow wrapped on the next line).
- File re-encoded as UTF-8 so both `ś/ł/ą/ę/ó/ż/ź/ć/ń` and ASCII fit
  cleanly (the upstream file mixed ISO-8859-2 and CP1250 bytes).
- Update the `# Destination` hint from `/sbin/sysinfo.sh` to
  `/etc/profile.d/99-sysinfo.sh` — that's where the script naturally
  belongs on modern OpenWrt: dropping it into `profile.d/` makes it
  fire automatically on each shell login (mirrors how OpenWrt's stock
  banner / motd is delivered) and survives sysupgrade when listed in
  `/etc/sysupgrade.conf`.

No code changes in this commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant