Repository navigation
fix(libSceNet): ignore IPv4-mapped results of an IPv6 name lookup on macOS - #10629
maximilianfv wants to merge 1 commit into
Conversation
…macOS macOS getaddrinfo answers an AF_INET6 lookup of an IPv4 address, such as "127.0.0.1", with the IPv4-mapped address ::ffff:127.0.0.1 even without AI_V4MAPPED, so sceNetResolverStartNtoa6 succeeded where it must fail with SCE_NET_ERROR_RESOLVER_ENODNS. FreeBSD returns no mapped address for an IPv4 literal or an A-only name unless AI_V4MAPPED is set, which the resolver never sets. Skip IPv4-mapped results of an AF_INET6 lookup on macOS. Co-authored-by: Ycaro Gabriel <280482597+ycarogabriel-lgtm@users.noreply.github.com> Co-authored-by: Himansh Raj <67262056+iamthehimansh@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The prior-art section says #7201 remains open and makes a whole-port change that overlaps the same |
MarcZX10
left a comment
There was a problem hiding this comment.
The PR body identifies overlapping lookup_host behavior in open #7201 but the checklist still says Depends on: none. CONTRIBUTING requires the authors to agree on merge order and record the dependency. I left the specific request in this comment; no author response or body update is present at this head. I have not approved pending that coordination.
|
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.
|
MarcZX10
left a comment
There was a problem hiding this comment.
Follow-up on the current overlap warnings at head b5868dd32860621102859b462b6cc0486794994a. Manual checks confirm two coordination items beyond the original checklist mismatch:
- #7201 edits the same
lookup_hostpath on macOS (it rejects numeric IPv4 literals beforegetaddrinfo; this PR filters IPv4-mapped results).git merge-tree --write-tree upstream/pr/7201 upstream/pr/10629conflicts insidelookup_host, so these behaviors need an agreed order and a combined test/implementation plan. The body mentions #7201 but the checklist still saysDepends on: none. - #10502 implements
sceNetShowIfconfigandsceNetShowNetstat, while this branch'sCheckNetstatstill expects those calls to throw. The three-way merge conflicts inGuestSceNet.cppat that test and in theSilent stubsdebt entry. Please coordinate order with #10502 and reconcile the test expectations so the combined branch tests the implemented diagnostics rather than treating them as unsupported.
I also confirmed adjacent debt-file conflicts with #9727 and #9733 via merge-tree; their implementation changes are in other functions, but the shared documentation hunks will need to retain both updates. The broad #5836 diff changes peer socket types/options, not lookup_host, so I found no direct resolver implementation overlap there.
Please agree on the merge order with the affected authors and record the required dependency or dependencies in the checklist. I have not run a local macOS resolver test; the PR's host probe and reported platform test remain author evidence.
|
On the limitation you list about A-only names: I probed it on an M5 Pro, macOS 27.2 (26B5086k), built both x86_64 (Rosetta 2) and arm64. Both builds give the same results. The network is dual-stack with global IPv6 and no DNS64.
So a real A-only name is mapped on macOS too, even with flags 0, and with this change it fails with
AI-assisted: yes |
What
On macOS,
getaddrinfowithai_family = AF_INET6and no flags answers an IPv4 literal such as"127.0.0.1"with the IPv4-mapped address::ffff:127.0.0.1.lookup_hostpasses that on, sosceNetResolverStartNtoa6(resolver, "127.0.0.1", ...)returns 0 and writes::ffff:127.0.0.1.guest_sce_netexpectsSCE_NET_ERROR_RESOLVER_ENODNS(0x804101E1) with the output buffer unchanged (core/libs/tests/GuestSceNet.cpp:1932), and thesceNetResolverStartNtoa6entry indocs/dev/debt/libSceNet.mdsays a name with no IPv6 address fails withRESOLVER_ENODNS.FreeBSD 11.4's
getaddrinforeturns no IPv4-mapped address for anAF_INET6query unlessAI_V4MAPPEDis set: an IPv4 literal is accepted only with that flag (explore_numeric), and DNS asks for A records only with that flag (_dns_getaddrinfo).lookup_hostnever sets it.This PR makes
lookup_hostskip IPv4-mapped results of anAF_INET6lookup on macOS (IN6_IS_ADDR_V4MAPPED).sceNetResolverStartNtoa6is the onlyAF_INET6caller oflookup_host. Linux and Windows are unchanged.A small host probe (
getaddrinfo,AF_INET6, flags 0) on macOS returned::ffff:127.0.0.1for"127.0.0.1",::1for"::1"and::1for"localhost".Limitations, on macOS only:
FILTER_V4MAPPED, which its libc Makefiles do not define.AF_INET6, now fails withRESOLVER_ENODNSas on FreeBSD (only an IPv4 literal was probed on macOS, not a real A-only name).Prior art: the same change was written before in two whole-port PRs that are now closed, so both authors are credited as co-authors on the commit. #7332 by Ycaro Gabriel (ycarogabriel-lgtm) has identical code in commit a8fa3e9 (2026-10-17). #8658 by Himansh Raj (iamthehimansh) has identical code plus a comment in commit 301073a (2026-10-19). Open #7201 by marion909 (commit c31e82f, 2026-10-16) takes a different approach for the same test: on macOS, an
AF_INET6lookup of a name that parses as an IPv4 literal fails beforegetaddrinforuns. That approach does not cover A-only names. Apart from the whole-port #7201, no open PR changeslookup_host.Tested
Apple M1 Pro, macOS 27.0.1, x86_64 build under Rosetta 2.
mainalone does not build on macOS, so I tested in a tree made of mugurc's macOS series (ci/macos-series-2,27e968974) merged withmainat1e20650e84, open #9231 (7c5d97324) and my own sceNetIoctlFIONREADfix (not yet opened). Only this change was toggled between runs.ctest -R '^(guest_sce_net|guest_resolver|guest_net_ctl|guest_inet_address|guest_net_.*|guest_datagram_.*|net_dontwait_.*|guest_socket_error|guest_udp)$'(22 tests): 21 pass with and without the change.guest_sce_netaborts with and without the change. Without the change it stops at the check above (GuestSceNet.cpp:1932on currentmain, located with lldb on an-O0rebuild). With the change it passes that check and stops later, at thesceNetCtlGetIfStat(&first)call (GuestSceNet.cpp:2168on currentmain). That stop is an uncaught "sceNetCtlGetIfStat: host interface byte counters are not implemented on this platform" (libSceNetCtl/Export.cpp:511), a separate macOS gap that open feat(libSceNetCtl): read macOS interface byte counters #9728 (MarcZX10) closes.Not tested on Linux or Windows. Their code is unchanged.
Checklist
main; no other open PR implements the same functions (except Macos port #7201, the whole macOS port, see What)NotImplemented_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)GuestSceNet.cppand neighbouringdocs/dev/debt/libSceNet.mdentries; I rebase this one after them); merge order with Macos port #7201 (lookup_host) asked at Macos port #7201 (comment)🤖 Generated with Claude Code