feat(libSceNet): keep TCP option state #11272

Merged
Queuse merged 4 commits from upstream-pr/11272 into main 2026-11-04 04:49:19 +00:00
Queuse commented 2026-10-25 23:18:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Queuse on 2026-10-25T23:18:13Z.


What

Store and read back TCP_MAXSEG, TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT for libSceNet stream sockets, including bounded output, input validation, socket isolation and keepalive inheritance through accept.

MSS starts at 536 for IPv4 and 1220 for IPv6, requires a peer before a set and raises accepted values below 216 to 216. Defaults and validation follow the PS5 13.60 libkernel_sys probes pinet4 and pmaxseg, with FreeBSD rules for unmeasured cases. The pmaxseg evidence also underlies #11251, which changes libkernel rather than these libSceNet paths.

These options keep guest state; they do not configure host MSS or keepalive timers. Connected MSS initially reports the stored family default rather than the negotiated segment. Direct libSceNet measurements on PS5 remain unavailable; the library debt records these limits.

#9525/#9542 and #10502 are now merged. This refresh preserves #10502's socket names/diagnostics alongside all TCP state and accept inheritance. Overlap snapshot 4a6693acf8 reported a debt-only intersection with #9948; #11272-first remains proposed, awaiting confirmation. Five comparisons were incomplete at that snapshot (#5836, #9932, #11969, #12104, #12288). Their shared-file changes were inspected; this was not a combined runtime pass. #11969 has since closed in favor of the #12682 -> #12688 -> #12700 stack. Future transport/close coordination follows those successors; the original scan and runtime results below remain tied to their stated heads.

Tested

Windows 11 x86-64, WinLibs MinGW-w64 GCC 15.2.0-r7, Ninja, Release. Exact head 53d19a3d87 includes main dacca6bb88.

  • Rebuilt the affected libc/libkernel/libSceNet closure and eight fixtures. guest_net_tcp_options, guest_net_protocol, guest_net_nodelay_readback, guest_net_buffer_validation, guest_net_socket_state, guest_net_boolean_readback, guest_net_oob_inline and guest_sce_net: 8/8 pass, no skips.
  • The socket-record conflict is resolved by retaining the four TCP fields and the new name field. Getter paths, diagnostics, test registrations and both debt updates coexist.
  • Public-header audit: 368 libraries, 13,051 exports. Test-registration audit, conventions and whitespace checks pass.
  • Canonical overlap snapshot 4a6693acf8: one reported debt intersection and five incomplete comparisons, as recorded above. A trial merge with that consulted main is clean; the runtime results belong to the published head/base, not that later merged tree.
  • The firmware 13.42 disassembly/emulator report is third-party Net-to-kernel forwarding evidence. It is distinct from the cited firmware 13.60 console probes and from direct Net hardware measurement.
  • No fresh Linux/macOS runtime, full hosted product build, title or console run. TCP_KEEPINIT remains unsupported; the retail call-site report is not a claim that these changes unblock a title.

