[Android] Fix DNS localhost subdomain resolution with IPv6 on Android#125478
Open
simonrozsival wants to merge 2 commits intodotnet:mainfrom
Open
[Android] Fix DNS localhost subdomain resolution with IPv6 on Android#125478simonrozsival wants to merge 2 commits intodotnet:mainfrom
simonrozsival wants to merge 2 commits intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
Contributor
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".
Fixes dotnet#124751
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
6816840 to
6fdaf5c
Compare
Member
Author
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was referenced Mar 12, 2026
Open
wfurt
reviewed
Mar 12, 2026
This was referenced Mar 12, 2026
This was referenced Mar 12, 2026
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>
Member
Author
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was referenced Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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