Repository navigation
fix(libSceNet): set an option on a libkernel socket through sceNetSetsockopt - #6142
oneandonlydean merged 2 commits into
Conversation
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
7c49a2d to
488172b
Compare
karimibrahim07
left a comment
There was a problem hiding this comment.
Windows check of head 488172b76, merged onto main 5d9dcc42d (clean merge). Windows 11 Pro (26300), WinLibs GCC 15.2.0 r7, Ninja Release.
guest_sce_net,guest_socket*,guest_tcpandguest_udppass, 22 of 22.- An update to the description: #5565 is merged now, so
mainalready answersTCP_NODELAYin libkernel (SetTcpLevelOption). I addedsceNetSetsockopt(kernel, 6 /* IPPROTO_TCP */, 1 /* TCP_NODELAY */, &one, 4) == 0toCheckKernelSocketOptionlocally, and it passes onmain+ this PR. So this PR alone takes MXGP'sTCP_NODELAYcalls to 0, and the "Depends on" note about #5565 can go. Worth adding that line to the test, since it's the exact call the title makes.
Code: the fallback runs after g_mutex is released and only for descriptors libkernel has open as sockets, so a closed or foreign descriptor still gets EBADF (the test covers that). The errno comes back through fail(*__error_nid_postfix()), which gives 0x8041012a for ENOPROTOOPT, as in your trace. One possible follow-up is sceNetGetsockopt, which still looks only in libSceNet's table. A title that sets an option this way might also read it back.
AI-assisted: yes. I ran the build and tests above, including the extra TCP_NODELAY check.
488172b to
f5e9027
Compare
|
Thanks @karimibrahim07, both points were right. #5565 being in means this PR alone is enough for MXGP's AI-assisted: yes |
|
Checked the libkernel fallback in |
…sockopt MXGP 26 (PPSA30839) opens TCP sockets with libkernel's socket() and turns on TCP_NODELAY with sceNetSetsockopt. libSceNet only looked in its own socket table, so the call failed with SCE_NET_ERROR_EBADF. On the console both calls work on the same kernel sockets. A descriptor libSceNet does not own but libkernel has open as a socket now goes to libkernel's setsockopt(), which answers the options it models. Anything else still fails with EBADF. The fallback runs after g_mutex is released. guest_sce_net sets SO_SNDBUF on a libkernel TCP socket through sceNetSetsockopt, and checks that the call fails with EBADF once the socket is closed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Setsockopt The call MXGP 26 makes; libkernel answers it since boykopovar#5565. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f5e9027 to
9c9311a
Compare
|
Rebased onto On Ubuntu 24.04 (GCC 13.3, Release), AI-assisted: yes (Claude Code) |
|
Merged while @adriadam10 is away, after #6140: the review passed and full CI is green on this head. |
What
MXGP 26: The Official Game (PPSA30839) opens TCP sockets with libkernel's
socket()and turns onTCP_NODELAYon them withsceNetSetsockopt.sceNetSetsockoptonly looked in libSceNet's own socket table, so the call failed withSCE_NET_ERROR_EBADF(0x80410109). On the console, libSceNet's calls and libkernel's socket calls work on the same kernel sockets.Now, when
sceNetSetsockoptgets a descriptor that libSceNet doesn't own but libkernel has open as a socket (GuestSocketIsOpen_nid_no_patch), it passes the call to libkernel'ssetsockopt(). libkernel answers the options it models and fails the rest the way it already does. Any other descriptor still fails withEBADF. The fallback runs afterg_mutexis released, as in #6140.guest_sce_netgains a check:SO_SNDBUFon a libkernel TCP socket throughsceNetSetsockopt;TCP_NODELAYon the same socket, the call the title makes, which libkernel answers since feat(libkernel): answer TCP_NODELAY, SO_NOSIGPIPE and SO_NBIO on a guest socket #5565;EBADF.This is the
sceNetSetsockopthalf of #6140, which does the same forsceNetSocketClose. The two don't depend on each other and merge cleanly in either order: they share only one identical#includeline.Tested
Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags, on
main3c87cdf:guest_sce_netaborts withmain'sExport.cppand passes with the change.guest_*tests pass.tools/check_conventions.py --base upstream/mainpasses.--to-intel, 90 s, every libSceNet socket call traced under gdb:main,sceNetSetsockopt(11, IPPROTO_TCP, TCP_NODELAY)returns0x80410109.ENOPROTOOPT(0x8041012a), because libkernel'ssetsockopt()onmainmodels only SOL_SOCKET options.TCP_NODELAYto libkernel) and fix(libSceNet): close a libkernel socket through sceNetSocketClose #6140, it returns 0 for descriptors 11 and 9. The title then also closes descriptor 7 successfully.Rebased onto
main82ddae7, with theTCP_NODELAYassertion added (f5e9027):guest_sce_netpasses 3 of 3, and all 383guest_*tests pass.@karimibrahim07 checked the previous head on Windows (Windows 11 Pro, WinLibs GCC 15.2.0, Release, merged onto 5d9dcc4):
guest_sce_net,guest_socket*,guest_tcpandguest_udppass, 22 of 22. They also found that with #5565 merged,mainanswersTCP_NODELAYin libkernel, so this PR alone makes the title'sTCP_NODELAYcalls succeed, and they suggested the assertion above.sceNetGetsockoptstill looks only in libSceNet's table, so a title that reads such an option back would still getEBADF. That is a separate change.Not checked on a console.
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)TCP_NODELAYcalls)🤖 Generated with Claude Code