Skip to content

feat(libSceNet): support SO_KEEPALIVE - #9523

Merged
adriadam10 merged 12 commits into
boykopovar:mainfrom
Queuse:codex/net-keepalive
Oct 25, 2026
Merged

adriadam10 merged 12 commits into
boykopovar:mainfrom
Queuse:codex/net-keepalive

Conversation

@Queuse

@Queuse Queuse commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

Implement SO_KEEPALIVE in sceNetSetsockopt and sceNetGetsockopt: TCP configures the host socket; non-stream sockets retain the flag without probes. Readback returns the FreeBSD flag bit (8) and truncates to the supplied output length.

Semantics follow FreeBSD 11.4 sosetopt/sogetopt and the Windows SO_KEEPALIVE contract. Host timer differences and unverified console behavior remain in library debt.

Tested

Windows 11 x86-64, WinLibs MinGW-w64 GCC 15.2.0-r7, Ninja, Release. Head 01b7dbaa7f includes main b4d8e8bb3b.

  • Rebuilt affected libraries and focused targets; guest_sce_net_keepalive, guest_net_protocol, guest_net_nodelay_readback and guest_net_buffer_validation: 4/4 pass, no skips.
  • Canonical public-declaration audit, conventions and whitespace checks pass.
  • The merge retains main's protocol getter, truncated TCP_NODELAY reads, test registrations and current debt entries. The shared integer-length guard remains after the short-output paths.
  • A source recheck and trial merge with consulted main 19fe176ddc are clean. Its later closed-stream polling, IPv6 text and unrelated libc/kernel changes are outside these option paths; the local runtime results above belong to the stated head/base.
  • No fresh Linux/macOS runtime, full hosted product build, title or console run.

Integration order remains #9523 → #9542 → #9515 → #9578 and #9525 → #9543. #9930 and #9931 are now merged, so their former prerequisites for #9932/#9948 are satisfied; #9948 still follows #9932. #6044 was closed without merging the test relocation. #10097 follows #9523 as its author confirmed. The #5836 peer/broadcast order remains a proposal. The #9525/#10949 intersection concerns CMake test registration, with no option-behavior dependency; the author of #10949 confirmed #9525-first and declared Depends on: #9525.

Canonical overlap snapshot 7e4f6e0440: confirmed intersections with #10097. 7 comparisons remain incomplete because those branches conflict with the base: #5836, #7201, #9727, #9733, #9932, #9948, #10502. Manual inspection covers peer/broadcast transport mapping, macOS paths, argument validation, socket records and diagnostic output. Preserve every option path, field, canonical declaration, fixture and debt entry during integration; these checks do not establish a combined runtime pass with the conflicting branches.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@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 implementation tracks the guest boolean and applies it to host TCP sockets, while preserving per-socket readback for non-stream sockets; the bit-valued readback and short-buffer behavior follow the cited FreeBSD model. The author-reported Windows test covers IPv4/IPv6 TCP/UDP, host TCP option state, accepted-socket inheritance, invalid arguments and socket isolation. The existing resolver timeout is reported on both main and this change. Current eligibility, conventions, intake, labels and report checks pass; hosted product/relinker jobs are skipped. I did not run a local test. I also checked that this PR and #9525 merge together cleanly.

@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 5836 core/libs/prx/libSceNet/CMakeLists.txt
core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 7201 core/libs/prx/libSceNet/Export.cpp
PR 9932 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 9948 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 10502 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md

@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.

My earlier implementation review and reported Windows coverage remain applicable, but the refreshed overlap report flags shared CMakeLists.txt, Export.cpp, and debt-file paths with #9506, #9525, #9542, #9543 and #9544, plus additional conflicted-base comparisons. The prior direct merge check with #9525 does not clear the newly reported candidates. Please compare the exact hunks, coordinate order with affected authors where required, record prerequisites in Depends on, and rerun the overlap check after rebasing. I’m requesting changes for the repository’s overlap/coordination rule; this is not a new behavior finding. Policy checks pass, product jobs are skipped, and I did not rerun local tests.

