Narrow AddressFamily passed to getaddrinfo when IPv6 is unsupported#112642
Narrow AddressFamily passed to getaddrinfo when IPv6 is unsupported#112642antonfirsov merged 5 commits intodotnet:mainfrom
Conversation
There was a problem hiding this comment.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
src/libraries/System.Net.NameResolution/src/System/Net/Dns.cs:390
- The new method ValidateAddressFamily should be covered by tests to ensure its correctness.
private static bool ValidateAddressFamily(ref AddressFamily addressFamily, string hostName, bool justAddresses, [NotNullWhen(false)] out object? resultOnFailure)
MihaZupan
left a comment
There was a problem hiding this comment.
LGTM
In #107979 (comment) you've mentioned that we filter out such results after the query. Should we be able to remove that logic, or can the OS still return AAAA results for IPv4-only calls?
|
|
||
| private static bool ValidateAddressFamily(ref AddressFamily addressFamily, string hostName, bool justAddresses, [NotNullWhen(false)] out object? resultOnFailure) | ||
| { | ||
| if (!SocketProtocolSupportPal.OSSupportsIPv6) |
There was a problem hiding this comment.
should this be symmetric e.g. should we apply same logic to IPv4?
There was a problem hiding this comment.
Is OSSupportsIPv4 == false a practical real-life user scenario? I would be hesitant to add logic to handle it otherwise. It would be virtually untestable; we don't have a System.Net.DisableIPv4 switch, and I don't think it would make much sense to add one.
|
/azp run runtime-libraries-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
CI failures are unrelated |
When IPv6 is unsupported or disabled, we should avoid passing
AF_UNSPECto the platform calls since those will doAAAAresolve attempts which might result in failures surfacing to the user, see #107979. Instead, we can narrow down the query toAF_INETso failures are avoided.The change has been validated by packet captures on Windows and Linux. There are no
AAAAquestions whenSystem.Net.DisableIPv6is set totrue.Fixes #107979.