Hosted run 40667809045 passed the Windows job on 53d19a3d87, including configuration, registration and the host-only link step. Full product build/test steps and the Linux, relinker and specialized runtime jobs were skipped; this does not add a hosted guest TCP runtime or title run.

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: none; original #9525/#9542 merge order fulfilled
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5009687918 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11272). Originally posted by [Queuse](https://github.com/Queuse) on 2026-10-25T23:18:13Z. --- ### What Store and read back TCP_MAXSEG, TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT for libSceNet stream sockets, including bounded output, input validation, socket isolation and keepalive inheritance through accept. MSS starts at 536 for IPv4 and 1220 for IPv6, requires a peer before a set and raises accepted values below 216 to 216. Defaults and validation follow the PS5 13.60 libkernel_sys probes [pinet4](https://gist.github.com/orezraey/d9efe0da49405f19d72cb35279c0db52) and [pmaxseg](https://gist.github.com/orezraey/236a0628ab38d8f0c1f0105c6c097beb), with FreeBSD rules for unmeasured cases. The pmaxseg evidence also underlies #11251, which changes libkernel rather than these libSceNet paths. These options keep guest state; they do not configure host MSS or keepalive timers. Connected MSS initially reports the stored family default rather than the negotiated segment. Direct libSceNet measurements on PS5 remain unavailable; the library debt records these limits. #9525/#9542 and #10502 are now merged. This refresh preserves #10502's socket names/diagnostics alongside all TCP state and accept inheritance. Overlap snapshot `4a6693acf8` reported a debt-only intersection with #9948; #11272-first remains proposed, awaiting confirmation. Five comparisons were incomplete at that snapshot (#5836, #9932, #11969, #12104, #12288). Their shared-file changes were inspected; this was not a combined runtime pass. #11969 has since closed in favor of the #12682 -> #12688 -> #12700 stack. Future transport/close coordination follows those successors; the original scan and runtime results below remain tied to their stated heads. ### Tested Windows 11 x86-64, WinLibs MinGW-w64 GCC 15.2.0-r7, Ninja, Release. Exact head `53d19a3d87` includes main `dacca6bb88`. - Rebuilt the affected libc/libkernel/libSceNet closure and eight fixtures. `guest_net_tcp_options`, `guest_net_protocol`, `guest_net_nodelay_readback`, `guest_net_buffer_validation`, `guest_net_socket_state`, `guest_net_boolean_readback`, `guest_net_oob_inline` and `guest_sce_net`: 8/8 pass, no skips. - The socket-record conflict is resolved by retaining the four TCP fields and the new name field. Getter paths, diagnostics, test registrations and both debt updates coexist. - Public-header audit: 368 libraries, 13,051 exports. Test-registration audit, conventions and whitespace checks pass. - Canonical overlap snapshot `4a6693acf8`: one reported debt intersection and five incomplete comparisons, as recorded above. A trial merge with that consulted main is clean; the runtime results belong to the published head/base, not that later merged tree. - The [firmware 13.42 disassembly/emulator report](https://github.com/boykopovar/AnyPS5/pull/11272#issuecomment-6418068485) is third-party Net-to-kernel forwarding evidence. It is distinct from the cited firmware 13.60 console probes and from direct Net hardware measurement. - No fresh Linux/macOS runtime, full hosted product build, title or console run. TCP_KEEPINIT remains unsupported; the retail call-site report is not a claim that these changes unblock a title. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Hosted [run 40667809045](https://github.com/boykopovar/AnyPS5/actions/runs/40667809045) passed the Windows job on `53d19a3d87`, including configuration, registration and the host-only link step. Full product build/test steps and the Linux, relinker and specialized runtime jobs were skipped; this does not add a hosted guest TCP runtime or title run. ### 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: <!-- #PR, or none --> none; original #9525/#9542 merge order fulfilled - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
MarcZX10 commented 2026-10-25 23:22:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T23:22:15Z.

Review: APPROVED


I reviewed the state model and the socket lifecycle paths for TCP_MAXSEG and the keepalive options, including family defaults, stream checks, unconnected/listening MSS rejection, the 176-to-216 clamp, input/output truncation, per-socket isolation, timer bounds, and accept-time inheritance. The zero-as-default readback for keepalive values matches FreeBSD's TP_KEEPIDLE/TP_KEEPINTVL/TP_KEEPCNT behavior. The focused test covers both libSceNet and libkernel entry points and verifies that option state does not leak between sockets or between existing and newly accepted connections.

On the exact head I ran git diff --check, tools/check_conventions.py --base upstream/main, and the public-header audit; all pass (368 libraries, 12,202 exports). The author reports seven focused Windows tests passing and a deliberate failure against the previous libSceNet binary for the unconnected-MSS case. Hosted policy checks pass, but product-build jobs are skipped, and the cited PS5 measurements cover libkernel_sys rather than direct libSceNet calls; that limitation is documented. I found no blocking issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5645856256 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11272#pullrequestreview-5645856256). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T23:22:15Z. **Review:** APPROVED --- I reviewed the state model and the socket lifecycle paths for TCP_MAXSEG and the keepalive options, including family defaults, stream checks, unconnected/listening MSS rejection, the 176-to-216 clamp, input/output truncation, per-socket isolation, timer bounds, and accept-time inheritance. The zero-as-default readback for keepalive values matches FreeBSD's `TP_KEEPIDLE`/`TP_KEEPINTVL`/`TP_KEEPCNT` behavior. The focused test covers both libSceNet and libkernel entry points and verifies that option state does not leak between sockets or between existing and newly accepted connections. On the exact head I ran `git diff --check`, `tools/check_conventions.py --base upstream/main`, and the public-header audit; all pass (368 libraries, 12,202 exports). The author reports seven focused Windows tests passing and a deliberate failure against the previous libSceNet binary for the unconnected-MSS case. Hosted policy checks pass, but product-build jobs are skipped, and the cited PS5 measurements cover libkernel_sys rather than direct libSceNet calls; that limitation is documented. I found no blocking issue.
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!11272
No description provided.