Skip to content

Add --ip, --link, --link-local-ip, --driver-opt, --network-alias flag…#41070

Open
beena352 wants to merge 10 commits into
masterfrom
user/beenachauhan/network-connect-endpoint-settings
Open

Add --ip, --link, --link-local-ip, --driver-opt, --network-alias flag…#41070
beena352 wants to merge 10 commits into
masterfrom
user/beenachauhan/network-connect-endpoint-settings

Conversation

@beena352

@beena352 beena352 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Adds endpoint configuration flags to wslc network connect and fixes the connect/disconnect mode gate to reject container:* in addition to host and none.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

New flags on wslc network connect

--network-alias, --ip, --link, --link-local-ip, --driver-opt. All flags are repeatable except --ip (one static IP per network). Validation includes: unknown setting key rejection, malformed IP rejection, empty alias/link rejection, malformed/blank/duplicate driver-opt rejection. Empty driver-opt values (key=) are accepted intentionally to match Docker CLI behavior.

The create path (wslc container create --endpoint-settings) also picks up the same parser, so IPAddress, Links, LinkLocalIPs, and DriverOpts now flow through to the Docker create request for the primary network (previously only Aliases was forwarded).

Bug fix: container:* mode gate

Previously the connect/disconnect gate only checked for "host" and "none" modes. Containers using container:<name> (shared network namespace) were incorrectly allowed through. Now uses NetworkModeAllocatesVmPorts() which covers all three cases. Added new localized error message MessageWslcNetworkModeNoAdditionalNetworks.

Test changes

  • Replaced stale NetworkAliasCreateTest block (expected E_NOTIMPL for IPAddress) with BogusKey / E_INVALIDARG unknown-key test.
  • Added positive create-path roundtrip tests: combo (Aliases + IPAddress + LinkLocalIPs + DriverOpts) and Links (2 containers on user-defined bridge).
  • Added container:<name> mode rejection test (substring match - mode resolves to container ID internally).
  • Added connect-while-stopped positive test (Docker allows attach in exited state).
  • Added driver-opt edge-case tests: key=value=extra preserves everything after first =; key= (empty value) accepted per Docker CLI parity.
  • Fixed E2E WSLCE2E_Network_Connect_NoneMode_Rejected pattern to match new error message.
  • Added E2E tests for --driver-opt and --link flag roundtrips via wslc network connect + inspect.

Validation Steps Performed

  1. Built and ran all WSLCTests::NetworkAliasCreateTest sub-blocks - unknown key rejection, positive combo roundtrip, and Links roundtrip all pass.
  2. Built and ran WSLCTests::ContainerNetworkEndpointSettingsUnknownKeyTest and NetworkConnectEndpointSettingsTest - all sub-blocks pass.
  3. Built and ran E2E tests: WSLCE2E_Network_Connect_DriverOpt_RoundTrips, WSLCE2E_Network_Connect_Link_RoundTrips.
  4. Verified wslc network connect --help renders all new flags with correct padding and descriptions.

Copilot AI review requested due to automatic review settings July 13, 2026 20:53

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

This PR extends wslc network connect to accept additional Docker EndpointConfig-style settings at connect time (--network-alias, --ip, --link, --link-local-ip, --driver-opt) and fixes container-create forwarding so primary endpoint settings (beyond Aliases) are no longer parsed-but-dropped.

Changes:

  • Add endpoint-settings parsing/validation (Aliases, IPAddress, Links, LinkLocalIPs, DriverOpts) and forward the full EndpointConfig in both create and connect flows.
  • Extend the CLI surface + plumbing (ArgumentDefinitionsNetworkConnectCommandNetworkTasksNetworkService) to emit KVP settings into ConnectToNetwork.
  • Update/expand unit + e2e tests to cover new flags, validation, and inspect round-trips.

Reviewed changes

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