@MarcZX10

Copy link
Copy Markdown
Contributor

Current-head recheck: this branch is 2 ahead / 119 behind today’s main (base a6dcea927); its individual merge, diff-check and conventions pass. Pairwise merges are clean with #9525, #9543, #9544, #9506 and #8362; #9542 conflicts in Export.cpp, and #9542 correctly declares Depends on: #9523. Please preserve that order, finish the remaining overlap coordination from the current scanner report, and refresh this branch onto current main before rerunning the focused keepalive test. The Windows test and baseline timeout are author-reported; I did not run local network tests.

@harisibrar1 harisibrar1 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.

Checked against main 830ccd1, FreeBSD 11.4 sogetopt/sosetopt (sys/kern/uipc_socket.c), and main's libkernel GuestSockets::GetSocketLevelOption/SetSocketLevelOption:

  • The setter/getter behaviour matches FreeBSD and libkernel's existing GuestKeepAlive handling: readback is bit 8, short buffers are truncated, and the flag is stored without host probes on non-stream sockets. Since inheritance on accepted sockets comes from the host socket, there's no need to copy the new keepalive field in sceNetAccept.
  • One small docs point: the new SO_KEEPALIVE debt bullet lands under ### Unknown function info in docs/dev/debt/libSceNet.md (line 27, just above ### Functional). That heading is for unknown or assumed signatures (see docs/dev/TechnicalDebt.md). Could it move to ### Functional, next to the TCP_NODELAY and SO_ONESBCAST entries, where #9525 puts its SO_TYPE/SO_ACCEPTCONN entry?
  • With git merge-file, this branch merges cleanly onto current main, and cleanly together with #9525.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

@Queuse

Queuse commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

@harisibrar1 thanks, moved the keepalive limitation under Functional in 8dea78c49. The branch also includes main b7d1d47a5; conventions and whitespace checks pass. I am rerunning the focused validation on the refreshed head.

@MarcZX10 the existing #9523 before #9542 order remains. I followed up with the authors of #6044 and #5836 and marked both coordination items pending in the description. #6879's libSceNet change only adds a system header; #7201 changes macOS resolver handling. Neither changes these socket-option paths. I will keep the remaining coordination open until the authors confirm the order.

Update: the focused network targets build with MSYS2 UCRT64 GCC 16.2.0. Runtime validation is blocked by this host's missing AVX2/FMA/BMI/LZCNT/MOVBE features. The boolean-readback test and unchanged guest_sce_net fixture both stop in main's unchanged CPU startup guard before assertions. A collaborator needs to run the Build workflow on a compatible runner for these refreshed heads. No new runtime pass is claimed. The final debt placement in f696ec880 also merges cleanly with #9543; checking 46 open network PRs finds no new debt-file conflict (only #5836's existing main conflict).

@adriadam10 adriadam10 self-assigned this Oct 25, 2026
@adriadam10
adriadam10 dismissed MarcZX10’s stale review October 25, 2026 15:20

Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
@Queuse

Queuse commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Refreshed in 01b7dbaa7f. The keepalive getter now composes with main's protocol and short TCP_NODELAY reads without restoring the old early length guard. After rebuilding on main b4d8e8bb3b, keepalive, protocol, TCP_NODELAY readback and buffer validation pass 4/4 on Windows; the public-header audit, conventions and whitespace checks pass too.

#9523 before #9542 remains the order, and #10097 follows this PR as its author confirmed. #6044 was closed without the test relocation; the separate #5836 proposal remains pending.

@adriadam10
adriadam10 merged commit 086ec0a into boykopovar:main Oct 25, 2026
13 of 14 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the SO_KEEPALIVE set/get against FreeBSD 11.4 sosetopt/sogetopt (bit 8 readback, truncation to the supplied length, flag kept without probes on non-stream sockets), the composition with main's protocol and TCP_NODELAY getters, the debt entry, and that guest_sce_net_keepalive pins values that fail without the change (previously EOPNOTSUPP); merged.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants