Skip to content

DNS: Simplify dns logic and switch to using 'search' instead of 'domain' which is obsolete.#14133

Merged
benhillis merged 4 commits intomasterfrom
user/benhill/dns_refactoring
Feb 3, 2026
Merged

DNS: Simplify dns logic and switch to using 'search' instead of 'domain' which is obsolete.#14133
benhillis merged 4 commits intomasterfrom
user/benhill/dns_refactoring

Conversation

@benhillis
Copy link
Copy Markdown
Member

This PR refactors HostDnsInfo to make GetDnsSettings a static method, removing unnecessary state (cached adapter addresses, mutex, UpdateNetworkInformation(), and the DnsUpdateHelper class) since the cache was being populated and immediately consumed without reuse. It also standardizes on the search directive for DNS suffixes instead of the obsolete domain directive, per resolv.conf(5).

Additionally the option to supply a header for /etc/resolv.conf was added to virtioproxy and NAT networking modes.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the DNS configuration logic in WSL to simplify the codebase and adopt modern DNS resolver configuration standards. The main changes eliminate unnecessary caching in HostDnsInfo and standardize on the 'search' directive instead of the obsolete 'domain' directive for DNS suffixes.

Changes:

  • Converted HostDnsInfo::GetDnsSettings and related methods to static functions, removing instance state (cached adapter addresses, mutex, UpdateNetworkInformation method, and DnsUpdateHelper class)
  • Switched from using the obsolete 'domain' directive to the standard 'search' directive for DNS suffixes in resolv.conf, consistent with resolv.conf(5) specification
  • Added support for configurable resolv.conf header options in VirtioProxy and NAT networking modes

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/windows/NetworkTests.cpp Updated test expectations to remove 'domain' directive and verify 'search' directive only
src/windows/service/exe/WslMirroredNetworking.h Removed m_hostDnsInfo member variable (no longer needed with static methods)
src/windows/service/exe/WslMirroredNetworking.cpp Updated to call static HostDnsInfo::GetDnsSettings instead of instance method
src/windows/service/exe/WslCoreVm.cpp Added LX_INIT_RESOLVCONF_FULL_HEADER parameter when creating VirtioNetworking
src/windows/service/exe/LxssInstance.h Removed m_dnsInfo member variable (no longer needed)
src/windows/service/exe/LxssInstance.cpp Removed UpdateNetworkInformation call and updated to use static GetDnsSettings
src/windows/common/WslCoreHostDnsInfo.h Made GetDnsSettings static, removed mutex and cached addresses, removed DnsUpdateHelper class, updated BuildDnsNotification signature
src/windows/common/WslCoreHostDnsInfo.cpp Removed caching logic, updated BuildDnsNotification to only use 'search' directive with explanatory comments
src/windows/common/VirtioNetworking.h Added m_dnsOptions parameter and removed m_dnsUpdateHelper member
src/windows/common/VirtioNetworking.cpp Updated constructor to accept dnsOptions, replaced DnsUpdateHelper with static HostDnsInfo calls
src/windows/common/NatNetworking.h Added dnsOptions parameter, replaced m_mirrorDnsInfo with m_useMirrorDnsSettings flag and m_dnsOptions
src/windows/common/NatNetworking.cpp Simplified DNS update logic to use static methods, removed 'domain' directive handling and logging
src/linux/init/GnsEngine.cpp Removed 'domain' directive processing, added documentation comments about using 'search' instead

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.


VirtioNetworking::VirtioNetworking(
GnsChannel&& gnsChannel, bool enableLocalhostRelay, std::shared_ptr<GuestDeviceManager> guestDeviceManager, wil::shared_handle userToken) :
GnsChannel&& gnsChannel, bool enableLocalhostRelay, LPCWSTR dnsOptions, std::shared_ptr<GuestDeviceManager> guestDeviceManager, wil::shared_handle userToken) :
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OneBlue - I'm open to other options, but basically I just don't want the WSL header in /etc/resolv.conf when we are running WSLA.

@benhillis benhillis merged commit 8aadbb4 into master Feb 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants