Skip to content

Absorb upstream #20: route decrypted RX through netif->input - #5

Merged
fudio101 merged 2 commits into
mainfrom
fix/wg-rx-via-tcpip-thread
Aug 14, 2026
Merged

Absorb upstream #20: route decrypted RX through netif->input#5
fudio101 merged 2 commits into
mainfrom
fix/wg-rx-via-tcpip-thread

Conversation

@fudio101

Copy link
Copy Markdown
Collaborator

Cherry-picks e74be464 from CamM2325/microlink#20 by @snowpaper (fixes CamM2325/microlink#17), plus a docs commit updating this fork's wireguard_lwip/README.md divergence record so the fix doesn't get "rediscovered" on a future upstream sync attempt. Author attribution on the code commit preserved via git cherry-pick -x.

Why we're absorbing this ourselves: upstream has had zero maintainer activity (no comments, no reviews) on any open PR since the last commit on 2026-03-17.

What it fixes: the decrypted-RX path called ip_input() directly on the caller's task, entering the lwIP core concurrently with tcpip_thread — under sustained TCP traffic this double-frees a pbuf (pbuf_free: p->ref > 0) and reboots the device. Notably, our own fork's ml_wg_mgr.c already sets netif->input = tcpip_input and has a comment claiming decrypted packets are posted to the TCPIP thread — this PR is what actually makes that true; before it, the assignment was a no-op for the RX path since ip_input() never consulted netif->input.

Applied cleanly (git apply --check) against our diverged fork. Built clean for lilygo-t-display-s3 (ESP-IDF 6.0.1) in the downstream ZenClock project.

snowpaper and others added 2 commits August 14, 2026 16:03
The decrypted-RX path called ip_input() directly on the caller's task,
entering the lwIP core concurrently with tcpip_thread. Under sustained
TCP traffic through the tunnel this double-frees a sent-segment pbuf
('pbuf_free: p->ref > 0' assert) and reboots the device.

ml_wg_mgr already sets netif->input = tcpip_input, i.e. the integration
intends all input serialized through the tcpip mailbox; the direct
ip_input() call bypassed that. Hand the pbuf to netif->input instead so
the lwIP core is only entered from tcpip_thread.

Verified on ESP32-S3 (ESP-IDF v5.3): multi-hundred-KB TCP relays that
previously crashed mid-transfer now run to completion.

Fixes #17

(cherry picked from commit e74be46)
Upstream-PR: CamM2325#20
Upstream-Issue: CamM2325#17


The divergence record in this README exists so a future sync attempt
knows what's already been fixed independently. Add the netif->input
fix so it isn't rediscovered as a fresh divergence.
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.

wireguardif.c RX path calls ip_input() off the tcpip_thread — pbuf double-free crash under TCP load

2 participants