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

Merged
ntamas94 merged 7 commits from upstream-pr/9948 into main 2026-11-04 17:34:36 +00:00
ntamas94 commented 2026-10-22 23:27:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ntamas94 on 2026-10-22T23:27:34Z.


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.

Refresh — 2026-11-03 (Codex, AI-assisted): Merged main 086c0686c8 and adapted sceNetShowNetstat's two buffer-size calls to SockInfoSource while retaining the copied socket owner's lifetime and configured buffer sizes. Kept main's queue-length evidence and the separate kernel-socket listing entry. MinGW-w64 GCC 15.2 syntax-only compilation passes for Export.cpp, libkernel Socket/src/Udp.cpp and GuestSceNet.cpp; conventions and whitespace checks pass. Focused runtime tests have not been rerun on this merged head.

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: #9932
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4975506945 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9948). Originally posted by [ntamas94](https://github.com/ntamas94) on 2026-10-22T23:27:34Z. --- ### 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. **Refresh — 2026-11-03 (Codex, AI-assisted):** Merged main 086c0686c8 and adapted sceNetShowNetstat's two buffer-size calls to SockInfoSource while retaining the copied socket owner's lifetime and configured buffer sizes. Kept main's queue-length evidence and the separate kernel-socket listing entry. MinGW-w64 GCC 15.2 syntax-only compilation passes for Export.cpp, libkernel Socket/src/Udp.cpp and GuestSceNet.cpp; conventions and whitespace checks pass. Focused runtime tests have not been rerun on this merged head. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #9932 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-23 05:43:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T05:43:32Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5624385357 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9948#pullrequestreview-5624385357). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T05:43:32Z. **Review:** COMMENTED --- 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 commented 2026-10-23 05:43:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T05:43:34Z.

Review: CHANGES_REQUESTED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5624385539 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9948#pullrequestreview-5624385539). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T05:43:34Z. **Review:** CHANGES_REQUESTED --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9948
No description provided.