feat(libSceNet): implement sceNetInitParam and the loopback answer of sceNetConfigGetIfFlags #10881

Merged
EagleBearerYS merged 5 commits from upstream-pr/10881 into main 2026-10-26 20:07:50 +00:00
EagleBearerYS commented 2026-10-25 07:10:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-25T07:10:41Z.


What

Two libSceNet calls stop throwing:

  • sceNetInitParam follows libSceNet's own code on firmware 13.42, as BunnyFl measured it (comment): a null parameter returns 0x80410116 (errno 22); the first non-null call stores the parameter's first 32 bytes and returns 0; every later call returns 0x80410110 (errno 16), a null parameter and a call after sceNetTerm included. The first success also marks the library initialized, which main's other calls check. The one field the module reads, bit 0 of the first word, raises sceNetPoolCreate's limit from 32 to 128 pools; main's sceNetPoolCreate has no limit, so the bit is stored but not modelled.
  • sceNetConfigGetIfFlags answers interface 0 (lo0 in the sceNetGetIfName numbering) with IFF_UP | IFF_LOOPBACK | IFF_RUNNING | IFF_MULTICAST (0x8049). That is what FreeBSD 11 reports for a configured loopback: lo_clone_create and loioctl in sys/net/if_loop.c, with if_flags | if_drv_flags as SIOCGIFFLAGS builds it in sys/net/if.c. A null flags pointer returns 0x8041130E before anything else, as measured on 13.42 (comment). Interfaces 1 to 9 throw, because their flags come from the kernel and the library models no other interface. A number of 10 or more returns -1 and leaves flags untouched, as the module does when sceNetGetIfName has no name for it and SIOCGIFFLAGS fails on the empty one (comment); the errno it sets isn't modelled.

Both are recorded under Unknown function info in docs/dev/debt/libSceNet.md.

Related: #9578 (which adds the libSceNetCtl host-gateway hook an eth0 answer would sit beside) and #9515 also edit libSceNet/Export.cpp; this merges cleanly with both.

