-
Notifications
You must be signed in to change notification settings - Fork 1.7k
wslc: add network create, delete, and list #40179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
beena352
wants to merge
6
commits into
microsoft:feature/wsl-for-apps
Choose a base branch
from
beena352:user/beenachauhan/network-crud
base: feature/wsl-for-apps
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9a98131
wslc: add network create, delete, and list
beena352 98b64dd
wrap network options parsing in catch-all and make IPAM optional in C…
beena352 225442c
Merge branch 'feature/wsl-for-apps' into user/beenachauhan/network-crud
beena352 933668e
add test pre-cleanup, const name variables, LOG_IF_FAILED guards
beena352 0c479b5
feedback
beena352 16caa15
fix conflict
beena352 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,13 +24,15 @@ cpp_quote("#endif") | |
| #define WSLC_MAX_IMAGE_NAME_LENGTH 255 | ||
| #define WSLC_MAX_VOLUME_NAME_LENGTH 255 | ||
| #define WSLC_MAX_VOLUME_DRIVER_LENGTH 255 | ||
| #define WSLC_MAX_NETWORK_NAME_LENGTH 255 | ||
| #define WSLC_CONTAINER_ID_LENGTH 64 | ||
| #define WSLC_MAX_BINDING_ADDRESS_LENGTH 45 | ||
|
|
||
| cpp_quote("#define WSLC_MAX_CONTAINER_NAME_LENGTH 255") | ||
| cpp_quote("#define WSLC_MAX_IMAGE_NAME_LENGTH 255") | ||
| cpp_quote("#define WSLC_MAX_VOLUME_NAME_LENGTH 255") | ||
| cpp_quote("#define WSLC_MAX_VOLUME_DRIVER_LENGTH 255") | ||
| cpp_quote("#define WSLC_MAX_NETWORK_NAME_LENGTH 255") | ||
| cpp_quote("#define WSLC_CONTAINER_ID_LENGTH 64") | ||
| cpp_quote("#define WSLC_MAX_BINDING_ADDRESS_LENGTH 45") | ||
|
|
||
|
|
@@ -591,6 +593,22 @@ typedef struct _WSLCPruneVolumesResults | |
| ULONGLONG SpaceReclaimed; | ||
| } WSLCPruneVolumesResults; | ||
|
|
||
| typedef struct _WSLCNetworkOptions | ||
| { | ||
| LPCSTR Name; | ||
| LPCSTR Driver; | ||
| [unique] LPCSTR Options; | ||
| [unique, size_is(LabelsCount)] const WSLCLabel* Labels; | ||
| ULONG LabelsCount; | ||
| } WSLCNetworkOptions; | ||
|
|
||
| typedef struct _WSLCNetworkInformation | ||
| { | ||
| char Name[WSLC_MAX_NETWORK_NAME_LENGTH + 1]; | ||
| char Id[WSLC_CONTAINER_ID_LENGTH + 1]; | ||
| char Driver[64]; | ||
| } WSLCNetworkInformation; | ||
|
|
||
| typedef struct _WSLCPruneLabelFilter | ||
| { | ||
| LPCSTR Key; | ||
|
|
@@ -719,6 +737,11 @@ interface IWSLCSession : IUnknown | |
| HRESULT Authenticate([in] LPCSTR ServerAddress, [in] LPCSTR Username, [in] LPCSTR Password, [out] LPSTR* IdentityToken); | ||
| HRESULT PushImage([in] LPCSTR Image, [in] LPCSTR RegistryAuthenticationInformation, [in, unique] IProgressCallback* ProgressCallback); | ||
| HRESULT PruneVolumes([in, unique] const WSLCPruneVolumesOptions* Options, [out] WSLCPruneVolumesResults* Results); | ||
|
|
||
| // Network management. | ||
| HRESULT CreateNetwork([in] const WSLCNetworkOptions* Options); | ||
| HRESULT DeleteNetwork([in] LPCSTR Name); | ||
| HRESULT ListNetworks([out, size_is(, *Count)] WSLCNetworkInformation** Networks, [out] ULONG* Count); | ||
| } | ||
|
|
||
| // | ||
|
|
@@ -807,3 +830,4 @@ cpp_quote("#define WSLC_E_CONTAINER_NOT_RUNNING MAKE_HRESULT(SEVERITY_ERROR, FAC | |
| cpp_quote("#define WSLC_E_CONTAINER_IS_RUNNING MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, WSLC_E_BASE + 6) /* 0x80040606 */") | ||
| cpp_quote("#define WSLC_E_SESSION_RESERVED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, WSLC_E_BASE + 7) /* 0x80040607 */") | ||
| cpp_quote("#define WSLC_E_INVALID_SESSION_NAME MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, WSLC_E_BASE + 8) /* 0x80040608 */") | ||
| cpp_quote("#define WSLC_E_NETWORK_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, WSLC_E_BASE + 9) /* 0x80040609 */") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This new error should be added to |
||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| WSLCNetworkMetadata.h | ||
|
|
||
| Abstract: | ||
|
|
||
| Constants and types for WSLC-managed Docker networks. | ||
|
|
||
| --*/ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <string> | ||
|
|
||
| namespace wsl::windows::service::wslc { | ||
|
|
||
| // Label key used to identify WSLC-managed Docker networks. | ||
| constexpr auto WSLCNetworkManagedLabel = "com.microsoft.wsl.network.managed"; | ||
| constexpr auto WSLCBridgeNetworkDriver = "bridge"; | ||
|
|
||
| // Reserved Docker network names that cannot be used for custom networks. | ||
| inline bool IsReservedNetworkName(const std::string& name) | ||
| { | ||
| return name == "bridge" || name == "host" || name == "none"; | ||
| } | ||
|
|
||
| struct NetworkEntry | ||
| { | ||
| std::string Id; | ||
| std::string Driver; | ||
| }; | ||
|
|
||
| } // namespace wsl::windows::service::wslc |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.