* wip
* works
* edit comments
* add test
* use unique_handle
* fix lookup to be efficient
* simplify ListAllocatedPorts
* remove include
* edits
* pass networking mode to port tracker
* add keepalive
* add bound check after parsing
* default to none before parsing
* exit early on invalid mode
---------
Co-authored-by: Catalin-Emil Fetoiu <cfetoiu@microsoft.com>
* Remove DnsTunnelingSocket flag from VirtioNetworking
Drops the DnsTunnelingSocket virtio networking flag (and the dedicated DNS
hvsocket plumbing it carried) in favor of the in-built DnsTunneling path.
In virtio proxy mode, DNS queries are now always forwarded by the host
virtio proxy itself: Linux's /etc/resolv.conf points at the eth0 gateway IP
rather than the listener IP, no DNS hvsocket is opened, and the Linux init
does not start a DnsTunnelingManager.
Changes:
- VirtioNetworking: remove DnsTunnelingSocket enum value, dnsHvsocket
constructor parameter, m_dnsTunnelingResolver field, and the
DnsResolver.h include. RefreshGuestConnection now uses only the
in-built DnsTunneling path.
- WslCoreVm: virtio proxy branch unconditionally sets the DnsTunneling
flag when DNS tunneling is enabled. message->EnableDnsTunneling is
suppressed for virtio proxy mode so Linux init won't open the DNS
hvsocket. The pre-accepted dnsTunnelingSocket is dropped on the
NAT->VirtioProxy fallback path.
- HcsVirtualMachine: WSLC virtio proxy branch likewise switches to the
DnsTunneling flag and discards the unused dnsSocketHandle.
- Tests: add VirtioProxyTests::DnsTunnelingResolvConfUsesGateway which
asserts resolv.conf contains the gateway IP and not the legacy
listener IP, confirming the in-built path is in use.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Validate DNS hvsocket before DnsResolver support check
Reorder ConfigureNetworking so the caller-provided DnsSocket is validated against the requested feature flag before the LoadDnsResolverMethods call may clear it. Avoids E_INVALIDARG in NAT mode when the support check fails.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Format VirtioNetworking constructor parameter list
Wrap the constructor declaration/definition parameter list per the repo's
BinPackParameters: false / 130-column style.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Revert manual wrapping; clang-format prefers single-line constructor
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* VirtioProxy: rely on wsldevicehost default MAC addresses and fix DNS tunneling assert
Setting MAC addresses through the virtio-proxy guest connection options has
proven problematic, so stop forwarding client_mac, gateway_mac, and
gateway_mac_ipv6 from VirtioNetworking::RefreshGuestConnection() and let
wsldevicehost fall back to its default values.
Also extend the WI_ASSERT in WslCoreVm::IsDnsTunnelingSupported() to accept
NetworkingMode::VirtioProxy. The VirtioProxy case was missed when the wslc
feature branch was merged into main, causing the assert to fire in debug
builds when DNS tunneling support is queried under that mode.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Remove dead NetworkSettings::GetBestGatewayMacAddress
The previous commit dropped the only callers of GetBestGatewayMacAddress
when virtio-proxy stopped pushing MAC addresses to wsldevicehost. Remove
the now-unused declaration and definition.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* add unit test
---------
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Make port 0 resolution inline
* reduce retry delay to 10ms
* add e2e test
* resolve comments
* resolve comments
* [wip] add test debug info
* copy the new binary to test stage
* switch to using inline perl sript instead of linux binary
---------
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
* Fallback to NAT when IPv6 is disabled via registry for mirrored networking
When the registry key HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters
has DisabledComponents set to 0xFF (all IPv6 components disabled), mirrored
networking mode cannot mirror host interfaces. This adds a check in
ValidateNetworkingMode() that detects this condition and falls back to NAT
networking mode with a user-facing warning.
Only mirrored networking mode is affected by this registry key; other
networking modes (NAT, Bridged, VirtioProxy) are not checked.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* add registry check
* pr review
* remove shutdown
* re-add shutdown
---------
Co-authored-by: Catalin-Emil Fetoiu <cfetoiu@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* route fixes from protonvpn testing
* add unit test, fix log
* ai code review
* format with vs 2022
* review
* remove optional has_value checks
* harden contracts for to, via having or not having values
* update IsOnlink check
* fix constructor parameters
* fix build
---------
Co-authored-by: Catalin-Emil Fetoiu <cfetoiu@microsoft.com>
Cherry-pick WSL1/WSL2 test changes from 9c4dba91 (feature/wsl-for-apps).
Replace runtime WSL1_TEST_ONLY()/WSL2_TEST_ONLY() skip macros with
WSL1_TEST_METHOD()/WSL2_TEST_METHOD() TAEF metadata macros. This moves
version filtering to the test runner level via /select: queries, so
inapplicable tests are excluded entirely instead of appearing as skipped.
Updated files:
- test/windows/Common.h: New macros + removed old skip macros
- test/windows/*.cpp: Converted all test methods
- tools/test/run-tests.ps1: Auto-add /select: when no user filter
- cloudtest/TestGroup.xml.in: Add version filter to TAEF args
- test/README.md: Document new macros
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Allow VirtioProxy to keep EnableDnsTunneling=true in config, but clear
socket-specific options (BestEffortDnsParsing, DnsTunnelingIpAddress)
- Suppress dedicated DNS tunneling hvsocket for VirtioProxy; tunneling
is handled through the VirtioNetworking device host instead
- Set DnsTunneling flag on VirtioNetworkingFlags so the device host
knows to tunnel DNS
- Expand SWIOTLB kernel cmdline to cover VirtioFs and VirtioProxy
- Bump DeviceHost package to 1.1.39-0
- Add VirtioProxy DNS test coverage for tunneling on/off
- Skip GuestPortIsReleasedV6 on Windows 10
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
* Initial work
* .
* pr feedback and add unit test
* minor tweaks an fix use after free in logging statement
* implement PR feedback
* hopefully final pr feedback
* pr feedback in test function
* Address PR feedback: add try/catch to TrackPort and PortZeroBind queue push
---------
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
* VirtioProxy: Add IPv6 address, gateway, and route support
- Add PreferredIpv6Address field and GetBestGatewayV6* methods to NetworkSettings
- Extend GetHostEndpointSettings() to discover IPv6 unicast address and gateway
- Add UpdateIpv6Address() using ModifyGuestEndpointSettingRequest<IPAddress>
- Push IPv6 default route to guest via UpdateDefaultRoute(AF_INET6)
- Remove AF_INET6 early return in ModifyOpenPorts, use INETADDR_PORT()
- Add EndpointRoute::DefaultRoute() static factory
- Pass client_ip_ipv6 in devicehost options (not yet parsed by devicehost)
- Remove gateway_ip from devicehost options (only needed for DHCP)
- Include IPv6 DNS servers in non-tunneling DNS settings
- Add ConfigurationV6 and DnsResolutionAAAA tests
* cleanup and add more ipv6 tests
* added test coverage and minor updates
* clang format
* pr feedback
* format source
* pr feedback
* test fixes
---------
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
* DNS: Simplify dns logic and switch to using 'search' instead of 'domain'
which is obsolete.
* add optional header for natnetworking
* format
* extend configuration test for virtioproxy networking mode
---------
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
* TEST: Add testcases to validated bridged networking connectivity
* minor bridged test updates
---------
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
* test: extend coverage of virtioproxy networking mode
* test: add dns test variations to all networking classes
* remove bridged dns variations
* pr feedback
---------
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
* Clean up localhost relay implementation to not rely on procfs parsing.
* pr feedback
---------
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
* test: add simple virtio proxy networking tests
* move mirrored tests to their own class
* fix failing mirrored variation
* use different port for HostUdpBindDoesNotPreventGuestTcpBind
---------
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Many Microsoft employees have contributed to the Windows Subsystem for Linux, this commit is the result of their work since 2016.
The entire history of the Windows Subsystem for Linux can't be shared here, but here's an overview of WSL's history after it moved to it own repository in 2021:
Number of commits on the main branch: 2930
Number of contributors: 31
Head over https://github.com/microsoft/WSL/releases for a more detailed history of the features added to WSL since 2021.