Fix collapsed upload throughput: backpressure instead of dropping packets on socketpair overflow#33
Open
jzthree wants to merge 1 commit into
Open
Conversation
…kets lwip_data_out() dropped upstream packets whenever writev() to the openconnect socketpair returned EAGAIN/ENOBUFS. On macOS the socketpair buffers ~2 datagrams (net.local.dgram.recvspace=4KB), so upload bursts overflowed constantly; lwIP's TCP stalled in retransmission timeouts and uploads ran at ~one send window per RTO (~60KB/s measured) while downloads ran at 4MB/s. Queue the packet on EAGAIN/EWOULDBLOCK/ENOBUFS (bounded FIFO, ordering preserved) and flush on EV_WRITE. Also harden the VPN read path: EAGAIN/ EINTR is not a dead VPN, and never fall through into pbuf_alloc() with a negative length after vpn_conn_down(). Measured on an AnyConnect VPN (macOS arm64): uploads 61KB/s -> 1.9MB/s single-stream, 3.8MB/s sustained; downloads unchanged at 4.2MB/s. Co-Authored-By: Claude Fable 5 <[email protected]>
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.
Problem
lwip_data_out()silently drops upstream packets wheneverwritev()to the VPN socketpair returnsEAGAIN/ENOBUFS(it increments a link-level drop stat and returns). On macOS,socketpair(AF_UNIX, SOCK_DGRAM)queues only ~2 datagrams by default (net.local.dgram.recvspace= 4 KB), so any sustained upload overflows the socketpair constantly. lwIP's TCP never gets fast-retransmit signals for those drops and sits in ~1 s retransmission timeouts — throughput collapses to roughly one send window per RTO.Measured on a production AnyConnect VPN (macOS arm64): uploads capped at ~60 KB/s while downloads ran at 4.2 MB/s over the same session. Linux is less affected (~200 KB default unix-dgram buffers) but the drop-instead-of-backpressure behavior is identical.
Fix
EAGAIN/EWOULDBLOCK/ENOBUFS, queue the packet (bounded FIFO, ordering preserved — new packets append while the queue is non-empty) and flush it from anEV_WRITEevent when the socketpair drains. Lossless backpressure instead of silent loss.EAGAIN/EINTRon the nonblocking socketpair is not a dead VPN, and the existing code fell through intopbuf_alloc()with a negative length after callingvpn_conn_down().Results
No configuration changes;
lwipopts.huntouched.