[DO NOT MERGE] Network refactor#40628
Closed
kvega005 wants to merge 3 commits into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors WSLC container networking from an enum-based model to a string-based NetworkMode model (e.g., "bridge", "host", "none", "container:<name>") and introduces a new WSLCNetworkConnection struct for representing additional network connections/endpoints.
Changes:
- Replace
WSLCContainerNetworkTypeusage withNetworkModestrings across container creation, launcher helpers, and tests. - Rework container creation networking logic to resolve network modes, validate endpoint combinations, and build endpoint configs/port mappings accordingly.
- Update SDK and service call sites to pass the new network mode representation, plus update a user-facing localization string.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/windows/WSLCTests.cpp | Updates test coverage to use network mode strings and new network/error behavior. |
| src/windows/wslcsession/WSLCContainer.h | Updates container implementation state to store network mode as a string. |
| src/windows/wslcsession/WSLCContainer.cpp | Implements network-mode resolution, endpoint validation, and updated port-mapping behavior. |
| src/windows/WslcSDK/WslcsdkPrivate.h | Changes SDK internal container settings representation for networking. |
| src/windows/WslcSDK/wslcsdk.cpp | Updates SDK conversions/defaults and maps SDK settings into runtime WSLCContainerOptions. |
| src/windows/wslc/services/ContainerService.cpp | Updates service container creation to pass "bridge" as the default network mode string. |
| src/windows/service/inc/wslc.idl | Replaces the container network enum/attachment model with NetworkMode + WSLCNetworkConnection[]. |
| src/windows/common/WSLCContainerLauncher.h | Updates launcher API/storage to take and store network mode as a string. |
| src/windows/common/WSLCContainerLauncher.cpp | Marshals network mode and additional network connections into WSLCContainerOptions. |
| localization/strings/en-US/Resources.resw | Replaces an error string with a new “exclusive network must be alone” message. |
Comment on lines
6043
to
6049
| WSLCContainerOptions options{}; | ||
| options.Image = "debian:latest"; | ||
| options.Name = "test-custom-network-empty"; | ||
| options.InitProcessOptions.CommandLine = {.Values = args, .Count = ARRAYSIZE(args)}; | ||
| options.ContainerNetwork.ContainerNetworkType = WSLCContainerNetworkTypeCustom; | ||
| WSLCNetworkAttachment emptyNet{}; | ||
| emptyNet.NetworkName = ""; | ||
| options.ContainerNetwork.Networks = &emptyNet; | ||
| options.ContainerNetwork.Networks = &emptyName; | ||
| options.ContainerNetwork.NetworksCount = 1; | ||
|
|
| uint32_t namedVolumesCount; | ||
| const WslcContainerProcessOptionsInternal* initProcessOptions; | ||
| WSLCContainerNetworkType networking; | ||
| std::string networking; |
Comment on lines
636
to
647
| STDAPI WslcInitContainerSettings(_In_ PCSTR imageName, _Out_ WslcContainerSettings* containerSettings) | ||
| try | ||
| { | ||
| auto internalType = CheckAndGetInternalType(containerSettings); | ||
| RETURN_HR_IF_NULL(E_POINTER, imageName); | ||
|
|
||
| *internalType = {}; | ||
|
|
||
| internalType->image = imageName; | ||
| // Default network configuration to WSLC SDK `0`, which is NONE. | ||
| internalType->networking = WSLCContainerNetworkTypeNone; | ||
| internalType->networking = "none"; | ||
|
|
Comment on lines
+258
to
272
| typedef struct _WSLCNetworkConnection | ||
| { | ||
| WSLCContainerNetworkTypeNone = 0, | ||
| WSLCContainerNetworkTypeHost = 1, | ||
| WSLCContainerNetworkTypeBridged = 2, | ||
| WSLCContainerNetworkTypeCustom = 3 | ||
| } WSLCContainerNetworkType; | ||
| [string] LPCSTR NetworkName; | ||
|
|
||
| typedef struct _WSLCNetworkAttachment | ||
| { | ||
| [unique] LPCSTR NetworkName; | ||
| [unique] LPCSTR ContainerIpAddress; // Reserved for future --ip support; must be NULL today. | ||
| } WSLCNetworkAttachment; | ||
| [unique, size_is(SettingsCount)] const KeyValuePair* Settings; | ||
| ULONG SettingsCount; | ||
| } WSLCNetworkConnection; | ||
|
|
||
| typedef struct _WSLCContainerNetwork | ||
| { | ||
| WSLCContainerNetworkType ContainerNetworkType; | ||
| [unique, size_is(NetworksCount)] const WSLCNetworkAttachment* Networks; | ||
| [unique, string] LPCSTR NetworkMode; | ||
|
|
||
| [unique, size_is(NetworksCount)] const WSLCNetworkConnection* Networks; | ||
| ULONG NetworksCount; | ||
| } WSLCContainerNetwork; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed