Absorb upstream #20: route decrypted RX through netif->input - #5
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picks
e74be464from CamM2325/microlink#20 by @snowpaper (fixes CamM2325/microlink#17), plus a docs commit updating this fork'swireguard_lwip/README.mddivergence record so the fix doesn't get "rediscovered" on a future upstream sync attempt. Author attribution on the code commit preserved viagit 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 withtcpip_thread— under sustained TCP traffic this double-frees a pbuf (pbuf_free: p->ref > 0) and reboots the device. Notably, our own fork'sml_wg_mgr.calready setsnetif->input = tcpip_inputand 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 sinceip_input()never consultednetif->input.Applied cleanly (
git apply --check) against our diverged fork. Built clean forlilygo-t-display-s3(ESP-IDF 6.0.1) in the downstream ZenClock project.