Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/shared/inc/hns_schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,10 @@ struct HNSNetwork
std::vector<Subnet> Subnets;
NetworkFlags Flags{};
InterfaceConstraint InterfaceConstraint{};
bool IsLoopback{};

NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(HNSNetwork, ID, Name, SourceMac, DNSSuffix, DNSServerList, DNSDomain, Subnets, Flags, InterfaceConstraint);
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(
HNSNetwork, ID, Name, SourceMac, DNSSuffix, DNSServerList, DNSDomain, Subnets, Flags, InterfaceConstraint, IsLoopback);
};

enum class NetworkMode
Expand Down
21 changes: 20 additions & 1 deletion src/windows/service/exe/MirroredNetworking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,26 @@ void MirroredNetworking::AddNetworkEndpoint(const GUID& NetworkId) noexcept
endpointInfo.NetworkId = NetworkId;
endpointInfo.EndpointId = endpointId;

if (m_config.FirewallConfig.Enabled())
// Loopback networks don't support firewall policies - creating an endpoint with firewall
// policies on a loopback network will fail with HCN error 0x803B001B ("Invalid JSON document
// string"). This behavior changed in KB5074109. Additionally, loopback networks require
// HostComputeNetwork instead of VirtualNetwork in the endpoint settings.
// See: https://github.com/microsoft/WSL/issues/14080
const bool isLoopbackNetwork = properties.IsLoopback;

if (isLoopbackNetwork)
{
WSL_LOG(
"MirroredNetworking::AddNetworkEndpoint [Loopback network - using simplified endpoint settings]",
TraceLoggingValue(NetworkId, "networkId"));
// Loopback networks require HostComputeNetwork (not VirtualNetwork) and don't support policies
hns::HostComputeEndpoint hnsEndpoint{};
hnsEndpoint.HostComputeNetwork = NetworkId;
hnsEndpoint.SchemaVersion.Major = 2;
hnsEndpoint.SchemaVersion.Minor = 16;
endpointSettings = ToJsonW(hnsEndpoint);
}
else if (m_config.FirewallConfig.Enabled())
{
// Create HNS firewall policy object for the endpoint
hns::HostComputeEndpoint hnsEndpoint{};
Expand Down
Loading