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

Merged
Queuse merged 9 commits from upstream-pr/9542 into main 2026-10-26 11:58:13 +00:00
Queuse commented 2026-10-22 01:08:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Queuse on 2026-10-22T01:08:17Z.


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 ec47c9aa87 includes main b4d8e8bb3b.

  • Rebuilt affected libraries and focused targets; guest_net_boolean_readback, 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: #9523 (merge order)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4960519261 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9542). Originally posted by [Queuse](https://github.com/Queuse) on 2026-10-22T01:08:17Z. --- ### 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](https://github.com/freebsd/freebsd-src/blob/releng/11.4/sys/kern/uipc_socket.c#L2620-L2688); 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 `ec47c9aa87` includes main `b4d8e8bb3b`. - Rebuilt affected libraries and focused targets; `guest_net_boolean_readback`, `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. <!-- 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. --> ### 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: #9523 (merge order) <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-22 01:12:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:12:28Z.

Review: CHANGES_REQUESTED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608128112 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9542#pullrequestreview-5608128112). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:12:28Z. **Review:** CHANGES_REQUESTED --- 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 commented 2026-10-22 01:13:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:13:52Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608135962 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9542#pullrequestreview-5608135962). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:13:52Z. **Review:** COMMENTED --- 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 commented 2026-10-22 01:13:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:13:54Z.

Review: DISMISSED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608136089 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9542#pullrequestreview-5608136089). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:13:54Z. **Review:** DISMISSED --- 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 commented 2026-10-22 01:27:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Queuse on 2026-10-22T01:27:59Z.


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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330448699 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9542#issuecomment-6330448699). Originally posted by [Queuse](https://github.com/Queuse) on 2026-10-22T01:27:59Z. --- @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.
MarcZX10 commented 2026-10-22 11:46:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:46:47Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339961270 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9542#issuecomment-6339961270). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:46:47Z. --- 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 commented 2026-10-22 13:04:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T13:04:39Z.

Review: COMMENTED


Checked against main 3ca07d086d 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5614632963 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9542#pullrequestreview-5614632963). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-22T13:04:39Z. **Review:** COMMENTED --- Checked against main 3ca07d086d 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.
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!9542
No description provided.