Skip to content

Fix mirrored networking loopback endpoint creation failure - Updated#40886

Open
OwenJRJones wants to merge 10 commits into
microsoft:masterfrom
OwenJRJones:fix-pr-14081
Open

Fix mirrored networking loopback endpoint creation failure - Updated#40886
OwenJRJones wants to merge 10 commits into
microsoft:masterfrom
OwenJRJones:fix-pr-14081

Conversation

@OwenJRJones

Copy link
Copy Markdown

Summary of the Pull Request

Fix loopback endpoint creation failure in mirrored networking mode after KB5074109. - Courtesy of @benm-dev (see #14081)
Fixed formatting issue in hns_schema.h that was preventing CI from passing - @OwenJRJones

PR Checklist

Detailed Description

After KB5074109, HNS loopback networks reject firewall policies when creating endpoints, returning error 0x803B001B. This fix detects loopback networks via IsLoopback property and uses simplified endpoint settings without policies.

Validation Steps Performed

  1. Direct HCN API testing confirmed:
    • Endpoint WITH firewall policy → 0x803B001B (FAIL)
    • Endpoint with HostComputeNetwork only → 0x00000000 (SUCCESS)
  2. WSL localhost TCP connectivity verified working with correct endpoint settings
  3. Tested on Windows Build 26220.7535

benm-dev and others added 9 commits March 27, 2026 12:35
## Problem
After installing KB5074109 (January 2026), WSL mirrored networking fails to
create the loopback endpoint, causing localhost (127.0.0.1) TCP/UDP connections
to fail. Users see the loopback0 interface in state DOWN with NO-CARRIER.

## Root Cause Analysis
HNS loopback networks no longer accept firewall policies when creating
endpoints. Direct HCN API testing confirms:

- Test 1: Endpoint WITH firewall policy -> 0x803B001B (FAIL)
  Error: 'Invalid JSON document string. {{Policies.VmCreatorId,UnknownField}}'

- Test 2: Endpoint with VirtualNetwork field -> 0x803B001B (FAIL)
  Error: 'Invalid JSON document string. {{VirtualNetwork,UnknownField}}'

- Test 3: Endpoint with HostComputeNetwork only -> 0x00000000 (SUCCESS)

The current code in MirroredNetworking::AddNetworkEndpoint() creates all
endpoints with firewall policies when m_config.FirewallConfig.Enabled() is
true (the default), causing loopback endpoint creation to fail silently.

## Solution
- Add IsLoopback field to HNSNetwork struct to detect loopback networks
- Skip firewall policies when creating endpoints on loopback networks
- Use HostComputeNetwork instead of VirtualNetwork for loopback endpoints

## Testing
Verified on Windows Build 26220.7535:
1. HCN API tests confirm endpoint creation succeeds without firewall policies
2. WSL localhost TCP connectivity works when loopback0 is properly configured

Fixes microsoft#14080
Related: microsoft#14063
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 23, 2026 21:33
@OwenJRJones OwenJRJones requested a review from a team as a code owner June 23, 2026 21:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes mirrored networking endpoint creation failures on loopback networks after KB5074109 by detecting loopback networks via IsLoopback and avoiding endpoint policies that HCN rejects in that scenario.

Changes:

  • Detect loopback HNS networks and create endpoints using simplified settings (no policies) while targeting HostComputeNetwork.
  • Extend the HNS network JSON schema model to parse the IsLoopback property.
  • Reformat the HNSNetwork JSON macro usage in hns_schema.h (to satisfy CI/style constraints).

Reviewed changes

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

File Description
src/windows/service/exe/MirroredNetworking.cpp Adds a loopback-network code path to avoid unsupported endpoint policy creation and use simplified endpoint settings.
src/shared/inc/hns_schema.h Adds IsLoopback to the HNSNetwork schema and updates the JSON mapping formatting.

@benhillis

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

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.

4 participants