fix(libkernel): report EISCONN for an address on a connected socketpair end as FreeBSD does #14043
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14043"
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 Ragbie on 2026-10-31T16:55:57Z.
What
An address on a socketpair end is handled as FreeBSD 11.4 handles it on a connected
AF_UNIXsocket. Before this PR every such call reportedEAFNOSUPPORTwithout reaching the host, on every host. Three cases differ:connecton a stream or sequenced-packet end whose peer is open now returnsEISCONN.soconnectatreturns it for a connected socket of a connection-oriented protocol before it looks at the address.shutdownleaves the end connected, so this also holds after it. After the peer closes,unp_disconnectdisconnects the end, andconnectstill reportsEAFNOSUPPORT, asunp_connectatdoes for a non-AF_UNIXaddress.sendtoandsendmsgwith an address on a datagram end whose peer is open now returnEISCONN, asuipc_senddoes whenunp_connis set. The check comes after the flag, length and buffer checks and before waiting for send space, which a datagram end never needs inuipc_send. After the end's ownshutdown(SHUT_WR)the send goes to the host and fails withEPIPE, assosend_genericchecksSBS_CANTSENDMOREfirst.sendtoandsendmsgwith an address on a stream or sequenced-packet end now ignore the address and send, asuipc_senddoes on a connected end. Stream ends already did this while the host reported a peer; sequenced-packet ends reportedEAFNOSUPPORT. After the peer closes the host send givesEPIPE, as FreeBSD'ssoisdisconnectedsetsSBS_CANTSENDMORE.The pair end counts as connected while its guest peer object is alive.
dupshares that object, so closing one alias keeps the end connected, as FreeBSD's file reference does.bindkeepsEAFNOSUPPORT, whichuipc_bindatreturns for a non-AF_UNIXaddress.connecton a datagram end is not changed.The libkernel
socketpairdebt entry said all three calls should report the console'sEISCONN. That entry came from #1711, which has no console measurement for it, and FreeBSD's source contradicts it forbindand for an addressed streamsendto. The entry now states the remaining differences:AF_UNIXpath is not resolved:bind, and aconnector addressedsendtothat FreeBSD passes tounp_connect, reportEAFNOSUPPORT.connecton a datagram end keeps it connected. FreeBSD disconnects it first and then fails.unpdg_sendspace) is not refused withEMSGSIZE.The entry was over the 1000-character limit, so it is reworded to fit. Two sentences that describe no difference from the console are dropped:
read/writegoing to the host, and the reason the loopback connection reports noPOLLHUP.Tested
guest_socket_pairgetsCheckAddressOnPairEnd:connectwith anAF_INETaddress returnsEISCONN, also aftershutdown(SHUT_RDWR), andEINVALfor a 1-byte address.bindreturnsEAFNOSUPPORT.sendtois delivered to the peer.connectreturnsEAFNOSUPPORT, and addressed sends end inEPIPE.sendtoandsendmsgreturnEISCONN, and the pair still exchanges data.bindreturnsEAFNOSUPPORT.shutdown(SHUT_WR), sends with and without an address returnEPIPE, also once the peer is closed.connectreturnsEISCONN, an addressedsendtois delivered, and after the peer closes it returnsEPIPE.Windows 11 Pro, Intel Core i5-14600KF, WinLibs GCC 15.2.0, full Release build:
main'sUdp.cpp):guest_socket_pairaborts.guest_socket_pairpasses with--repeat until-fail:5, and the 156 tests matchingsocket|tcp|udp|kqueue|equeue|guest_net|select|poll|net_|recv|send|shutdown(without theselect_tests_*tests of the test-selection tool) pass with--repeat until-fail:3.ctestonmain474030e58:99% tests passed, 2 tests failed out of 3191. Both fail onmainon this machine too:guest_wide_formatting:%Zgives the host's non-ASCII zone name, which #10987 addresses.agc_driver_image_plane_address_on_line.check_skips.pyreports one skip,guest_fopen_errors. It skips itself on this machine because creating symbolic links needs Developer Mode.Linux (Ubuntu 24.04 container, GCC 13.3.0): without the fix
guest_socket_pairaborts; with it, it passes with--repeat until-fail:5, and the 117 tests matching the same pattern pass with--repeat until-fail:3. Full Linuxctestwas not run.macOS: not tested. The changed code is shared, and macOS has no sequenced-packet pair.
Overlaps: none. #7090 (
SCM_RIGHTS) and #11896 (MSG_WAITALL) change other parts ofUdp.cpp; #13742 changessocketpair's result-pointer check.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)