I had a spare ZTE ZXHN F680 GPON router sitting around, and the only internet connection available to me was a 5 GHz Wi-Fi network I couldn't reconfigure. I wanted the F680 to join that network as a wireless client and NAT it out to its own 2.4 GHz AP and LAN ports.
The ISP firmware hides the Wi-Fi client UI on this build, though the kernel interfaces are still there (apcli0 for the 5 GHz client, wlan0 through wlan3 for 2.4 GHz APs, and wlan4 through wlan7 for 5 GHz APs). The catch was that apcli0 would associate, finish the 4-way handshake, and tick up its RX counters without a single packet ever reaching Linux layer 3. The driver was handing every received frame to a dead hardware forwarding path because of one byte in .bss, and the /proc knob meant to disable it was touching the wrong radio.
Setup and why I didn't bridge
The box is a ZTE ZXHN F680 running Linux 4.1.25 with a MediaTek MT7615E for 5 GHz and an MT7603E for 2.4 GHz. The target layout was plain routed NAT:
upstream Wi-Fi (5 GHz, WPA2-PSK or Open) | | apcli0 v ZXHN F680 --[routed NAT]--> 2.4 GHz AP + LAN (192.168.12.1/24) I routed instead of bridging so my LAN stayed separate from an upstream network I didn't control. I also learned the hard way not to try the MAC-cloning bridge workaround. Cloning apcli0's MAC onto br0 killed httpd, telnetd, and ftpd immediately while ICMP kept answering, leaving no way back in without pulling the power cord.
Two dead ends in /proc
Before disassembling the driver, I wasted a good chunk of time poking /proc/wifi_hdswitch/.
Writing 0 to /proc/wifi_hdswitch/on is supposed to turn off hardware forwarding and send received frames up the normal Linux network stack. On apcli0, it changed nothing. Looking at the modules later explained why. That proc file is registered by the 2.4 GHz driver (mt7603e) and only flips the 2.4 GHz copy of the flag. The 5 GHz driver keeps its own.
Writing 0 to /proc/wifi_hdswitch/attach_function was worse. It froze APCLI RX completely, since that hook sits on the Linux-to-IDM transmit path rather than the receive path.
Why frames vanished before layer 3
Stripping out the noise, the 5 GHz driver's receive handler (RtmpOsPktRcvHandle) does this:
skb_push(skb, 14); if (skb->protocol == 0x888e) { netif_rx(skb); } else if (cg_hdswitch_on == 0) { netif_rx(skb); } else { idx = *(u32 *)(skb->dev + 0x470); handler = wifihdswitchhandler[idx]; idm = idmdev[idx]; handler(skb, idm); } That explains why EAPOL (0x888e) got through and the 4-way handshake finished cleanly. Everything else fell into the else branch. AP VAPs set dev + 0x470 = 1 during init, sending their frames to idm1 (the LAN/CPU path). apcli0 leaves that field zero-initialized, so its traffic goes to idm0 (the WAN/GPON path) and disappears without Linux ever seeing it.
The flag guarding that branch, cg_hdswitch_on, is not a shared kernel global. Each Wi-Fi module has its own byte in .bss:
mt7603e (2.4 GHz): .bss + 0x764 (backed by /proc/wifi_hdswitch/on) mt7615 (5 GHz): .bss + 0xf1c (no proc entry, defaults to 1) Zeroing that byte in mt7615_ap makes RtmpOsPktRcvHandle fall through to skb_pull(14) and netif_rx(skb).
Patching it in RAM with /dev/kmem
Module .bss addresses move on every boot, so the script pulls the base address from sysfs at runtime:
B7=$(cat /sys/module/mt7615_ap/sections/.bss) # example boot: 0xbf7de920 # cg_hdswitch_on = B7 + 0xf1c = 0xbf7df83c Before writing to an undocumented offset in kernel memory, I sanity-checked /dev/kmem against the mt7603e copy we could already toggle. Flipping /proc/wifi_hdswitch/on while reading .bss + 0x764 gave a clean 01 -> 00 -> 01, confirming that the virtual address math lined up with module memory.
To do the read and write on the router, I assembled a 1,048-byte static ARM EABI5 binary (kmemtool) with Keystone. It only makes raw open, _llseek, read, write, and exit syscalls, emits zero VFP or NEON instructions, and takes a base address plus an offset:
/userconfig/kmemtool /dev/kmem "$B7" f1c r # expect 01 /userconfig/kmemtool /dev/kmem "$B7" f1c w 00 If the initial read doesn't return 01, nothing gets written. Everything stays in RAM (no MTD or flash writes), so a reboot wipes the patch cleanly.
The counters and pings reacted right away:
mt7615 cg: 01 -> 00, readback 00 static ARP ping: 5/5, 0% loss dynamic ARP ping: 5/5, 0% loss mangle -i apcli0: 13 packets / 1092 bytes idm0 TX: 3228090/23770 before and after DHCP, NAT, and IRQ pinning
Associating apcli0 only took the usual iwpriv calls plus ApCliMWDS=0 so it behaves as a normal 3-address client instead of a WDS peer.
DHCP fought back. Broadcast DHCPDISCOVER frames left apcli0 and never got a reply. The upstream AP appears to drop broadcast DHCP from apcli0's locally administered MAC, and the driver ignores ifconfig apcli0 hw ether. Sending a unicast DHCPDISCOVER directly to the last known gateway worked right away. Because the stock BusyBox build has no udhcpc, I wrote a small static Rust DHCP client that saves the last lease and tries unicast first before falling back to broadcast.
From there, standard routed NAT gets clients online:
echo 1 > /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -o apcli0 -j MASQUERADE iptables -I FORWARD 1 -i br0 -o apcli0 -j ACCEPT iptables -I FORWARD 2 -i apcli0 -o br0 -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -I INPUT 1 -i apcli0 -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -I INPUT 2 -i apcli0 -p udp --dport 68 -j ACCEPT One tuning detail that actually mattered on this dual-core Cortex-A9 was interrupt affinity. Both radios and Ethernet default to CPU0, so pinning the 5 GHz PCIe IRQ to CPU1 stopped the uplink from fighting the 2.4 GHz AP and Ethernet under load.
Verified end-to-end from a LAN client:
DHCP: 192.168.12.50/24 via 192.168.12.1 dig @192.168.12.1 example.com -> NOERROR curl http://example.com -> HTTP 200 ping 8.8.8.8 -> 0% loss Getting WPA2-Enterprise and 802.11w PMF working
The router also had to work on a campus network running WPA2-Enterprise with 802.11w PMF. The stock driver blocks both. Its RSN IE capability mask drops flags the controller expects, and in STA mode igtk_cipher stays uninitialized, causing BIP cipher insertion to fail with insert fail, IGTK cipher is wrong.
Fixing that took three instruction patches in mt7615_ap.ko's .text:
0x90e08 tst r3, #0x90 -> tst r3, #0xd0 0x4b91c mov r3, #0x90 -> mov r3, #0xd0 0x11ca54 bne 0x11cae0 -> b 0x11cae0 The third patch forces BIP-128 into the RSN IE even when the driver's internal state says it isn't needed; without it, PMF association fails.
The patch ships as a 1.9 KB kernel module emitted directly by a Python script (no C compiler, linker, or kernel tree involved). On load, it checks all three original instruction words before writing anything, patches them under stop_machine(), executes dsb sy and v7_coherent_kern_range() after each store, verifies readback, and unloads. A mismatch aborts with -EINVAL and leaves memory untouched.
Authentication needed its own daemon. The rootfs has no wpa_supplicant, so rather than pull in that and OpenSSL, eap_ttls is a static Rust binary that speaks EAP-TTLS with inner PAP over TLS 1.3/1.2 and validates the server against a PEM CA bundle.
One quirk there: the F680 boots with no RTC and no NTP, so the clock reads January 1, 1970 when the daemon starts. Certificate validation has to tolerate the pre-epoch date, or every CA check fails before the network is even up.
The PMK handoff is the part I'd point at if someone asked what was hard. The daemon runs the TLS exporter, takes the first 32 bytes, and writes them straight into the mt7615 data structures through /dev/kmem:
pAd = *(bss + 0xf74) wcid = *(pAd + 0x1f790c) entry = pAd + 0x450 + wcid * 0x12e8 It checks the station entry magic (0x00004001), writes the PMK to both wdev.SecConfig.PMK (pAd + 0x14bfc2) and pEntry.PMK (entry + 0x202), reads both back to compare, and clears PrivacyFilter at entry + 0x93c if it's set. The write happens immediately before waiting for EAP-Success, so the driver's own 4-way handshake finds the key already in place and runs M1 through M4 normally.
Getting EAPOL frames to userspace needed one more poke. The mt7615 receive vector jumps through a table entry at .text + 0x90230, and repointing it from 0x902a4 to 0x90244 lets the daemon pick up EtherType 0x888e frames on an AF_PACKET socket instead of losing them in the driver path. Same pattern as the RSN fix: a small RAM patch, checked against the expected value before writing.
That whole part took longer to get working than the repeater itself.
What still doesn't work
Boot persistence is still manual. This firmware never executes /userconfig/autorun.sh. The process that would load a hook (pc) maps /lib/libbbx.so from a read-only rootfs, and no user-writable hook runs before it starts. Dropping in a same-size patched library on rootfs would work, but writing to rootfs on a box with no UART recovery isn't a risk I wanted to ship.
After a reboot, bringing everything back takes one command and about 40 seconds:
sh /userconfig/restore_after_boot.sh Two other permanent quirks remain. The 2.4 GHz module was compiled without APCLI support, so the upstream link has to be 5 GHz. Also, apcli0's rx_dropped counter sits around 3.3 billion and drifts both up and down, which is an uninitialized stats bug in the driver rather than actual packet loss.
The scripts, payloads, and full disassembly notes live at github.com/walsoup/f680-repeater. Everything here targets firmware build ZTEGF680606MA, so check the offsets on your own dump before reusing any of it on another build. No vendor binaries are distributed in the repo.
(AI assistants helped with parts of the scripts and docs; all hardware behavior and test results above are from the actual device.)