Fix wslc network create default driver handling when --driver is not specified (#40827)
beena352 committed
Jun 18, 2026 at 15:57 UTC
5c01371dc05dceca8ea4c8ff0b8eff03e8d9c866
4 files changed
+25
-6
src/windows/service/inc/wslc.idl
+1
-1
@@ -508,7 +508,7 @@ typedef struct _WSLCVolumeInformation
508
typedef struct _WSLCNetworkOptions
509
{
510
LPCSTR Name;
511
- LPCSTR Driver;
511
+ [unique] LPCSTR Driver;
512
[unique, size_is(DriverOptsCount)] const WSLCDriverOption* DriverOpts;
513
ULONG DriverOptsCount;
514
[unique, size_is(LabelsCount)] const WSLCLabel* Labels;
src/windows/wslcsession/WSLCSession.cpp
+1
-2
@@ -2362,10 +2362,9 @@ try
2362
2363
RETURN_HR_IF_NULL(E_POINTER, Options);
2364
RETURN_HR_IF_NULL(E_POINTER, Options->Name);
2365
- RETURN_HR_IF_NULL(E_POINTER, Options->Driver);
2365
2366
std::string name = Options->Name;
2368
- std::string driver = Options->Driver;
2367
+ std::string driver = (Options->Driver != nullptr) ? Options->Driver : WSLCBridgeNetworkDriver;
2368
2369
ValidateName(name.c_str(), WSLC_MAX_NETWORK_NAME_LENGTH);
2370
test/windows/WSLCTests.cpp
+23
@@ -5093,6 +5093,29 @@ class WSLCTests
5093
}
5094
}
5095
5096
+ WSLC_TEST_METHOD(NetworkCreateDefaultDriverTest)
5097
+ {
5098
+ const std::string networkName = "default-driver-net";
5099
+
5100
+ LOG_IF_FAILED(m_defaultSession->DeleteNetwork(networkName.c_str()));
5101
+
5102
+ WSLCNetworkOptions options{};
5103
+ options.Name = networkName.c_str();
5104
+ options.Driver = nullptr;
5105
+ options.DriverOpts = nullptr;
5106
+ options.DriverOptsCount = 0;
5107
+
5108
+ auto cleanup = wil::scope_exit([&]() { LOG_IF_FAILED(m_defaultSession->DeleteNetwork(networkName.c_str())); });
5109
+
5110
+ VERIFY_SUCCEEDED(m_defaultSession->CreateNetwork(&options, nullptr));
5111
+
5112
+ wil::unique_cotaskmem_array_ptr<WSLCNetworkInformation> networks;
5113
+ VERIFY_SUCCEEDED(m_defaultSession->ListNetworks(networks.addressof(), networks.size_address<ULONG>()));
5114
+ VERIFY_ARE_EQUAL(1u, networks.size());
5115
+ VERIFY_ARE_EQUAL(networkName, std::string(networks[0].Name));
5116
+ VERIFY_ARE_EQUAL(std::string("bridge"), std::string(networks[0].Driver));
5117
+ }
5118
+
5119
WSLC_TEST_METHOD(NetworkCreateReservedNameTest)
5120
{
5121
WSLCNetworkOptions options{};
test/windows/wslc/e2e/WSLCE2ENetworkCreateTests.cpp
-3
@@ -49,9 +49,6 @@ class WSLCE2ENetworkCreateTests
49
50
WSLC_TEST_METHOD(WSLCE2E_Network_Create_DefaultDriver_Success)
51
{
52
- // TODO: http://task.ms/62564313
53
- SKIP_TEST_UNSTABLE();
54
-
52
auto result = RunWslc(std::format(L"network create {}", TestNetworkName));
53
result.Verify({.Stderr = L"", .ExitCode = 0});
54
VERIFY_ARE_EQUAL(TestNetworkName, result.GetStdoutOneLine());