Skip to content

feat(libSceNet): implement the Ex and Internal socket forms, sceNetSysctl, scope-ID text and the default route - #9578

Merged
oneandonlydean merged 19 commits into
boykopovar:mainfrom
EagleBearerYS:feat/libscenet-ex-forwards
Nov 2, 2026
Merged

oneandonlydean merged 19 commits into
boykopovar:mainfrom
EagleBearerYS:feat/libscenet-ex-forwards

Conversation

@EagleBearerYS

@EagleBearerYS EagleBearerYS commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

This implements 7 libSceNet functions that threw. 4 more from the same batch stay throwing, because their answer would be a guess.

  • The Ex and Internal forms: sceNetSocketInternal, sceNetGetsockoptEx and sceNetSetsockoptEx forward to sceNetSocket, sceNetGetsockopt and sceNetSetsockopt. Their restored argument lists match the public ones. How the console tells them apart is recorded as debt.
  • sceNetSysctl calls libkernel's sysctl (FreeBSD sysctl(3) arguments). A failure is reported as 0x80410100 | errno, like the library's other calls.
  • The scope-ID forms: sceNetInetNtopWithScopeId and sceNetInetPtonWithScopeId follow rooklz's reading of the console's libSceNet.sprx (comment).
    • The zone is an interface name from the module's table (lo0, eth0, eth1, dbg0, gbe0, bt0, wlan0, wlan1, phone0, pppoe0). Ntop prints %<name>, and a decimal zone such as fe80::1%2 doesn't convert.
    • Pton's % branch runs only with a scope output.
    • Null ntop arguments set ENOSPC. Another family gives EAFNOSUPPORT: null from ntop, 0x8041012F from pton.
    • A name maps to a host interface through feat(net): resolve interface ids to host indexes #14213's interface table and helpers, taken with the same text.
    • A null pton destination throws std::invalid_argument, where the module faults.
  • sceNetConfigGetDefaultRoute follows rooklz's measured chain (comment).
    • Before initialization it returns 0x804101C8 with errno 200.
    • Without a route it returns 0x8041130C with the output untouched.
    • Otherwise it returns 1 after storing the gateway.
    • The gateway is the host's: the IPv4 gateway of the interface that sceNetCtlGetInfo describes as DEFAULT_ROUTE, through a libSceNetCtl helper next to the DNS one.
    • A null output with a route throws std::invalid_argument, where the module faults.

Still throwing:

  • sceNetConfigGetDefaultRoute6: NetCtl has no IPv6 model.
  • sceNetConfigGetIfFlags and sceNetGetIfnameNumList: the console's interface numbering isn't known.
  • sceNetInitParam: NetInitializeParameter's layout isn't known.

81bc358 (the scope-ID forms) and 0a4d4e7 (the default route) replace the earlier numeric zones and throws with the module's answers, after rooklz's reading and oneandonlydean's review. Both commits carry rooklz's Co-authored-by line. The debt entries list what isn't measured:

  • ntop for a scope that no interface has (it still throws, and no test asserts it);
  • the exact name comparison;
  • the order of the family and null checks;
  • that the default route's kernel dword is the gateway in network byte order.

#9494 and #9515, which this was stacked on, have both merged. The scope-ID forms use #9494's text rules through sceNetInetNtop and sceNetInetPton.

Related: #9231 changes sceNetSocket's errors and, on macOS, sceNetInetPton's IPv4 path. sceNetSocketInternal follows whatever sceNetSocket returns.

Overlap: checked with git merge-tree against every open PR touching these files, on main 6ef5a1c. The conflicts it reported came from #9515's commits in this branch's base, which are on main now that #9515 has merged: #9365, #9099 and #8359 in docs/dev/debt/libkernel.md, and #7511 in Socket/src/Udp.cpp. This PR's own commits change only libSceNet, libSceNetCtl, GuestSceNet.cpp, libSceNet's debt file and the iphlpapi link in core/libs/CMakeLists.txt. #9231 merges cleanly with this PR and with #9494, whose IPv6 path in sceNetInetPton its macOS IPv4 check sits next to, and Gonic0 agreed that neither waits for the other (comment). The order agreed on #9515 (comment), #9523 → #9542 → #9515 → this PR, has reached this PR: the other three have merged. #9542 (Queuse) carried the same sceNetGetsockopt readback as #9515's e887616, and the merge of #9515's 4432e8a in 57ba2fc kept #9542's version. #14213 (rooklz, interface names) shares the interface table, its host helpers and the iphlpapi links, which this PR takes with the same text, so a merge keeps one copy of each. git merge-tree against its 20fd7cf conflicts only in GuestSceNet.cpp, in the same two places as before these commits: both PRs add test functions, and their calls, at the same point. Keeping both sides resolves it.

