Skip to content

Mirrored networking blocks for minutes when the host route table is large (HNS re-enumerates the full table per route)Β #42348

Backlog

Description

@Lihewin

Windows Version

Microsoft Windows [Version 10.0.26300.9974]

WSL Version

3.0.5.0 (stock), also reproduced with a local 3.0.6.0 build from microsoft/WSL main

Are you using WSL 1, WSL 2, or WSLC?

WSL 2

Kernel Version

6.18.58.1-1

Distro Version

Ubuntu 26.04

Other Software

Host networking is HNS (hostnetsvc.dll 10.0.26100.9949, in-box Windows component). A third-party routing/VPN application installed ~25k static routes on one host adapter, all with Protocol = MIB_IPPROTO_NETMGMT.

Repro Steps

  1. On the host, have an adapter with a large static route table. In our environment one adapter had 25,409 static routes (9,858 IPv4 + 15,551 IPv6); the whole machine had 25,496 routes. Any routing/VPN application can create this, or use the synthetic route-generation script in the linked HNS issue.
  2. Set networkingMode=mirrored in %UserProfile%\.wslconfig.
  3. Run wsl --shutdown, then start a distro.
  4. Observe that startup takes minutes; while it is stuck, the guest only has lo (no eth, no routes, no /mnt/wsl/resolv.conf).
  5. Attach a debugger to wslservice.exe and dump all thread stacks while it is stuck.

Expected Behavior

Mirrored networking initializes in seconds and the guest receives the mirrored interfaces and routes. WSL startup and shutdown should not scale with the host route count.

Actual Behavior

  • Cold start: 536 s with 25,409 host routes vs 3.7 s with 8 routes.
  • wsl --shutdown: 477 s with 25,409 host routes vs 1.6 s with 8 routes.

While blocked, wslservice.exe is in:

wslservice!wsl::core::networking::WslMirroredNetworkManager::AddEndpointImpl
wslservice!wsl::core::networking::WslMirroredNetworkManager::AddEndpoint
wslservice!wsl::core::MirroredNetworking::AddNetworkEndpoint
  -> HcnModifyEndpoint
     RPCRT4!NdrClientCall3
     RPCRT4!LRPC_BASE_CCALL::SendReceive
     ntdll!NtAlpcSendWaitReceivePort

At the same moment, HNS is in:

hostnetsvc!HNS::Service::Network::MirroringCore::BootstrapNetworkRoute
hostnetsvc!HNS::Service::Common::Notify::GetStaticRoutes
hostnetsvc!HNS::Service::Common::Notify::GetRoute
IPHLPAPI!InternalGetIpForwardEntry2
NSI!NsiAllocateAndGetTable
ntdll!NtDeviceIoControlFile

GetStaticRoutes already has a full MIB_IPFORWARD_ROW2 snapshot, but calls GetRoute(&row, /*refresh=*/true) for every matching route; GetRoute then calls GetIpForwardEntry2, which re-enumerates the entire NSI route table. The cost is O(routes Γ— table size).

HNS also calls GetRoute from NotifyRouteChangeCallback for every route change. A 51-second ETW capture during the stall contained 2,186 NotifyRouteChangeCallback events (~43/s).

Because WSL holds m_networkLock while waiting for HcnModifyEndpoint, wsl --shutdown blocks on the same lock until HNS finishes.

Diagnostic Logs

Simultaneous WSL/HNS thread stacks, the 51 s ETW capture, and a read-only probe (GetIpForwardTable2 = 25,488 rows in 51–70 ms; 128 GetIpForwardEntry2 calls = 3.47–4.30 s; 0 snapshot mismatches) are available in the HNS issue: microsoft/Windows-Containers#671. I can attach the full dumps here as well.

Additional context

This is not a WSL-side logic bug: the per-route re-query is in hostnetsvc.dll, a Windows in-box component owned by the HNS team. Filing here to track the WSL-visible impact and to ask whether WSL can:

  1. avoid triggering a full HNS endpoint refresh on every route change while the host routing table is being populated (coalesce/debounce);
  2. avoid holding m_networkLock while waiting for HcnModifyEndpoint, so shutdown and unrelated operations are not blocked by an HNS refresh;
  3. coordinate with the HNS team on the fix tracked in [HNS] GetStaticRoutes re-queries the full NSI route table for every route (O(NΒ²)), causing multi-minute mirrored endpoint bootstrap on hosts with large route tablesΒ Windows-Containers#671.

