Uh oh!
There was an error while loading. Please reload this page.
[Android] Fix DNS localhost subdomain resolution with IPv6 on Android - #125478
Conversation
Tagging subscribers to this area: @karelz, @dotnet/ncl |
There was a problem hiding this comment.
Pull request overview
Fixes Android-specific failures in RFC 6761 *.localhost subdomain resolution when an AddressFamily filter is applied (notably InterNetworkV6), by adding an Android IPv6 localhost fallback that retries using ip6-localhost if localhost IPv6 resolution fails.
Changes:
- Add Android-only IPv6 fallback: if resolving
localhostwithInterNetworkV6fails withHostNotFound, retry withip6-localhost(sync + async paths). - Refactor async localhost-subdomain fallback to use helper local functions that include the Android retry behavior.
- Re-enable the Android variants of the
RespectsAddressFamilytests by removing[ActiveIssue]annotations.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/libraries/System.Net.NameResolution/src/System/Net/Dns.cs | Adds Android IPv6 retry (localhost → ip6-localhost) for InterNetworkV6 when localhost-subdomain fallback resolves plain localhost; applied to sync + async telemetry path. |
| src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostEntryTest.cs | Removes Android [ActiveIssue] to re-enable localhost subdomain AddressFamily test coverage. |
| src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostAddressesTest.cs | Removes Android [ActiveIssue] to re-enable localhost subdomain AddressFamily test coverage. |
On Android, getaddrinfo("localhost", AF_INET6) fails with EAI_NONAME
because the default /etc/hosts maps ::1 to "ip6-localhost" instead of
"localhost". This causes the RFC 6761 localhost subdomain fallback to
fail when InterNetworkV6 is requested.
Add an Android-specific catch in the fallback path: when IPv6 localhost
resolution fails with HostNotFound, retry with "ip6-localhost".
Fixesdotnet#124751
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>6816840 to
6fdaf5cComparesimonrozsival
commented
Mar 12, 2026
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Uh oh!
There was an error while loading. Please reload this page.
Remove the OperatingSystem.IsAndroid() guard so the ip6-localhost IPv6 fallback applies on any system where /etc/hosts maps ::1 to ip6-localhost instead of localhost (e.g. Android, some Linux distros). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
simonrozsival
commented
Mar 13, 2026
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
simonrozsival
commented
Mar 16, 2026
/azp run runtime, runtime-extra-platforms |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Fix DNS localhost subdomain tests with AddressFamily on Android
Fixes#124751
Problem
The
DnsGetHostEntry_LocalhostSubdomain_RespectsAddressFamilyandDnsGetHostAddresses_LocalhostSubdomain_RespectsAddressFamilytests consistently fail on Android.The RFC 6761 localhost subdomain fallback (introduced in #123076) resolves
"test.localhost"by first trying the OS resolver, then falling back to resolving plain"localhost"with the sameAddressFamily. On Android, the second step fails forInterNetworkV6because Android's default/etc/hostsmaps::1toip6-localhostinstead oflocalhost:This causes
getaddrinfo("localhost", AF_INET6)to returnEAI_NONAME.Fix
When the localhost fallback fails with
InterNetworkV6on Android, retry the resolution using"ip6-localhost"— Android's default hostname for the IPv6 loopback address.The fallback chain becomes:
getaddrinfo("test.localhost", AF_INET6)→ fails → existing subdomain fallbackgetaddrinfo("localhost", AF_INET6)→ fails on Android → new: Android IPv6 fallbackgetaddrinfo("ip6-localhost", AF_INET6)→ succeedsThis is applied to both the sync (
GetHostEntryOrAddressesCore) and async (GetAddrInfoWithTelemetryAsync) code paths.Testing
RespectsAddressFamilytest cases[ActiveIssue]annotations for DNS localhost subdomain tests with AddressFamily fail on Android #124751 are removed from both test methods