Repository navigation
feat(libSceNet): implement the Ex and Internal socket forms, sceNetSysctl, scope-ID text and the default route - #9578
EagleBearerYS wants to merge 19 commits into
Conversation
sceNetInetPton and sceNetInetNtop called Winsock's InetPtonA and InetNtopA on Windows. Those print IPv4-translated and ISATAP addresses with a dotted tail, print ::ffff:0.0.0.1 as ::ffff:0:1, and accept a leading zero in a dotted tail, where FreeBSD does neither. Both now convert with libkernel's inet_pton and inet_ntop, which follow the FreeBSD 11.4 rules since boykopovar#3530.
boykopovar#5124 adds an entry after sceNetShowNetstat at the end of the unknown function info list, so adding the inet entry there made the two pull requests conflict.
…ockopt sceNetSetsockopt takes both, but sceNetGetsockopt failed them with EOPNOTSUPP. It now reads them from the host socket. FreeBSD's sogetopt returns so_options & option for the boolean options, so they read back as 0x4 and 0x20 when set.
setsockopt reaches a socket created with sceNetSocket through the option setter libSceNet registers, but getsockopt looked the descriptor up only among libkernel's own sockets and failed, so a title could set an option on such a socket through the BSD call and not read it back. libSceNet now registers an option getter with libkernel next to its setter, which answers through sceNetGetsockopt, so SO_RCVTIMEO and SO_SNDTIMEO come back as a struct timeval.
…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.
Progress report (16ff208 → 7f30082)📈 System libraries: 49.4% (+0.05%, +7 implemented functions) ✅ 7 implemented
Changed libraries (implemented exports)
|
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
I reviewed the current overlap report against the declared dependency branches. #9515 changes One additional overlap needs coordination: #9231 remains open and changes The no-gateway branch of |
MarcZX10
left a comment
There was a problem hiding this comment.
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.
|
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 |
There was a problem hiding this comment.
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.
|
I also withdraw the stale-base request. The current head |
|
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: # docs/dev/debt/libkernel.md
Main's boykopovar#10706 declares getsockopt_nid_postfix and sceNetGetsockopt in the libraries' public headers, so this branch's local declarations of them in GuestSceNet.cpp and libSceNet's Export.cpp go.
Main's boykopovar#10706 declares the libSceNet functions this branch implements, and libkernel's sysctl, __inet_pton and __inet_ntop, in the libraries' public headers, so this branch's local declarations of them in GuestSceNet.cpp and libSceNet's Export.cpp go.
Main extends the libkernel debt entry on libSceNet sockets with poll and fcntl, where this branch adds getsockopt to the same entry; the merge keeps both.
What
This implements 7 libSceNet functions that threw. 4 more from the same batch stay throwing, because their answer would be a guess.
0x80410100 | errno, like the library's other calls.fe80::1%2, RFC 4007 section 11) through sceNetInetNtop and sceNetInetPton. They print and parse it as FreeBSD's getnameinfo with NI_NUMERICSCOPE and getaddrinfo do. Interface-name zones and AF_INET throw.Still throwing:
This is stacked on #9494 and #9515. 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-treeagainst every open PR touching these files, onmain6ef5a1c. The conflicts the check reports all come from #9515's commits in this branch's base, not from this PR's own commits: #9365, #9099 and #8359 indocs/dev/debt/libkernel.md, and #7511 inSocket/src/Udp.cpp. This PR's commits change only libSceNet, libSceNetCtl,GuestSceNet.cppand libSceNet's debt file. #9231 merges cleanly with this PR and with #9494, whose IPv6 path insceNetInetPtonits macOS IPv4 check sits next to, and Gonic0 agreed that neither waits for the other (comment). #9542 (Queuse) duplicates thesceNetGetsockoptreadback of #9515's e887616, which this branch carries. Under the order agreed on #9515 (comment), #9523 → #9542 → #9515 → this PR, #9515 drops that hunk once #9542 lands, and this PR follows at its next merge ofmain.Tested
guest_sce_netfails ×2 on both with the stubs, and passes ×5 on both with this PR.guest_sce_net_testsgains these cases:fe80::1%2round trip, with rejected and boundary texts;main. None of the new cases needs IPv6 networking.main8b3e398 merged in (clean; the PR's own diff is unchanged), on GitHub's runners (run):guest_sce_netandguest_net_ctlpass 10 of 10 on Linux and Windows, none skipped. On its one run withmain's implementation,guest_sce_netfails on both runners andguest_net_ctlpasses. libkernel's suite passes on both, and libc's on Windows.precise_waitfailed 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 withmain's implementation as well. The rerun of the Linux job passed.check_conventions.pypasses, with no comment lines added.main938812d (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_optionsandguest_socket_errorpass 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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.maindb6af9e (run).mainnow has fix(libSceNet): convert sceNetInetPton text and null outputs as measured on a PS5 #10275 (orezraey'ssceNetInetPton, measured on a PS5: a nulldstfor IPv6 returnsNET_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 asmainhas it and sends only its IPv6 conversion through libkernel'sinet_pton, as this PR does; the IPv4 conversion and the dotted-part check stay on the host. The debt file keepsmain'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_errorandguest_socket_optionspass 10 runs in a row on both runners, 4 of 4 each, none skipped. The libc and libkernel suites pass on both, run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners. This PR'ssceNetInetPtonWithScopeIdcallssceNetInetPtonwith the text before the zone, so it takes the same rules.main67bbe03 (abbb7ac, whose one conflict wasdocs/dev/debt/libkernel.md, where feat(libkernel): answer sceKernelAddReadEvent and sceKernelAddWriteEvent on regular files #9099 (aarushkha, regular-file events) reworded thesceKernelAddReadEventpipe entry and added its own regular-file entry just above this PR'sclose,setsockoptandgetsockoptline; the merge keeps both ofmain'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_errorandguest_socket_optionspass 10 runs in a row with the change, on Linux and on Windows: 4 run, 4 pass, 0 skip, 0 fail. Withmain's code,guest_sce_netfails on both. The libc and libkernel suites pass on both (143 and 205 tests on Linux, 170 and 218 on Windows), run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.maina512780 (fc47c2f; see fix(libkernel): getsockopt reads options of libSceNet sockets #9515). The conflicts were incore/libs/tests/GuestSceNet.cppand libSceNet'sExport.cpp, where refactor(libs): add full export headers for libs #10706 (the public-header migration) removed their local declarations, among them this PR's forsceNetSocketInternal,sceNetGetsockoptEx,sceNetSetsockoptEx,sceNetSysctl,sceNetInetNtopWithScopeId,sceNetInetPtonWithScopeId,sceNetConfigGetDefaultRouteand libkernel'ssysctl,__inet_ptonand__inet_ntop. The merge takesmain's side:Net.hppand libkernel'sinclude/Api.hppnow declare each of them with the same arguments as this PR's definitions, andtests/test_public_headers.py --audit-onlypasses. So the PR's own diff loses those declarations and is otherwise unchanged.guest_net_ctl,guest_sce_net,guest_socket_error,guest_socket_optionsandpublic_headerspass 10 runs in a row with the change, on Linux and on Windows: 5 run, 5 pass, 0 skip, 0 fail. Withmain's code,guest_sce_netfails on both.guest_floating_pointfailed once in that run, on itsfeholdexcept workers preserve the main environmentcheck, 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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.main75227c7 (run). The one conflict wasdocs/dev/debt/libkernel.md's entry on libSceNet sockets, wheremainaddspollandfcntland this PR addsgetsockopt; 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_netandguest_tcppass 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, atfeholdexcept 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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)