Skip to content

feat(libSceNet): read reuse and broadcast flags - #9542

Draft
Queuse wants to merge 6 commits into
boykopovar:mainfrom
Queuse:codex/net-boolean-readback
Draft

Queuse wants to merge 6 commits into
boykopovar:mainfrom
Queuse:codex/net-boolean-readback

Conversation

@Queuse

@Queuse Queuse commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

Read SO_REUSEADDR and SO_BROADCAST from the native socket in sceNetGetsockopt, returning the FreeBSD flag bits (4 and 32) and truncating output to the supplied length. Semantics follow FreeBSD 11.4 sogetopt/sooptcopyout; console results remain unverified in library debt.

Merge after #9523 because both edit the getter length-validation hunk.

Tested

Windows 11 x86-64, WinLibs MinGW-w64 GCC 15.2.0-r7, Ninja, Release. Head 28371daefd includes main 2fade7ef4e.

  • Rebuilt affected libraries and focused targets; guest_net_boolean_readback: 1/1 pass, with no skips.
  • Conventions and whitespace checks pass.
  • No fresh Linux/macOS, full hosted product build, title or console run.

Integration order remains #9523 → #9542 → #9515 → #9578 and #9525 → #9543 → #9930 → #8686; #9931 follows #9542. #9930/#9931 may land independently after their prerequisites, before the agreed #9932/#9948 updates. Preserve every option path, short-buffer rule, test and debt entry.

#6044 was closed without merging its test relocation, so that former coordination item is retired. The existing #5836 order proposal remains unconfirmed; its peer-transport and broadcast-alias changes must retain current buffer validation and option state when integrated. No author agreement is assumed. #10097 changes neighboring SO_ERROR debt and lists #9523 first; retain both debt entries during integration.

Earlier combined Windows/WSL2 network results remain tied to tree c9c1293; they are separate from this head's fresh Windows run.

Fresh overlap snapshot 30be9b428b: existing getter/debt intersections remain covered by the ordering above. 7 shared-file comparisons are incomplete because those branches conflict with the base: #5836, #7201, #9727, #9733, #9948, #10502, #10706. Manual inspection identifies export-header refactoring (#10706), diagnostic display (#10502), argument validation (#9727), send/platform paths (#9733/#7201), socket records (#9948), and the already pending peer/broadcast changes (#5836). No duplicate option branch was found in the inspected shared hunks. Retain the private socket fields, canonical declarations, test registrations and debt entries when integrating. These source checks do not establish author agreement or a combined runtime pass.

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: feat(libSceNet): support SO_KEEPALIVE #9523
  • 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 new readback branch and tests are focused, the Windows test results are reported, and the current eligibility, conventions, intake, labels and report checks pass; product jobs are skipped. I found no defect in the option mapping or short-buffer handling.

Please complete the overlap ordering before merge. #9525 also changes sceNetGetsockopt in Export.cpp and the libSceNet test-registration area; a direct git merge-tree of the two heads is clean, and their option cases appear separable, but the repository overlap rule still calls for recording which PR lands first. Since both PRs are yours, please add #9525 to the overlap/order note and to Depends on if #9542 should follow it, or record the agreed order if #9542 lands first. Keep the already-declared #9523 prerequisite for the getter-length hunk.

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

Correction to my preceding review: the live branch overlap report lists #9523 at the sceNetGetsockopt length-validation lines, which this PR already declares, but does not list #9525. A direct merge-tree of #9542 and #9525 is clean; I withdraw the requested ordering change for #9525.

I found a separate unresolved overlap with #6044: it moves the existing libSceNet tests to tests/networking and rewrites their CMake registrations to add_library_test(networking) in the same libSceNet/CMakeLists.txt test block where this PR adds a test. A pairwise merge also conflicts in that CMake file. Please coordinate the landing order and record Depends on: #6044 if this PR should follow the reorganization, or note the agreed order and carry the new test registration/path through whichever lands second.

@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 focused option mapping is consistent with the existing setters and FreeBSD flag-bit behavior; the reported Windows test covers enabled/disabled values, native readback, short buffers and invalid arguments. Current eligibility, conventions, intake, labels and report checks pass; product jobs are skipped.

The branch-mode overlap report identifies #9523 at the getter length-validation lines, and this PR correctly declares Depends on: #9523. The other unresolved manual overlap is #6044: its current diff moves the libSceNet tests to tests/networking and rewrites registrations in the same libSceNet/CMakeLists.txt test block where this PR adds guest_net_boolean_readback. Pairwise merge-tree reports a conflict in that CMake file. Please coordinate the order and record the dependency if this PR should follow #6044, then ensure the test source path and registration use the final organization.

@Queuse

Queuse commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks for the correction. I'll keep #9523 as the prerequisite; there's no need to add #9525.

I confirmed the CMake conflict with #6044. That branch also conflicts in the same file against main alone, so this is a test-organization conflict rather than a dependency in the socket behavior.

@TaymKal would landing #9523 and this PR before #6044 work for you? The new GuestNetBooleanReadback.cpp test would then need to move to tests/networking and use add_library_test(networking) along with the other network tests. If #6044 needs to land first, I can rebase this PR and make those changes here instead. The order is still a proposal until we agree.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 10097 docs/dev/debt/libSceNet.md L41-42

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 9727 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 9733 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

Copy link
Copy Markdown
Contributor

I refreshed this head against the current queue: diff-check and conventions pass, and it merges cleanly with current main; sync is 1 ahead / 119 behind (a6dcea927 base). Your #9523 prerequisite is recorded, and the Linux/Windows focused results are in the PR history. The proposed order with #6044 is still awaiting that author’s confirmation; please close that coordination loop, then update to current main and rerun the focused network tests/checks.

@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 3ca07d0 and FreeBSD 11.4 sys/kern/uipc_socket.c (sogetopt/sooptcopyout):

  • The readback looks right to me: enabled options return their flag bit, as so_options & optname does. The short-length exemption is limited to these two SOL_SOCKET options, so every other option still gets EINVAL below 4 bytes and reports *optlen = 4 as before. A three-way merge with current main applies cleanly.
  • Small debt suggestion: on a Windows host, the guest's SO_REUSEADDR is passed to Winsock's SO_REUSEADDR (setter, Export.cpp around line 1511 on main). On Winsock that lets a second socket bind an address and port another socket is actively using, while FreeBSD only lets the flag reuse a port held in TIME_WAIT and needs SO_REUSEPORT on both sockets for a second unicast bind. The setter on main already does this, but since this PR adds the debt entry for these options, a sentence there would record the gap. Maybe also note that SO_REUSEPORT (0x200) still fails with EOPNOTSUPP.

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, added the Winsock SO_REUSEADDR binding difference and the unsupported SO_REUSEPORT result to the debt entry in 1ca11e1f7. This records the existing setter limitation without changing its behavior.

@MarcZX10 this branch now includes main b7d1d47a5. #9523 remains its prerequisite. I followed up on #6044 and #5836, and the description explicitly keeps their ordering pending. Conventions and whitespace checks pass; focused runtime validation of this refreshed head is still in progress.

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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants