Skip to content

fix(libSceNet): describe sockets made with socket() in sceNetGetSockInfo - #9948

Open
ntamas94 wants to merge 12 commits into
boykopovar:mainfrom
ntamas94:fix/ps4-net-sockinfo-kernel-sockets
Open

ntamas94 wants to merge 12 commits into
boykopovar:mainfrom
ntamas94:fix/ps4-net-sockinfo-kernel-sockets

Conversation

@ntamas94

@ntamas94 ntamas94 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

On the console the kernel socket calls and libSceNet share one descriptor space: sceNetGetSockInfo describes a socket made with socket() exactly like one made with sceNetSocket, and lists it when s is below 0. AnyPS5 answered EBADF for such a descriptor and left it out of the list, because libSceNet only looked in its own table. Knowledge is Power: Decades (CUSA12435) calls sceNetGetSockInfo on its PlayLink server socket, which it makes with socket(), right after binding it, and reads from it only when recv_queue_length is not 0 (#9932).

libkernel now exports two helpers next to KernelLookupSocketNative_nid_no_patch: KernelDescribeSocket_nid_no_patch returns one of its sockets' native handle together with the owner that keeps it open, its family, type and non-blocking mode, and KernelListSockets_nid_no_patch lists its descriptors. sceNetGetSockInfo reads its own table first and the kernel's otherwise, and merges both into the sorted list. The socket is not adopted into libSceNet's table, so closing it with close() leaves nothing stale behind. Other sceNet calls on such a socket still answer EBADF; the debt entry says so.

sock_buffer_size now takes the record's source (native handle and configured sizes) instead of a Sock; #8362 calls it with a Sock in its new fill_sock_info6, so whichever of the two lands second needs that call adapted.

guest_sce_net gains rows for a UDP socket made with socket_nid_postfix and bound to 127.0.0.1: its record (descriptor, type 2, address, port, SELF flag, buffer sizes), its place in the list, and EBADF after close_nid_postfix. With the old Export.cpp, SocketPoll.hpp and Udp.cpp the test aborts at the first new row.

Tested

Windows 11, MinGW-w64 GCC (winlibs), Ninja: guest_sce_net passed on the final head (659962c, main 895f47f), python tools/check_conventions.py --base origin/main passes. Measured on a PS4 Pro (firmware 10.71) with a homebrew probe: a bound UDP socket from socket() and one from sceNetSocket both return 1 with a full record, and sceNetGetSockInfo(-1, NULL, 0, 0) counts both:

sceNet s=15 n=1 flags=0 ret=1 (0x1) errno=123 written=160
posix s=16 n=1 flags=0 ret=1 (0x1) errno=123 written=160
count s=-1 info=NULL ret=2 errno=123
all s=-1 n=4 flags=0 ret=2 (0x2) errno=123 written=320

Not run with a title.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: fix(libSceNet): report the receive queue length in sceNetGetSockInfo #9932
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

ntamas94 and others added 5 commits October 23, 2026 00:09
sceNetGetSockInfo always reported 0 in recv_queue_length, so a title that
reads a socket only when its record shows queued data never reads. The
record now carries the host's FIONREAD count; a socket the host refuses
FIONREAD for keeps 0, the value a PS4 Pro on firmware 10.71 reports for
an empty queue. The datagram difference between hosts and the other
measured values of the record are recorded as technical debt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The console shares one descriptor space between the kernel socket calls
and libSceNet, and sceNetGetSockInfo on a PS4 Pro (firmware 10.71)
describes and lists a socket made with socket() as it does one made with
sceNetSocket. AnyPS5 answered EBADF for such a descriptor and left it out
of the s < 0 list. libkernel now describes one of its sockets (native
handle with its owner, family, type, non-blocking mode) and lists its
descriptors; sceNetGetSockInfo reads its own table first and the kernel's
otherwise, without adopting the socket into libSceNet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MarcZX10

Copy link
Copy Markdown
Contributor

I reviewed the descriptor lookup/listing changes and the new guest_sce_net cases. Holding the kernel socket owner while reading its native handle, and keeping the POSIX descriptor separate from the libSceNet table, matches the intended socket() behavior; the list is sorted after combining both tables. The declared dependency on #9932 is appropriate. The existing hosted eligibility, conventions, intake and report checks pass; hosted product-test jobs are skipped.

The PR reports guest_sce_net passing on Windows at this head. Since the implementation also adds the Linux ioctl(FIONREAD) path and the product jobs did not run, could you run the focused guest_sce_net test on Linux as well? That would verify both the new kernel-descriptor path and the receive-queue field on the other native socket API. I have not run a local C++ test on this head.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 5021 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 5836 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 7088 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7090 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7201 core/libs/prx/libSceNet/Export.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7485 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7490 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
PR 7507 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 8448 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 8463 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 8605 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 9231 core/libs/prx/libSceNet/Export.cpp
PR 9509 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 9515 core/libs/prx/libSceNet/Export.cpp
core/libs/prx/libkernel/Socket/include/SocketPoll.hpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
core/libs/tests/GuestSceNet.cpp
PR 9543 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 9578 core/libs/prx/libSceNet/Export.cpp
core/libs/prx/libkernel/Socket/include/SocketPoll.hpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 9713 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 10097 docs/dev/debt/libSceNet.md
PR 10502 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 10544 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 10621 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 10628 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 10629 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 10645 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 10767 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 10881 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 10949 core/libs/prx/libSceNet/Export.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libSceNet.md
PR 11037 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 11134 core/libs/prx/libSceNet/Export.cpp
PR 11135 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 11141 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 11155 docs/dev/debt/libSceNet.md
PR 11194 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 11219 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 11223 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 11242 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 11243 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
PR 11247 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 11272 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 11281 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 11341 core/libs/prx/libSceNet/Export.cpp

@Queuse

Queuse commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

I tested the combined network changes on main b7a451d62b: #9523 a559f1e0be, #9542 ff4412c7e6, #9525 435a41bb82, #9543 aedc74347a, #9930 c079a98a41, #9931 fea0994737, #9932 d174eb7d04 and this PR 659962c821.

The reproducible integration tree is c9c12937ba. I resolved the shared getter hunks by retaining every option path and moving the general minimum-length check after TCP_NODELAY while preserving short reuse/broadcast reads. All test registrations and the neighboring debt entries are retained.

After rebuilding libc, libkernel, libSceNet and the eight test targets:

  • Windows 11, WinLibs MinGW-w64 GCC 15.2.0-r7, Ninja, Release: 8/8 passed, 3.42 s.
  • Linux under WSL2, Ubuntu 26.04.1, GCC 15.2.0, Ninja, Release: 8/8 passed, 1.48 s.

The tests were guest_net_socket_state, guest_net_protocol, guest_net_buffer_validation, guest_net_boolean_readback, guest_sce_net_keepalive, guest_net_oob_inline, guest_sce_net and guest_net_nodelay_readback. Conventions and whitespace checks pass too.

This supplies combined runtime evidence for the agreed ordering, including your kernel-created socket records. It is a focused local integration run; full hosted CI, a title and console hardware were not run. The remaining #6044/#5836 coordination is unchanged.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new integration evidence answers my earlier Linux test request: the reported Windows 8/8 and WSL2 8/8 focused runs include this PR alongside #9932, #9930, #9931 and the other listed network changes, and retain the kernel-created socket record coverage. I also reran current-main whitespace and conventions checks; both pass.\n\nOne remaining integration gap: the branch is 5 commits ahead and 264 behind current main (merge base 895f47f4), while current main has since advanced libSceNet/Export.cpp and docs/dev/debt/libSceNet.md, both files changed here. The PR’s integration run is based on b7a451d, not current main. Please refresh on current main, preserve the already-merged queue-length and network changes in Export.cpp, and rerun the focused socket-info tests on the refreshed head. The KernelDescribeSocket owner lifetime and descriptor listing logic otherwise look sound in this pass; I found no separate defect.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase/merge current main and rerun the focused guest_sce_net coverage. The branch is 264 commits behind (merge base 895f47f4), and current main has intervening edits in both libSceNet/Export.cpp and docs/dev/debt/libSceNet.md, which this PR changes. The reported 8/8 Windows + WSL2 integration run is useful and covers the dependency network changes, but used main b7a451d, so it does not validate this PR integrated with today’s sceNetGetSockInfo queue-length and related network updates. Current-main diff-check and conventions pass; this request is specifically for resolving those shared-file updates and retesting the final head.

ntamas94 and others added 3 commits October 23, 2026 08:58
@ntamas94

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I merged current main 0a0ed72 (through the refreshed #9932 head 645bb29, which this PR is stacked on); the only conflict was the shared sceNetGetSockInfo debt entry, resolved by keeping #9932's new datagram notes and this PR's socket() sentence (998 characters). On the merge head 5125258, Windows 11, MinGW-w64 GCC, Ninja, after a fresh configure (main added the 3rdparty/ogg and 3rdparty/vorbis submodules):

python tools/check_conventions.py --base origin/main
All conventions checks passed.
ctest --test-dir build -R '^guest_sce_net$' --output-on-failure
1/1 Test #1422: guest_sce_net ....................   Passed    1.54 sec
100% tests passed, 0 tests failed out of 1

Thanks also for counting Queuse's Windows and WSL2 integration run as the Linux evidence.

ntamas94 and others added 3 commits October 23, 2026 09:08
@ntamas94

Copy link
Copy Markdown
Contributor Author

Updated to 1d95b47: merged the refreshed #9932 (641b92a, with main ef0d8ae), which now records the console's datagram queue count. To keep both sceNetGetSockInfo debt entries under 1000 characters, this PR's socket() note is now its own entry. check_conventions --base origin/main and guest_sce_net pass on 1d95b47 (Windows 11, MinGW-w64 GCC, fresh build).

@Queuse Queuse mentioned this pull request Oct 25, 2026
12 tasks done

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants