fix(libSceNet): report SO_SNDBUF and SO_RCVBUF from sceNetGetsockopt #5536

Merged
milescoviello merged 1 commit from upstream-pr/5536 into main 2026-10-14 22:29:08 +00:00
milescoviello commented 2026-10-13 23:07:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-13T23:07:30Z.


What

Steam Remote Play (PPSA99350, from the homebrew catalog) reads SO_RCVBUF on its UDP socket with sceNetGetsockopt. On main that fails with EOPNOTSUPP (0x8041012d), although sceNetSetsockopt already accepts SO_SNDBUF and SO_RCVBUF.

FreeBSD 11.4 answers both options with the buffer's high-water mark (sogetopt, sys/kern/uipc_socket.c):

		case SO_SNDBUF:
			optval = so->so_snd.sb_hiwat;
			goto integer;

		case SO_RCVBUF:
			optval = so->so_rcv.sb_hiwat;
			goto integer;

sosetopt sets that mark to the requested size through sbreserve (chgsbsize(..., &sb->sb_hiwat, cc, ...)), so a guest reads back exactly the size it set.

sceNetGetsockopt now answers both options:

  • A size the guest set with sceNetSetsockopt is reported as it was set. Reading the host instead would give twice the value on Linux, which doubles it.
  • Before the guest sets one, the host socket's current size is reported.

guest_sce_net gains CheckBufferSizes. On a UDP socket both options are readable with a positive size before any set, and SO_SNDBUF 32768 and SO_RCVBUF 65536 read back exactly after sceNetSetsockopt.

Rebased onto #4988, which added SO_ERROR to the same switch and a field to the same Sock struct; both cases and both fields are kept. #5349 changes a nearby line of GuestSceNet.cpp and does not change these two options.

Tested

Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags, on main 30f961266:

  • With main's Export.cpp and the new test, guest_sce_net fails; with the change it passes 20/20.
  • All 345 guest_* tests pass in two runs.
  • A MinGW-w64 GCC 13 -fsyntax-only -Wall -Wextra compile of Export.cpp is clean.
  • Steam Remote Play (PPSA99350), relinked with --to-intel and run on Linux under gdb, logging every libSceNet and other service call that returns an error code:
    • With main's libSceNet, sceNetGetsockopt returns 0x8041012d.
    • With this change it returns 0. The only remaining error is sceNetSendto with ENETUNREACH, because the run has no network.
  • tools/check_conventions.py --base upstream/main passes.

Checked on Windows by orishamir (comment): Windows 11, RTX 4080, WinLibs GCC 15.2, this head on main e34c47921. guest_sce_net passes 5 of 5 and aborts with Export.cpp taken back to main; the full ctest has no failures. Steam Remote Play (PPSA99350) logs SO_RCVBUF 0 on main and the socket's own 4194304 with this change.

Not checked on a console.

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
  • Unblocks: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4850615058 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5536). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-13T23:07:30Z. --- ### What Steam Remote Play (PPSA99350, from the homebrew catalog) reads `SO_RCVBUF` on its UDP socket with `sceNetGetsockopt`. On `main` that fails with `EOPNOTSUPP` (`0x8041012d`), although `sceNetSetsockopt` already accepts `SO_SNDBUF` and `SO_RCVBUF`. FreeBSD 11.4 answers both options with the buffer's high-water mark ([`sogetopt`, `sys/kern/uipc_socket.c`](https://github.com/freebsd/freebsd-src/blob/releng/11.4/sys/kern/uipc_socket.c#L2828-L2834)): ```c case SO_SNDBUF: optval = so->so_snd.sb_hiwat; goto integer; case SO_RCVBUF: optval = so->so_rcv.sb_hiwat; goto integer; ``` `sosetopt` sets that mark to the requested size through `sbreserve` (`chgsbsize(..., &sb->sb_hiwat, cc, ...)`), so a guest reads back exactly the size it set. `sceNetGetsockopt` now answers both options: - A size the guest set with `sceNetSetsockopt` is reported as it was set. Reading the host instead would give twice the value on Linux, which doubles it. - Before the guest sets one, the host socket's current size is reported. `guest_sce_net` gains `CheckBufferSizes`. On a UDP socket both options are readable with a positive size before any set, and `SO_SNDBUF` 32768 and `SO_RCVBUF` 65536 read back exactly after `sceNetSetsockopt`. Rebased onto #4988, which added `SO_ERROR` to the same `switch` and a field to the same `Sock` struct; both cases and both fields are kept. #5349 changes a nearby line of `GuestSceNet.cpp` and does not change these two options. ### Tested Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags, on `main` 30f961266: - With `main`'s `Export.cpp` and the new test, `guest_sce_net` fails; with the change it passes 20/20. - All 345 `guest_*` tests pass in two runs. - A MinGW-w64 GCC 13 `-fsyntax-only -Wall -Wextra` compile of `Export.cpp` is clean. - Steam Remote Play (PPSA99350), relinked with `--to-intel` and run on Linux under gdb, logging every libSceNet and other service call that returns an error code: - With `main`'s libSceNet, `sceNetGetsockopt` returns `0x8041012d`. - With this change it returns 0. The only remaining error is `sceNetSendto` with `ENETUNREACH`, because the run has no network. - `tools/check_conventions.py --base upstream/main` passes. Checked on Windows by orishamir ([comment](https://github.com/boykopovar/AnyPS5/pull/5536#issuecomment-6173708434)): Windows 11, RTX 4080, WinLibs GCC 15.2, this head on `main` e34c47921. `guest_sce_net` passes 5 of 5 and aborts with `Export.cpp` taken back to `main`; the full `ctest` has no failures. Steam Remote Play (PPSA99350) logs `SO_RCVBUF 0` on `main` and the socket's own `4194304` with this change. Not checked on a console. ### 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: none - [x] Unblocks: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
milescoviello commented 2026-10-14 02:58:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-14T02:58:05Z.


Rebased onto main 486420f91 after #4988 merged. The conflict was its SO_ERROR case and reported_error field next to these; both are kept. After the rebase: the build is clean, guest_sce_net passes 5/5 and all 357 guest_* tests pass (Ubuntu 24.04, GCC 13.3, Release). A MinGW-w64 GCC 13 -fsyntax-only -Wall -Wextra compile of Export.cpp has no errors.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159873482 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5536#issuecomment-6159873482). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-14T02:58:05Z. --- Rebased onto `main` 486420f91 after #4988 merged. The conflict was its `SO_ERROR` case and `reported_error` field next to these; both are kept. After the rebase: the build is clean, `guest_sce_net` passes 5/5 and all 357 `guest_*` tests pass (Ubuntu 24.04, GCC 13.3, Release). A MinGW-w64 GCC 13 `-fsyntax-only -Wall -Wextra` compile of `Export.cpp` has no errors. AI-assisted: yes
orishamir commented 2026-10-14 16:57:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-14T16:57:50Z.


Windows run, since the description says Windows wasn't checked. Windows 11, RTX 4080, WinLibs GCC 15.2.0 r7, Release, this head (2c25b181f) merged onto main e34c47921.

  • guest_sce_net passes 5 of 5. The full ctest has 0 failures out of 1198; the 14 skips come from the tests' own checks.
  • With only core/libs/prx/libSceNet/Export.cpp taken back to main, guest_sce_net aborts (exit 0xC0000409).
  • Steam Remote Play (PPSA99350, catalog 1.0.0), 45 s: at start it reads SO_RCVBUF on a new UDP socket and logs it (src/main.cpp). On main it logs socket self-test: SO_RCVBUF 0. With this PR it logs SO_RCVBUF 4194304, which is the Winsock socket's own size here: nothing in libSceNet sets it before the read. Otherwise the two runs match: same state (LOOKING FOR A PC RUNNING STEAM), 16 dumped frames each and no new stderr line.

AI-assisted: yes (Claude Code Opus 5.5)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6173708434 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5536#issuecomment-6173708434). Originally posted by [orishamir](https://github.com/orishamir) on 2026-10-14T16:57:50Z. --- Windows run, since the description says Windows wasn't checked. Windows 11, RTX 4080, WinLibs GCC 15.2.0 r7, Release, this head (2c25b181f) merged onto `main` e34c47921. - `guest_sce_net` passes 5 of 5. The full `ctest` has 0 failures out of 1198; the 14 skips come from the tests' own checks. - With only `core/libs/prx/libSceNet/Export.cpp` taken back to `main`, `guest_sce_net` aborts (exit 0xC0000409). - Steam Remote Play (PPSA99350, catalog 1.0.0), 45 s: at start it reads `SO_RCVBUF` on a new UDP socket and logs it ([`src/main.cpp`](https://github.com/jmelovich/Steam-Link-PS5/blob/ab1d8c0d28/src/main.cpp#L472-L483)). On `main` it logs `socket self-test: SO_RCVBUF 0`. With this PR it logs `SO_RCVBUF 4194304`, which is the Winsock socket's own size here: nothing in libSceNet sets it before the read. Otherwise the two runs match: same state (`LOOKING FOR A PC RUNNING STEAM`), 16 dumped frames each and no new stderr line. AI-assisted: yes (Claude Code Opus 5.5)
milescoviello commented 2026-10-14 17:02:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-14T17:02:32Z.


Thanks for the Windows run, and for checking that the test aborts with main's Export.cpp. I added it to the description.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6173802682 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5536#issuecomment-6173802682). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-14T17:02:32Z. --- Thanks for the Windows run, and for checking that the test aborts with `main`'s `Export.cpp`. I added it to the description. AI-assisted: yes
adriadam10 commented 2026-10-14 21:47:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T21:47:18Z.


Checked the diff against FreeBSD sogetopt (sb_hiwat), guest_sce_net (passes; aborts with Export.cpp reverted to main), and orishamir's Windows run; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6179214744 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5536#issuecomment-6179214744). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T21:47:18Z. --- Checked the diff against FreeBSD `sogetopt` (`sb_hiwat`), `guest_sce_net` (passes; aborts with `Export.cpp` reverted to `main`), and orishamir's Windows run; merging.
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!5536
No description provided.