Show a summary per file
File Description
test/windows/WSLCTests.cpp Updates/extends unit tests for endpoint settings at create/connect time.
test/windows/wslc/e2e/WSLCE2ENetworkTests.cpp Adds e2e coverage for new network connect flags and help output.
src/windows/wslcsession/WSLCContainer.cpp Implements unified endpoint-settings parsing + forwards full EndpointConfig.
src/windows/wslc/tasks/NetworkTasks.cpp Collects new CLI args into a ConnectNetworkOptions model.
src/windows/wslc/services/NetworkService.h Updates Connect API to take ConnectNetworkOptions.
src/windows/wslc/services/NetworkService.cpp Builds KVP settings and calls ConnectToNetwork with settings payload.
src/windows/wslc/services/NetworkModel.h Introduces ConnectNetworkOptions.
src/windows/wslc/commands/NetworkConnectCommand.cpp Registers new repeatable/non-repeatable connect flags.
src/windows/wslc/arguments/ArgumentDefinitions.h Defines new CLI arguments (driver-opt, ip, link, link-local-ip).
src/windows/service/inc/wslc.idl Changes WSLCNetworkConnectionOptions to carry Settings KVPs.
src/windows/inc/wslc_schema.h Extends inspect schema to include Links, DriverOpts, IPAMConfig.
src/windows/inc/docker_schema.h Extends Docker request/inspect schema to include full EndpointConfig.
localization/strings/en-US/Resources.resw Adds new user-facing/localizable strings for endpoint settings + flags.
localization/strings/en-GB/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/zh-TW/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/zh-CN/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/tr-TR/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/sv-SE/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/ru-RU/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/pt-PT/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/pt-BR/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/pl-PL/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/nl-NL/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/nb-NO/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/ko-KR/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/ja-JP/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/it-IT/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/hu-HU/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/fr-FR/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/fi-FI/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/es-ES/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/de-DE/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/da-DK/Resources.resw Updates locale resource strings (see review comments re: locale policy).
localization/strings/cs-CZ/Resources.resw Updates locale resource strings (see review comments re: locale policy).

Comment thread localization/strings/zh-CN/Resources.resw Outdated
Comment thread localization/strings/en-GB/Resources.resw Outdated
Copilot AI review requested due to automatic review settings July 14, 2026 22:03

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

Copilot reviewed 34 out of 34 changed files in this pull request and generated 3 comments.

Comment thread localization/strings/en-GB/Resources.resw Outdated
Comment thread localization/strings/fr-FR/Resources.resw Outdated
Comment thread test/windows/wslc/e2e/WSLCE2ENetworkTests.cpp Outdated
Copilot AI review requested due to automatic review settings July 14, 2026 22:51

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

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

Comments suppressed due to low confidence (2)

localization/strings/fr-FR/Resources.resw:2390

  • This PR modifies a non-en-US localized Resources.resw file and adds/changes string values in English. Per CONTRIBUTING.md ("Localization and translation issues"), per-locale localization/strings/<locale>/Resources.resw files are generated downstream and translation edits in PRs here are overwritten and cannot be merged; only localization/strings/en-US/Resources.resw should be updated in this repo (unless this is an automated localization-service PR). Please revert the changes in this file (and other non-en-US locales touched by this PR) and keep only the en-US updates.
  <data name="MessageWslcEndpointSettingsNotSupported" xml:space="preserve">
    <value>Les paramètres de point de terminaison ne sont pas encore pris en charge (réseau « {} »).</value>
    <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
  </data>
  <data name="MessageWslcAliasEmpty" xml:space="preserve">
    <value>L’alias réseau ne peut pas être vide.</value>
  </data>
  <data name="MessageWslcAliasRequiresUserDefinedNetwork" xml:space="preserve">
    <value>Les alias réseau nécessitent un réseau défini par l’utilisateur. Utilisez --network pour en spécifier un.</value>

localization/strings/zh-TW/Resources.resw:3003

  • This non-en-US localized Resources.resw file has been edited to add/replace string values with English (e.g., WSLCCLI_NetworkAliasArgDescription, WSLCCLI_IpAddressArgDescription, etc.). CONTRIBUTING.md states these per-locale files are generated downstream and PR translation edits here cannot be merged; only localization/strings/en-US/Resources.resw should be updated (unless this is an automated localization-service PR). Please revert the changes in this locale file.
    <value>顯示此工具的版本資訊</value>
  </data>
  <data name="WSLCCLI_VolumeArgDescription" xml:space="preserve">
    <value>將磁碟區繫結掛接至容器</value>
  </data>
  <data name="WSLCCLI_VolumeForceArgDescription" xml:space="preserve">
    <value>如果此磁碟區不存在,請勿顯示錯誤</value>
  </data>
  <data name="WSLCCLI_WorkingDirArgDescription" xml:space="preserve">
    <value>容器內的工作目錄</value>