Tested

  • GitHub's runners: run 40166706454: guest_sce_net passes 10 of 10 on Linux and on Windows, 0 skipped.
  • GitHub's runners, be3f208b02 (run), the commit that follows the measurement: guest_sce_net passes 10 runs in a row, and fails with e9db171018's code. Linux: 1 run, 1 pass, 0 skip, 0 fail. Windows: 1 run, 1 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 207) and on Windows (171 and 223). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • Linux (Ubuntu 24.04, gcc 13.3, CI's configure flags):
    • guest_sce_net gains CheckInitParam and CheckIfFlags. Each aborts with its commit's product change reverted (1 of 1 per commit) and passes with it.
    • The new cases need no IPv6; on a host without an IPv6 loopback the executable still ends in its existing skip.
    • The full ctest run: 2,211 tests, 2,116 pass and 90 skipped; the 5 failures are all IPv6 sockets on a VM booted with IPv6 disabled.
  • bf0f293edd, a merge of main 2b5225605b (run). KernelPanicNT's #9727 adds CheckRejectedArguments() to GuestSceNet.cpp's main right where this PR adds CheckIfFlags(); the merge keeps both, and nothing else conflicted. This PR's changed lines are the same as before the merge. guest_sce_net passes 10 runs in a row, and fails on the before arm. Linux: 1 run, 1 pass, 0 skip, 0 fail. Windows: 1 run, 1 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 209), and libc passes on Windows (171). Windows' libkernel suite runs 227 tests and fails guest_timed_join_import_libkernel_sys and guest_timed_join_import_libkernel_web, which this PR doesn't touch; main 88f99678bf fails the same two in this verify's Windows job (run), and main's own Windows CI passes them. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 6f3771820a, after oneandonlydean's review (run): sceNetConfigGetIfFlags returns -1 with flags untouched for an interface number of 10 or more, as BunnyFl's read of the module shows, instead of throwing. CheckIfFlags asserts that for 10 and 0xffffffff, and no longer asserts that interfaces 1 and 4 (eth0 and wlan0) throw. guest_sce_net passes 10 runs in a row, and fails with bf0f293edd's code. Linux: 1 run, 1 pass, 0 skip, 0 fail. Windows: 1 run, 1 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 209), and libc passes on Windows (171). Windows' libkernel suite runs 227 tests and fails guest_timed_join_import_libkernel_sys and guest_timed_join_import_libkernel_web, the same two as at bf0f293edd, which this PR doesn't touch (main's run). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.

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:5002651087 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10881). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-25T07:10:41Z. --- ### What Two libSceNet calls stop throwing: - `sceNetInitParam` follows libSceNet's own code on firmware 13.42, as BunnyFl measured it ([comment](https://github.com/boykopovar/AnyPS5/pull/10881#issuecomment-6397362559)): a null parameter returns 0x80410116 (errno 22); the first non-null call stores the parameter's first 32 bytes and returns 0; every later call returns 0x80410110 (errno 16), a null parameter and a call after `sceNetTerm` included. The first success also marks the library initialized, which main's other calls check. The one field the module reads, bit 0 of the first word, raises `sceNetPoolCreate`'s limit from 32 to 128 pools; main's `sceNetPoolCreate` has no limit, so the bit is stored but not modelled. - `sceNetConfigGetIfFlags` answers interface 0 (`lo0` in the `sceNetGetIfName` numbering) with `IFF_UP | IFF_LOOPBACK | IFF_RUNNING | IFF_MULTICAST` (0x8049). That is what FreeBSD 11 reports for a configured loopback: `lo_clone_create` and `loioctl` in `sys/net/if_loop.c`, with `if_flags | if_drv_flags` as `SIOCGIFFLAGS` builds it in `sys/net/if.c`. A null `flags` pointer returns 0x8041130E before anything else, as measured on 13.42 ([comment](https://github.com/boykopovar/AnyPS5/pull/10881#issuecomment-6397362559)). Interfaces 1 to 9 throw, because their flags come from the kernel and the library models no other interface. A number of 10 or more returns -1 and leaves `flags` untouched, as the module does when `sceNetGetIfName` has no name for it and `SIOCGIFFLAGS` fails on the empty one ([comment](https://github.com/boykopovar/AnyPS5/pull/10881#issuecomment-6397362559)); the errno it sets isn't modelled. Both are recorded under Unknown function info in `docs/dev/debt/libSceNet.md`. Related: #9578 (which adds the libSceNetCtl host-gateway hook an `eth0` answer would sit beside) and #9515 also edit `libSceNet/Export.cpp`; this merges cleanly with both. ### Tested - **GitHub's runners:** [run 40166706454](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40166706454): `guest_sce_net` passes 10 of 10 on Linux and on Windows, 0 skipped. - **GitHub's runners, be3f208b02** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40192160254)), the commit that follows the measurement: `guest_sce_net` passes 10 runs in a row, and fails with e9db171018's code. Linux: 1 run, 1 pass, 0 skip, 0 fail. Windows: 1 run, 1 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 207) and on Windows (171 and 223). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **Linux** (Ubuntu 24.04, gcc 13.3, CI's configure flags): - `guest_sce_net` gains `CheckInitParam` and `CheckIfFlags`. Each aborts with its commit's product change reverted (1 of 1 per commit) and passes with it. - The new cases need no IPv6; on a host without an IPv6 loopback the executable still ends in its existing skip. - The full ctest run: 2,211 tests, 2,116 pass and 90 skipped; the 5 failures are all IPv6 sockets on a VM booted with IPv6 disabled. - **bf0f293edd, a merge of `main` 2b5225605b** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40244747574)). KernelPanicNT's #9727 adds `CheckRejectedArguments()` to `GuestSceNet.cpp`'s `main` right where this PR adds `CheckIfFlags()`; the merge keeps both, and nothing else conflicted. This PR's changed lines are the same as before the merge. `guest_sce_net` passes 10 runs in a row, and fails on the before arm. Linux: 1 run, 1 pass, 0 skip, 0 fail. Windows: 1 run, 1 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 209), and libc passes on Windows (171). Windows' libkernel suite runs 227 tests and fails `guest_timed_join_import_libkernel_sys` and `guest_timed_join_import_libkernel_web`, which this PR doesn't touch; `main` 88f99678bf fails the same two in this verify's Windows job ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40238050809)), and `main`'s own Windows CI passes them. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **6f3771820a, after oneandonlydean's review** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40278665014)): `sceNetConfigGetIfFlags` returns -1 with `flags` untouched for an interface number of 10 or more, as BunnyFl's read of the module shows, instead of throwing. `CheckIfFlags` asserts that for 10 and `0xffffffff`, and no longer asserts that interfaces 1 and 4 (eth0 and wlan0) throw. `guest_sce_net` passes 10 runs in a row, and fails with bf0f293edd's code. Linux: 1 run, 1 pass, 0 skip, 0 fail. Windows: 1 run, 1 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 209), and libc passes on Windows (171). Windows' libkernel suite runs 227 tests and fails `guest_timed_join_import_libkernel_sys` and `guest_timed_join_import_libkernel_web`, the same two as at bf0f293edd, which this PR doesn't touch ([main's run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40238050809)). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. ### 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
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!10881
No description provided.