Tested

  • GitHub's Linux and Windows runners (run), against the merge of fix(libSceNet): follow FreeBSD inet text rules for IPv6 #9494 and fix(libkernel): getsockopt reads options of libSceNet sockets #9515: guest_sce_net fails ×2 on both with the stubs, and passes ×5 on both with this PR.
  • Linux (Ubuntu 24.04, Release): guest_sce_net_tests gains these cases:
    • the Ex and Internal forms equal their twins;
    • sceNetSysctl against libkernel's sysctl on hw.pagesize, with its error cases;
    • the fe80::1%2 round trip, with rejected and boundary texts;
    • the default route against sceNetCtlGetInfo's DEFAULT_ROUTE.
    • Each function reverted alone fails (7 of 7), and the PR passes 10 of 10 repeats.
    • That machine has no IPv6 loopback, so the test's existing IPv6 socket checks skip there, as on main. None of the new cases needs IPv6 networking.
    • The no-gateway branch of the default-route case wasn't exercised.
    • Full ctest under CI's configure has only that machine's IPv6 failures, plus one AGC fill test that passes on rerun.
  • 43ea777, main 8b3e398 merged in (clean; the PR's own diff is unchanged), on GitHub's runners (run): guest_sce_net and guest_net_ctl pass 10 of 10 on Linux and Windows, none skipped. On its one run with main's implementation, guest_sce_net fails on both runners and guest_net_ctl passes. libkernel's suite passes on both, and libc's on Windows.
    • On Linux, libc's precise_wait failed on the fix arm only in the run's first attempt. It's a runner timing test outside the files this PR touches, and in run 39788040462 it failed with main's implementation as well. The rerun of the Linux job passed.
  • check_conventions.py passes, with no comment lines added.
  • Not tested with a title.
  • dda8c45, a merge of fix(libkernel): getsockopt reads options of libSceNet sockets #9515's merge of main 938812d (efd999c). It brings no conflict of its own, and the PR's own diff is unchanged. On GitHub's runners (run), guest_net_ctl, guest_sce_net, guest_socket_options and guest_socket_error pass 10 runs in a row on Linux and on Windows, 4 of 4, none skipped. The libc and libkernel suites pass on both (119 and 201 tests on Linux, 146 and 211 on Windows), run with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • c0caad0, a merge of main db6af9e (run). main now has fix(libSceNet): convert sceNetInetPton text and null outputs as measured on a PS5 #10275 (orezraey's sceNetInetPton, measured on a PS5: a null dst for IPv6 returns NET_EINVAL, IPv4 text ends at the first whitespace, and the dotted IPv4 part of IPv6 text is checked the same way). The merge keeps that function as main has it and sends only its IPv6 conversion through libkernel's inet_pton, as this PR does; the IPv4 conversion and the dotted-part check stay on the host. The debt file keeps main's measured entry and this PR's IPv6 entry, which now says the FreeBSD forms are unverified on a console beyond those PS5 measurements. guest_net_ctl, guest_sce_net, guest_socket_error and guest_socket_options pass 10 runs in a row on both runners, 4 of 4 each, none skipped. The libc and libkernel suites pass on both, run with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners. This PR's sceNetInetPtonWithScopeId calls sceNetInetPton with the text before the zone, so it takes the same rules.
  • 5cffcf5, a merge of fix(libkernel): getsockopt reads options of libSceNet sockets #9515's merge of main 67bbe03 (abbb7ac, whose one conflict was docs/dev/debt/libkernel.md, where feat(libkernel): answer sceKernelAddReadEvent and sceKernelAddWriteEvent on regular files #9099 (aarushkha, regular-file events) reworded the sceKernelAddReadEvent pipe entry and added its own regular-file entry just above this PR's close, setsockopt and getsockopt line; the merge keeps both of main's entries and this PR's line). It brings no conflict of its own, and the PR's own diff is unchanged. On GitHub's runners (run), guest_net_ctl, guest_sce_net, guest_socket_error and guest_socket_options pass 10 runs in a row with the change, on Linux and on Windows: 4 run, 4 pass, 0 skip, 0 fail. With main's code, guest_sce_net fails on both. The libc and libkernel suites pass on both (143 and 205 tests on Linux, 170 and 218 on Windows), run with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 6c938db, a merge of fix(libkernel): getsockopt reads options of libSceNet sockets #9515's merge of main a512780 (fc47c2f; see fix(libkernel): getsockopt reads options of libSceNet sockets #9515). The conflicts were in core/libs/tests/GuestSceNet.cpp and libSceNet's Export.cpp, where refactor(libs): add full export headers for libs #10706 (the public-header migration) removed their local declarations, among them this PR's for sceNetSocketInternal, sceNetGetsockoptEx, sceNetSetsockoptEx, sceNetSysctl, sceNetInetNtopWithScopeId, sceNetInetPtonWithScopeId, sceNetConfigGetDefaultRoute and libkernel's sysctl, __inet_pton and __inet_ntop. The merge takes main's side: Net.hpp and libkernel's include/Api.hpp now declare each of them with the same arguments as this PR's definitions, and tests/test_public_headers.py --audit-only passes. So the PR's own diff loses those declarations and is otherwise unchanged.
    • On GitHub's runners (run), guest_net_ctl, guest_sce_net, guest_socket_error, guest_socket_options and public_headers pass 10 runs in a row with the change, on Linux and on Windows: 5 run, 5 pass, 0 skip, 0 fail. With main's code, guest_sce_net fails on both.
    • The libkernel suite passes on both (206 tests on Linux, 222 on Windows) and the libc suite on Windows (170). On Linux, libc's guest_floating_point failed once in that run, on its feholdexcept workers preserve the main environment check, which feat(libc): implement feholdexcept #8863 added; this PR changes nothing in libc. Run alone on this head 20 times in a row (run), it passes on both runners, and both suites pass on both (143 and 206 tests on Linux, 170 and 222 on Windows). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 7f30082, a merge of main 75227c7 (run). The one conflict was docs/dev/debt/libkernel.md's entry on libSceNet sockets, where main adds poll and fcntl and this PR adds getsockopt; the merge keeps both, in the same words as fix(libkernel): getsockopt reads options of libSceNet sockets #9515's merge. The PR's code diff is unchanged. guest_sce_net and guest_tcp pass 10 runs in a row on both runners. guest_floating_point, which this PR doesn't touch, passed 10 of 10 on Windows; on Linux it passed seven times and aborted on the eighth run, at feholdexcept workers preserve the main environment. At 6c938db it passed 20 runs in a row on both runners (run). That check is the AMD x87 pointer-word case reported in tests: guest_floating_point fails at random on AMD hosts: "feholdexcept workers preserve the main environment" #10899, which fix(tests): compare x87 pointer words in guest_floating_point only when both images have ES set #10937 addresses; both aborts here were on AMD EPYC Linux runners. 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.
  • 89da0c7, a merge of main 2b52256 (run). main now has fix(libSceNet): follow FreeBSD inet text rules for IPv6 #9494, so its part of this branch leaves the diff: the IPv6 text conversion in sceNetInetPton and sceNetInetNtop, CheckRejectedAddressText and the sceNetInetPton, sceNetInetNtop debt entry. This PR's other changed lines are the same as before the merge. One conflict, in docs/dev/debt/libSceNet.md: KernelPanicNT's fix(libSceNet): reject the flags and names the module rejects #9727 adds a sceNetResolverStartNtoa entry after the sceNetInetPton, sceNetInetNtop entry both sides now carry, and the merge takes it. guest_net_ctl and guest_sce_net pass 10 runs in a row, and guest_sce_net fails on the before arm. Linux: 2 run, 2 pass, 0 skip, 0 fail. Windows: 2 run, 2 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 88f9967 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.
  • 57ba2fc, after oneandonlydean's review (run). It holds three commits: f051532, a merge of main 439d03d, whose one conflict, in libSceNetCtl's Export.cpp, keeps this PR's NetCtlHostIpv4Gateway helper next to main's STUN block from feat(libSceNetCtl): implement sceNetCtlGetNatInfo #10790; 930c1c0, which removes the four assertions that pinned valid inputs to throw (the named zone fe80::1%lo0, the two AF_INET scope conversions, and sceNetConfigGetDefaultRoute with a valid output and no host gateway), keeping the malformed and null-pointer checks, the numeric IPv6 round trips and the success and no-write controls; and a merge of fix(libkernel): getsockopt reads options of libSceNet sockets #9515's 4432e8a, which drops the duplicate readback block (see fix(libkernel): getsockopt reads options of libSceNet sockets #9515). This PR's other changed lines are the same. guest_sce_net, guest_net_ctl, guest_socket_error, guest_socket_options, guest_tcp, guest_net_boolean_readback, guest_socket_descriptor_flags and public_headers pass 10 runs in a row. Linux: 8 run, 8 pass, 0 skip, 0 fail. Windows: 8 run, 8 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (166 and 264). On Windows libc passes (194) and libkernel passes 283 of 286: exec_arguments, guest_timed_join_import_libkernel_sys and guest_timed_join_import_libkernel_web fail at their setup in the verify's Windows build (FileNotFoundError starting the title, or copying the libraries they load), with main's code too, and pass in main's own Windows job at 1829def (job). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 8c13ac3, a merge of main cc672fd (run). The one conflict was in libSceNet's Export.cpp, where fix(libSceNet): print the interface and socket tables from sceNetShowIfconfig and sceNetShowNetstat #10502 (frankea, the interface and socket tables from sceNetShowIfconfig and sceNetShowNetstat) declares libSceNetCtl's NetCtlHostIpv4Address_nid_no_patch on the line where this PR declares NetCtlHostIpv4Gateway_nid_no_patch; the merge keeps both declarations. This PR's other changed lines are the same. guest_sce_net, guest_net_ctl, guest_net_boolean_readback, guest_socket_descriptor_flags, guest_socket_error, guest_socket_options and guest_tcp pass 10 runs in a row. Linux: 7 run, 7 pass, 0 skip, 0 fail. Windows: 7 run, 7 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (166 and 265). On Windows libc passes (194), and libkernel passes 284 of 287: exec_arguments, guest_timed_join_import_libkernel_sys and guest_timed_join_import_libkernel_web fail at their setup in the verify's Windows build (FileNotFoundError starting the title, or copying the libraries they load), with main's code too, and pass in main's own Windows job at 1829def (job). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • e88598f, a merge of main 2960e9a after fix(libkernel): getsockopt reads options of libSceNet sockets #9515 merged (run). The merge was clean. With fix(libkernel): getsockopt reads options of libSceNet sockets #9515 on main, its lines leave this PR's diff: the libkernel socket files and debt entry, and its getter in libSceNet's Export.cpp with its tests in GuestSceNet.cpp. The diff now holds only libSceNet, libSceNetCtl, GuestSceNet.cpp and libSceNet's debt file, and this PR's own changed lines are the same as before the merge. guest_sce_net, guest_net_ctl, guest_net_boolean_readback, guest_socket_descriptor_flags, guest_socket_error, guest_socket_options and guest_tcp pass 10 runs in a row, and with main's code guest_sce_net fails on both runners ("sceNetSocketInternal not implemented"). Linux: 7 run, 7 pass, 0 skip, 0 fail. Windows: 7 run, 7 pass, 0 skip, 0 fail. The libc and libkernel suites run 191 and 291 tests on Linux and 220 and 314 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 0a4d4e7, the module's answers for the scope-ID forms and the default route (run). Two commits on e88598f, with no merge. guest_sce_net and the 11 net_dontwait_blocking_* and net_epoll_lifetime_* tests, which build libSceNet's Export.cpp into themselves, pass 10 runs in a row. Linux: 12 run, 12 pass, 0 skip, 0 fail. Windows: 12 run, 12 pass, 0 skip, 0 fail. With e88598f's Export.cpp, guest_sce_net aborts on both runners at its first new check ("the interface name zone in fe80::1%lo0 is not implemented"). The libc and libkernel suites run 191 and 291 tests on Linux and 220 and 314 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • The default-route case checks the branch its host has. The no-route branch (0x8041130C with the output untouched, for a null output too) also ran on Linux in a network namespace with only lo up.

Checklist

…ards

Base for the libSceNet Ex/Internal forwards: upstream main 94fbb8c with fix/libscenet-inet-text-rules (ef49574) and fix/libkernel-getsockopt-net-sockets (aea804d).
…ns to their public twins

sceNetSocketInternal, sceNetGetsockoptEx and sceNetSetsockoptEx threw.
Their argument lists, restored with the rest of the firmware exports in
4d6942f, are the same as sceNetSocket, sceNetGetsockopt and
sceNetSetsockopt, so they now call those. Nothing in the tree records
how the console tells the entry points apart (for example by the
calling process); the debt file says so.

Tested: guest_sce_net_tests creates a datagram socket through
sceNetSocketInternal, sets SO_REUSEADDR and SO_RCVTIMEO through
sceNetSetsockoptEx and reads them back through sceNetGetsockoptEx and
sceNetGetsockopt with the same values. On a closed socket and on -1,
and for an unsupported family and type, each Ex/Internal call returns
the same error and errno as its public twin.
sceNetSysctl threw. Its restored argument list is FreeBSD's sysctl(3)
(name, name length, old value and size, new value and size), so it now
calls libkernel's sysctl. It answers exactly the MIBs libkernel models,
and a failure is returned as the library's other calls return one
(0x80410100 | errno, with the errno set).

Tested: guest_sce_net_tests reads hw.pagesize (6.7) through both
sysctl and sceNetSysctl and gets the same value and size, including a
size-only query. A one-level name gives EINVAL, a null name EFAULT, a
write EPERM and a one-byte buffer ENOMEM, each as 0x804101xx with the
errno set.
sceNetInetNtopWithScopeId and sceNetInetPtonWithScopeId threw. They now
handle AF_INET6 text with an RFC 4007 numeric zone (fe80::1%2): the
address part goes through sceNetInetNtop and sceNetInetPton, so it
follows the FreeBSD inet text rules, and the zone is printed and parsed
as FreeBSD 11.4's getnameinfo (NI_NUMERICSCOPE) and getaddrinfo do. A
zero scope ID prints the address alone and text without a zone parses
to scope ID 0. An empty zone, one above 2^32 - 1, or an invalid address
part returns 0 and leaves both outputs untouched; a buffer too small
for the scoped text gives ENOSPC.

A zone given as an interface name, and AF_INET, still throw: the tree
has no mapping from interface names to the console's interface indexes
and no answer for an IPv4 zone. The debt file says so.

Tested: guest_sce_net_tests round-trips fe80::1%2 (same address bytes
as fe80::1, scope ID 2) and ff02::1%4294967295, checks the exact
buffer size and ENOSPC one byte short, the unscoped forms, four
rejected texts with untouched outputs, EINVAL for null pointers, and
that an interface-name zone and AF_INET throw.
…ultRoute

sceNetConfigGetDefaultRoute threw. It now writes the IPv4 gateway of the
host interface that libSceNetCtl's sceNetCtlGetInfo already describes as
DEFAULT_ROUTE, in network byte order, the order sceNetInetPton writes an
AF_INET address in, and returns 0. libSceNetCtl exports
NetCtlHostIpv4Gateway_nid_no_patch for it, next to the DNS helper
sceNetGetDnsInfo uses. Without a gateway, or for a null pointer, it
still throws: the console's answer for a missing route is not measured.

Tested: guest_sce_net_tests, after sceNetCtlInit, prints the gateway
with sceNetInetNtop and compares it with sceNetCtlGetInfo's
DEFAULT_ROUTE text (192.0.2.1 on this host); a null pointer throws.
On a host without a default route the case checks that the call
throws and leaves the output untouched.
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Progress report (4569fe6 → 0a4d4e7)

📈 System libraries: 26.35% (+0.02%, +7 implemented functions)

✅ 7 implemented
Library Name
libSceNet sceNetConfigGetDefaultRoute
libSceNet sceNetGetsockoptEx
libSceNet sceNetInetNtopWithScopeId
libSceNet sceNetInetPtonWithScopeId
libSceNet sceNetSetsockoptEx
libSceNet sceNetSocketInternal
libSceNet sceNetSysctl

Changed libraries (implemented exports)

Library Before After Change
libSceNet 83/232 (35.78%) 90/232 (38.79%) +3.02%

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

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 5021 core/libs/CMakeLists.txt
PR 5836 core/libs/prx/libSceNet/CMakeLists.txt
core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 7275 core/libs/CMakeLists.txt
PR 8650 core/libs/CMakeLists.txt
PR 9019 core/libs/CMakeLists.txt
PR 9156 core/libs/CMakeLists.txt
PR 9162 core/libs/CMakeLists.txt
PR 9293 core/libs/CMakeLists.txt
PR 9297 core/libs/CMakeLists.txt
PR 9302 core/libs/CMakeLists.txt
PR 9383 core/libs/CMakeLists.txt
PR 9948 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 12104 docs/dev/debt/libSceNet.md
PR 12642 core/libs/CMakeLists.txt
PR 12683 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 13253 core/libs/CMakeLists.txt
PR 13256 core/libs/CMakeLists.txt
PR 14212 docs/dev/debt/libSceNet.md
PR 14264 core/libs/CMakeLists.txt
PR 14299 core/libs/CMakeLists.txt

@MarcZX10

Copy link
Copy Markdown
Contributor

I reviewed the current overlap report against the declared dependency branches. #9515 changes libSceNet/Export.cpp and Socket/src/Udp.cpp, which are also in this PR's aggregate diff because #9578 is stacked on it. The relevant work composes in principle: the new getsockopt getter uses the socket-option hook added by #9515, and the Ex forwarding methods use the sceNetGetsockopt implementation updated there. Please keep #9515's hook and option behavior intact when reconciling; the required dependency is already declared.

One additional overlap needs coordination: #9231 remains open and changes sceNetInetPton in the same Export.cpp, while this PR changes that function's IPv6 conversion path to use libkernel's parser. Its change is Apple-only and should compose with the family-specific IPv6 delegation, but that needs an agreed order/rebase and retention of the leading-zero IPv4 behavior. Please coordinate with #9231's author and record a dependency if either PR must land first.

The no-gateway branch of sceNetConfigGetDefaultRoute is explicitly not exercised in the reported Linux run. Its helper correctly leaves the caller's output untouched when it finds no route, and the code throws in that case; keep the debt statement that this result is unverified.

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

Reviewed the eight-commit diff and the focused coverage. The Ex/Internal forms are explicit forwards with uncertainty recorded; sysctl is routed through the existing libkernel implementation and its error mapping is documented as unverified; scope IDs are deliberately numeric-only with unsupported interface-name/AF_INET paths left throwing; and the default-route helper writes only after finding a gateway, with its no-route and null behavior kept explicitly unimplemented. The tests include boundaries/rejections, focused red-green controls, repeats, and accurately disclose the missing no-gateway execution and IPv6 environment limitation. The checklist declares the stacked prerequisites #9494 and #9515 and correctly says no title unblock. Eligibility, conventions, intake, labels and report checks pass; product build jobs are skipped. The Linux/Windows comparisons in the description are author-reported; I did not run tests locally. No actionable issue found in this review.

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

Thanks, @MarcZX10. Gonic0 agreed on #9231 that neither PR waits for the other (comment): its macOS check of an IPv4 address's leading zeros runs before the host conversion, which this stack leaves IPv4 to, and the two merge cleanly with this PR and with #9494. The Overlap section and Depends on now say so, here and on #9494, where the sceNetInetPton IPv6 change comes from.

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

Follow-up to my earlier approval after refreshing upstream/main and rerunning the focused target on this exact head. The local guest_sce_net_tests target builds successfully from this PR head. CTest starts the test, but the process aborts in HostCpu before test assertions because this host lacks LZCNT, BMI1/2, MOVBE, AVX2 and FMA. The PR's Linux/Windows test matrix is reported as author-run on a merge of #9494 and #9515; current required eligibility, conventions, intake, labels and report checks pass, while product and relinker jobs are skipped by path policy. Please refresh the branch against current main and rerun the focused Linux/Windows checks before merge. check_main_sync.py reports 10 ahead / 116 behind (merge base 94fbb8cea), despite a clean merge. Since the PR's last checked base 6ef5a1c and that merge base, main changed libSceNet/Export.cpp, libSceNetCtl/Export.cpp, GuestSceNet.cpp and both debt files. In particular, GuestSceNet.cpp now has additional tests, and libSceNetCtl initialization changed; please verify the new cases and the default-route helper still behave as intended after rebasing. My prior review found no code defect on the then-current base. The focused Linux/Windows checks in the PR description are useful evidence; the remaining requests are for current-base validation only. I withdraw the queue-based hold; it is fine to keep submitting PRs and they will be handled in due course.

I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.

@MarcZX10

MarcZX10 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

I also withdraw the stale-base request. The current head 43ea7772bbca1d830872b3af6ae35dbd258e92d6 merges current upstream/main 8b3e39832af85f404c6195418d11b3e1ebd1924d (zero commits behind); current diff-check and conventions pass. The 11-commit PR stack includes #9494 and #9515, which remain open as the declared prerequisites, so preserve their changes and rerun the focused matrix after their integration. The existing author Linux/Windows red-green reports cover the merged dependency state. My local guest_sce_net_tests target built on this exact head, but CTest aborted during HostCpu initialization before assertions because this host lacks the required LZCNT/BMI/MOVBE/AVX2/FMA features; this is an environment-blocked run, not a passing test or assertion failure. Hosted product jobs are skipped. The agreed #9231 order is recorded, and the no-gateway branch remains accurately marked untested in the PR description.

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

main is merged (8b3e398, 43ea777), with the PR's own diff unchanged; guest_sce_net and guest_net_ctl pass 10 of 10 on GitHub's Linux and Windows runners (run).

@MarcZX10

Copy link
Copy Markdown
Contributor

I’ve noticed that asking you to hold this PR was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course.

# Conflicts:
#	core/libs/prx/libSceNetCtl/Export.cpp
…puts throw

The named zone "fe80::1%lo0", the two AF_INET scope conversions and
sceNetConfigGetDefaultRoute with a valid output and no host gateway are
valid but unimplemented forms; tests no longer pin them as throws. The
malformed and null-pointer checks, the numeric IPv6 round trips and the
success controls stay.
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 28, 2026
@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@oneandonlydean done in 930c1c0: the four assertions are gone (fe80::1%lo0, the two AF_INET scope conversions, and the default route with a valid output and no host gateway), and the malformed and null-pointer checks, the numeric IPv6 round trips and the success and no-write controls stay. The head, 57ba2fc, also merges #9515's merge of main. The tests pass 10 runs in a row on Linux and Windows (run).

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 28, 2026
# Conflicts:
#	core/libs/prx/libSceNet/Export.cpp

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

Re-reviewed exact head e88598fd9e9e933fa281e54993bff47a0c7692b9 against current upstream/main 4c7d275bef89d309313d16bc2bc05d37a1b50be2. The PR’s previously raised test issue is resolved: the assertions that pinned valid-but-unimplemented scope/default-route forms to throwing were removed, and the remaining malformed-input, numeric IPv6, and success/no-write cases are retained. The author reports the focused Linux and Windows suites passing 10 runs on this exact head. I refreshed the head, verified git merge-tree --write-tree produces a clean current-main preview, and ran git diff --check and python3 tools/check_conventions.py --base upstream/main; all passed. I found no remaining blocking issue.

@blawesom

Copy link
Copy Markdown
Contributor

Static review plus an independent Linux run (CachyOS, kernel 7.2.10, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, Ryzen 7 9800X3D). No findings.

What I checked (static)

  • The Ex/Internal socket forms forward exactly to their public counterparts (sceNetGetsockoptEx → sceNetGetsockopt, sceNetSetsockoptEx → sceNetSetsockopt, sceNetSocketInternal → sceNetSocket), deleting the NotImplemented_nid_no_patch stubs. The test (CheckExForwards) pins error-return parity for both a closed socket and -1 (same return value and same sceNetErrnoLoc() state), so a future divergence between the two paths is caught immediately.
  • sceNetSysctl delegates to libkernel's sysctl_nid_postfix with the FreeBSD sysctl(3) argument list and wraps failures via fail(*__error_nid_postfix()) — matching the library's existing error convention (0x80410100 | errno style, per the debt note). Test covers size-query, truncated-buffer (EFAULT) and null-pointer paths. The debt entry correctly records that how the console's routine reports errors is not measured.
  • sceNetInetNtopWithScopeId/sceNetInetNtopWithScopeId implement RFC 4007 § 11 numeric zones (fe80::1%2) by splitting on %, delegating the unscoped portion to the existing sceNetInetNtop/sceNetInetPton, and rejecting interface-name zones and AF_INET with std::runtime_error — matching the repo rule (throw, don't fake an answer) since the tree has no name→index mapping or IPv4 zone semantics. The test pins: zone round-trip (fe80::1%2), max-zone boundary (%4294967295 accepted, %4294967296 rejected), empty trailing %, non-digit zone, IPv4 rejection (all with output buffer/scopeId left untouched), and ENOSPC on a too-small output buffer. That's thorough coverage of the input-space boundaries.
  • sceNetConfigGetDefaultRoute reports the host IPv4 gateway via the new NetCtlHostIpv4Gateway_nid_no_patch helper; throws on null or missing gateway (recorded as unmeasured console behavior). CheckDefaultRoute cross-validates against sceNetCtlGetInfo(DEFAULT_ROUTE) (null-gateway early return path included).

Focused test run

tree result
this head 9578 1/1 guest_sce_net Passed (1.43s)

Not an AGC/shader/VideoOut change — no paired Vulkan-validation run required.

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the Linux run, @blawesom.

@rooklz

rooklz commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Thanks — the shape is right, but the module differs from this implementation on four points. I read the exports in libSceNet.sprx (GNU build ID ad19de2df01d46dfc925bcebb5aabdab00000000): sceNetInetNtopWithScopeId is FUN_00006be0 → FUN_000065e0, and sceNetInetPtonWithScopeId is FUN_000072d0 → FUN_00006ee0.

  1. The zone is an interface name, not a decimal index. FUN_00005d40 compares the text after % against a fixed table and maps it to a slot; FUN_00005ea0 turns that slot into the kernel index. The table strings at 0x3d99f, 0x3d5d6, 0x3cf65, 0x3cc84, 0x3bcbb, 0x3ce57 are lo0, eth0, eth1, dbg0, gbe0, bt0 (plus wlan0, wlan1, phone0, pppoe0). A decimal zone matches none of them, so "fe80::1%2" and "ff02::1%4294967295" return 0 rather than 1.
  2. Ntop prints the name too. For a nonzero scope it calls FUN_00005f20, which finds the interface whose index matches and copies its 16-byte name, then appends %<name>. scopeId = 2 therefore prints %eth0-style text, not %2, so the "fe80::1%2"/scope == 2 round trip in CheckScopeIdText cannot hold on hardware.
  3. Null Ntop arguments set ENOSPC (28), not EINVAL. FUN_000065e0 starts with if (address == 0 || text == 0) { *errno = 0x1c; return 0; }, and the same 0x1c is the too-small-buffer result. Only a family other than 28 gives EAFNOSUPPORT (0x2f), returned as null with errno set — not a throw.
  4. Pton does not require a scope output. The % branch is guarded by scopeId != nullptr; with a null scopeId a plain address still converts and % simply fails to parse (returns 0). FUN_000072d0 returns 0x8041012f with errno 47 for a family other than 28, and 0x80410116 with errno 22 only for a null text; a null destination faults in the module, where returning EINVAL is the reasonable host behaviour.

I have a candidate implementation of both exports that follows the module (host if_indextoname/if_nametoindex for the name mapping, with a debt entry for the console-vs-host index difference). I am holding it back because it changes the same two exports as this PR; tell me whether you would rather fold the behaviour here or take that branch instead.

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@rooklz thank you for reading the module. Your four points show this PR's scope-ID forms don't match the console: the zone is an interface name from the module's table, not a decimal index; Ntop prints that name; null Ntop arguments set ENOSPC; and Pton converts a plain address when there's no scope output.

I'd like to fold your behaviour in here, with the credit yours. If you point me to your branch or commit, I'll take it into this PR as your commit, under your name, with its tests and debt entry. If it needs adapting to this PR's tests, the adapted commit will carry you as co-author. Either way, CheckScopeIdText's %2 round trip goes, since it can't hold on hardware. The other five functions here stay as they are.

@rooklz

rooklz commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Measured behaviour from the firmware libSceNet.sprx for this export (NID lFJb+BlPK1c, wrapper at 0x153f0; the not-initialized check lives in the shared route-table getter at 0xc70), in case you want to fold it in:

  • Not initialized: returns 0x804101C8 with errno 200 before the getter — it does not throw.
  • The wrapper answers the locked route-table getter (AF_INET, record, 1, 1). A negative getter result passes through unchanged; a result other than 1 returns 0x8041130C with the output untouched; 1 stores the kernel-record dword at offset 0x84 into the output and returns 1 — success is reported by return value 1, not 0.
  • So a null pointer is not rejected by the wrapper (it is not checked), and a missing default route returns 0x8041130C with the output untouched rather than throwing.

I have a branch implementing exactly this chain (host gateway from the routing table, network byte order), but it overlaps this PR on the same lines, so I am holding it until this one lands or is updated with the measured chain.

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@rooklz thank you, that's the chain this PR's sceNetConfigGetDefaultRoute gets wrong: it throws for a null gateway and for a missing default route, and it returns 0 on success. I'll fold your measured behaviour in here with you as co-author: not initialized returns 0x804101C8 with errno 200, a missing default route returns 0x8041130C with the output untouched, and a found route returns 1. The scope-ID behaviour from your four points goes in the same way. If you'd rather both land as your own commits, point me to the branch and I'll take them under your name instead.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Reviewed at e88598fd9e9e933fa281e54993bff47a0c7692b9 (in addition to the scope-ID points).

The firmware measurement posted above for sceNetConfigGetDefaultRoute (NID lFJb+BlPK1c) differs from this head in three ways:

  • Success returns 1, not 0. core/libs/prx/libSceNet/Export.cpp line 3170 returns 0, and core/libs/tests/GuestSceNet.cpp line 436 expects 0. A caller that checks for 1 would read our success as a failure.
  • No default route returns 0x8041130C with the output untouched. Line 3168 throws instead.
  • Not initialized returns 0x804101C8 (errno 200), and a null output isn't checked by the wrapper. Line 3166 throws for null, and GuestSceNet.cpp line 431 pins that throw.

Could the function follow the measured chain (not-initialized check, 1 on success, 0x8041130C with the output untouched when there is no route) and the tests check those results instead of the throw?

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@oneandonlydean yes. As in my reply to rooklz just above, sceNetConfigGetDefaultRoute will follow the measured chain: the not-initialized answer (0x804101C8, errno 200), 1 on success, and 0x8041130C with the output untouched when there's no route. The tests will check those results in place of the null throw and the == 0. The scope-ID forms change the same way, from rooklz's four points, and rooklz is credited on both.

EagleBearerYS and others added 2 commits November 1, 2026 23:21
rooklz read sceNetInetNtopWithScopeId (FUN_00006be0) and
sceNetInetPtonWithScopeId (FUN_000072d0) in libSceNet.sprx. The zone
after '%' is one of the ten interface names, never a number, and ntop
prints the name of the interface whose index is the scope. A null
address or text and a short buffer set ENOSPC, and another family sets
EAFNOSUPPORT. Pton reads a zone only when the scope output is not null,
and answers another family with EAFNOSUPPORT and a null text with
EINVAL.

The host has none of these interfaces. Names and indexes go through the
interface table and host-index mapping of rooklz's "feat(net): resolve
interface ids to host indexes", taken with the same text so the two
changes merge without conflict there. A null destination throws
std::invalid_argument, where the module faults.

Co-authored-by: rooklz <175737347+rooklz@users.noreply.github.com>
rooklz read sceNetConfigGetDefaultRoute (NID lFJb+BlPK1c, wrapper at
0x153f0) in libSceNet.sprx. Before sceNetInit it returns 0x804101C8
with errno 200. Without a default route it returns 0x8041130C and
leaves the output alone. With one it stores the route and returns 1,
not 0. The wrapper never checks the output pointer.

The not-initialized answer reads the library's sceNetInit/sceNetTerm
flag through fail(), as the other exports do. The route is still the
host gateway. A null output with a route throws std::invalid_argument,
where the module faults.

Co-authored-by: rooklz <175737347+rooklz@users.noreply.github.com>
@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@rooklz @oneandonlydean the measured behaviour is in, as 81bc358 (the scope-ID forms) and 0a4d4e7 (sceNetConfigGetDefaultRoute). Both commits carry rooklz's Co-authored-by line.

sceNetConfigGetDefaultRoute, on Dean's three points:

  • Success returns 1, and the test expects 1.
  • Without a route it returns 0x8041130C and leaves the output untouched, and returns the same for a null output.
  • Before initialization it returns 0x804101C8 with errno 200, with or without an output, and the test checks that in place of the old null throw.

What's left of the null case comes from the wrapper's missing null check, not the old line 431 pin. A null output only matters once there's a route, and there the module faults. In that case it throws std::invalid_argument, as #14178 does for faulting arguments.

The scope-ID forms, on rooklz's four points:

  1. The zone is a name from the module's table, and a decimal zone such as fe80::1%2 doesn't convert.
  2. Ntop prints %<name>, so the old %2 round trip is gone from CheckScopeIdText.
  3. Null ntop arguments set ENOSPC, and another family gives EAFNOSUPPORT with null, without a throw.
  4. Pton's % branch runs only with a scope output. Another family gives 0x8041012F with errno 47, and a null text 0x80410116 with errno 22.

A name maps to a host interface through #14213's interface table and helpers, taken with the same text, so a merge of the two keeps one copy of each. Thanks for the EINVAL suggestion for pton's null destination. I kept std::invalid_argument there, since the module faults and the project's rule is to do what the console does or throw. The debt entries list what isn't measured: ntop for a scope that no interface has (it still throws, and no test asserts it), the exact name comparison, the order of the family and null checks, and the byte order of the route's kernel dword.

On GitHub's runners (run), guest_sce_net and the 11 tests that build libSceNet's Export.cpp into themselves pass 10 runs in a row: 12 run, 12 pass, 0 skip, 0 fail on both Linux and Windows. With the previous head's Export.cpp, guest_sce_net fails on both. The description has the details.

@oneandonlydean
oneandonlydean merged commit 459f61e into boykopovar:main Nov 2, 2026
13 checks passed
@rooklz

rooklz commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Post-merge re-check of the null-gateway case, reading the same wrapper again (NID `lFJb+BlPK1c`, 0x153f0) plus the shared getter it calls at 0xc70: the user pointer is never passed to the getter — the wrapper stores to `[rdi]` itself after the getter returns 1, with no null check anywhere on the path. So null output + route present faults in the module, and null output + no route returns `0x8041130C` before the store. That matches what landed in 0a4d4e7 (route-miss first, then the `std::invalid_argument` throw), and the null+no-route ordering is right too. Correction to my 2026-11-01 note: the `0x8041130E` I listed for a null gateway is not produced by this wrapper/getter pair (it does not appear in either function); treat that value as unsubstantiated for this export. The merged implementation stands.

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.

5 participants