Copilot AI review requested due to automatic review settings July 14, 2026 22:55

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

Copilot reviewed 34 out of 34 changed files in this pull request and generated 4 comments.

Comment thread src/windows/wslcsession/WSLCContainer.cpp
Comment thread src/windows/wslcsession/WSLCContainer.cpp
Comment thread test/windows/wslc/e2e/WSLCE2ENetworkTests.cpp Outdated
Comment thread localization/strings/fr-FR/Resources.resw
@beena352
beena352 force-pushed the user/beenachauhan/network-connect-endpoint-settings branch from 1c44677 to dba9f54 Compare July 14, 2026 23:04
Copilot AI review requested due to automatic review settings July 14, 2026 23:13

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

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

Comment thread src/windows/wslcsession/WSLCContainer.cpp Outdated
Comment thread localization/strings/fr-FR/Resources.resw
Copilot AI review requested due to automatic review settings July 14, 2026 23:28

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comment thread src/windows/wslcsession/WSLCContainer.cpp Outdated
Copilot AI review requested due to automatic review settings July 14, 2026 23:49

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comment thread src/windows/wslcsession/WSLCContainer.cpp
Copilot AI review requested due to automatic review settings July 14, 2026 23:54

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

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

Comment thread src/windows/wslcsession/WSLCContainer.cpp
Comment thread src/windows/wslcsession/WSLCContainer.cpp
Copilot AI review requested due to automatic review settings July 15, 2026 17:39
@beena352
beena352 marked this pull request as ready for review July 15, 2026 17:40
@beena352
beena352 requested review from a team as code owners July 15, 2026 17:40

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

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

Comment thread src/windows/wslcsession/WSLCContainer.cpp
Comment thread test/windows/WSLCTests.cpp
Copilot AI review requested due to automatic review settings July 15, 2026 20:26

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

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

Copilot AI review requested due to automatic review settings July 15, 2026 20:38

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comment thread src/windows/wslcsession/WSLCContainer.cpp

@dkbennett dkbennett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Couple minor refactor-ish things, nice tests and overall work looks good!

return {
Argument::Create(ArgType::NetworkName, true),
Argument::Create(ArgType::ContainerId, true),
Argument::Create(ArgType::NetworkAlias, false, NO_LIMIT),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These should be alphabetical order after positional arguments (this affects how they will be ordered in the help output).

So NetworkName & ContainerId are correct as-is since they are positional, but then it should be DriverOpt, IpAddress, etc. A little bizarre and I should probably add sorting to the help output so it doesn't matter, but nice to be consistent either way.

const auto networkName = WideToMultiByte(context.Args.Get<ArgType::NetworkName>());
const auto containerId = WideToMultiByte(context.Args.Get<ArgType::ContainerId>());
NetworkService::Connect(context.Data.Get<Data::Session>(), networkName, containerId);
models::ConnectNetworkOptions options{};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could be more compositional here with the tasks: e.g. have a new task that just sets network options, which is then consumed by Connect. So if we have other network commands that also need to set options we avoid duplicate code.

A good example would be SetContainerOptionsFromArgs, where we have a task which just sets container options based on the args present and adds it to context data, which then other container tasks consume as needed. I think this should be similar for more modularity in future network commands and code reuse.

Comment thread src/windows/wslc/arguments/ArgumentDefinitions.h
Comment thread localization/strings/en-US/Resources.resw Outdated
Comment thread src/windows/wslcsession/WSLCContainer.cpp
Copilot AI review requested due to automatic review settings July 20, 2026 17:10

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

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Comment on lines +315 to +321
auto key = entry.substr(0, separator);
auto value = entry.substr(separator + 1);
THROW_HR_WITH_USER_ERROR_IF(E_INVALIDARG, Localization::MessageWslcDriverOptInvalid(entry), isBlank(key));
THROW_HR_WITH_USER_ERROR_IF(
E_INVALIDARG,
Localization::MessageWslcAliasEmpty(),
alias.empty() || std::all_of(alias.begin(), alias.end(), [](unsigned char ch) { return std::isspace(ch); }));
Localization::MessageWslcDriverOptDuplicate(key),
!driverOpts.try_emplace(std::move(key), std::move(value)).second);
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