fix(libkernel): stop Winsock failing an unconnected datagram receive after an unreachable port #9477
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9477"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T23:00:11Z.
What
Winsock reports an ICMP port-unreachable reply as
WSAECONNRESETon the next receive of any datagram socket. So on Windows a guest UDP socket made withsocketthat sent to a port nobody listens on failed its nextrecvfromwithECONNRESET, since libkernel mapsWSAECONNRESETto 54.FreeBSD's
udp_common_ctlinputpasses the reply on only to a socket connected to the sender, so an unconnected socket keeps receiving. Linux behaves the same way.socketnow turnsSIO_UDP_CONNRESEToff on datagram sockets on Windows.sceNetSocketin libSceNet keeps Winsock's reporting; #5295 made the same change there and is closed.The second commit records the trade-off in
docs/dev/debt/libkernel.md: on Windows, a datagram socket connected to a port nobody listens on now doesn't fail its next send or receive at all, where FreeBSD fails it withECONNREFUSED.socketpair's datagram ends keep Winsock's reporting.Overlap: #8537 rewrites the
setrlimitentry indocs/dev/debt/libkernel.md, right before thesocketentry this PR adds. That file is the only one they share. Neither needs to wait for the other: whichever merges second keeps both entries, and this PR takes the rebase in either order (note).Tested
On GitHub's runners from my fork, merged with
mainata6dcea9279(run):CheckUnreachablePortIgnoredinguest_udp: a non-blocking socket sends to a closed loopback port. Its next three receives must fail withEAGAIN(35), and then a datagram from another socket must arrive.main'sUdp.cppthe check aborts, because the receive fails with 54. With the change,guest_udppasses 10 runs in a row.guest_udppasses withmain's code and, 10 runs in a row, with the change.core/libs/prx/libcandcore/libs/prx/libkernelpasses: 115 and 197 on Linux, 142 and 207 on Windows.mainatda54c652e3(410536f795, no conflicts, the PR's own diff unchanged; run):guest_udpfails on Windows withmain's code and passes 10 runs in a row with the change; on Linux it passes both ways. The libc and libkernel suites pass on both (116 and 197 on Linux, 143 and 207 on Windows).mainat9a030c2d50(6b75fb99f6, run): one conflict, indocs/dev/debt/libkernel.md, where #8537 rewrote thesetrlimitentry just above this PR'ssocketentry. The merge keepsmain'ssetrlimitentry and this PR'ssocketentry after it. The PR'sUdp.cppandGuestUdp.cppchanges are unchanged (same patch-id), and the debt file's added line is the same, with new context.guest_udpfails 3 of 3 on Windows withmain's code and passes 10 runs in a row with the change; on Linux it passes both ways. The libc and libkernel suites pass on both (117 and 198 on Linux, 144 and 208 on Windows). They ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T23:04:30Z.
Review: APPROVED
Reviewed the Windows datagram-socket setup, test, and debt note. The
SIO_UDP_CONNRESEToption is applied only toSOCK_DGRAMsockets created throughsocket, and the test checks repeated receives after an ICMP unreachable followed by a successful datagram from another sender. The documented connected-socket trade-off is explicit. Conventions, intake, eligibility, labels, and report checks pass; hosted Linux/Windows test/build jobs were skipped. The Windows/Linux focused runs described in the PR are author-reported; I did not run them locally.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:30:50Z.
Review: DISMISSED
The Windows-only
SIO_UDP_CONNRESETadjustment is limited to datagram sockets created bysocket, and the test verifies the ICMP failure does not poison later receives before a valid datagram arrives. The documented trade-off for connected sockets is explicit. The open overlap #8537 changes the adjacentsetrlimitentry in the samedocs/dev/debt/libkernel.md; both entries must survive, so please coordinate/record the rebase order underDepends onif a predecessor is required. The branch and test reports are based ona6dcea9279, while current upstream main isab347d144d. Please rebase and rerunguest_udp, conventions and current overlap checks, preserving the #8537 debt edit. Hosted product jobs are skipped; I did not run local tests.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T06:00:30Z.
Thanks, @MarcZX10. The branch now has
mainatda54c652e3merged in (410536f795), with the PR's own diff unchanged. On GitHub's runners (run)guest_udppasses 10 runs in a row on both and fails on Windows withmain's code; the libc and libkernel suites pass on both, and conventions pass. Tested now says so. #8537'ssetrlimitentry is kept either way: the order note is on #8537 (comment), and Overlap and Depends on say no order is needed.