Conversation
tcpdev_read()/tcpdev_connect(): Return -EPIPE or -ECONNREFUSED instead of no reply at all, which would hang the network due to the read/connect being blocked on a single reply buffer in the tcpdev ktcp<->kernel transfer driver. Fixes network stack hangs during read or connect when CB is deallocated through a received RST or any other reason that deallocates an active CB. tcp_established(): decrement tcpcb_need_push when a RST frees a CB that still has unread data to stop continual AVAIL_DATA notifications. tcp_synrecv(): free the cloned CB on RST rather than only resetting state, each half-open RST leaked ~4.5K. inet_process_tcpdev() / TDT_ACCEPT: Copy accept() result out immediately and and release bufin_sem, which breaks a bufin_sem/bufout_sem deadlock between ktcp and ftpd under load.
Closed
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.
First pass of ELKS networking fixes from recently opened issues. This batch of fixes is based on #2781 and @duzenko's proposed code changes, along with other cleanups.
@duzenko, this should fix a majority of the issues seen in your #2781 issue, eliminating hangs associated with RST's received during socket
readorconnectin network applications, as well as eliminating the race/deadlock condition sometimes seen during ktcp's processing ofacceptwhen heavy inbound and outbound data are also being processed. Ktcp memory leaks during some conditions when an RST is received are also fixed.Additionally, more PASV port numbers were added to qemu.sh, and the -N 10.0.2.2 option was removed from the /etc/net.cfg default ftpd startup, since by default the slirp gateway of 10.0.2.2 is used without requiring the -N option. This lets
psshow ftpd state without wrapping in column 80.DEBUG_TCP is temporarily set for
ktcpto show more details during testing, then will be turned off for much less verbose display.Technical Summary
tcpdev_read()/tcpdev_connect():
Return -EPIPE or -ECONNREFUSED instead of no reply at all, which would hang the network due to the read/connect being blocked on a single reply buffer in the tcpdev ktcp<->kernel transfer driver. Fixes network stack hangs during read or connect when CB is deallocated through a received RST or any other reason that deallocates an active CB.
tcp_established(): decrement tcpcb_need_push when a RST frees a CB that still has unread data to stop continual AVAIL_DATA notifications.
tcp_synrecv(): free the cloned CB on RST rather than only resetting state, each half-open RST leaked ~4.5K.
net_process_tcpdev() / TDT_ACCEPT:
Copy accept() result out immediately and and release bufin_sem, which breaks a bufin_sem/bufout_sem deadlock between ktcp and ftpd under load.
Tested on QEMU, although needs more heavy testing with RST and heavy loads.