A WSL-side batching change for SendRouteRequestToGns only shortens the later serial phase (WSL β†’ GNS β†’ guest). It cannot shorten the first phase, where WSL is blocked in HcnModifyEndpoint(Refresh) while HNS enumerates the table per route.

AI was used to help prepare this report.

Activity

  1. github-actions commented on Nov 24, 2026

    @github-actions
    Contributor

    Logs are required for review from WSL team

    If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
    Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

    How to collect WSL logs

    Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

    Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
    Set-ExecutionPolicy Bypass -Scope Process -Force
    .\collect-wsl-logs.ps1
    

    The script will output the path of the log file once done.

    If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

    Once completed please upload the output files to this GitHub issue.

    See Collect WSL logs (recommended method).

    If you choose to email these logs instead of attaching them to the bug, please send them to wsl-gh-logs@microsoft.com with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

  2. github-actions commented on Nov 24, 2026

    @github-actions
    Contributor

    No logs.etl found in the archive. Make sure that you ran collect-wsl-logs.ps1 as administrator and that the logs.etl file is in the archive.

    Diagnostic information
    appxpackage.txt not found
    optional-components.txt not found
    No logs.etl found in archive.
    Error while parsing the logs. See action page for details
    
  3. Lihewin commented on Nov 24, 2026

    @Lihewin
    Author

    wsl-42348-collector.zip

    Attached: wsl-42348-collector.zip (3.5 MB).

    This is based on the official collect-wsl-logs.ps1 -LogProfile networking run (started 22:26:03, Windows 10.0.26300.9974, WSL 3.0.5.0, 25,409 static host routes). At the "reproduce the problem" prompt I switched .wslconfig to networkingMode=mirrored, ran wsl --shutdown (1.8 s), then wsl -d Ubuntu-26.04 -- true, which returned after 519.6 s. The capture was stopped immediately afterwards.

    The archive contains:

    • collector text logs: Get-NetRoute before/after (25,503 lines each = 25,409 static routes + header), hns_events.log, hnsdiag, Get-NetAdapter, Get-NetIPConfiguration, wslservice.txt
    • wfpdiag.cab
    • a 51 s targeted WPR trace of the same stall (wsl-hns-long.etl + XML)
    • simultaneous wslservice/HNS thread stacks, GetStaticRoutes disassembly, and the read-only route probe
    • a README with the details

    Two caveats, both documented in the README:

    1. The collector's own WPR trace (logs.etl, WSL-Networking profile) grew to 74.1 GiB during the 519.6 s stall. Compressing and attaching it was not practical.
    2. The collector's post-repro Linux state was not captured because it passed a Windows-relative path (WslLogs-.../networking.sh) to wsl.exe, which failed with execvpe(...): No such file or directory.

    Because the original files were too large and the collection was abnormal, AI was used to trim and modify the archive to preserve the core parts. If you need a specific time slice of the 74 GB trace (e.g. the first 60 s of the mirrored start), I can provide it through a file share.

    Cross-reference: microsoft/Windows-Containers#671

  4. github-actions commented on Nov 24, 2026

    @github-actions
    Contributor

    No logs.etl found in the archive. Make sure that you ran collect-wsl-logs.ps1 as administrator and that the logs.etl file is in the archive.

    Diagnostic information
    appxpackage.txt not found
    optional-components.txt not found
    No logs.etl found in archive.
    Error while parsing the logs. See action page for details
    
  5. Lihewin commented on Nov 24, 2026

    @Lihewin
    Author
  6. github-actions commented on Nov 24, 2026

    @github-actions
    Contributor
    Diagnostic information
    Detected appx version: 3.0.5.0
    
  7. added
    wsl2
    on Nov 24, 2026
  8. chemwolf6922 commented on Nov 25, 2026

    @chemwolf6922
    Contributor

    Hi Lihewin .
    Thanks for reporting this. I have forwarded this issue to the network team internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    networkwsl2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions