Richfr/ Add windowsAddress support to WslcCreateContainer() API#40037
Richfr/ Add windowsAddress support to WslcCreateContainer() API#400371wizkid merged 33 commits intofeature/wsl-for-appsfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the WSLC Client SDK’s container port-mapping path to support custom host binding addresses (including IPv6) instead of always binding to 127.0.0.1, and relaxes/updates validation around the windowsAddress field.
Changes:
- Convert
windowsAddress(IPv4/IPv6) into a string binding address forWSLCPortMappingduring container creation. - Add input validation for
windowsAddress->ss_familyinWslcSetContainerSettingsPortMappings.
There was a problem hiding this comment.
Almost certainly needs a test update to prevent a negative test from failing when it passes in an address. Not sure if we can expect IPv6 everywhere, but at least passing in 127.0.0.1 (or maybe IPv6 loopback works even if no external IPv6 address is available?).
[Edit: Search suggests that IPv6 loopback is always available if device supports IPv6.]
OneBlue
left a comment
There was a problem hiding this comment.
Added a couple comments, I would also recommend:
- Updating the pull request title
- Adding test coverage for the binding address wiring (at least for localhost, since that's the only thing that the service supports today)
You'll probably have to update existing tests as well
|
Hey @1wizkid 👋 — Following up on this PR. Currently the wslc tests are failing in CI, and there are 11 unresolved review threads with feedback from maintainers, including:
Is this change still needed? The review feedback covers some important safety and design issues that should be addressed before this can move forward. Let us know if you need any help! |
|
Ill focus on this today.
Thanks,
Richard
Sent from my T-Mobile 5G Device
Get Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
|
Pull request was closed
7f1eca4 to
715ce52
Compare
…ate windowAddress values if present.
…into richfr/portmapping Need latest changes from origin/richfr/portmapping
OneBlue
left a comment
There was a problem hiding this comment.
Let's remove the .etl file before merging
| { | ||
| if (inet_ntop(af, src, dst, dstCount) == nullptr) | ||
| { | ||
| return HRESULT_FROM_WIN32(WSAGetLastError()); |
There was a problem hiding this comment.
If inet_ntop() returns null but WSAGetLastError() happens to be 0 (e.g., stale last-error state), HRESULT_FROM_WIN32(0) will incorrectly return S_OK. Consider capturing the error immediately and returning a non-success fallback when the error code is 0 (e.g., E_FAIL), or proactively setting/clearing last error before calling inet_ntop().
| return HRESULT_FROM_WIN32(WSAGetLastError()); | |
| const auto lastError = WSAGetLastError(); | |
| return lastError == 0 ? E_FAIL : HRESULT_FROM_WIN32(lastError); |
| WslcContainerSettings containerSettings1; | ||
| VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings1)); | ||
| VERIFY_SUCCEEDED(WslcSetContainerSettingsNetworkingMode(&containerSettings1, WSLC_CONTAINER_NETWORKING_MODE_NONE)); |
There was a problem hiding this comment.
The new containerSettings1…containerSettings5 names don’t communicate intent and make the test harder to scan. Consider using descriptive names tied to the scenario (e.g., noneNetworkingSettings, defaultBindSettings, ipv4BindSettings, ipv6BindSettings, badFamilySettings) to improve readability and reduce the chance of mixing settings between blocks.
| WslcContainerSettings containerSettings2; | ||
| VERIFY_SUCCEEDED(WslcInitContainerSettings("python:3.12-alpine", &containerSettings2)); | ||
| VERIFY_SUCCEEDED(WslcSetContainerSettingsInitProcess(&containerSettings2, &procSettings)); | ||
| VERIFY_SUCCEEDED(WslcSetContainerSettingsNetworkingMode(&containerSettings2, WSLC_CONTAINER_NETWORKING_MODE_BRIDGED)); |
There was a problem hiding this comment.
The new containerSettings1…containerSettings5 names don’t communicate intent and make the test harder to scan. Consider using descriptive names tied to the scenario (e.g., noneNetworkingSettings, defaultBindSettings, ipv4BindSettings, ipv6BindSettings, badFamilySettings) to improve readability and reduce the chance of mixing settings between blocks.
| WslcContainerSettings containerSettings3; | ||
| VERIFY_SUCCEEDED(WslcInitContainerSettings("python:3.12-alpine", &containerSettings3)); | ||
| VERIFY_SUCCEEDED(WslcSetContainerSettingsInitProcess(&containerSettings3, &procSettings)); | ||
| VERIFY_SUCCEEDED(WslcSetContainerSettingsNetworkingMode(&containerSettings3, WSLC_CONTAINER_NETWORKING_MODE_BRIDGED)); |
There was a problem hiding this comment.
The new containerSettings1…containerSettings5 names don’t communicate intent and make the test harder to scan. Consider using descriptive names tied to the scenario (e.g., noneNetworkingSettings, defaultBindSettings, ipv4BindSettings, ipv6BindSettings, badFamilySettings) to improve readability and reduce the chance of mixing settings between blocks.
| WslcContainerSettings containerSettings4; | ||
| VERIFY_SUCCEEDED(WslcInitContainerSettings("python:3.12-alpine", &containerSettings4)); | ||
| VERIFY_SUCCEEDED(WslcSetContainerSettingsInitProcess(&containerSettings4, &procSettings)); | ||
| VERIFY_SUCCEEDED(WslcSetContainerSettingsNetworkingMode(&containerSettings4, WSLC_CONTAINER_NETWORKING_MODE_BRIDGED)); |
There was a problem hiding this comment.
The new containerSettings1…containerSettings5 names don’t communicate intent and make the test harder to scan. Consider using descriptive names tied to the scenario (e.g., noneNetworkingSettings, defaultBindSettings, ipv4BindSettings, ipv6BindSettings, badFamilySettings) to improve readability and reduce the chance of mixing settings between blocks.
| WslcContainerSettings containerSettings5; | ||
| VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings5)); | ||
| VERIFY_SUCCEEDED(WslcSetContainerSettingsNetworkingMode(&containerSettings5, WSLC_CONTAINER_NETWORKING_MODE_BRIDGED)); |
There was a problem hiding this comment.
The new containerSettings1…containerSettings5 names don’t communicate intent and make the test harder to scan. Consider using descriptive names tied to the scenario (e.g., noneNetworkingSettings, defaultBindSettings, ipv4BindSettings, ipv6BindSettings, badFamilySettings) to improve readability and reduce the chance of mixing settings between blocks.
Summary of the Pull Request
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed