feat(libSceNet): implement sceNetIoctl #9060

Merged
ags-arnab merged 1 commit from upstream-pr/9060 into main 2026-10-23 08:48:25 +00:00
ags-arnab commented 2026-10-21 11:11:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ags-arnab on 2026-10-21T11:11:28Z.


What

sceNetIoctl threw not implemented. It now implements the (socketId, command, argument) signature recovered on main in 9ccfc4219.

On a socket from sceNetSocket:

  • FIONBIO (0x8004667e) sets the same state as SO_NBIO, through the existing setter. FreeBSD's soo_ioctl sets SS_NBIO for it, and the library already maps fcntl's O_NONBLOCK to SO_NBIO.
  • FIONREAD (0x4004667f) reports the bytes the host socket has queued.
  • Any other request fails with ENOTTY, as libkernel's ioctl does on its own sockets, and a null argument to FIONBIO or FIONREAD fails with EFAULT.

A socket from libkernel's socket goes to libkernel's ioctl. Any other descriptor fails with NET_EBADF, as in sceNetSetsockopt.

Requests on a sceNetSocket socket are not forwarded to libkernel's ioctl, because there they do not reach the library: on Linux FIONBIO switches the host socket's O_NONBLOCK without the library's SO_NBIO state, and on Windows the descriptor is a NUL placeholder, so FIONREAD and enabling FIONBIO throw. That libkernel gap is recorded in docs/dev/debt/libkernel.md, and a new sceNetIoctl entry under "Functional" in docs/dev/debt/libSceNet.md lists what differs from FreeBSD and from shadPS4.

tools/progress.py --compare: +1 implemented function.

tools/pr_overlap.py --branch reports two overlaps, both at line 226 of docs/dev/debt/libkernel.md: #8700 adds an entry next to the one added here, and #9566 rewords the ioctl, _ioctl entry just above it. Whichever merges second keeps both changes. The open pull requests it could not compare because they conflict with main change other libSceNet functions; none touches sceNetIoctl or ioctl handling.

Tested

  • Rebased onto main 9d6adeb55 after #9076. The sceNetIoctl debt line now sits after #9076's sceNetUsleep line; nothing else changed. An earlier rebase onto a6dcea927 had adopted the recovered std::uint32_t command signature. ycbuzi's Windows runs in the comments were on d625840 and 081ed539b.
  • Linux x86-64, Ubuntu 26.04 container, GCC 15.2.0, Release, full build: guest_sce_net passes 3 of 3. The host is Apple silicon and Rosetta has no AVX2, so the test ran under qemu-x86_64 -cpu max (QEMU 10.2.1). With main's sceNetIoctl and the new test it aborts with sceNetIoctl not implemented.
  • Windows: not built or run by me (WinLibs GCC 15.2.0 unavailable). ycbuzi's runs in the comments cover the same code at 081ed539b, and this rebase changes only the position of the debt line.
  • No title was run.
  • python3 tools/check_conventions.py --base origin/main passes.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4950603384 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9060). Originally posted by [ags-arnab](https://github.com/ags-arnab) on 2026-10-21T11:11:28Z. --- ### What `sceNetIoctl` threw `not implemented`. It now implements the `(socketId, command, argument)` signature recovered on `main` in 9ccfc4219. On a socket from `sceNetSocket`: - `FIONBIO` (`0x8004667e`) sets the same state as `SO_NBIO`, through the existing setter. FreeBSD's [`soo_ioctl`](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/sys/kern/sys_socket.c#L156-L170) sets `SS_NBIO` for it, and the library already maps `fcntl`'s `O_NONBLOCK` to `SO_NBIO`. - `FIONREAD` (`0x4004667f`) reports the bytes the host socket has queued. - Any other request fails with `ENOTTY`, as libkernel's `ioctl` does on its own sockets, and a null argument to `FIONBIO` or `FIONREAD` fails with `EFAULT`. A socket from libkernel's `socket` goes to libkernel's `ioctl`. Any other descriptor fails with `NET_EBADF`, as in `sceNetSetsockopt`. Requests on a `sceNetSocket` socket are not forwarded to libkernel's `ioctl`, because there they do not reach the library: on Linux `FIONBIO` switches the host socket's `O_NONBLOCK` without the library's `SO_NBIO` state, and on Windows the descriptor is a `NUL` placeholder, so `FIONREAD` and enabling `FIONBIO` throw. That libkernel gap is recorded in `docs/dev/debt/libkernel.md`, and a new `sceNetIoctl` entry under "Functional" in `docs/dev/debt/libSceNet.md` lists what differs from FreeBSD and from [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/60c42b925c3d1e00008621b8587819999260ec31/src/core/libraries/net/net.cpp#L1839). `tools/progress.py --compare`: +1 implemented function. `tools/pr_overlap.py --branch` reports two overlaps, both at line 226 of `docs/dev/debt/libkernel.md`: #8700 adds an entry next to the one added here, and #9566 rewords the `ioctl, _ioctl` entry just above it. Whichever merges second keeps both changes. The open pull requests it could not compare because they conflict with `main` change other libSceNet functions; none touches `sceNetIoctl` or ioctl handling. ### Tested <!-- 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. --> - Rebased onto `main` 9d6adeb55 after #9076. The `sceNetIoctl` debt line now sits after #9076's `sceNetUsleep` line; nothing else changed. An earlier rebase onto a6dcea927 had adopted the recovered `std::uint32_t command` signature. ycbuzi's Windows runs in the comments were on d625840 and 081ed539b. - Linux x86-64, Ubuntu 26.04 container, GCC 15.2.0, Release, full build: `guest_sce_net` passes 3 of 3. The host is Apple silicon and Rosetta has no AVX2, so the test ran under `qemu-x86_64 -cpu max` (QEMU 10.2.1). With `main`'s `sceNetIoctl` and the new test it aborts with `sceNetIoctl not implemented`. - Windows: not built or run by me (WinLibs GCC 15.2.0 unavailable). ycbuzi's runs in the comments cover the same code at 081ed539b, and this rebase changes only the position of the debt line. - No title was run. - `python3 tools/check_conventions.py --base origin/main` passes. ### 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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-10-21 11:11:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-21T11:11:34Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5598775570 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9060#pullrequestreview-5598775570). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-21T11:11:34Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
ycbuzi commented 2026-10-21 17:51:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T17:51:04Z.


Windows run of d625840abd merged onto main 745b394629 (16478633d4, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceNet and guest_sce_net_tests with no errors or warnings. ctest --repeat until-fail:2 on guest_sce_net: passes on both repeats. Not run: a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6322738113 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9060#issuecomment-6322738113). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T17:51:04Z. --- Windows run of d625840abd merged onto `main` 745b394629 (16478633d4, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `libSceNet` and `guest_sce_net_tests` with no errors or warnings. `ctest --repeat until-fail:2` on `guest_sce_net`: passes on both repeats. Not run: a title.
ycbuzi commented 2026-10-22 08:22:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-22T08:22:00Z.


Windows run of 081ed539b2, the uint32_t request update, merged onto main d6eafa54d0 (7a3853c95a, clean). Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceNet and guest_sce_net_tests with no errors or warnings. ctest --repeat until-fail:2 on guest_sce_net: passes on both repeats. Not run: a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336202586 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9060#issuecomment-6336202586). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-22T08:22:00Z. --- Windows run of 081ed539b2, the `uint32_t` request update, merged onto `main` d6eafa54d0 (7a3853c95a, clean). Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `libSceNet` and `guest_sce_net_tests` with no errors or warnings. `ctest --repeat until-fail:2` on `guest_sce_net`: passes on both repeats. Not run: a title.
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!9060
No description provided.